@odoo/o-spreadsheet 16.0.2 → 16.0.4

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,11 +1,11 @@
1
- !function(e,t){"use strict";let o=e=>e;function n(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const i=function(e,...t){return n(o(e),...t)},r=function(e,...t){return new s(e,t)};class s extends String{constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return n(o(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,r("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,r("Invalid reference"))}}class g extends c{constructor(){super(a.NotAvailable,r("Data not available"),l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const f=.5,m="#f5f5f5",v="#F8F9FA",b="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y=11982760,x="#01666b",R="#188038",I="#E6F4EA",T="#CEEAD6",A=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0","#a61c00","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79","#85200c","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#0b5394","#351c75","#741b47","#5b0f00","#660000","#783f04","#7f6000","#274e13","#0c343d","#1c4587","#073763","#20124d","#4c1130"],O=26,M=48,N=96,_=23,F=15,D=18,k=14,$=4,L=4,P=3,U=L,V=17,z=250,B=1,H="400",W=10,G="'Roboto', arial",q=["thin","#000"],Z=["thin",R],j=/[ymd:]/,X=a.InvalidReference,Y="START_REVISION",K=20,Q=.4,J=["'","*","?","/","\\","[","]"],ee=/'|\*|\?|\/|\\|\[|\]/,te="|",oe=r("Invalid expression");var ne;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.Dropdown=16]="Dropdown",e[e.Composer=20]="Composer",e[e.ColorPicker=25]="ColorPicker",e[e.IconPicker=25]="IconPicker",e[e.Popover=30]="Popover",e[e.ChartAnchor=1e3]="ChartAnchor"}(ne||(ne={}));const ie=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48}],re={};for(let e of ie)re[e.pt]=e.px;const se=new Date(1899,11,30),ae=864e5,le=2e3,ce=(new Date).getFullYear(),he=new Date(0)-se,de=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ue=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,ge=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function pe(e){let t;const o=(e=e.trim()).match(ge);if(o){if(t=function(e){if(e=e.trim(),ge.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),n=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),i=n.length>=2,r=3===n.length;let s=Number(n[0]),a=i?Number(n[1]):0,l=r?Number(n[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!i)return null;s>=12&&t?s-=12:s<12&&o&&(s+=12),a+=Math.floor(l/60),l%=60,s+=Math.floor(a/60),a%=60,s>=24&&(c="hhhh:mm:ss");return{value:s/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,s,a,l)}}return null}(o[0]),null===t)return null;e=e.replace(o[0],"").trim()}let n;const i=e.match(de),r=e.match(ue);if(i||r){let t;if(i?(t=i[0],n=fe(t,"mdy")):(t=r[0],n=fe(t,"ymd")),null===n)return null;e=e.replace(t,"").trim()}return""!==e||!n&&!t?null:n&&t?{value:n.value+t.value,format:n.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(n.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,n.jsDate.getMonth()+t.jsDate.getMonth()-11,n.jsDate.getDate()+t.jsDate.getDate()-30,n.jsDate.getHours()+t.jsDate.getHours(),n.jsDate.getMinutes()+t.jsDate.getMinutes(),n.jsDate.getSeconds()+t.jsDate.getSeconds())}:n||t}function fe(e,t){const o="mdy"===t;if(o||"ymd"===t){const t=e.split(/\/|-|\s/),n=o?0:1,i=o?1:2,r=o?2:0,s=Number(t[n]),a=Number(t[i]),l=2===t[n].length&&s<10||2===t[i].length&&a<10,c=t[r]?function(e){const t=Number(e);switch(e.length){case 1:return le+t;case 2:return le+(le+t>ce+10?-100:0)+t;case 3:case 4:return t}return 0}(t[r]):ce,h=new Date(c,s-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==s-1||h.getDate()!==a)return null;const u=h-se;let g=l?`mm${d}dd`:`m${d}d`;return t[r]&&(g=o?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/ae),format:g,jsDate:h}}return null}function me(e){const t=Math.trunc(e);let o=new Date(t*ae-he),n=e-t;n=n<0?1+n:n;const i=Math.round(24*n),r=Math.round(24*(n-i/24)*60),s=Math.round(24*(n-i/24-r/24/60)*60*60);return o.setHours(i),o.setMinutes(r),o.setSeconds(s),o}function ve(e){const t=e.getTime()-se.getTime();return Math.round(t/ae)}function be(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Se(e){return be(e)===e.getDate()}function Ce(e,t,o){const n=e.getFullYear(),i=e.getMonth(),r=e.getDate(),s=new Date(n,i+t);return o&&r===be(e)||r>be(s)?s.setDate(be(s)):s.setDate(r),s}function Ee(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function we(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const n=me(e),i=me(t);let r=n.getDate(),s=i.getDate();const a=n.getMonth(),l=i.getMonth(),c=n.getFullYear(),h=i.getFullYear();let d=0,u=0;switch(o){case 0:31===r&&(r=30),30===r&&31===s&&(s=30),1===a&&r===(Ee(c)?29:28)&&(r=30,1===l&&s===(Ee(h)?29:28)&&(s=30)),d=c+(30*a+r)/360,u=h+(30*l+s)/360;break;case 1:let o=365;const n=c===h;if(!n&&!(c+1===h)||!n&&a<l||!n&&a===l&&r<s){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Ee(o)?366:365;o=t/e}else n?Ee(c)&&(o=366):(Ee(c)&&a<2&&(o=366),Ee(h)&&(l>1||1===l&&29===s)&&(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===r&&(r=30),31===s&&(s=30),d=c+(30*a+r)/360,u=h+(30*l+s)/360}return u-d}function ye(e){return JSON.stringify(e,Object.keys(e).sort())}function xe(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Re(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(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?void 0:e.constructor)===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ie(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 Te(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function Ae(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function Oe(e,t,o){return e<t?t:e>o?o:e}function Me(e,t,o){e.save(),e.font=Ne(o);const n=e.measureText(t).width;return e.restore(),n}function Ne(e){return`${e.italic?"italic ":""}${e.bold?"bold":H} ${_e(e)}px ${G}`}function _e(e){const t=e.fontSize||W;if(!re[t])throw new Error("Size of the font is not supported");return re[t]}function Fe(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const n=Math.ceil(Math.abs((t-e)/o)),i=Array(n);for(let t=0;t<n;t++)i[t]=e+t*o;return i}function De(e){return e.reduce(((e,t,o,n)=>{if(1===Math.abs(t-n[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*ke(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}function $e(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function Le(e){return null!==pe(e)}const Pe=/^\[([^\[]+)\]\((.+)\)$/,Ue=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ve(e){return Pe.test(e)}function ze(e,t){return`[${e}](${t})`}function Be(e){const t=e.match(Pe)||[],o=t[1],n=t[2];if(!o||!n)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:n}}const He="o-spreadsheet://";function We(e){if(!Ve(e))return!1;const{url:t}=Be(e);return t.startsWith(He)}function Ge(e){return`${He}${e}`}function qe(e){if(e.startsWith(He))return e.substr(He.length);throw new Error(`${e} is not a valid sheet link`)}function Ze(e){return void 0!==e}function je(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?je(e):!e))}function Xe(e,t){for(let[o,n]of Object.entries(t))if(ye(n)===ye(e))return parseInt(o,10);const o=Object.keys(t),n=0===o.length?0:Math.max(...o.map((e=>parseInt(e,10))));return t[n+1]=e,n+1}function Ye(e){let t="";for(let o=0,n=e.length;o<n;o++)t+=e[o];return t}function Ke(e){let t,o=!1;const n=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return n.map=e=>Ke((()=>e(n()))),n}function Qe(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function Je(e,t){return"after"===e?t+1:t}function et(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let n of o){if(typeof e[n]!=typeof e[n])return!1;if("object"==typeof e[n]){if(!et(e[n],t[n]))return!1}else if(e[n]!==t[n])return!1}return!0}function tt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function ot(e){return e?e.toLowerCase():""}const nt=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function it(e){return st(e.toString(16).padStart(6,"0"))}let rt=0;function st(e){if(e.includes("rgba"))throw new Error(`rgba() conversion currently not supported: ${e}`);if(e.includes("rgb"))return function(e){return"#"+Ye(e.slice(4,-1).split(",").map((e=>parseInt(e,10).toString(16).padStart(2,"0")))).toUpperCase()}(e);if(3!==(e=e.replace("#","").toUpperCase()).length&&4!==e.length||(e=e.split("").reduce(((e,t)=>e+t+t),"")),""!==e.replace(/[a-f0-9]/gi,""))throw new Error("invalid color");return"#"+e}function at(e){try{const{r:t,g:o,b:n,a:i}=ut(e);return lt(t)&&lt(o)&&lt(n)&&lt(i)}catch(e){return!1}}const lt=e=>e>=0&&e<=255;function ct(e,t,o,n=1){if(!lt(e)||!lt(t)||!lt(o)||n<0||n>1)throw new Error(`Invalid RGBA values ${[e,t,o,n]}`);return{a:n,b:o,g:t,r:e}}function ht(e){let{r:t,g:o,b:n}=ut(e);t/=255,o/=255,n/=255;const i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*i(t)+.7152*i(o)+.0722*i(n)}function dt(e){let t=e.r.toString(16),o=e.g.toString(16),n=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==n.length&&(n="0"+n),1==i.length&&(i="0"+i),"ff"===i&&(i=""),"#"+t+o+n+i}function ut(e){let t,o,n,i;if(7===(e=st(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),n=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),n=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:n}}function gt(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)),n=e.l-t/2,i=0,r=0,s=0;return 0<=e.h&&e.h<60?(i=t,r=o,s=0):60<=e.h&&e.h<120?(i=o,r=t,s=0):120<=e.h&&e.h<180?(i=0,r=t,s=o):180<=e.h&&e.h<240?(i=0,r=o,s=t):240<=e.h&&e.h<300?(i=o,r=0,s=t):300<=e.h&&e.h<360&&(i=t,r=0,s=o),i=Math.round(255*(i+n)),r=Math.round(255*(r+n)),s=Math.round(255*(s+n)),{a:e.a,r:i,g:r,b:s}}function pt(e){const t=e.r/255,o=e.g/255,n=e.b/255;let i=Math.min(t,o,n),r=Math.max(t,o,n),s=r-i,a=0,l=0,c=0;return a=0==s?0:r==t?(o-n)/s%6:r==o?(n-t)/s+2:(t-o)/s+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+i)/2,l=0==s?0:s/(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}}const ft=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),mt=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),vt=new RegExp(/^([A-Z]{1,3})+$/,"i"),bt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),St=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Ct=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[ft.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 Et(e){return bt.test(e)}function wt(e){return St.test(e)}function yt(e){return vt.test(e)}function xt(e){return mt.test(e)}function Rt(e){const t=e.split("!"),o=t.pop();return{sheetName:Te(t.join("!"))||void 0,xc:o}}function It(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):It(Math.floor(e/26)-1)+It(e%26)}function Tt(e){let t=0;const o=e.length;for(let n=0;n<o;n++){t+=(e.charCodeAt(n)-65+(n<o-1?1:0))*26**(o-n-1)}return t}function At(e){const t=(e=e.toUpperCase().trim()).match(ft);if(null!==t){const[o,n,i]=t;if(o===e){return{col:Tt(n),row:parseInt(i,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function Ot(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+It(e)+(o.rowFixed?"$":"")+String(t+1)}const Mt=140,Nt=20,_t=.035;function Ft(e){return Nt+(Mt-Nt)*Math.exp(-_t*(e-1))}const Dt=20,kt=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,$t=/0/g,Lt={};function Pt(e){let t=Lt[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let n;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(n=e.substring(t+1).indexOf("]")+t+2,0===n)throw new Error(`Invalid currency brackets format: ${e}`);const i=e.substring(t+2,n-1);if(i.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:i})}else{const i=e.substring(t).indexOf("[");n=i>-1?i+t:e.length;const r=e.substring(t,n);r.match(j)?o.push({type:"DATE",format:r}):o.push({type:"NUMBER",format:Yt(r)})}t=n}return o}(e),Lt[e]=t),t}function Ut(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=qt(e));return function(e,t){if("DATE"===t[0].type)return Ht(e,t[0].format);let o=e<0?"-":"";for(let n of t)switch(n.type){case"NUMBER":o+=Vt(Math.abs(e),n.format);break;case"STRING":o+=n.format}return o}(e,Pt(t));case"object":return"0"}}function Vt(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let o=0;void 0!==t.decimalPart&&(o=t.decimalPart.length);const{integerDigits:n,decimalDigits:i}=Bt(e,o);let r=function(e,t,o){var n;const i="0"===e?"":e;let r=i;const s=t.length-i.length;if(s>0){const e=(t.substring(0,s).match($t)||[]).length;r="0".repeat(e)+r}o&&(r=(null===(n=r.match(kt))||void 0===n?void 0:n.join(","))||r);return r}(n,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(r+="."+function(e,t){let o=e;if(t.length-e.length>0){const n=(t.substring(e.length,t.length+1).match($t)||[]).length;o+="0".repeat(n)}return o}(i||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const zt=[];function Bt(e,t=Dt){let o=zt[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),zt[t]=o);const[n,i]=o.format(e).split(".");return{integerDigits:n,decimalDigits:i}}function Ht(e,t){const o=me(e),n=t.indexOf("h");let i="",r="";return n>0?(i=Wt(o,t.substring(0,n-1)),r=Gt(o,t.substring(n))):0===n?r=Gt(o,t):n<0&&(i=Wt(o,t)),i+(i&&r?" ":"")+r}function Wt(e,t){const o=t.match(/\/|-|\s/)[0];return t.split(o).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function Gt(e,t){let o=t.split(/:|\s/);const n=e.getHours(),i="a"===o[o.length-1];let r=n,s="";return i&&(r=0===r?12:r>12?r-12:r,s=n>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-se)/36e5).toString();case"hh":return r.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+s}function qt(e){let{decimalDigits:t}=Bt(e,10);return t?"0."+"0".repeat(t.length):"0"}function Zt(e,t,o){return Qt(Pt(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:o}]:e)).flat())}function jt(e,t){var o;const n={...e},i=Math.sign(t),r=(null===(o=n.decimalPart)||void 0===o?void 0:o.length)||0,s=Math.min(Math.max(0,r+i),Dt);return n.decimalPart="0".repeat(s),""===n.decimalPart&&delete n.decimalPart,n}const Xt=/,*?$/;function Yt(e){var t;if(function(e){return Boolean(e.replace(Kt,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const o=e.includes("%"),n=(null===(t=e.match(Xt))||void 0===t?void 0:t[0])||"",i=n?1e3**n.length:1;let r=e.slice(0,e.length-(n.length||0));const s=r.includes(",");if(r.match(/\..*,/))throw new Error("A format can't contain ',' symbol in the decimal part");r=r.replace("%","").replace(",","");const a=r.match(/[\%|,]/);if(a)throw new Error(`A format can only contain a single '${a[0]}' symbol`);const[l,c]=r.split(".");if(c&&c.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==c?{integerPart:l,isPercent:o,thousandsSeparator:s,decimalPart:c,magnitude:i}:{integerPart:l,isPercent:o,thousandsSeparator:s,magnitude:i}}const Kt=/[,#0.%]/g;function Qt(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const Jt=/^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+/,eo="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",to="(\\s*-)?",oo="(\\s*[\\$€])?",no="^(("+[to+oo+eo,to+eo+oo,oo+to+eo].join(")|(")+"))$",io=new RegExp(no,"i");function ro(e){return!!e&&io.test(e.trim())}const so=/[,\$€]+/g;function ao(e){e=e.replace(so,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function lo(e,t,o){const n=[...e].sort(((e,t)=>e-t));let i=(n.length+(o?-1:1))*t;if(o||i--,Number.isInteger(i))return n[i];const r=Math.ceil(i),s=Math.floor(i);return n[r]*(i-s)+n[s]*(r-i)}class co{constructor(e,t){this.getSheetSize=t,this.prefixSheet=!1,this._zone=e.zone,this.parts=e.parts,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName}static fromRange(e,t){return e instanceof co?e:new co(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:n}=this._zone;if(void 0!==n&&void 0!==o)return{left:e,top:t,right:n,bottom:o};if(void 0===o&&void 0!==n)return{right:n,top:t,left:e,bottom:this.getSheetSize(this.sheetId).height-1};if(void 0===n&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).width-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=wt(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),n=void 0===t.bottom,i=void 0===t.right;return n&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed,t.left===t.right&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed)),i&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed,t.top===t.bottom&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed)),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(void 0!==this._zone.right&&this._zone.right<this._zone.left){let e=this._zone.right;this._zone.right=this._zone.left,this._zone.left=e;let t=this.parts[1].colFixed;this.parts[1].colFixed=this.parts[0].colFixed,this.parts[0].colFixed=t}if(void 0!==this._zone.bottom&&this._zone.bottom<this._zone.top){let e=this._zone.bottom;this._zone.bottom=this._zone.top,this._zone.top=e;let t=this.parts[1].rowFixed;this.parts[1].rowFixed=this.parts[0].rowFixed,this.parts[0].rowFixed=t}}clone(e){return new co({zone:(null==e?void 0:e.zone)?e.zone:{...this._zone},sheetId:(null==e?void 0: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:(null==e?void 0:e.parts)?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:(null==e?void 0:e.prefixSheet)?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function ho(e,t,o){const n=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:n})}function uo(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function go(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}class po{constructor(){this.isFastIdStrategy=!1,this.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 fo(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let o,n,i,r,s=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Et(c))i=r=Tt(c),o=n=0,s=!0;else if(wt(c))o=n=parseInt(c,10)-1,i=r=0,a=!0;else{const e=At(c);i=r=e.col,o=n=e.row,l=!0}if(2===t.length)if(Et(h))r=Tt(h),s=!0;else if(wt(h))n=parseInt(h,10)-1,a=!0;else{const e=At(h);r=e.col,n=e.row,o=s?n:o,i=a?r:i,l=!0}if(s&&a)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const d={top:o,left:i,bottom:s?void 0:n,right:a?void 0:r};return l=l&&(a||s),l&&(d.hasHeader=l),d}(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 mo(e){const t=fo(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function vo(e){const{bottom:t,top:o,left:n,right:i}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(n)||void 0!==i&&isNaN(i))&&((void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)&&e.top>=0&&e.left>=0)}function bo(e){const{top:t,bottom:o,left:n,right:i}=e,s="hasHeader"in e&&e.hasHeader,a=t===o&&n===i;if(void 0===o&&void 0!==i)return 0!==t||s?`${Ot(n,t)}:${It(i)}`:`${It(n)}:${It(i)}`;if(void 0===i&&void 0!==o)return 0!==n||s?`${Ot(n,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==i)return a?Ot(n,t):`${Ot(n,t)}:${Ot(i,o)}`;throw new Error(r("Bad zone format"))}function So(e,t,o,n,i){const r="left"===t?"columns":"rows",s="before"===n?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=s&&a&&a>s?Do(e,r,"RESIZE",i):s<e[t]?Do(e,r,"MOVE",i):{...e}}function Co(e,t,o,n,i){const r="left"===t?"columns":"rows",s="before"===n?o-1:o,a="left"===t?"right":"bottom";return e[t]<=s&&e[a]>s?Do(e,r,"RESIZE",i):s<e[t]?Do(e,r,"MOVE",i):{...e}}function Eo(e,t,o){const n="left"===t?"right":"bottom";let i=e[t],r=e[n];for(let s of o.sort(((e,t)=>t-e)))e[t]>s&&(i--,r--),e[t]<s&&e[n]>=s&&r--;return{...e,[t]:i,[n]:r}}function wo(e,t,o){const n="left"===t?"right":"bottom";let i=e[t],r=e[n];const s=e[n];for(let n of o.sort(((e,t)=>t-e)))e[t]>n&&(i--,void 0!==r&&r--),void 0!==s&&void 0!==r&&e[t]<=n&&s>=n&&r--;if(!(void 0!==r&&i>r))return{...e,[t]:i,[n]:r}}function yo(...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 xo(e,t){if(Io(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 Ro(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Io(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function To(e,t,o){const{left:n,right:i,top:r,bottom:s}=o;return e>=n&&e<=i&&t>=r&&t<=s}function Ao(e,t){return Ro(yo(t,e),t)}function Oo(e,t){const o=e.map(fo),n=t.map(mo),i=Math.max(...o.concat(n).map((e=>e.bottom||0))),r=Math.max(...o.concat(n).map((e=>e.right||0))),s=o.map((e=>({...e,bottom:void 0===e.bottom?i+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=n.map((e=>({...e,bottom:void 0===e.bottom?i+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(s.map(Fo).flat(),a.map(Fo).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),n=[];let i=Lo(t);for(const{col:e,row:t}of o)if(!To(e,t,i))if(e===i.left&&t===i.bottom+1){const e=i.bottom+1;i={...i,bottom:e}}else n.push(i),i=Lo({col:e,row:t});return[...n,i]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],o=Mo(e),n=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>n(e,t)?yo(e,t):e),o.shift());t.push(e)}return Mo(t)}(c).map((e=>({...e,bottom:e.bottom===i+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(bo)}function Mo(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Ao(e,t)))||o.push(e)}return o.reverse()}function No(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function _o(e){const{width:t,height:o}=No(e);return 1===t||1===o}function Fo(e){const t=[],[o,n]=[e.right,e.left].sort(((e,t)=>e-t)),[i,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of Fe(o,n+1))for(const o of Fe(i,r+1))t.push({col:e,row:o});return t}function Do(e,t,o,n){const i="both"===t?n[0]:"columns"===t?n:0,r="both"===t?n[1]:"rows"===t?n:0,s="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||s?!(Po(e)&&!s)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=i,l.top+=r),void 0!==l.right&&(l.right+=i),void 0!==l.bottom&&(l.bottom+=r),l}function ko(e,t){let o,n;const{left:i,right:r,top:s,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=i?l:c!=r?c:l,n=h!=s?h:d!=a?d:h,{col:o,row:n}}function $o(e){return{top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom),left:Math.min(e.left,e.right),right:Math.max(e.left,e.right)}}function Lo(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Po(e){return void 0===e.right}function Uo(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function Vo(...e){return e.length<2||1===Oo(e.map(bo),[]).length}class zo{constructor(){this.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 Bo=new zo,Ho=new zo;class Wo extends t.Component{constructor(){super(...arguments),this.canvas=t.useRef("graphContainer")}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.createChart(e.chartJsConfig)}));let e=this.chartRuntime;t.onPatched((()=>{const t=this.chartRuntime;et(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){var t,o,n,i;const r=e.chartJsConfig;r.data&&r.data.datasets?(this.chart.data=r.data,(null===(t=r.options)||void 0===t?void 0:t.title)&&(this.chart.config.options.title=r.options.title),r.options&&"valueLabel"in r.options&&(null===(o=r.options)||void 0===o?void 0:o.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.legend=null===(n=r.options)||void 0===n?void 0:n.legend,this.chart.config.options.scales=null===(i=r.options)||void 0===i?void 0:i.scales,this.chart.update({duration:0})}}Wo.template="o-spreadsheet-ChartJsComponent",Ho.add("line",Wo),Ho.add("bar",Wo),Ho.add("pie",Wo),Ho.add("gauge",Wo);const Go=new zo;var qo;Go.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var o;e.current+=e.increment;const n=e.current.toString(),i=Ut(e.current,null===(o=t.cell)||void 0===o?void 0:o.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:n},tooltip:n?{props:{content:i}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{var n,i;const r=(null===(n=t.cell)||void 0===n?void 0:n.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:null===(i=t.cell)||void 0===i?void 0:i.formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,o,n)=>{e.current+=e.increment;let i=0,r=0;switch(n){case"up":i=0,r=-e.current;break;case"down":i=0,r=e.current;break;case"left":i=-e.current,r=0;break;case"right":i=e.current,r=0}if(!t.cell||!t.cell.isFormula())return{cellData:{}};const s=t.sheetId,a=o.createAdaptedRanges(t.cell.dependencies,i,r,s),l=o.buildFormulaContent(s,t.cell,a);return{cellData:{border:t.border,style:t.cell.style,format:t.cell.format,content:l},tooltip:l?{props:{content:l}}:void 0}}}),function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(qo||(qo={}));const Zo=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),jo=new Set([...Zo,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),Xo=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),Yo=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE"]);function Ko(e){return Yo.has(e.type)}class Qo{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new Qo}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var Jo,en,tn;e.CommandResult=void 0,(Jo=e.CommandResult||(e.CommandResult={}))[Jo.Success=0]="Success",Jo[Jo.CancelledForUnknownReason=1]="CancelledForUnknownReason",Jo[Jo.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",Jo[Jo.MergeIsDestructive=3]="MergeIsDestructive",Jo[Jo.CellIsMerged=4]="CellIsMerged",Jo[Jo.InvalidTarget=5]="InvalidTarget",Jo[Jo.EmptyUndoStack=6]="EmptyUndoStack",Jo[Jo.EmptyRedoStack=7]="EmptyRedoStack",Jo[Jo.NotEnoughElements=8]="NotEnoughElements",Jo[Jo.NotEnoughSheets=9]="NotEnoughSheets",Jo[Jo.MissingSheetName=10]="MissingSheetName",Jo[Jo.DuplicatedSheetName=11]="DuplicatedSheetName",Jo[Jo.DuplicatedSheetId=12]="DuplicatedSheetId",Jo[Jo.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",Jo[Jo.WrongSheetMove=14]="WrongSheetMove",Jo[Jo.WrongSheetPosition=15]="WrongSheetPosition",Jo[Jo.InvalidAnchorZone=16]="InvalidAnchorZone",Jo[Jo.SelectionOutOfBound=17]="SelectionOutOfBound",Jo[Jo.TargetOutOfSheet=18]="TargetOutOfSheet",Jo[Jo.WrongCutSelection=19]="WrongCutSelection",Jo[Jo.WrongPasteSelection=20]="WrongPasteSelection",Jo[Jo.WrongPasteOption=21]="WrongPasteOption",Jo[Jo.WrongFigurePasteOption=22]="WrongFigurePasteOption",Jo[Jo.EmptyClipboard=23]="EmptyClipboard",Jo[Jo.EmptyRange=24]="EmptyRange",Jo[Jo.InvalidRange=25]="InvalidRange",Jo[Jo.InvalidZones=26]="InvalidZones",Jo[Jo.InvalidSheetId=27]="InvalidSheetId",Jo[Jo.InputAlreadyFocused=28]="InputAlreadyFocused",Jo[Jo.MaximumRangesReached=29]="MaximumRangesReached",Jo[Jo.InvalidChartDefinition=30]="InvalidChartDefinition",Jo[Jo.InvalidDataSet=31]="InvalidDataSet",Jo[Jo.InvalidLabelRange=32]="InvalidLabelRange",Jo[Jo.InvalidScorecardKeyValue=33]="InvalidScorecardKeyValue",Jo[Jo.InvalidScorecardBaseline=34]="InvalidScorecardBaseline",Jo[Jo.InvalidGaugeDataRange=35]="InvalidGaugeDataRange",Jo[Jo.EmptyGaugeRangeMin=36]="EmptyGaugeRangeMin",Jo[Jo.GaugeRangeMinNaN=37]="GaugeRangeMinNaN",Jo[Jo.EmptyGaugeRangeMax=38]="EmptyGaugeRangeMax",Jo[Jo.GaugeRangeMaxNaN=39]="GaugeRangeMaxNaN",Jo[Jo.GaugeRangeMinBiggerThanRangeMax=40]="GaugeRangeMinBiggerThanRangeMax",Jo[Jo.GaugeLowerInflectionPointNaN=41]="GaugeLowerInflectionPointNaN",Jo[Jo.GaugeUpperInflectionPointNaN=42]="GaugeUpperInflectionPointNaN",Jo[Jo.GaugeLowerBiggerThanUpper=43]="GaugeLowerBiggerThanUpper",Jo[Jo.InvalidAutofillSelection=44]="InvalidAutofillSelection",Jo[Jo.WrongComposerSelection=45]="WrongComposerSelection",Jo[Jo.MinBiggerThanMax=46]="MinBiggerThanMax",Jo[Jo.LowerBiggerThanUpper=47]="LowerBiggerThanUpper",Jo[Jo.MidBiggerThanMax=48]="MidBiggerThanMax",Jo[Jo.MinBiggerThanMid=49]="MinBiggerThanMid",Jo[Jo.FirstArgMissing=50]="FirstArgMissing",Jo[Jo.SecondArgMissing=51]="SecondArgMissing",Jo[Jo.MinNaN=52]="MinNaN",Jo[Jo.MidNaN=53]="MidNaN",Jo[Jo.MaxNaN=54]="MaxNaN",Jo[Jo.ValueUpperInflectionNaN=55]="ValueUpperInflectionNaN",Jo[Jo.ValueLowerInflectionNaN=56]="ValueLowerInflectionNaN",Jo[Jo.MinInvalidFormula=57]="MinInvalidFormula",Jo[Jo.MidInvalidFormula=58]="MidInvalidFormula",Jo[Jo.MaxInvalidFormula=59]="MaxInvalidFormula",Jo[Jo.ValueUpperInvalidFormula=60]="ValueUpperInvalidFormula",Jo[Jo.ValueLowerInvalidFormula=61]="ValueLowerInvalidFormula",Jo[Jo.InvalidSortZone=62]="InvalidSortZone",Jo[Jo.WaitingSessionConfirmation=63]="WaitingSessionConfirmation",Jo[Jo.MergeOverlap=64]="MergeOverlap",Jo[Jo.TooManyHiddenElements=65]="TooManyHiddenElements",Jo[Jo.Readonly=66]="Readonly",Jo[Jo.InvalidViewportSize=67]="InvalidViewportSize",Jo[Jo.InvalidScrollingDirection=68]="InvalidScrollingDirection",Jo[Jo.FigureDoesNotExist=69]="FigureDoesNotExist",Jo[Jo.InvalidConditionalFormatId=70]="InvalidConditionalFormatId",Jo[Jo.InvalidCellPopover=71]="InvalidCellPopover",Jo[Jo.EmptyTarget=72]="EmptyTarget",Jo[Jo.InvalidFreezeQuantity=73]="InvalidFreezeQuantity",Jo[Jo.FrozenPaneOverlap=74]="FrozenPaneOverlap",Jo[Jo.ValuesNotChanged=75]="ValuesNotChanged",Jo[Jo.InvalidFilterZone=76]="InvalidFilterZone",Jo[Jo.FilterOverlap=77]="FilterOverlap",Jo[Jo.FilterNotFound=78]="FilterNotFound",Jo[Jo.MergeInFilter=79]="MergeInFilter",Jo[Jo.NonContinuousTargets=80]="NonContinuousTargets",Jo[Jo.DuplicatedFigureId=81]="DuplicatedFigureId",Jo[Jo.InvalidSelectionStep=82]="InvalidSelectionStep",Jo[Jo.DuplicatedChartId=83]="DuplicatedChartId",Jo[Jo.ChartDoesNotExist=84]="ChartDoesNotExist",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(en||(en={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Selection=5]="Selection",e[e.Autofill=6]="Autofill",e[e.Headers=7]="Headers"}(tn||(tn={}));const on=new zo;on.add("simple_value_copy",{condition:(e,t)=>{var o;return 1===t.length&&!e.isFormula()&&!(null===(o=e.format)||void 0===o?void 0:o.match(j))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("copy_text",{condition:e=>!e.isFormula()&&e.evaluated.type===qo.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula(),generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_number",{condition:e=>e.evaluated.type===qo.number,generateRule:(e,t)=>{const o=function(e,t){let o=[],n=!1;for(let i of t)if(i===e&&(n=!0),(null==i?void 0:i.evaluated.type)===qo.number)o.push(i.evaluated.value);else{if(n)return o;o=[]}return o}(e,t);let n=1;return 2==o.length?n=2*(o[1]-o[0]):o.length>2&&(n=function(e){const t=[];let o=e[0];for(let n=1;n<e.length;n++){const i=e[n];t.push(i-o),o=i}return t.reduce(((e,t)=>e+t),0)/t.length}(o)*o.length),{type:"INCREMENT_MODIFIER",increment:n,current:e.evaluated.type===qo.number?e.evaluated.value:0}},sequence:40});const nn={};let rn=0;function sn(e,...t){const o="__sheet__"+rn++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],n=[];let i=[];function r(e,t){const n=[];for(const i of o[e]){let s=t&&t+" "+i||i;s.includes("&")&&(s=i.replace(/&/g,t||"")),e<o.length-1&&(s=r(e+1,s)),n.push(s)}return n.join(", ")}function s(){i.length&&(n.push(r(0)+" {"),n.push(...i),n.push("}"),i=[])}for(;t.length;){let e=t.shift();"}"===e?(s(),o.pop()):("{"===t[0]&&(s(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&i.push(" "+e+";"))}return n.join("\n")}(t),nn[e]=o}(o,String.raw(e,...t)),function(e){const t=nn[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function an({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function ln(e){return"\n"+Object.entries(e).map((([e,t])=>`${e}: ${t};`)).join("\n")+"\n"}sn`
1
+ !function(e,t){"use strict";let o=e=>e;function n(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const i=function(e,...t){return n(o(e),...t)},r=function(e,...t){return new s(e,t)};class s extends String{constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return n(o(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,r("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,r("Invalid reference"))}}class g extends c{constructor(){super(a.NotAvailable,r("Data not available"),l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,r('Unknown function: "%s"',e))}}const f=.5,m="#f5f5f5",v="#F8F9FA",b="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y=11982760,x="#01666b",R="#188038",I="#E6F4EA",T="#CEEAD6",A=["#000000","#434343","#666666","#999999","#b7b7b7","#cccccc","#d9d9d9","#efefef","#f3f3f3","#ffffff","#980000","#ff0000","#ff9900","#ffff00","#00ff00","#00ffff","#4a86e8","#0000ff","#9900ff","#ff00ff","#e6b8af","#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#c9daf8","#cfe2f3","#d9d2e9","#ead1dc","#dd7e6b","#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#a4c2f4","#9fc5e8","#b4a7d6","#d5a6bd","#cc4125","#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6d9eeb","#6fa8dc","#8e7cc3","#c27ba0","#a61c00","#cc0000","#e69138","#f1c232","#6aa84f","#45818e","#3c78d8","#3d85c6","#674ea7","#a64d79","#85200c","#990000","#b45f06","#bf9000","#38761d","#134f5c","#1155cc","#0b5394","#351c75","#741b47","#5b0f00","#660000","#783f04","#7f6000","#274e13","#0c343d","#1c4587","#073763","#20124d","#4c1130"],O=26,M=48,N=96,_=23,F=15,D=18,k=14,$=4,L=4,P=3,U=L,V=17,z=250,B=1,H="400",W=10,G="'Roboto', arial",q=["thin","#000"],Z=["thin",R],j=/[ymd:]/,X=a.InvalidReference,Y="START_REVISION",K=20,Q=.4,J=["'","*","?","/","\\","[","]"],ee=/'|\*|\?|\/|\\|\[|\]/,te="|",oe=r("Invalid expression");var ne;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.Dropdown=16]="Dropdown",e[e.Composer=20]="Composer",e[e.ColorPicker=25]="ColorPicker",e[e.IconPicker=25]="IconPicker",e[e.Popover=30]="Popover",e[e.ChartAnchor=1e3]="ChartAnchor"}(ne||(ne={}));const ie=[{pt:7.5,px:10},{pt:8,px:11},{pt:9,px:12},{pt:10,px:13},{pt:10.5,px:14},{pt:11,px:15},{pt:12,px:16},{pt:14,px:18.7},{pt:15,px:20},{pt:16,px:21.3},{pt:18,px:24},{pt:22,px:29.3},{pt:24,px:32},{pt:26,px:34.7},{pt:36,px:48}],re={};for(let e of ie)re[e.pt]=e.px;const se=new Date(1899,11,30),ae=864e5,le=2e3,ce=(new Date).getFullYear(),he=new Date(0)-se,de=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ue=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,ge=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function pe(e){let t;const o=(e=e.trim()).match(ge);if(o){if(t=function(e){if(e=e.trim(),ge.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),n=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),i=n.length>=2,r=3===n.length;let s=Number(n[0]),a=i?Number(n[1]):0,l=r?Number(n[2]):0,c=r?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!i)return null;s>=12&&t?s-=12:s<12&&o&&(s+=12),a+=Math.floor(l/60),l%=60,s+=Math.floor(a/60),a%=60,s>=24&&(c="hhhh:mm:ss");return{value:s/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,s,a,l)}}return null}(o[0]),null===t)return null;e=e.replace(o[0],"").trim()}let n;const i=e.match(de),r=e.match(ue);if(i||r){let t;if(i?(t=i[0],n=fe(t,"mdy")):(t=r[0],n=fe(t,"ymd")),null===n)return null;e=e.replace(t,"").trim()}return""!==e||!n&&!t?null:n&&t?{value:n.value+t.value,format:n.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(n.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,n.jsDate.getMonth()+t.jsDate.getMonth()-11,n.jsDate.getDate()+t.jsDate.getDate()-30,n.jsDate.getHours()+t.jsDate.getHours(),n.jsDate.getMinutes()+t.jsDate.getMinutes(),n.jsDate.getSeconds()+t.jsDate.getSeconds())}:n||t}function fe(e,t){const o="mdy"===t;if(o||"ymd"===t){const t=e.split(/\/|-|\s/),n=o?0:1,i=o?1:2,r=o?2:0,s=Number(t[n]),a=Number(t[i]),l=2===t[n].length&&s<10||2===t[i].length&&a<10,c=t[r]?function(e){const t=Number(e);switch(e.length){case 1:return le+t;case 2:return le+(le+t>ce+10?-100:0)+t;case 3:case 4:return t}return 0}(t[r]):ce,h=new Date(c,s-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==s-1||h.getDate()!==a)return null;const u=h-se;let g=l?`mm${d}dd`:`m${d}d`;return t[r]&&(g=o?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/ae),format:g,jsDate:h}}return null}function me(e){const t=Math.trunc(e);let o=new Date(t*ae-he),n=e-t;n=n<0?1+n:n;const i=Math.round(24*n),r=Math.round(24*(n-i/24)*60),s=Math.round(24*(n-i/24-r/24/60)*60*60);return o.setHours(i),o.setMinutes(r),o.setSeconds(s),o}function ve(e){const t=e.getTime()-se.getTime();return Math.round(t/ae)}function be(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Se(e){return be(e)===e.getDate()}function Ce(e,t,o){const n=e.getFullYear(),i=e.getMonth(),r=e.getDate(),s=new Date(n,i+t);return o&&r===be(e)||r>be(s)?s.setDate(be(s)):s.setDate(r),s}function Ee(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function we(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const n=me(e),i=me(t);let r=n.getDate(),s=i.getDate();const a=n.getMonth(),l=i.getMonth(),c=n.getFullYear(),h=i.getFullYear();let d=0,u=0;switch(o){case 0:31===r&&(r=30),30===r&&31===s&&(s=30),1===a&&r===(Ee(c)?29:28)&&(r=30,1===l&&s===(Ee(h)?29:28)&&(s=30)),d=c+(30*a+r)/360,u=h+(30*l+s)/360;break;case 1:let o=365;const n=c===h;if(!n&&!(c+1===h)||!n&&a<l||!n&&a===l&&r<s){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Ee(o)?366:365;o=t/e}else n?Ee(c)&&(o=366):(Ee(c)&&a<2&&(o=366),Ee(h)&&(l>1||1===l&&29===s)&&(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===r&&(r=30),31===s&&(s=30),d=c+(30*a+r)/360,u=h+(30*l+s)/360}return u-d}function ye(e){return JSON.stringify(e,Object.keys(e).sort())}function xe(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Re(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(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?void 0:e.constructor)===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ie(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 Te(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function Ae(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function Oe(e,t,o){return e<t?t:e>o?o:e}function Me(e,t,o){e.save(),e.font=Ne(o);const n=e.measureText(t).width;return e.restore(),n}function Ne(e){return`${e.italic?"italic ":""}${e.bold?"bold":H} ${_e(e)}px ${G}`}function _e(e){const t=e.fontSize||W;if(!re[t])throw new Error("Size of the font is not supported");return re[t]}function Fe(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const n=Math.ceil(Math.abs((t-e)/o)),i=Array(n);for(let t=0;t<n;t++)i[t]=e+t*o;return i}function De(e){return e.reduce(((e,t,o,n)=>{if(1===Math.abs(t-n[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*ke(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}function $e(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}function Le(e){return null!==pe(e)}const Pe=/^\[([^\[]+)\]\((.+)\)$/,Ue=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Ve(e){return Pe.test(e)}function ze(e,t){return`[${e}](${t})`}function Be(e){const t=e.match(Pe)||[],o=t[1],n=t[2];if(!o||!n)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:n}}const He="o-spreadsheet://";function We(e){if(!Ve(e))return!1;const{url:t}=Be(e);return t.startsWith(He)}function Ge(e){return`${He}${e}`}function qe(e){if(e.startsWith(He))return e.substr(He.length);throw new Error(`${e} is not a valid sheet link`)}function Ze(e){return void 0!==e}function je(e){return void 0!==e&&""!==e}function Xe(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?Xe(e):!e))}function Ye(e,t){for(let[o,n]of Object.entries(t))if(ye(n)===ye(e))return parseInt(o,10);const o=Object.keys(t),n=0===o.length?0:Math.max(...o.map((e=>parseInt(e,10))));return t[n+1]=e,n+1}function Ke(e){let t="";for(let o=0,n=e.length;o<n;o++)t+=e[o];return t}function Qe(e){let t,o=!1;const n=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return n.map=e=>Qe((()=>e(n()))),n}function Je(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function et(e,t){return"after"===e?t+1:t}function tt(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let n of o){if(typeof e[n]!=typeof e[n])return!1;if("object"==typeof e[n]){if(!tt(e[n],t[n]))return!1}else if(e[n]!==t[n])return!1}return!0}function ot(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function nt(e){return e?e.toLowerCase():""}const it=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function rt(e){return at(e.toString(16).padStart(6,"0"))}let st=0;function at(e){if(e.includes("rgba"))throw new Error(`rgba() conversion currently not supported: ${e}`);if(e.includes("rgb"))return function(e){return"#"+Ke(e.slice(4,-1).split(",").map((e=>parseInt(e,10).toString(16).padStart(2,"0")))).toUpperCase()}(e);if(3!==(e=e.replace("#","").toUpperCase()).length&&4!==e.length||(e=e.split("").reduce(((e,t)=>e+t+t),"")),""!==e.replace(/[a-f0-9]/gi,""))throw new Error("invalid color");return"#"+e}function lt(e){try{const{r:t,g:o,b:n,a:i}=gt(e);return ct(t)&&ct(o)&&ct(n)&&ct(i)}catch(e){return!1}}const ct=e=>e>=0&&e<=255;function ht(e,t,o,n=1){if(!ct(e)||!ct(t)||!ct(o)||n<0||n>1)throw new Error(`Invalid RGBA values ${[e,t,o,n]}`);return{a:n,b:o,g:t,r:e}}function dt(e){let{r:t,g:o,b:n}=gt(e);t/=255,o/=255,n/=255;const i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*i(t)+.7152*i(o)+.0722*i(n)}function ut(e){let t=e.r.toString(16),o=e.g.toString(16),n=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==n.length&&(n="0"+n),1==i.length&&(i="0"+i),"ff"===i&&(i=""),"#"+t+o+n+i}function gt(e){let t,o,n,i;if(7===(e=at(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),n=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),n=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:n}}function pt(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)),n=e.l-t/2,i=0,r=0,s=0;return 0<=e.h&&e.h<60?(i=t,r=o,s=0):60<=e.h&&e.h<120?(i=o,r=t,s=0):120<=e.h&&e.h<180?(i=0,r=t,s=o):180<=e.h&&e.h<240?(i=0,r=o,s=t):240<=e.h&&e.h<300?(i=o,r=0,s=t):300<=e.h&&e.h<360&&(i=t,r=0,s=o),i=Math.round(255*(i+n)),r=Math.round(255*(r+n)),s=Math.round(255*(s+n)),{a:e.a,r:i,g:r,b:s}}function ft(e){const t=e.r/255,o=e.g/255,n=e.b/255;let i=Math.min(t,o,n),r=Math.max(t,o,n),s=r-i,a=0,l=0,c=0;return a=0==s?0:r==t?(o-n)/s%6:r==o?(n-t)/s+2:(t-o)/s+4,a=Math.round(60*a),a<0&&(a+=360),c=(r+i)/2,l=0==s?0:s/(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}}const mt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),vt=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),bt=new RegExp(/^([A-Z]{1,3})+$/,"i"),St=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Ct=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Et=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[mt.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 wt(e){return St.test(e)}function yt(e){return Ct.test(e)}function xt(e){return bt.test(e)}function Rt(e){return vt.test(e)}function It(e){const t=e.split("!"),o=t.pop();return{sheetName:Te(t.join("!"))||void 0,xc:o}}function Tt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Tt(Math.floor(e/26)-1)+Tt(e%26)}function At(e){let t=0;const o=e.length;for(let n=0;n<o;n++){t+=(e.charCodeAt(n)-65+(n<o-1?1:0))*26**(o-n-1)}return t}function Ot(e){const t=(e=e.toUpperCase().trim()).match(mt);if(null!==t){const[o,n,i]=t;if(o===e){return{col:At(n),row:parseInt(i,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function Mt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+Tt(e)+(o.rowFixed?"$":"")+String(t+1)}const Nt=140,_t=20,Ft=.035;function Dt(e){return _t+(Nt-_t)*Math.exp(-Ft*(e-1))}const kt=20,$t=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,Lt=/0/g,Pt={};function Ut(e){let t=Pt[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let n;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(n=e.substring(t+1).indexOf("]")+t+2,0===n)throw new Error(`Invalid currency brackets format: ${e}`);const i=e.substring(t+2,n-1);if(i.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:i})}else{const i=e.substring(t).indexOf("[");n=i>-1?i+t:e.length;const r=e.substring(t,n);r.match(j)?o.push({type:"DATE",format:r}):o.push({type:"NUMBER",format:Kt(r)})}t=n}return o}(e),Pt[e]=t),t}function Vt(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Zt(e));return function(e,t){if("DATE"===t[0].type)return Wt(e,t[0].format);let o=e<0?"-":"";for(let n of t)switch(n.type){case"NUMBER":o+=zt(Math.abs(e),n.format);break;case"STRING":o+=n.format}return o}(e,Ut(t));case"object":return"0"}}function zt(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let o=0;void 0!==t.decimalPart&&(o=t.decimalPart.length);const{integerDigits:n,decimalDigits:i}=Ht(e,o);let r=function(e,t,o){var n;const i="0"===e?"":e;let r=i;const s=t.length-i.length;if(s>0){const e=(t.substring(0,s).match(Lt)||[]).length;r="0".repeat(e)+r}o&&(r=(null===(n=r.match($t))||void 0===n?void 0:n.join(","))||r);return r}(n,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(r+="."+function(e,t){let o=e;if(t.length-e.length>0){const n=(t.substring(e.length,t.length+1).match(Lt)||[]).length;o+="0".repeat(n)}return o}(i||"",t.decimalPart)),t.isPercent&&(r+="%"),r}const Bt=[];function Ht(e,t=kt){let o=Bt[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),Bt[t]=o);const[n,i]=o.format(e).split(".");return{integerDigits:n,decimalDigits:i}}function Wt(e,t){const o=me(e),n=t.indexOf("h");let i="",r="";return n>0?(i=Gt(o,t.substring(0,n-1)),r=qt(o,t.substring(n))):0===n?r=qt(o,t):n<0&&(i=Gt(o,t)),i+(i&&r?" ":"")+r}function Gt(e,t){const o=t.match(/\/|-|\s/)[0];return t.split(o).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function qt(e,t){let o=t.split(/:|\s/);const n=e.getHours(),i="a"===o[o.length-1];let r=n,s="";return i&&(r=0===r?12:r>12?r-12:r,s=n>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-se)/36e5).toString();case"hh":return r.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+s}function Zt(e){let{decimalDigits:t}=Ht(e,10);return t?"0."+"0".repeat(t.length):"0"}function jt(e,t,o){return Jt(Ut(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:o}]:e)).flat())}function Xt(e,t){var o;const n={...e},i=Math.sign(t),r=(null===(o=n.decimalPart)||void 0===o?void 0:o.length)||0,s=Math.min(Math.max(0,r+i),kt);return n.decimalPart="0".repeat(s),""===n.decimalPart&&delete n.decimalPart,n}const Yt=/,*?$/;function Kt(e){var t;if(function(e){return Boolean(e.replace(Qt,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const o=e.includes("%"),n=(null===(t=e.match(Yt))||void 0===t?void 0:t[0])||"",i=n?1e3**n.length:1;let r=e.slice(0,e.length-(n.length||0));const s=r.includes(",");if(r.match(/\..*,/))throw new Error("A format can't contain ',' symbol in the decimal part");r=r.replace("%","").replace(",","");const a=r.match(/[\%|,]/);if(a)throw new Error(`A format can only contain a single '${a[0]}' symbol`);const[l,c]=r.split(".");if(c&&c.length>20)throw new Error("A format can't contain more than 20 decimal places");return void 0!==c?{integerPart:l,isPercent:o,thousandsSeparator:s,decimalPart:c,magnitude:i}:{integerPart:l,isPercent:o,thousandsSeparator:s,magnitude:i}}const Qt=/[,#0.%]/g;function Jt(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}const eo=/^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+/,to="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",oo="(\\s*-)?",no="(\\s*[\\$€])?",io="^(("+[oo+no+to,oo+to+no,no+oo+to].join(")|(")+"))$",ro=new RegExp(io,"i");function so(e){return!!e&&ro.test(e.trim())}const ao=/[,\$€]+/g;function lo(e){e=e.replace(ao,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function co(e,t,o){const n=[...e].sort(((e,t)=>e-t));let i=(n.length+(o?-1:1))*t;if(o||i--,Number.isInteger(i))return n[i];const r=Math.ceil(i),s=Math.floor(i);return n[r]*(i-s)+n[s]*(r-i)}class ho{constructor(e,t){this.getSheetSize=t,this.prefixSheet=!1,this._zone=e.zone,this.parts=e.parts,this.prefixSheet=e.prefixSheet,this.invalidXc=e.invalidXc,this.sheetId=e.sheetId,this.invalidSheetName=e.invalidSheetName}static fromRange(e,t){return e instanceof ho?e:new ho(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:n}=this._zone;if(void 0!==n&&void 0!==o)return{left:e,top:t,right:n,bottom:o};if(void 0===o&&void 0!==n)return{right:n,top:t,left:e,bottom:this.getSheetSize(this.sheetId).height-1};if(void 0===n&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).width-1};throw new Error(r("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=yt(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),n=void 0===t.bottom,i=void 0===t.right;return n&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed,t.left===t.right&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed)),i&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed,t.top===t.bottom&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed)),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(void 0!==this._zone.right&&this._zone.right<this._zone.left){let e=this._zone.right;this._zone.right=this._zone.left,this._zone.left=e;let t=this.parts[1].colFixed;this.parts[1].colFixed=this.parts[0].colFixed,this.parts[0].colFixed=t}if(void 0!==this._zone.bottom&&this._zone.bottom<this._zone.top){let e=this._zone.bottom;this._zone.bottom=this._zone.top,this._zone.top=e;let t=this.parts[1].rowFixed;this.parts[1].rowFixed=this.parts[0].rowFixed,this.parts[0].rowFixed=t}}clone(e){return new ho({zone:(null==e?void 0:e.zone)?e.zone:{...this._zone},sheetId:(null==e?void 0: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:(null==e?void 0:e.parts)?e.parts:this.parts.map((e=>({rowFixed:e.rowFixed,colFixed:e.colFixed}))),prefixSheet:(null==e?void 0:e.prefixSheet)?e.prefixSheet:this.prefixSheet},this.getSheetSize)}}function uo(e,t,o){const n=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:n})}function go(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function po(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}class fo{constructor(){this.isFastIdStrategy=!1,this.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 mo(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let o,n,i,r,s=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(wt(c))i=r=At(c),o=n=0,s=!0;else if(yt(c))o=n=parseInt(c,10)-1,i=r=0,a=!0;else{const e=Ot(c);i=r=e.col,o=n=e.row,l=!0}if(2===t.length)if(wt(h))r=At(h),s=!0;else if(yt(h))n=parseInt(h,10)-1,a=!0;else{const e=Ot(h);r=e.col,n=e.row,o=s?n:o,i=a?r:i,l=!0}if(s&&a)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const d={top:o,left:i,bottom:s?void 0:n,right:a?void 0:r};return l=l&&(a||s),l&&(d.hasHeader=l),d}(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 vo(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 bo(e){const{bottom:t,top:o,left:n,right:i}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(n)||void 0!==i&&isNaN(i))&&((void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)&&e.top>=0&&e.left>=0)}function So(e){const{top:t,bottom:o,left:n,right:i}=e,s="hasHeader"in e&&e.hasHeader,a=t===o&&n===i;if(void 0===o&&void 0!==i)return 0!==t||s?`${Mt(n,t)}:${Tt(i)}`:`${Tt(n)}:${Tt(i)}`;if(void 0===i&&void 0!==o)return 0!==n||s?`${Mt(n,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==i)return a?Mt(n,t):`${Mt(n,t)}:${Mt(i,o)}`;throw new Error(r("Bad zone format"))}function Co(e,t,o,n,i){const r="left"===t?"columns":"rows",s="before"===n?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=s&&a&&a>s?ko(e,r,"RESIZE",i):s<e[t]?ko(e,r,"MOVE",i):{...e}}function Eo(e,t,o,n,i){const r="left"===t?"columns":"rows",s="before"===n?o-1:o,a="left"===t?"right":"bottom";return e[t]<=s&&e[a]>s?ko(e,r,"RESIZE",i):s<e[t]?ko(e,r,"MOVE",i):{...e}}function wo(e,t,o){const n="left"===t?"right":"bottom";let i=e[t],r=e[n];for(let s of o.sort(((e,t)=>t-e)))e[t]>s&&(i--,r--),e[t]<s&&e[n]>=s&&r--;return{...e,[t]:i,[n]:r}}function yo(e,t,o){const n="left"===t?"right":"bottom";let i=e[t],r=e[n];const s=e[n];for(let n of o.sort(((e,t)=>t-e)))e[t]>n&&(i--,void 0!==r&&r--),void 0!==s&&void 0!==r&&e[t]<=n&&s>=n&&r--;if(!(void 0!==r&&i>r))return{...e,[t]:i,[n]:r}}function xo(...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 Ro(e,t){if(To(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 Io(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function To(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Ao(e,t,o){const{left:n,right:i,top:r,bottom:s}=o;return e>=n&&e<=i&&t>=r&&t<=s}function Oo(e,t){return Io(xo(t,e),t)}function Mo(e,t){const o=e.map(mo),n=t.map(vo),i=Math.max(...o.concat(n).map((e=>e.bottom||0))),r=Math.max(...o.concat(n).map((e=>e.right||0))),s=o.map((e=>({...e,bottom:void 0===e.bottom?i+1:e.bottom,right:void 0===e.right?r+1:e.right}))),a=n.map((e=>({...e,bottom:void 0===e.bottom?i+1:e.bottom,right:void 0===e.right?r+1:e.right}))),l=function(e,t){const o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(s.map(Do).flat(),a.map(Do).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),n=[];let i=Po(t);for(const{col:e,row:t}of o)if(!Ao(e,t,i))if(e===i.left&&t===i.bottom+1){const e=i.bottom+1;i={...i,bottom:e}}else n.push(i),i=Po({col:e,row:t});return[...n,i]}(l);return function(e){if(0===e.length)return[];if(e.some((e=>e.left!==e.right)))throw new Error("only columns can be merged");const t=[],o=No(e),n=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>n(e,t)?xo(e,t):e),o.shift());t.push(e)}return No(t)}(c).map((e=>({...e,bottom:e.bottom===i+1?void 0:e.bottom,right:e.right===r+1?void 0:e.right}))).map(So)}function No(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Oo(e,t)))||o.push(e)}return o.reverse()}function _o(e){return{height:e.bottom-e.top+1,width:e.right-e.left+1}}function Fo(e){const{width:t,height:o}=_o(e);return 1===t||1===o}function Do(e){const t=[],[o,n]=[e.right,e.left].sort(((e,t)=>e-t)),[i,r]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of Fe(o,n+1))for(const o of Fe(i,r+1))t.push({col:e,row:o});return t}function ko(e,t,o,n){const i="both"===t?n[0]:"columns"===t?n:0,r="both"===t?n[1]:"rows"===t?n:0,s="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||s?!(Uo(e)&&!s)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=i,l.top+=r),void 0!==l.right&&(l.right+=i),void 0!==l.bottom&&(l.bottom+=r),l}function $o(e,t){let o,n;const{left:i,right:r,top:s,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=i?l:c!=r?c:l,n=h!=s?h:d!=a?d:h,{col:o,row:n}}function Lo(e){return{top:Math.min(e.top,e.bottom),bottom:Math.max(e.top,e.bottom),left:Math.min(e.left,e.right),right:Math.max(e.left,e.right)}}function Po(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function Uo(e){return void 0===e.right}function Vo(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function zo(...e){return e.length<2||1===Mo(e.map(So),[]).length}class Bo{constructor(){this.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 Ho=new Bo,Wo=new Bo;class Go extends t.Component{constructor(){super(...arguments),this.canvas=t.useRef("graphContainer")}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.createChart(e.chartJsConfig)}));let e=this.chartRuntime;t.onPatched((()=>{const t=this.chartRuntime;tt(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){var t,o,n,i;const r=e.chartJsConfig;r.data&&r.data.datasets?(this.chart.data=r.data,(null===(t=r.options)||void 0===t?void 0:t.title)&&(this.chart.config.options.title=r.options.title),r.options&&"valueLabel"in r.options&&(null===(o=r.options)||void 0===o?void 0:o.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.legend=null===(n=r.options)||void 0===n?void 0:n.legend,this.chart.config.options.scales=null===(i=r.options)||void 0===i?void 0:i.scales,this.chart.update({duration:0})}}Go.template="o-spreadsheet-ChartJsComponent",Wo.add("line",Go),Wo.add("bar",Go),Wo.add("pie",Go),Wo.add("gauge",Go);const qo=new Bo;var Zo;qo.add("INCREMENT_MODIFIER",{apply:(e,t)=>{var o;e.current+=e.increment;const n=e.current.toString(),i=Vt(e.current,null===(o=t.cell)||void 0===o?void 0:o.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:n},tooltip:n?{props:{content:i}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{var n,i;const r=(null===(n=t.cell)||void 0===n?void 0:n.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:null===(i=t.cell)||void 0===i?void 0:i.formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,o,n)=>{e.current+=e.increment;let i=0,r=0;switch(n){case"up":i=0,r=-e.current;break;case"down":i=0,r=e.current;break;case"left":i=-e.current,r=0;break;case"right":i=e.current,r=0}if(!t.cell||!t.cell.isFormula())return{cellData:{}};const s=t.sheetId,a=o.createAdaptedRanges(t.cell.dependencies,i,r,s),l=o.buildFormulaContent(s,t.cell,a);return{cellData:{border:t.border,style:t.cell.style,format:t.cell.format,content:l},tooltip:l?{props:{content:l}}:void 0}}}),function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(Zo||(Zo={}));const jo=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),Xo=new Set([...jo,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),Yo=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),Ko=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","CREATE_CHART","UPDATE_CHART","CREATE_FILTER_TABLE","REMOVE_FILTER_TABLE"]);function Qo(e){return Ko.has(e.type)}class Jo{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new Jo}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var en,tn,on;e.CommandResult=void 0,(en=e.CommandResult||(e.CommandResult={}))[en.Success=0]="Success",en[en.CancelledForUnknownReason=1]="CancelledForUnknownReason",en[en.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",en[en.MergeIsDestructive=3]="MergeIsDestructive",en[en.CellIsMerged=4]="CellIsMerged",en[en.InvalidTarget=5]="InvalidTarget",en[en.EmptyUndoStack=6]="EmptyUndoStack",en[en.EmptyRedoStack=7]="EmptyRedoStack",en[en.NotEnoughElements=8]="NotEnoughElements",en[en.NotEnoughSheets=9]="NotEnoughSheets",en[en.MissingSheetName=10]="MissingSheetName",en[en.DuplicatedSheetName=11]="DuplicatedSheetName",en[en.DuplicatedSheetId=12]="DuplicatedSheetId",en[en.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",en[en.WrongSheetMove=14]="WrongSheetMove",en[en.WrongSheetPosition=15]="WrongSheetPosition",en[en.InvalidAnchorZone=16]="InvalidAnchorZone",en[en.SelectionOutOfBound=17]="SelectionOutOfBound",en[en.TargetOutOfSheet=18]="TargetOutOfSheet",en[en.WrongCutSelection=19]="WrongCutSelection",en[en.WrongPasteSelection=20]="WrongPasteSelection",en[en.WrongPasteOption=21]="WrongPasteOption",en[en.WrongFigurePasteOption=22]="WrongFigurePasteOption",en[en.EmptyClipboard=23]="EmptyClipboard",en[en.EmptyRange=24]="EmptyRange",en[en.InvalidRange=25]="InvalidRange",en[en.InvalidZones=26]="InvalidZones",en[en.InvalidSheetId=27]="InvalidSheetId",en[en.InputAlreadyFocused=28]="InputAlreadyFocused",en[en.MaximumRangesReached=29]="MaximumRangesReached",en[en.InvalidChartDefinition=30]="InvalidChartDefinition",en[en.InvalidDataSet=31]="InvalidDataSet",en[en.InvalidLabelRange=32]="InvalidLabelRange",en[en.InvalidScorecardKeyValue=33]="InvalidScorecardKeyValue",en[en.InvalidScorecardBaseline=34]="InvalidScorecardBaseline",en[en.InvalidGaugeDataRange=35]="InvalidGaugeDataRange",en[en.EmptyGaugeRangeMin=36]="EmptyGaugeRangeMin",en[en.GaugeRangeMinNaN=37]="GaugeRangeMinNaN",en[en.EmptyGaugeRangeMax=38]="EmptyGaugeRangeMax",en[en.GaugeRangeMaxNaN=39]="GaugeRangeMaxNaN",en[en.GaugeRangeMinBiggerThanRangeMax=40]="GaugeRangeMinBiggerThanRangeMax",en[en.GaugeLowerInflectionPointNaN=41]="GaugeLowerInflectionPointNaN",en[en.GaugeUpperInflectionPointNaN=42]="GaugeUpperInflectionPointNaN",en[en.GaugeLowerBiggerThanUpper=43]="GaugeLowerBiggerThanUpper",en[en.InvalidAutofillSelection=44]="InvalidAutofillSelection",en[en.WrongComposerSelection=45]="WrongComposerSelection",en[en.MinBiggerThanMax=46]="MinBiggerThanMax",en[en.LowerBiggerThanUpper=47]="LowerBiggerThanUpper",en[en.MidBiggerThanMax=48]="MidBiggerThanMax",en[en.MinBiggerThanMid=49]="MinBiggerThanMid",en[en.FirstArgMissing=50]="FirstArgMissing",en[en.SecondArgMissing=51]="SecondArgMissing",en[en.MinNaN=52]="MinNaN",en[en.MidNaN=53]="MidNaN",en[en.MaxNaN=54]="MaxNaN",en[en.ValueUpperInflectionNaN=55]="ValueUpperInflectionNaN",en[en.ValueLowerInflectionNaN=56]="ValueLowerInflectionNaN",en[en.MinInvalidFormula=57]="MinInvalidFormula",en[en.MidInvalidFormula=58]="MidInvalidFormula",en[en.MaxInvalidFormula=59]="MaxInvalidFormula",en[en.ValueUpperInvalidFormula=60]="ValueUpperInvalidFormula",en[en.ValueLowerInvalidFormula=61]="ValueLowerInvalidFormula",en[en.InvalidSortZone=62]="InvalidSortZone",en[en.WaitingSessionConfirmation=63]="WaitingSessionConfirmation",en[en.MergeOverlap=64]="MergeOverlap",en[en.TooManyHiddenElements=65]="TooManyHiddenElements",en[en.Readonly=66]="Readonly",en[en.InvalidViewportSize=67]="InvalidViewportSize",en[en.InvalidScrollingDirection=68]="InvalidScrollingDirection",en[en.FigureDoesNotExist=69]="FigureDoesNotExist",en[en.InvalidConditionalFormatId=70]="InvalidConditionalFormatId",en[en.InvalidCellPopover=71]="InvalidCellPopover",en[en.EmptyTarget=72]="EmptyTarget",en[en.InvalidFreezeQuantity=73]="InvalidFreezeQuantity",en[en.FrozenPaneOverlap=74]="FrozenPaneOverlap",en[en.ValuesNotChanged=75]="ValuesNotChanged",en[en.InvalidFilterZone=76]="InvalidFilterZone",en[en.FilterOverlap=77]="FilterOverlap",en[en.FilterNotFound=78]="FilterNotFound",en[en.MergeInFilter=79]="MergeInFilter",en[en.NonContinuousTargets=80]="NonContinuousTargets",en[en.DuplicatedFigureId=81]="DuplicatedFigureId",en[en.InvalidSelectionStep=82]="InvalidSelectionStep",en[en.DuplicatedChartId=83]="DuplicatedChartId",en[en.ChartDoesNotExist=84]="ChartDoesNotExist",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(tn||(tn={})),function(e){e[e.Background=0]="Background",e[e.Highlights=1]="Highlights",e[e.Clipboard=2]="Clipboard",e[e.Search=3]="Search",e[e.Chart=4]="Chart",e[e.Selection=5]="Selection",e[e.Autofill=6]="Autofill",e[e.Headers=7]="Headers"}(on||(on={}));const nn=new Bo;nn.add("simple_value_copy",{condition:(e,t)=>{var o;return 1===t.length&&!e.isFormula()&&!(null===(o=e.format)||void 0===o?void 0:o.match(j))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("copy_text",{condition:e=>!e.isFormula()&&e.evaluated.type===Zo.text,generateRule:()=>({type:"COPY_MODIFIER"}),sequence:20}).add("update_formula",{condition:e=>e.isFormula(),generateRule:(e,t)=>({type:"FORMULA_MODIFIER",increment:t.length,current:0}),sequence:30}).add("increment_number",{condition:e=>e.evaluated.type===Zo.number,generateRule:(e,t)=>{const o=function(e,t){let o=[],n=!1;for(let i of t)if(i===e&&(n=!0),(null==i?void 0:i.evaluated.type)===Zo.number)o.push(i.evaluated.value);else{if(n)return o;o=[]}return o}(e,t);let n=1;return 2==o.length?n=2*(o[1]-o[0]):o.length>2&&(n=function(e){const t=[];let o=e[0];for(let n=1;n<e.length;n++){const i=e[n];t.push(i-o),o=i}return t.reduce(((e,t)=>e+t),0)/t.length}(o)*o.length),{type:"INCREMENT_MODIFIER",increment:n,current:e.evaluated.type===Zo.number?e.evaluated.value:0}},sequence:40});const rn={};let sn=0;function an(e,...t){const o="__sheet__"+sn++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],n=[];let i=[];function r(e,t){const n=[];for(const i of o[e]){let s=t&&t+" "+i||i;s.includes("&")&&(s=i.replace(/&/g,t||"")),e<o.length-1&&(s=r(e+1,s)),n.push(s)}return n.join(", ")}function s(){i.length&&(n.push(r(0)+" {"),n.push(...i),n.push("}"),i=[])}for(;t.length;){let e=t.shift();"}"===e?(s(),o.pop()):("{"===t[0]&&(s(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&i.push(" "+e+";"))}return n.join("\n")}(t),rn[e]=o}(o,String.raw(e,...t)),function(e){const t=rn[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function ln({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function cn(e){return"\n"+Object.entries(e).map((([e,t])=>`${e}: ${t};`)).join("\n")+"\n"}an`
2
2
  .o-error-tooltip {
3
3
  font-size: 13px;
4
4
  background-color: white;
5
5
  border-left: 3px solid red;
6
6
  padding: 10px;
7
7
  }
8
- `;class cn extends t.Component{}cn.size={width:180,height:40},cn.template="o-spreadsheet-ErrorToolTip",cn.components={};const hn={onHover:(e,t)=>{const o=t.getCell(t.getActiveSheetId(),e.col,e.row);return(null==o?void 0:o.evaluated.type)===qo.error&&o.evaluated.error.logLevel>l.silent?{isOpen:!0,props:{text:o.evaluated.error.message},Component:cn,cellCorner:"TopRight"}:{isOpen:!1}}};class dn extends t.Component{constructor(){super(...arguments),this.itemRef=t.useRef("menuValueItem")}setup(){t.onWillPatch((()=>{this.props.scrolledTo&&this.scrollListToSelectedValue()}))}scrollListToSelectedValue(){var e,t;this.itemRef.el&&(null===(t=(e=this.itemRef.el).scrollIntoView)||void 0===t||t.call(e,{block:"bottom"===this.props.scrolledTo?"end":"start"}))}}dn.template="o-spreadsheet-FilterMenuValueItem";const un=sn`
8
+ `;class hn extends t.Component{}hn.size={width:180,height:40},hn.template="o-spreadsheet-ErrorToolTip",hn.components={};const dn={onHover:(e,t)=>{const o=t.getCell(t.getActiveSheetId(),e.col,e.row);return(null==o?void 0:o.evaluated.type)===Zo.error&&o.evaluated.error.logLevel>l.silent?{isOpen:!0,props:{text:o.evaluated.error.message},Component:hn,cellCorner:"TopRight"}:{isOpen:!1}}};class un extends t.Component{constructor(){super(...arguments),this.itemRef=t.useRef("menuValueItem")}setup(){t.onWillPatch((()=>{this.props.scrolledTo&&this.scrollListToSelectedValue()}))}scrollListToSelectedValue(){var e,t;this.itemRef.el&&(null===(t=(e=this.itemRef.el).scrollIntoView)||void 0===t||t.call(e,{block:"bottom"===this.props.scrolledTo?"end":"start"}))}}un.template="o-spreadsheet-FilterMenuValueItem";const gn=an`
9
9
  .o-filter-menu {
10
10
  box-sizing: border-box;
11
11
  padding: 8px 16px;
@@ -107,7 +107,7 @@
107
107
  }
108
108
  }
109
109
  }
110
- `;class gn extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{et(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getFilter(t,e.col,e.row);if(!o)return[];const n=(o.filteredZone?Fo(o.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:o})=>{var n;return null===(n=this.env.model.getters.getCell(t,e,o))||void 0===n?void 0:n.formattedValue})),i=this.env.model.getters.getFilterValues(t,e.col,e.row),r=[...n,...i],s=i.map(ot);return[...new Set(r.map(ot))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===s.findIndex((t=>t===e)),string:r.find((t=>ot(t)===e))||""})))}checkValue(e){var t;this.state.selectedValue=e.string,e.checked=!e.checked,null===(t=this.searchBar.el)||void 0===t||t.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable(e,t.col,t.row)}get displayedValues(){return this.state.textFilter?function(e,t,o){const n=[];return t.forEach((t=>{const i=function(e,t){e=e.toLocaleLowerCase();let o=0,n=0,i=(t=t.toLocaleLowerCase()).length,r=0;for(let s=0;s<i;s++)t[s]===e[r]?(r++,n+=100+n-s/200):n=0,o+=n;return r===e.length?o:0}(e,o(t));i>0&&n.push({score:i,elem:t})})),n.sort(((e,t)=>t.score-e.score)),n.map((e=>e.elem))}(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const o=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...o,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let o;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));o=-1===e?void 0:e}switch(e.key){case"ArrowDown":o=void 0===o?0:Math.min(o+1,t.length-1),e.preventDefault();break;case"ArrowUp":o=void 0===o?t.length-1:Math.max(o-1,0),e.preventDefault();break;case"Enter":void 0!==o&&this.checkValue(t[o]),e.preventDefault()}this.state.selectedValue=void 0!==o?t[o].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,o;const n=this.props.filterPosition,i=this.filterTable;if(!n||!i||!i.contentZone)return;const r=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:r,col:n.col,row:i.contentZone.top,zone:i.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(o=(t=this.props).onClosed)||void 0===o||o.call(t)}}gn.size={width:z,height:295},gn.template="o-spreadsheet-FilterMenu",gn.style=un,gn.components={FilterMenuValueItem:dn};const pn={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:gn,cellCorner:"BottomLeft"})};function fn(e,t){const o=[];for(const n of e.children)"function"==typeof n?o.push(...n(t)):o.push(n);return o.sort(((e,t)=>e.sequence-t.sequence))}function mn(e,t){return"function"==typeof e.name?e.name(t):e.name}function vn(e,t){return!!t.target&&e.contains(t.target)}function bn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function Sn(e){const o=t.useState({x:0,y:0});function n(){const t=e.el;if(null===t)return;const{top:n,left:i}=t.getBoundingClientRect();i===o.x&&n===o.y||(o.x=i,o.y=n)}return t.onMounted(n),t.onPatched(n),o}class Cn extends t.Component{constructor(){super(...arguments),this.spreadsheetPosition=function(){const e=t.useState({x:0,y:0});let o=document.querySelector(".o-spreadsheet");function n(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:n}=o.getBoundingClientRect();e.x=n,e.y=t}}return n(),t.onMounted(n),t.onPatched(n),e}()}get style(){const e="left:"+(this.horizontalPosition()-this.spreadsheetPosition.x),t="top:"+(this.verticalPosition()-this.spreadsheetPosition.y),o=Math.max(0,this.viewportDimension.height-36-F),n=`max-height:${o}`,i=0!==o?"box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);":"";return`\n position: absolute;\n z-index: ${ne.Popover};\n ${t}px;\n ${e}px;\n ${n}px;\n width:${this.props.childWidth}px;\n overflow-y: auto;\n overflow-x: hidden;\n ${i}\n `}get viewportDimension(){return this.env.model.getters.getSheetViewDimensionWithHeaders()}get shouldRenderRight(){const{x:e}=this.props.position;return e+this.props.childWidth<this.viewportDimension.width}get shouldRenderBottom(){const{y:e}=this.props.position;return e+this.props.childHeight<this.viewportDimension.height+(this.env.isDashboard()?0:63)}horizontalPosition(){const{x:e}=this.props.position;return this.shouldRenderRight?e:e-this.props.childWidth-this.props.flipHorizontalOffset}verticalPosition(){const{y:e}=this.props.position;return this.shouldRenderBottom?e:Math.max(e-this.props.childHeight+this.props.flipVerticalOffset,this.props.marginTop)}}Cn.template="o-spreadsheet-Popover",Cn.defaultProps={flipHorizontalOffset:0,flipVerticalOffset:0,verticalOffset:0,marginTop:0,onMouseWheel:()=>{}},sn`
110
+ `;class pn extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{tt(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getFilter(t,e.col,e.row);if(!o)return[];const n=(o.filteredZone?Do(o.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:o})=>{var n;return null===(n=this.env.model.getters.getCell(t,e,o))||void 0===n?void 0:n.formattedValue})),i=this.env.model.getters.getFilterValues(t,e.col,e.row),r=[...n,...i],s=i.map(nt);return[...new Set(r.map(nt))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===s.findIndex((t=>t===e)),string:r.find((t=>nt(t)===e))||""})))}checkValue(e){var t;this.state.selectedValue=e.string,e.checked=!e.checked,null===(t=this.searchBar.el)||void 0===t||t.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable(e,t.col,t.row)}get displayedValues(){return this.state.textFilter?function(e,t,o){const n=[];return t.forEach((t=>{const i=function(e,t){e=e.toLocaleLowerCase();let o=0,n=0,i=(t=t.toLocaleLowerCase()).length,r=0;for(let s=0;s<i;s++)t[s]===e[r]?(r++,n+=100+n-s/200):n=0,o+=n;return r===e.length?o:0}(e,o(t));i>0&&n.push({score:i,elem:t})})),n.sort(((e,t)=>t.score-e.score)),n.map((e=>e.elem))}(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const o=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...o,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let o;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));o=-1===e?void 0:e}switch(e.key){case"ArrowDown":o=void 0===o?0:Math.min(o+1,t.length-1),e.preventDefault();break;case"ArrowUp":o=void 0===o?t.length-1:Math.max(o-1,0),e.preventDefault();break;case"Enter":void 0!==o&&this.checkValue(t[o]),e.preventDefault()}this.state.selectedValue=void 0!==o?t[o].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,o;const n=this.props.filterPosition,i=this.filterTable;if(!n||!i||!i.contentZone)return;const r=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:r,col:n.col,row:i.contentZone.top,zone:i.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(o=(t=this.props).onClosed)||void 0===o||o.call(t)}}pn.size={width:z,height:295},pn.template="o-spreadsheet-FilterMenu",pn.style=gn,pn.components={FilterMenuValueItem:un};const fn={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:pn,cellCorner:"BottomLeft"})};function mn(e,t){const o=[];for(const n of e.children)"function"==typeof n?o.push(...n(t)):o.push(n);return o.sort(((e,t)=>e.sequence-t.sequence))}function vn(e,t){return"function"==typeof e.name?e.name(t):e.name}function bn(e,t){return!!t.target&&e.contains(t.target)}function Sn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function Cn(e){const o=t.useState({x:0,y:0});function n(){const t=e.el;if(null===t)return;const{top:n,left:i}=t.getBoundingClientRect();i===o.x&&n===o.y||(o.x=i,o.y=n)}return t.onMounted(n),t.onPatched(n),o}class En extends t.Component{constructor(){super(...arguments),this.spreadsheetPosition=function(){const e=t.useState({x:0,y:0});let o=document.querySelector(".o-spreadsheet");function n(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:n}=o.getBoundingClientRect();e.x=n,e.y=t}}return n(),t.onMounted(n),t.onPatched(n),e}()}get style(){const e="left:"+(this.horizontalPosition()-this.spreadsheetPosition.x),t="top:"+(this.verticalPosition()-this.spreadsheetPosition.y),o=Math.max(0,this.viewportDimension.height-36-F),n=`max-height:${o}`,i=0!==o?"box-shadow: 1px 2px 5px 2px rgb(51 51 51 / 15%);":"";return`\n position: absolute;\n z-index: ${ne.Popover};\n ${t}px;\n ${e}px;\n ${n}px;\n width:${this.props.childWidth}px;\n overflow-y: auto;\n overflow-x: hidden;\n ${i}\n `}get viewportDimension(){return this.env.model.getters.getSheetViewDimensionWithHeaders()}get shouldRenderRight(){const{x:e}=this.props.position;return e+this.props.childWidth<this.viewportDimension.width}get shouldRenderBottom(){const{y:e}=this.props.position;return e+this.props.childHeight<this.viewportDimension.height+(this.env.isDashboard()?0:63)}horizontalPosition(){const{x:e}=this.props.position;return this.shouldRenderRight?e:e-this.props.childWidth-this.props.flipHorizontalOffset}verticalPosition(){const{y:e}=this.props.position;return this.shouldRenderBottom?e:Math.max(e-this.props.childHeight+this.props.flipVerticalOffset,this.props.marginTop)}}En.template="o-spreadsheet-Popover",En.defaultProps={flipHorizontalOffset:0,flipVerticalOffset:0,verticalOffset:0,marginTop:0,onMouseWheel:()=>{}},an`
111
111
  .o-menu {
112
112
  background-color: white;
113
113
  padding: 5px 0px;
@@ -154,7 +154,7 @@
154
154
  }
155
155
  }
156
156
  }
157
- `;class En extends t.Component{constructor(){super(...arguments),this.MENU_WIDTH=z,this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=Sn(this.menuRef)}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0}),t.useExternalListener(window,"contextmenu",this.onExternalClick,{capture:!0}),t.onWillUpdateProps((e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){return this.menuComponentHeight(this.props.menuItems)}get subMenuHeight(){return this.menuComponentHeight(this.subMenu.menuItems)}get popover(){const e=1===this.props.depth;let t=6;return this.env.isDashboard()||(t+=89),{marginTop:t,flipHorizontalOffset:z*(this.props.depth-1),flipVerticalOffset:e?0:28}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,o;const n=await e.action(this.env);this.close(),null===(o=(t=this.props).onMenuClicked)||void 0===o||o.call(t,{detail:n})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.props.menuItems.slice(0,e);return this.menuComponentHeight(t)+this.position.y}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>vn(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}menuComponentHeight(e){const t=e.filter((e=>e.separator));return 28*e.length+11*t.length}getName(e){return mn(e,this.env)}getDescription(e){return(t=e).description?t.description:"";var t}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.model.getters.isReadonly()||e.isReadonlyAllowed)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){const o=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+z,y:o-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=fn(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var o;return(null===(o=e.parentMenu)||void 0===o?void 0:o.id)===t.id}closeSubMenu(){this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 0}onClickMenu(e,t){this.isEnabled(e)&&(this.isRoot(e)?this.openSubMenu(e,t):this.activateMenu(e))}onMouseOver(e,t){e.isEnabled(this.env)&&(this.isRoot(e)?this.openSubMenu(e,t):this.closeSubMenu())}}En.template="o-spreadsheet-Menu",En.components={Menu:En,Popover:Cn},En.defaultProps={depth:1};sn`
157
+ `;class wn extends t.Component{constructor(){super(...arguments),this.MENU_WIDTH=z,this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=Cn(this.menuRef)}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0}),t.useExternalListener(window,"contextmenu",this.onExternalClick,{capture:!0}),t.onWillUpdateProps((e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){return this.menuComponentHeight(this.props.menuItems)}get subMenuHeight(){return this.menuComponentHeight(this.subMenu.menuItems)}get popover(){const e=1===this.props.depth;let t=6;return this.env.isDashboard()||(t+=89),{marginTop:t,flipHorizontalOffset:z*(this.props.depth-1),flipVerticalOffset:e?0:28}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,o;const n=await e.action(this.env);this.close(),null===(o=(t=this.props).onMenuClicked)||void 0===o||o.call(t,{detail:n})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.props.menuItems.slice(0,e);return this.menuComponentHeight(t)+this.position.y}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>bn(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}menuComponentHeight(e){const t=e.filter((e=>e.separator));return 28*e.length+11*t.length}getName(e){return vn(e,this.env)}getDescription(e){return(t=e).description?t.description:"";var t}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.model.getters.isReadonly()||e.isReadonlyAllowed)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){const o=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+z,y:o-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=mn(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var o;return(null===(o=e.parentMenu)||void 0===o?void 0:o.id)===t.id}closeSubMenu(){this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 0}onClickMenu(e,t){this.isEnabled(e)&&(this.isRoot(e)?this.openSubMenu(e,t):this.activateMenu(e))}onMouseOver(e,t){e.isEnabled(this.env)&&(this.isRoot(e)?this.openSubMenu(e,t):this.closeSubMenu())}}wn.template="o-spreadsheet-Menu",wn.components={Menu:wn,Popover:En},wn.defaultProps={depth:1};an`
158
158
  .o-link-tool {
159
159
  font-size: 13px;
160
160
  background-color: white;
@@ -198,7 +198,7 @@
198
198
  cursor: pointer;
199
199
  color: #000;
200
200
  }
201
- `;class wn extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getCell(o,e,t);if(null==n?void 0:n.isLink())return n;throw new Error(`LinkDisplay Component can only be used with link cells. ${Ot(e,t)} is not a link.`)}openLink(){this.cell.action(this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.props.cellPosition,n=this.cell.style,i=(null==n?void 0:n.textColor)===x||null==n?void 0:n.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:o,sheetId:e,content:this.cell.link.label,style:{...n,textColor:i,underline:void 0}})}}wn.components={Menu:En},wn.template="o-spreadsheet-LinkDisplay",wn.size={width:220,height:43};const yn={onHover:(e,t)=>{const o=t.getActiveSheetId(),n=t.getCell(o,e.col,e.row);return!t.isDashboard()&&(null==n?void 0:n.isLink())&&t.isVisibleInViewport(o,e.col,e.row)?{isOpen:!0,Component:wn,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}},xn=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,description:"",action:!1,children:[],separator:!1,icon:!1,id:e});function Rn(e,t){return Object.assign({},xn(e),t)}function In(e){return"function"!=typeof e}class Tn extends zo{add(e,t){return this.content[e]=Rn(e,t),this}addChild(e,t,o){const n=t.splice(0,1)[0];let i=this.content[n];if(!i)throw new Error(`Path ${n+":"+t.join(":")} not found`);for(let e of t)if(i=i.children.filter(In).find((t=>t.id===e)),!i)throw new Error(`Path ${n+":"+t.join(":")} not found`);return"function"!=typeof o?i.children.push(Rn(e,o)):i.children.push(o),this}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}const An=new Tn;An.add("sheet",{name:r("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map(((e,t)=>Rn(e.id,{name:e.name,sequence:t,action:()=>({link:{label:e.name,url:Ge(e.id)},urlRepresentation:e.name,isUrlEditable:!1})})))));sn`
201
+ `;class yn extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getCell(o,e,t);if(null==n?void 0:n.isLink())return n;throw new Error(`LinkDisplay Component can only be used with link cells. ${Mt(e,t)} is not a link.`)}openLink(){this.cell.action(this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.props.cellPosition,n=this.cell.style,i=(null==n?void 0:n.textColor)===x||null==n?void 0:n.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:o,sheetId:e,content:this.cell.link.label,style:{...n,textColor:i,underline:void 0}})}}yn.components={Menu:wn},yn.template="o-spreadsheet-LinkDisplay",yn.size={width:220,height:43};const xn={onHover:(e,t)=>{const o=t.getActiveSheetId(),n=t.getCell(o,e.col,e.row);return!t.isDashboard()&&(null==n?void 0:n.isLink())&&t.isVisibleInViewport(o,e.col,e.row)?{isOpen:!0,Component:yn,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}},Rn=e=>({isVisible:()=>!0,isEnabled:()=>!0,isReadonlyAllowed:!1,description:"",action:!1,children:[],separator:!1,icon:!1,id:e});function In(e,t){return Object.assign({},Rn(e),t)}function Tn(e){return"function"!=typeof e}class An extends Bo{add(e,t){return this.content[e]=In(e,t),this}addChild(e,t,o){const n=t.splice(0,1)[0];let i=this.content[n];if(!i)throw new Error(`Path ${n+":"+t.join(":")} not found`);for(let e of t)if(i=i.children.filter(Tn).find((t=>t.id===e)),!i)throw new Error(`Path ${n+":"+t.join(":")} not found`);return"function"!=typeof o?i.children.push(In(e,o)):i.children.push(o),this}getAll(){return super.getAll().sort(((e,t)=>e.sequence-t.sequence))}}const On=new An;On.add("sheet",{name:r("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map(((e,t)=>In(e.id,{name:e.name,sequence:t,action:()=>({link:{label:e.name,url:Ge(e.id)},urlRepresentation:e.name,isUrlEditable:!1})})))));an`
202
202
  .o-link-editor {
203
203
  font-size: 13px;
204
204
  background-color: white;
@@ -268,7 +268,7 @@
268
268
  }
269
269
  }
270
270
  }
271
- `;class On extends t.Component{constructor(){super(...arguments),this.menuItems=An.getAll(),this.state=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Sn(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getCell(o,e,t);return(null==n?void 0:n.isLink())?{link:{url:n.link.url,label:n.formattedValue},urlRepresentation:n.urlRepresentation,isUrlEditable:n.isUrlEditable}:{link:{url:"",label:(null==n?void 0:n.formattedValue)||""},isUrlEditable:!0,urlRepresentation:""}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e;this.state.link.url=t.link.url,this.state.link.label=t.link.label,this.state.isUrlEditable=t.isUrlEditable,this.state.urlRepresentation=t.urlRepresentation}openMenu(){this.menu.isOpen=!0}removeLink(){this.state.link.url="",this.state.urlRepresentation="",this.state.isUrlEditable=!0}save(){var e,t;const{col:o,row:n}=this.props.cellPosition,i=this.state.link.label||this.state.link.url;this.env.model.dispatch("UPDATE_CELL",{col:o,row:n,sheetId:this.env.model.getters.getActiveSheetId(),content:ze(i,this.state.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.state.link.url&&this.save();break;case"Escape":this.cancel()}}}On.template="o-spreadsheet-LinkEditor",On.size={width:340,height:180},On.components={Menu:En};const Mn={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:On,cellCorner:"BottomLeft"})},Nn=new zo;Nn.add("ErrorToolTip",hn).add("LinkCell",yn).add("LinkEditor",Mn).add("FilterMenu",pn);const _n=new zo,Fn=new zo,Dn=new zo,kn=(new zo).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let n=0;n<e.quantity;n++)t.push(n+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let n of De(o)){const o=0===n[0]?0:n[0]-1,i=0===n[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:n.length,base:o,sheetId:e.sheetId,position:i})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of Yo.values())kn.contains(e)||kn.add(e,$n);function $n(e){return[e]}const Ln=[qo.number,qo.error,qo.text,qo.boolean];function Pn(e,t){return{index:t,type:e?e.evaluated.type:qo.empty,value:e?e.evaluated.value:""}}function Un(e,t,o,n,i){let s=Qo.Success,a=n.right>n.left;if(e.model.getters.doesIntersectMerge(t,n)){let o;a=!1;for(let i=n.top;i<=n.bottom;i++){o=[];for(let r=n.left;r<=n.right;r++){let n=e.model.getters.getMerge(t,r,i);n&&!o.includes(n.id.toString())&&o.push(n.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i});else{const o=e.model.getters.getContiguousZone(t,n);Ro(o,n)?s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i}):e.askConfirmation(r("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?"),(()=>{n=o,s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i})}),(()=>{s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i})}))}if(s.isCancelledBecause(62)){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:n}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function Vn(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const zn={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function Bn(e,t,o){const n=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});n.isCancelledBecause(77)?e.raiseError(zn.filterOverlap):n.isCancelledBecause(79)?e.raiseError(zn.mergeInFilter):n.isCancelledBecause(80)&&e.raiseError(zn.nonContinuousTargets)}const Hn={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Wn(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Hn.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Hn.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Hn.wrongFigurePasteOption):t.reasons.includes(74)&&e.raiseError(Hn.frozenPaneOverlap))}function Gn(e,t,o){const n=e.model.dispatch("PASTE",{target:t,pasteOption:o});Wn(e,n)}function qn(e,t,o){const n=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o});Wn(e,n)}function Zn(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function jn(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function Xn(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Yn(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}async function Kn(e){try{return await e.clipboard.readText()}catch(e){return console.warn("The OS clipboard could not be read."),void console.error(e)}}const Qn=async e=>{e.model.dispatch("COPY"),await e.clipboard.writeText(e.model.getters.getClipboardContent())},Jn=async e=>{Vn(e),await e.clipboard.writeText(e.model.getters.getClipboardContent())},ei=async e=>{const t=e.model.getters.getClipboardContent(),o=await Kn(e),n=e.model.getters.getSelectedZones();o&&o!==t?qn(e,n,o):Gn(e,n)},ti=async e=>{const t=e.model.getters.getClipboardContent(),o=await Kn(e),n=e.model.getters.getSelectedZones();o&&o!==t?e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:n,text:o}):e.model.dispatch("PASTE",{target:e.model.getters.getSelectedZones(),pasteOption:"onlyValue"})},oi=e=>Gn(e,e.model.getters.getSelectedZones(),"onlyFormat"),ni=e=>!e.model.getters.isCutOperation(),ii=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const n=e.model.getters.getActiveRows();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.top,o=n.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},ri=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},si=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const n=e.model.getters.getActiveCols();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.left,o=n.right}return t===o?r("Delete column %s",It(t)):r("Delete columns %s - %s",It(t),It(o))},ai=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},li=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Wn(e,o)},ci=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Wn(e,o)},hi=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Wn(e,o)},di=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Wn(e,o)},ui=e=>{const t=e.model.getters.getActiveRows();let o,n;if(t.size)o=Math.min(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,n=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:n,dimension:"ROW"})},gi=e=>{const t=e.model.getters.getActiveRows();let o,n;if(t.size)o=Math.max(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,n=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:n,dimension:"ROW"})},pi=e=>{const t=e.model.getters.getActiveCols();let o,n;if(t.size)o=Math.min(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,n=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:n})},fi=e=>{const t=e.model.getters.getActiveCols();let o,n;if(t.size)o=Math.max(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,n=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:n})},mi=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},vi=e=>{let{col:t,row:o}=e.model.getters.getPosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},bi=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},Si=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),n=e.model.getters.getActiveSheetId();Un(e,n,t.cell,o[0],"ascending")},Ci=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),n=e.model.getters.getActiveSheetId();Un(e,n,t.cell,o[0],"descending")},Ei=e=>1===e.model.getters.getSelectedZones().length,wi=new Tn;wi.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:Jn}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Qn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ei}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:ni}).addChild("paste_value_only",["paste_special"],{name:r("Paste values only"),sequence:10,action:ti}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:oi}).add("add_row_before",{name:e=>{const t=jn(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},sequence:70,action:ui,isVisible:Ei}).add("add_column_before",{name:e=>{const t=Zn(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},sequence:90,action:pi,isVisible:Ei}).add("insert_cell",{name:r("Insert cells"),sequence:100,isVisible:Ei,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:r("Shift down"),sequence:10,action:li}).addChild("insert_cell_right",["insert_cell"],{name:r("Shift right"),sequence:20,action:ci}).add("delete_row",{name:ii,sequence:110,action:ri,isVisible:Ei}).add("delete_column",{name:si,sequence:120,action:ai,isVisible:Ei}).add("delete_cell",{name:r("Delete cells"),sequence:130,isVisible:Ei}).addChild("delete_cell_up",["delete_cell"],{name:r("Shift up"),sequence:10,action:hi}).addChild("delete_cell_down",["delete_cell"],{name:r("Shift left"),sequence:20,action:di}).add("insert_link",{name:r("Insert link"),separator:!0,sequence:150,action:vi});const yi=new Tn;yi.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:Jn}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Qn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ei}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:ni}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:ti}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:oi}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,isVisible:Ei,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:Si}).addChild("sort_descending",["sort_columns"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ci}).add("add_column_before",{name:e=>{const t=Zn(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},sequence:70,action:pi}).add("add_column_after",{name:e=>{const t=Zn(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},sequence:80,action:fi}).add("delete_column",{name:si,sequence:90,action:ai}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const n=e.model.getters.getActiveCols();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.left,o=n.right}return t===o?r("Clear column %s",It(t)):r("Clear columns %s - %s",It(t),It(o))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],n=t[t.length-1];return 1===t.length?r("Hide column %s",It(o).toString()):n-o+1===t.length?r("Hide columns %s - %s",It(o).toString(),It(n).toString()):r("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>o.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:r("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:110,action:mi});const xi=new Tn;function Ri(e,t,o){const n=e.model.getters.getSheetName(t),i=r("Rename Sheet");e.editText(i,(o=>{if(null===o||o===n)return;""===o&&Ri(e,t,r("The sheet name cannot be empty."));const i=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});i.isSuccessful||(i.reasons.includes(11)&&Ri(e,t,r("A sheet with the name %s already exists. Please select another name.",o)),i.reasons.includes(13)&&Ri(e,t,r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",J.join(" "))))}),{placeholder:n,error:o})}xi.add("cut",{name:r("Cut"),sequence:10,description:"Ctrl+X",action:Jn}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Qn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ei}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:ni}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:ti}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:oi}).add("add_row_before",{name:e=>{const t=jn(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},sequence:50,action:ui}).add("add_row_after",{name:e=>{const t=jn(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},sequence:60,action:gi}).add("delete_row",{name:ii,sequence:70,action:ri}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const n=e.model.getters.getActiveRows();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.top,o=n.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],n=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):n-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(n+1).toString()):r("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>o.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:r("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:90,action:mi});const Ii=new Tn;Ii.add("delete",{name:r("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(r("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:r("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}}).add("rename",{name:r("Rename"),sequence:30,action:e=>Ri(e,e.model.getters.getActiveSheetId())}).add("move_right",{name:r("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getVisibleSheetIds();return o.indexOf(t)!==o.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:r("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"left"})}).add("hide_sheet",{name:r("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})});const Ti={Errors:{25:r("The range is invalid"),50:r("The argument is missing. Please provide a value"),51:r("The second argument is missing. Please provide a value"),52:r("The minpoint must be a number"),53:r("The midpoint must be a number"),54:r("The maxpoint must be a number"),55:r("The first value must be a number"),56:r("The second value must be a number"),46:r("Minimum must be smaller then Maximum"),49:r("Minimum must be smaller then Midpoint"),48:r("Midpoint must be smaller then Maximum"),47:r("Lower inflection point must be smaller than upper inflection point"),57:r("Invalid Minpoint formula"),59:r("Invalid Maxpoint formula"),58:r("Invalid Midpoint formula"),60:r("Invalid upper inflection point formula"),61:r("Invalid lower inflection point formula"),24:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},Ai={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},Oi={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),31:r("The dataset is invalid"),32:r("Labels are invalid"),33:r("The key value is invalid"),34:r("The baseline value is invalid"),35:r("The data range is invalid"),36:r("A minimum range limit value is needed"),37:r("The minimum range limit value must be a number"),38:r("A maximum range limit value is needed"),39:r("The maximum range limit value must be a number"),40:r("Minimum range limit must be smaller than maximum range limit"),41:r("The lower inflection point value must be a number"),42:r("The upper inflection point value must be a number")}},Mi={Automatic:r("Automatic"),Number:r("Number"),Percent:r("Percent"),Currency:r("Currency"),CurrencyRounded:r("Currency rounded"),Date:r("Date"),Time:r("Time"),DateTime:r("Date time"),Duration:r("Duration"),CustomCurrency:r("Custom currency")},Ni={Custom:r("Custom")},_i=r("Merged cells are preventing this operation. Unmerge those cells and try again.");function Fi(e,t,o){const n=e.model.getters.getActiveSheetId(),i="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(i,{sheetId:n,quantity:o}).isCancelledBecause(64)&&e.raiseError(_i)}const Di=new Tn;Di.add("file",{name:r("File"),sequence:10}).add("edit",{name:r("Edit"),sequence:20}).add("view",{name:r("View"),sequence:30}).add("insert",{name:r("Insert"),sequence:40}).add("format",{name:r("Format"),sequence:50}).add("data",{name:r("Data"),sequence:60}).addChild("save",["file"],{name:r("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:r("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:r("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:r("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:Qn}).addChild("cut",["edit"],{name:r("Cut"),description:"Ctrl+X",sequence:40,action:Jn}).addChild("paste",["edit"],{name:r("Paste"),description:"Ctrl+V",sequence:50,action:ei}).addChild("paste_special",["edit"],{name:r("Paste special"),sequence:60,separator:!0,isVisible:ni}).addChild("paste_special_value",["edit","paste_special"],{name:r("Paste value only"),sequence:10,action:ti}).addChild("paste_special_format",["edit","paste_special"],{name:r("Paste format only"),sequence:20,action:oi}).addChild("sort_range",["data"],{name:r("Sort range"),sequence:62,isVisible:Ei,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:Si}).addChild("sort_descending",["data","sort_range"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ci}).addChild("find_and_replace",["edit"],{name:r("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:r("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:ii,sequence:80,action:ri}).addChild("edit_delete_column",["edit"],{name:si,sequence:90,action:ai}).addChild("edit_delete_cell_shift_up",["edit"],{name:r("Delete cell and shift up"),sequence:93,action:hi}).addChild("edit_delete_cell_shift_left",["edit"],{name:r("Delete cell and shift left"),sequence:97,action:di}).addChild("edit_unhide_columns",["edit"],{name:r("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:r("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=jn(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())},sequence:10,action:ui,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=jn(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())},sequence:20,action:gi,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Zn(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())},sequence:30,action:pi,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Zn(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},sequence:40,action:fi,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:r("Insert cells and shift down"),sequence:43,action:li}).addChild("insert_insert_cell_shift_right",["insert"],{name:r("Insert cells and shift right"),sequence:47,action:ci,separator:!0}).addChild("insert_chart",["insert"],{name:r("Chart"),sequence:50,action:e=>{const t=e.model.getters,o=t.getSelectedZone();let n=o;const i=e.model.uuidGenerator.uuidv4();let r;o.left!==o.right&&(n={...o,left:o.left+1});const s=[bo(n)],a=t.getActiveSheetId(),l={width:536,height:335},{x:c,y:h}=t.getMainViewportCoordinates(),{scrollX:d,scrollY:u}=t.getActiveSheetScrollInfo(),{width:g,height:p}=t.getVisibleRect(t.getActiveMainViewport()),f={x:c+d+Math.max(0,(g-l.width)/2),y:h+u+Math.max(0,(p-l.height)/2)};let m="";const v=e.model.getters.getCellsInZone(a,{...n,bottom:n.top}),b=!!v.find((e=>e&&e.evaluated.type!==qo.number));if(b){const t=v.reduce(((t,o)=>{const n=o&&o.evaluated.type!==qo.error&&e.model.getters.getCellText(o);return n&&t.push(n),t}),[]),o=t.splice(-1)[0];m=t.join(", "),o&&(m+=(m?" "+e._t("and")+" ":"")+o)}o.left!==o.right&&(r=bo({...o,right:o.left,top:b?o.top+1:o.top}));const S=n.right===n.left?"none":"top";e.model.dispatch("CREATE_CHART",{sheetId:a,id:i,position:f,size:l,definition:{title:m,dataSets:s,labelRange:r,type:"bar",stacked:!1,dataSetsHaveTitle:b,verticalAxisPosition:"left",legendPosition:S}}),e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel")}}).addChild("insert_link",["insert"],{name:r("Link"),separator:!0,sequence:60,action:vi}).addChild("insert_sheet",["insert"],{name:r("New sheet"),sequence:70,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,n=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:n,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:n})},separator:!0}).addChild("unfreeze_panes",["view"],{name:r("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:r("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:r("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:r("1 row"),action:e=>Fi(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:r("2 rows"),action:e=>Fi(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:r("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Fi(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:r("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:r("1 column"),action:e=>Fi(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:r("2 columns"),action:e=>Fi(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:r("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();Fi(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:r("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Mi.Automatic,sequence:10,separator:!0,action:e=>Xn(e,"")}).addChild("format_number_number",["format","format_number"],{name:Mi.Number,description:"1,000.12",sequence:20,action:e=>Xn(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Mi.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>Xn(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Mi.Currency,description:"$1,000.12",sequence:37,action:e=>Xn(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Mi.CurrencyRounded,description:"$1,000",sequence:38,action:e=>Xn(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Mi.CustomCurrency,sequence:39,separator:!0,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Mi.Date,description:"9/26/2008",sequence:40,action:e=>Xn(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Mi.Time,description:"10:43:00 PM",sequence:50,action:e=>Xn(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Mi.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>Xn(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Mi.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>Xn(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:r("Bold"),sequence:20,description:"Ctrl+B",action:e=>Yn(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:r("Italic"),sequence:30,description:"Ctrl+I",action:e=>Yn(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:r("Underline"),description:"Ctrl+U",sequence:40,action:e=>Yn(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:r("Strikethrough"),sequence:50,action:e=>Yn(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:r("Font size"),sequence:60}).addChild("format_wrapping",["format"],{name:r("Wrapping"),sequence:70,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:r("Overflow"),sequence:10,action:e=>Yn(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:r("Wrap"),sequence:20,action:e=>Yn(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:r("Clip"),sequence:30,action:e=>Yn(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:r("Conditional formatting"),sequence:80,action:mi,separator:!0}).addChild("format_clearFormat",["format"],{name:r("Clear formatting"),sequence:90,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:r("Add Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelection().zones;Bn(e,t,o)},isVisible:e=>!bi(e),isEnabled:e=>(e=>Vo(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:r("Remove Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:bi});for(let e of ie)Di.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>Yn(t,{fontSize:e.pt})});const ki=new class extends zo{addTransformation(e,t,o){for(let n of t)this.content[n]||(this.content[n]=new Map),this.content[n].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},$i=new po;sn`
271
+ `;class Mn extends t.Component{constructor(){super(...arguments),this.menuItems=On.getAll(),this.state=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Cn(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getCell(o,e,t);return(null==n?void 0:n.isLink())?{link:{url:n.link.url,label:n.formattedValue},urlRepresentation:n.urlRepresentation,isUrlEditable:n.isUrlEditable}:{link:{url:"",label:(null==n?void 0:n.formattedValue)||""},isUrlEditable:!0,urlRepresentation:""}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e;this.state.link.url=t.link.url,this.state.link.label=t.link.label,this.state.isUrlEditable=t.isUrlEditable,this.state.urlRepresentation=t.urlRepresentation}openMenu(){this.menu.isOpen=!0}removeLink(){this.state.link.url="",this.state.urlRepresentation="",this.state.isUrlEditable=!0}save(){var e,t;const{col:o,row:n}=this.props.cellPosition,i=this.state.link.label||this.state.link.url;this.env.model.dispatch("UPDATE_CELL",{col:o,row:n,sheetId:this.env.model.getters.getActiveSheetId(),content:ze(i,this.state.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.state.link.url&&this.save();break;case"Escape":this.cancel()}}}Mn.template="o-spreadsheet-LinkEditor",Mn.size={width:340,height:180},Mn.components={Menu:wn};const Nn={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Mn,cellCorner:"BottomLeft"})},_n=new Bo;_n.add("ErrorToolTip",dn).add("LinkCell",xn).add("LinkEditor",Nn).add("FilterMenu",fn);const Fn=new Bo,Dn=new Bo,kn=new Bo,$n=(new Bo).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let n=0;n<e.quantity;n++)t.push(n+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let n of De(o)){const o=0===n[0]?0:n[0]-1,i=0===n[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:n.length,base:o,sheetId:e.sheetId,position:i})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of Ko.values())$n.contains(e)||$n.add(e,Ln);function Ln(e){return[e]}const Pn=[Zo.number,Zo.error,Zo.text,Zo.boolean];function Un(e,t){return{index:t,type:e?e.evaluated.type:Zo.empty,value:e?e.evaluated.value:""}}function Vn(e,t,o,n,i){let s=Jo.Success,a=n.right>n.left;if(e.model.getters.doesIntersectMerge(t,n)){let o;a=!1;for(let i=n.top;i<=n.bottom;i++){o=[];for(let r=n.left;r<=n.right;r++){let n=e.model.getters.getMerge(t,r,i);n&&!o.includes(n.id.toString())&&o.push(n.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i});else{const o=e.model.getters.getContiguousZone(t,n);Io(o,n)?s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i}):e.askConfirmation(r("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?"),(()=>{n=o,s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i})}),(()=>{s=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:n,sortDirection:i})}))}if(s.isCancelledBecause(62)){const{col:t,row:i}=o;e.model.selection.selectZone({cell:{col:t,row:i},zone:n}),e.raiseError(r("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function zn(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(r("This operation is not allowed with multiple selections."))}const Bn={filterOverlap:r("You cannot create overlapping filters."),nonContinuousTargets:r("A filter can only be created on a continuous selection."),mergeInFilter:r("You can't create a filter over a range that contains a merge.")};function Hn(e,t,o){const n=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});n.isCancelledBecause(77)?e.raiseError(Bn.filterOverlap):n.isCancelledBecause(79)?e.raiseError(Bn.mergeInFilter):n.isCancelledBecause(80)&&e.raiseError(Bn.nonContinuousTargets)}const Wn={wrongPasteSelection:r("This operation is not allowed with multiple selections."),willRemoveExistingMerge:r("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:r("Cannot do a special paste of a figure."),frozenPaneOverlap:r("Cannot paste merged cells over a frozen pane.")};function Gn(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Wn.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Wn.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Wn.wrongFigurePasteOption):t.reasons.includes(74)&&e.raiseError(Wn.frozenPaneOverlap))}function qn(e,t,o){const n=e.model.dispatch("PASTE",{target:t,pasteOption:o});Gn(e,n)}function Zn(e,t,o){const n=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o});Gn(e,n)}function jn(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function Xn(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function Yn(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Kn(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}async function Qn(e){try{return await e.clipboard.readText()}catch(e){return console.warn("The OS clipboard could not be read."),void console.error(e)}}const Jn=async e=>{e.model.dispatch("COPY"),await e.clipboard.writeText(e.model.getters.getClipboardContent())},ei=async e=>{zn(e),await e.clipboard.writeText(e.model.getters.getClipboardContent())},ti=async e=>{const t=e.model.getters.getClipboardContent(),o=await Qn(e),n=e.model.getters.getSelectedZones();o&&o!==t?Zn(e,n,o):qn(e,n)},oi=async e=>{const t=e.model.getters.getClipboardContent(),o=await Qn(e),n=e.model.getters.getSelectedZones();o&&o!==t?e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:n,text:o}):e.model.dispatch("PASTE",{target:e.model.getters.getSelectedZones(),pasteOption:"onlyValue"})},ni=e=>qn(e,e.model.getters.getSelectedZones(),"onlyFormat"),ii=e=>!e.model.getters.isCutOperation(),ri=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete rows");let t,o;const n=e.model.getters.getActiveRows();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.top,o=n.bottom}return t===o?r("Delete row %s",(t+1).toString()):r("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},si=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},ai=e=>{if(e.model.getters.getSelectedZones().length>1)return r("Delete columns");let t,o;const n=e.model.getters.getActiveCols();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.left,o=n.right}return t===o?r("Delete column %s",Tt(t)):r("Delete columns %s - %s",Tt(t),Tt(o))},li=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},ci=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Gn(e,o)},hi=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Gn(e,o)},di=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Gn(e,o)},ui=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Gn(e,o)},gi=e=>{const t=e.model.getters.getActiveRows();let o,n;if(t.size)o=Math.min(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,n=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:n,dimension:"ROW"})},pi=e=>{const t=e.model.getters.getActiveRows();let o,n;if(t.size)o=Math.max(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,n=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:n,dimension:"ROW"})},fi=e=>{const t=e.model.getters.getActiveCols();let o,n;if(t.size)o=Math.min(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,n=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:n})},mi=e=>{const t=e.model.getters.getActiveCols();let o,n;if(t.size)o=Math.max(...t),n=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,n=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:n})},vi=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},bi=e=>{let{col:t,row:o}=e.model.getters.getPosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},Si=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},Ci=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),n=e.model.getters.getActiveSheetId();Vn(e,n,t.cell,o[0],"ascending")},Ei=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),n=e.model.getters.getActiveSheetId();Vn(e,n,t.cell,o[0],"descending")},wi=e=>1===e.model.getters.getSelectedZones().length,yi=new An;yi.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ei}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Jn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ti}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:ii}).addChild("paste_value_only",["paste_special"],{name:r("Paste values only"),sequence:10,action:oi}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ni}).add("add_row_before",{name:e=>{const t=Xn(e);return 1===t?r("Insert row"):r("Insert %s rows",t.toString())},sequence:70,action:gi,isVisible:wi}).add("add_column_before",{name:e=>{const t=jn(e);return 1===t?r("Insert column"):r("Insert %s columns",t.toString())},sequence:90,action:fi,isVisible:wi}).add("insert_cell",{name:r("Insert cells"),sequence:100,isVisible:wi,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:r("Shift down"),sequence:10,action:ci}).addChild("insert_cell_right",["insert_cell"],{name:r("Shift right"),sequence:20,action:hi}).add("delete_row",{name:ri,sequence:110,action:si,isVisible:wi}).add("delete_column",{name:ai,sequence:120,action:li,isVisible:wi}).add("delete_cell",{name:r("Delete cells"),sequence:130,isVisible:wi}).addChild("delete_cell_up",["delete_cell"],{name:r("Shift up"),sequence:10,action:di}).addChild("delete_cell_down",["delete_cell"],{name:r("Shift left"),sequence:20,action:ui}).add("insert_link",{name:r("Insert link"),separator:!0,sequence:150,action:bi});const xi=new An;xi.add("cut",{name:r("Cut"),description:"Ctrl+X",sequence:10,action:ei}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Jn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ti}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:ii}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:oi}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ni}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?r("Sort columns"):r("Sort column"),sequence:50,isVisible:wi,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:Ci}).addChild("sort_descending",["sort_columns"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ei}).add("add_column_before",{name:e=>{const t=jn(e);return 1===t?r("Insert column left"):r("Insert %s columns left",t.toString())},sequence:70,action:fi}).add("add_column_after",{name:e=>{const t=jn(e);return 1===t?r("Insert column right"):r("Insert %s columns right",t.toString())},sequence:80,action:mi}).add("delete_column",{name:ai,sequence:90,action:li}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear columns");let t,o;const n=e.model.getters.getActiveCols();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.left,o=n.right}return t===o?r("Clear column %s",Tt(t)):r("Clear columns %s - %s",Tt(t),Tt(o))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],n=t[t.length-1];return 1===t.length?r("Hide column %s",Tt(o).toString()):n-o+1===t.length?r("Hide columns %s - %s",Tt(o).toString(),Tt(n).toString()):r("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>o.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name:r("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:110,action:vi});const Ri=new An;function Ii(e,t,o){const n=e.model.getters.getSheetName(t),i=r("Rename Sheet");e.editText(i,(o=>{if(null===o||o===n)return;""===o&&Ii(e,t,r("The sheet name cannot be empty."));const i=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});i.isSuccessful||(i.reasons.includes(11)&&Ii(e,t,r("A sheet with the name %s already exists. Please select another name.",o)),i.reasons.includes(13)&&Ii(e,t,r("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",J.join(" "))))}),{placeholder:n,error:o})}Ri.add("cut",{name:r("Cut"),sequence:10,description:"Ctrl+X",action:ei}).add("copy",{name:r("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Jn}).add("paste",{name:r("Paste"),description:"Ctrl+V",sequence:30,action:ti}).add("paste_special",{name:r("Paste special"),sequence:40,separator:!0,isVisible:ii}).addChild("paste_value_only",["paste_special"],{name:r("Paste value only"),sequence:10,action:oi}).addChild("paste_format_only",["paste_special"],{name:r("Paste format only"),sequence:20,action:ni}).add("add_row_before",{name:e=>{const t=Xn(e);return 1===t?r("Insert row above"):r("Insert %s rows above",t.toString())},sequence:50,action:gi}).add("add_row_after",{name:e=>{const t=Xn(e);return 1===t?r("Insert row below"):r("Insert %s rows below",t.toString())},sequence:60,action:pi}).add("delete_row",{name:ri,sequence:70,action:si}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return r("Clear rows");let t,o;const n=e.model.getters.getActiveRows();if(0!==n.size)t=Math.min(...n),o=Math.max(...n);else{const n=e.model.getters.getSelectedZones()[0];t=n.top,o=n.bottom}return t===o?r("Clear row %s",(t+1).toString()):r("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],n=t[t.length-1];return 1===t.length?r("Hide row %s",(o+1).toString()):n-o+1===t.length?r("Hide rows %s - %s",(o+1).toString(),(n+1).toString()):r("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>o.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name:r("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:r("Conditional formatting"),sequence:90,action:vi});const Ti=new An;Ti.add("delete",{name:r("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(r("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:r("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}}).add("rename",{name:r("Rename"),sequence:30,action:e=>Ii(e,e.model.getters.getActiveSheetId())}).add("move_right",{name:r("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getVisibleSheetIds();return o.indexOf(t)!==o.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"right"})}).add("move_left",{name:r("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),direction:"left"})}).add("hide_sheet",{name:r("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})});const Ai={Errors:{25:r("The range is invalid"),50:r("The argument is missing. Please provide a value"),51:r("The second argument is missing. Please provide a value"),52:r("The minpoint must be a number"),53:r("The midpoint must be a number"),54:r("The maxpoint must be a number"),55:r("The first value must be a number"),56:r("The second value must be a number"),46:r("Minimum must be smaller then Maximum"),49:r("Minimum must be smaller then Midpoint"),48:r("Midpoint must be smaller then Maximum"),47:r("Lower inflection point must be smaller than upper inflection point"),57:r("Invalid Minpoint formula"),59:r("Invalid Maxpoint formula"),58:r("Invalid Midpoint formula"),60:r("Invalid upper inflection point formula"),61:r("Invalid lower inflection point formula"),24:r("A range needs to be defined"),Unexpected:r("The rule is invalid for an unknown reason")},ColorScale:r("Color scale"),IconSet:r("Icon set")},Oi={IsEmpty:r("Is empty"),IsNotEmpty:r("Is not empty"),ContainsText:r("Contains"),NotContains:r("Does not contain"),BeginsWith:r("Starts with"),EndsWith:r("Ends with"),Equal:r("Is equal to"),NotEqual:r("Is not equal to"),GreaterThan:r("Is greater than"),GreaterThanOrEqual:r("Is greater than or equal to"),LessThan:r("Is less than"),LessThanOrEqual:r("Is less than or equal to"),Between:r("Is between"),NotBetween:r("Is not between")},Mi={Series:r("Series"),Errors:{Unexpected:r("The chart definition is invalid for an unknown reason"),31:r("The dataset is invalid"),32:r("Labels are invalid"),33:r("The key value is invalid"),34:r("The baseline value is invalid"),35:r("The data range is invalid"),36:r("A minimum range limit value is needed"),37:r("The minimum range limit value must be a number"),38:r("A maximum range limit value is needed"),39:r("The maximum range limit value must be a number"),40:r("Minimum range limit must be smaller than maximum range limit"),41:r("The lower inflection point value must be a number"),42:r("The upper inflection point value must be a number")}},Ni={Automatic:r("Automatic"),Number:r("Number"),Percent:r("Percent"),Currency:r("Currency"),CurrencyRounded:r("Currency rounded"),Date:r("Date"),Time:r("Time"),DateTime:r("Date time"),Duration:r("Duration"),CustomCurrency:r("Custom currency")},_i={Custom:r("Custom")},Fi=r("Merged cells are preventing this operation. Unmerge those cells and try again.");function Di(e,t,o){const n=e.model.getters.getActiveSheetId(),i="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(i,{sheetId:n,quantity:o}).isCancelledBecause(64)&&e.raiseError(Fi)}const ki=new An;ki.add("file",{name:r("File"),sequence:10}).add("edit",{name:r("Edit"),sequence:20}).add("view",{name:r("View"),sequence:30}).add("insert",{name:r("Insert"),sequence:40}).add("format",{name:r("Format"),sequence:50}).add("data",{name:r("Data"),sequence:60}).addChild("save",["file"],{name:r("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:r("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:r("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:r("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:Jn}).addChild("cut",["edit"],{name:r("Cut"),description:"Ctrl+X",sequence:40,action:ei}).addChild("paste",["edit"],{name:r("Paste"),description:"Ctrl+V",sequence:50,action:ti}).addChild("paste_special",["edit"],{name:r("Paste special"),sequence:60,separator:!0,isVisible:ii}).addChild("paste_special_value",["edit","paste_special"],{name:r("Paste value only"),sequence:10,action:oi}).addChild("paste_special_format",["edit","paste_special"],{name:r("Paste format only"),sequence:20,action:ni}).addChild("sort_range",["data"],{name:r("Sort range"),sequence:62,isVisible:wi,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:r("Ascending (A ⟶ Z)"),sequence:10,action:Ci}).addChild("sort_descending",["data","sort_range"],{name:r("Descending (Z ⟶ A)"),sequence:20,action:Ei}).addChild("find_and_replace",["edit"],{name:r("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:r("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:ri,sequence:80,action:si}).addChild("edit_delete_column",["edit"],{name:ai,sequence:90,action:li}).addChild("edit_delete_cell_shift_up",["edit"],{name:r("Delete cell and shift up"),sequence:93,action:di}).addChild("edit_delete_cell_shift_left",["edit"],{name:r("Delete cell and shift left"),sequence:97,action:ui}).addChild("edit_unhide_columns",["edit"],{name:r("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:r("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=Xn(e);return 1===t?r("Row above"):r("%s Rows above",t.toString())},sequence:10,action:gi,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Xn(e);return 1===t?r("Row below"):r("%s Rows below",t.toString())},sequence:20,action:pi,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=jn(e);return 1===t?r("Column left"):r("%s Columns left",t.toString())},sequence:30,action:fi,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=jn(e);return 1===t?r("Column right"):r("%s Columns right",t.toString())},sequence:40,action:mi,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:r("Insert cells and shift down"),sequence:43,action:ci}).addChild("insert_insert_cell_shift_right",["insert"],{name:r("Insert cells and shift right"),sequence:47,action:hi,separator:!0}).addChild("insert_chart",["insert"],{name:r("Chart"),sequence:50,action:e=>{const t=e.model.getters,o=t.getSelectedZone();let n=o;const i=e.model.uuidGenerator.uuidv4();let r;o.left!==o.right&&(n={...o,left:o.left+1});const s=[So(n)],a=t.getActiveSheetId(),l={width:536,height:335},{x:c,y:h}=t.getMainViewportCoordinates(),{scrollX:d,scrollY:u}=t.getActiveSheetScrollInfo(),{width:g,height:p}=t.getVisibleRect(t.getActiveMainViewport()),f={x:c+d+Math.max(0,(g-l.width)/2),y:h+u+Math.max(0,(p-l.height)/2)};let m="";const v=e.model.getters.getCellsInZone(a,{...n,bottom:n.top}),b=!!v.find((e=>e&&e.evaluated.type!==Zo.number));if(b){const t=v.reduce(((t,o)=>{const n=o&&o.evaluated.type!==Zo.error&&e.model.getters.getCellText(o);return n&&t.push(n),t}),[]),o=t.splice(-1)[0];m=t.join(", "),o&&(m+=(m?" "+e._t("and")+" ":"")+o)}o.left!==o.right&&(r=So({...o,right:o.left,top:b?o.top+1:o.top}));const S=n.right===n.left?"none":"top";e.model.dispatch("CREATE_CHART",{sheetId:a,id:i,position:f,size:l,definition:{title:m,dataSets:s,labelRange:r,type:"bar",stacked:!1,dataSetsHaveTitle:b,verticalAxisPosition:"left",legendPosition:S}}),e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel")}}).addChild("insert_link",["insert"],{name:r("Link"),separator:!0,sequence:60,action:bi}).addChild("insert_sheet",["insert"],{name:r("New sheet"),sequence:70,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,n=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:n,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:n})},separator:!0}).addChild("unfreeze_panes",["view"],{name:r("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:r("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:r("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:r("1 row"),action:e=>Di(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:r("2 rows"),action:e=>Di(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:r("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Di(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:r("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:r("1 column"),action:e=>Di(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:r("2 columns"),action:e=>Di(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:r("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();Di(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?r("Hide gridlines"):r("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?r("Hide formulas"):r("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:r("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Ni.Automatic,sequence:10,separator:!0,action:e=>Yn(e,"")}).addChild("format_number_number",["format","format_number"],{name:Ni.Number,description:"1,000.12",sequence:20,action:e=>Yn(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Ni.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>Yn(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Ni.Currency,description:"$1,000.12",sequence:37,action:e=>Yn(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Ni.CurrencyRounded,description:"$1,000",sequence:38,action:e=>Yn(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Ni.CustomCurrency,sequence:39,separator:!0,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Ni.Date,description:"9/26/2008",sequence:40,action:e=>Yn(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Ni.Time,description:"10:43:00 PM",sequence:50,action:e=>Yn(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Ni.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>Yn(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Ni.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>Yn(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:r("Bold"),sequence:20,description:"Ctrl+B",action:e=>Kn(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:r("Italic"),sequence:30,description:"Ctrl+I",action:e=>Kn(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:r("Underline"),description:"Ctrl+U",sequence:40,action:e=>Kn(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:r("Strikethrough"),sequence:50,action:e=>Kn(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:r("Font size"),sequence:60}).addChild("format_wrapping",["format"],{name:r("Wrapping"),sequence:70,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:r("Overflow"),sequence:10,action:e=>Kn(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:r("Wrap"),sequence:20,action:e=>Kn(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:r("Clip"),sequence:30,action:e=>Kn(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:r("Conditional formatting"),sequence:80,action:vi,separator:!0}).addChild("format_clearFormat",["format"],{name:r("Clear formatting"),sequence:90,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:r("Add Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelection().zones;Hn(e,t,o)},isVisible:e=>!Si(e),isEnabled:e=>(e=>zo(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:r("Remove Filter"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:Si});for(let e of ie)ki.addChild(`format_font_size_${e.pt}`,["format","format_font_size"],{name:e.pt.toString(),sequence:e.pt,action:t=>Kn(t,{fontSize:e.pt})});const $i=new class extends Bo{addTransformation(e,t,o){for(let n of t)this.content[n]||(this.content[n]=new Map),this.content[n].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Li=new fo;an`
272
272
  .o-selection {
273
273
  .o-selection-input {
274
274
  display: flex;
@@ -312,7 +312,7 @@
312
312
  }
313
313
  }
314
314
  }
315
- `;class Li extends t.Component{constructor(){super(...arguments),this.id=$i.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1})}get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t.toString(),isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}setup(){t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){var e,t;const o=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,o),this.previousRanges=o}focus(e){this.state.isMissing=!1,this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){var t,o;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(o=(t=this.props).onSelectionConfirmed)||void 0===o||o.call(t)}onInputChanged(e,t){const o=t.target;this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o.value}),o.blur(),this.triggerChange()}disable(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const o=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===o.length&&(this.state.isMissing=!0);const n=this.env.model.getters.getActiveSheetId();this.originSheet!==n&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:n,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}Li.template="o-spreadsheet-SelectionInput";class Pi extends t.Component{constructor(){super(...arguments),this.state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0}),this.dataSeriesRanges=[]}setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}get errorMessages(){var e,t;return[...(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.labelsDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Oi.Errors[e]||Oi.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(31))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}onUpdateDataSetsHaveTitle(e){this.props.updateChart({dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart({dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart({labelRange:this.labelRange})}}Pi.template="o-spreadsheet-LineBarPieConfigPanel",Pi.components={SelectionInput:Li};class Ui extends Pi{onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}}Ui.template="o-spreadsheet-BarConfigPanel";class Vi{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 zi(e){return 8===(e=st(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}function Bi(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?wo(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?So(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Hi(e,t,o,n){let i=!1;const r=[];for(let n in o){let s=o[n];if(s.labelCell){const e=qi(s.labelCell,t);s.labelCell!==e&&(i=!0,s={...s,labelCell:e})}const a=qi(s.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===X?(i=!0,s=void 0):a!==s.dataRange&&(i=!0,s={...s,dataRange:a}),r[n]=s}let s=n;const a=qi(s,t);a!==s&&(i=!0,s=a);return{isStale:i,dataSets:r.filter(Ze),labelRange:s}}function Wi(e,t,o){return o.map((o=>({dataRange:ho(e,t,o.dataRange),labelCell:o.labelCell?ho(e,t,o.labelCell):void 0})))}function Gi(e,t,o){return o?ho(e,t,o):void 0}function qi(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function Zi(e,t,o,n){const i=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:s,sheetId:a,invalidSheetName:l}=t;if(!l)if(s.left!==s.right&&s.top!==s.bottom){if(void 0===s.right)continue;for(let t=s.left;t<=s.right;t++){const o={...s,left:t,right:t};i.push(ji(e,a,o,n?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else s.left===s.right&&s.top===s.bottom?n||i.push(ji(e,a,s,void 0)):i.push(ji(e,a,s,n?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0))}return i}function ji(e,t,o,n){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${bo(o)}`);if(n){const i=bo(o),r=bo(n);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,i)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,bo(o))}}function Xi(e,t){var o;const n=null===(o=t.labelCell)||void 0===o?void 0:o.zone;let i=t.dataRange.zone;if(n){const{height:e,width:t}=No(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const r=t.dataRange.clone({zone:i});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(r,"forceSheetReference")}}function Yi(e,t){let o;if(e.labelRange){const n=Bi(fo(e.labelRange),t);o=n?bo(n):void 0}const n=e.dataSets.map(fo).map((e=>Bi(e,t))).filter(Ze).map(bo);return{...e,labelRange:o,dataSets:n}}const Ki=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Qi{constructor(){this.graphColorIndex=0}next(){return Ki[this.graphColorIndex++%Ki.length]}}function Ji(e){return e&&ht(e)<.3?"#FFFFFF":"#000000"}function er(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Ct.test(e)));if(t)return 31;if(e.dataSets.map(fo).some((e=>e.top!==e.bottom&&Po(e))))return 31}return 0}function tr(e){if(e.labelRange){if(!Ct.test(e.labelRange||""))return 32}return 0}function or(e,t,o){const n=null==e?void 0:e.evaluated;if(e&&void 0!==n){if("text"===o||(null==t?void 0:t.type)!==qo.number||n.type!==qo.number)return e.formattedValue;{let e=t.value-n.value;if("percentage"===o&&0!==e&&(e=e/n.value*100),"percentage"!==o&&n.format)return Ut(e,n.format);const i=Math.abs(parseFloat(e.toFixed(2))).toLocaleString();return"percentage"===o?i+"%":i}}return""}function nr(e,t,o,n,i){if("text"===t||(null==e?void 0:e.type)!==qo.number||(null==o?void 0:o.type)!==qo.number)return;const r=o.value-e.value;return r>0?n:r<0?i:void 0}function ir(e,t,o){if("text"===o||(null==e?void 0:e.type)!==qo.number||(null==t?void 0:t.type)!==qo.number)return"neutral";const n=t.value-e.value;return n>0?"up":n<0?"down":"neutral"}function rr(e,t){if(t.dataRange){const o=t.labelCell?[bo(t.labelCell.zone)]:[],n=Oo([bo(t.dataRange.zone)],o)[0];if(void 0===n)return[];const i=e.getRangeFromSheetXC(t.dataRange.sheetId,n);return e.getRangeValues(i)}return[]}function sr(e,t){const o=Fe(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((o=>{const n=e[o],i=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[o]}));return n||i.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function ar(e){return e?e.length>K?e.substring(0,K)+"…":e:""}function lr(e,t,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:i(e.title),fontColor:o},legend:{onClick:void 0}},data:{labels:t.map(ar),datasets:[]}}}function cr(e,t,o){let n={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(n={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>null!=e?String(e):""))});else if(1===t.length)for(let o=0;o<rr(e,t[0]).length;o++)n.formattedValues.push(""),n.values.push("");else if(t[0]){n={formattedValues:Fe(0,rr(e,t[0]).length).map((e=>e.toString())),values:n.formattedValues}}return n}function hr(e,t){const o=[];for(const[n,i]of Object.entries(t)){let t;if(i.labelCell){const o=i.labelCell,r=o?e.getCell(o.sheetId,o.zone.left,o.zone.top):void 0;t=r&&o?ar(r.formattedValue):t=`${Oi.Series} ${parseInt(n)+1}`}else t=t=`${Oi.Series} ${parseInt(n)+1}`;let r=i.dataRange?rr(e,i):[];o.push({data:r,label:t})}return o}function dr(e){return 0===e?"origin":e-1}Bo.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new ur(e,t,o),getChartRuntime:function(e,t){let o=cr(t,e.dataSets,e.labelRange).formattedValues,n=hr(t,e.dataSets);({labels:o,dataSetsValues:n}=sr(o,n));const i=function(e,t){var o;const n=Ji(e.background),i=lr(e,t,n),r={labels:{fontColor:n}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;i.options.legend={...null===(o=i.options)||void 0===o?void 0:o.legend,...r},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0}}]},e.stacked&&(i.options.scales.xAxes[0].stacked=!0,i.options.scales.yAxes[0].stacked=!0);return i}(e,o),r=new Qi;for(let{label:e,data:t}of n){const o=r.next(),n={label:e,data:t,borderColor:o,backgroundColor:o};i.data.datasets.push(n)}return{chartJsConfig:i,background:e.background||w}},validateChartDefinition:(e,t)=>ur.validateChartDefinition(e,t),transformDefinition:(e,t)=>ur.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>ur.getDefinitionFromContextCreation(e),name:r("Bar")});class ur extends Vi{constructor(e,t,o){super(e,t,o),this.type="bar",this.dataSets=Zi(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=uo(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked}static transformDefinition(e,t){return Yi(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,er,tr)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=Wi(this.sheetId,e,this.dataSets),o=Gi(this.sheetId,e,this.labelRange),n=this.getDefinitionWithSpecificDataSets(t,o,e);return new ur(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ur(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked}}getDefinitionForExcel(){const e=this.dataSets.map((e=>Xi(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:zi(this.background||w),fontColor:zi(Ji(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:n}=Hi(this.getters,e,this.dataSets,this.labelRange);if(!n)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new ur(i,this.sheetId,this.getters)}}function gr(e,t){const o=Bo.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function pr(e){return e.dataRange&&!Ct.test(e.dataRange)?35:0}function fr(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function mr(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?40:0}function vr(e,t){if(""===e)switch(t){case"rangeMin":return 36;case"rangeMax":return 38}return 0}function br(e,t){if(isNaN(e))switch(t){case"rangeMin":return 37;case"rangeMax":return 39;case"lowerInflectionPointValue":return 41;case"upperInflectionPointValue":return 42}return 0}Bo.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new Sr(e,t,o),getChartRuntime:function(e,t){const o=function(e){const t=Ji(e.background),o=lr(e,[],t);return o.options.hover=void 0,o.options.events=[],o.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},o.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},o.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},o}(e),n=e.sectionRule.colors,i=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,s=Number(i.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==i.value){const e="number"===i.type?s:l+h*s/100;d.push({value:Oe(e,l,c),color:n.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:Oe(e,l,c),color:n.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(n.upperColor);const p=e.dataRange,f=h/30;let m=l-f,v=null,b=!1;if(void 0!==p){const e=t.getCell(p.sheetId,p.zone.left,p.zone.top);(null==e?void 0:e.evaluated.type)===qo.number&&(m=Oe(null==e?void 0:e.evaluated.value,l-f,c+f),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return o.options.valueLabel.display=b,o.options.valueLabel.formatter=v,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:m,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>Sr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Sr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Sr.getDefinitionFromContextCreation(e),name:r("Gauge")});class Sr extends Vi{constructor(e,t,o){super(e,t,o),this.type="gauge",this.dataRange=uo(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,pr,e.chainValidations(fr(vr,e.batchValidations),fr(br,e.batchValidations),mr),e.chainValidations((o=br,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=Bi(fo(e.dataRange),t)),{...e,dataRange:o?bo(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=Gi(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new Sr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Sr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=qi(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new Sr(o,this.sheetId,this.getters)}}const Cr={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Er={inSeconds:function(e){return Math.floor(e/Cr.second)},inMinutes:function(e){return Math.floor(e/Cr.minute)},inHours:function(e){return Math.floor(e/Cr.hour)},inDays:function(e){return Math.floor(e/Cr.day)},inMonths:function(e){return Math.floor(e/Cr.month)},inYears:function(e){return Math.floor(e/Cr.year)}},wr=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function yr(e,t){const o=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),n=function(e,t){const o=e.map((e=>{var t;return null===(t=pe(e))||void 0===t?void 0:t.jsDate}));if(o.some((e=>void 0===e))||e.length<2)return;const n=o.map((e=>e.getTime())),i=Math.max(...n)-Math.min(...n),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Cr.second>=Cr[r]&&Er.inSeconds(i)<180)return"second";if(Cr.minute>=Cr[r]&&Er.inMinutes(i)<180)return"minute";if(Cr.hour>=Cr[r]&&Er.inHours(i)<96)return"hour";if(Cr.day>=Cr[r]&&Er.inDays(i)<90)return"day";if(Cr.month>=Cr[r]&&Er.inMonths(i)<36)return"month";return"year"}(e,o),i={};return n&&(i[n]=o),{parser:o,displayFormats:i,unit:n}}Bo.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new xr(e,t,o),getChartRuntime:function(e,t){const o=function(e,t){if(function(e,t){return!e.labelsAsText&&Rr(e,t)}(e,t))return"time";if(function(e,t){return!e.labelsAsText&&Ir(e,t)}(e,t))return"linear";return"category"}(e,t),n=cr(t,e.dataSets,e.labelRange);let i="linear"===o?n.values:n.formattedValues,r=hr(t,e.dataSets);({labels:i,dataSetsValues:r}=sr(i,r)),"time"===o&&({labels:i,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],n=Ie(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=Qe(o,e);for(let t of n)t.data[e]=void 0}return{labels:o,dataSetsValues:n}}(i,r));const s=function(e,t){var o;const n=Ji(e.background),i=lr(e,t,n),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,n]of o.entries())n.fillStyle=t.datasets[e].borderColor;return o}}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;i.options.legend={...null===(o=i.options)||void 0===o?void 0:o.legend,...r},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0}}]},e.stacked&&(i.options.scales.yAxes[0].stacked=!0);return i}(e,i),a=function(e,t){var o;if(t)return null===(o=e.getCell(t.sheetId,t.zone.left,t.zone.top))||void 0===o?void 0:o.evaluated.format}(t,e.labelRange);"time"===o?(s.options.scales.xAxes[0].type="time",s.options.scales.xAxes[0].time=yr(i,a),s.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(s.options.scales.xAxes[0].type="linear",s.options.scales.xAxes[0].ticks.callback=e=>Ut(e,a));const l=new Qi;for(let[t,{label:n,data:a}]of r.entries()){["linear","time"].includes(o)&&(a=a.map(((e,t)=>({x:i[t]||void 0,y:e}))));const r=l.next();let c=ut(r);e.stacked&&(c.a=Q);const h={label:n,data:a,lineTension:0,borderColor:r,backgroundColor:dt(c),pointBackgroundColor:r,fill:!!e.stacked&&dr(t)};s.data.datasets.push(h)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>xr.validateChartDefinition(e,t),transformDefinition:(e,t)=>xr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>xr.getDefinitionFromContextCreation(e),name:r("Line")});class xr extends Vi{constructor(e,t,o){super(e,t,o),this.type="line",this.dataSets=Zi(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=uo(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked}static validateChartDefinition(e,t){return e.checkValidations(t,er,tr)}static transformDefinition(e,t){return Yi(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:n}=Hi(this.getters,e,this.dataSets,this.labelRange);if(!n)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new xr(i,this.sheetId,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>Xi(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:zi(this.background||w),fontColor:zi(Ji(this.background)),dataSets:e}}copyForSheetId(e){const t=Wi(this.sheetId,e,this.dataSets),o=Gi(this.sheetId,e,this.labelRange),n=this.getDefinitionWithSpecificDataSets(t,o,e);return new xr(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new xr(t,e,this.getters)}}function Rr(e,t){var o;if(!e.labelRange||!e.dataSets||!Ir(e,t))return!1;const n=null===(o=t.getCell(e.labelRange.sheetId,e.labelRange.zone.left,e.labelRange.zone.top))||void 0===o?void 0:o.evaluated.format;return Boolean(n&&wr.test(n))}function Ir(e,t){if(!e.labelRange||!e.dataSets)return!1;const o=t.getRangeValues(e.labelRange);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}Bo.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new Tr(e,t,o),getChartRuntime:function(e,t){let o=cr(t,e.dataSets,e.labelRange).formattedValues,n=hr(t,e.dataSets);({labels:o,dataSetsValues:n}=sr(o,n));const i=function(e,t){var o;const n=Ji(e.background),i=lr(e,t,n),r={labels:{fontColor:n}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;return i.options.legend={...null===(o=i.options)||void 0===o?void 0:o.legend,...r},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},i}(e,o),r=new Qi;for(let{label:e,data:t}of n){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Ar(r,n)};i.data.datasets.push(o)}return{chartJsConfig:i,background:e.background||w}},validateChartDefinition:(e,t)=>Tr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Tr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Tr.getDefinitionFromContextCreation(e),name:r("Pie")});class Tr extends Vi{constructor(e,t,o){super(e,t,o),this.type="pie",this.dataSets=Zi(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=uo(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition}static transformDefinition(e,t){return Yi(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,er,tr)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title}}copyForSheetId(e){const t=Wi(this.sheetId,e,this.dataSets),o=Gi(this.sheetId,e,this.labelRange),n=this.getDefinitionWithSpecificDataSets(t,o,e);return new Tr(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Tr(t,e,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>Xi(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:zi(this.background||w),fontColor:zi(Ji(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:n}=Hi(this.getters,e,this.dataSets,this.labelRange);if(!n)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new Tr(i,this.sheetId,this.getters)}}function Ar(e,t){const o=[],n=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=n;t++)o.push(e.next());return o}function Or(e){return e.keyValue&&!Ct.test(e.keyValue)?33:0}function Mr(e){return e.baseline&&!Ct.test(e.baseline)?34:0}Bo.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new Nr(e,t,o),getChartRuntime:function(e,t){let o,n,r="",s="";if(e.keyValue){const n=e.keyValue.zone;o=t.getCell(e.keyValue.sheetId,n.left,n.top),r=(null==o?void 0:o.evaluated.value)?String(null==o?void 0:o.evaluated.value):"",s=(null==o?void 0:o.formattedValue)||""}if(e.baseline){const o=e.baseline.zone;n=t.getCell(e.baseline.sheetId,o.left,o.top)}const a=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:i(e.title),keyValue:s||r,baselineDisplay:or(n,null==o?void 0:o.evaluated,e.baselineMode),baselineArrow:ir(null==n?void 0:n.evaluated,null==o?void 0:o.evaluated,e.baselineMode),baselineColor:nr(null==n?void 0:n.evaluated,e.baselineMode,null==o?void 0:o.evaluated,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?i(e.baselineDescr):"",fontColor:Ji(a),background:a,baselineStyle:"percentage"!==e.baselineMode?null==n?void 0:n.style:void 0,keyValueStyle:null==o?void 0:o.style}},validateChartDefinition:(e,t)=>Nr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Nr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Nr.getDefinitionFromContextCreation(e),name:r("Scorecard")});class Nr extends Vi{constructor(e,t,o){super(e,t,o),this.type="scorecard",this.keyValue=uo(o,t,e.keyValue),this.baseline=uo(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Or,Mr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:"difference",baselineColorUp:"#00A04A",baselineColorDown:"#DC6965",baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,n;return e.baseline&&(o=Bi(fo(e.baseline),t)),e.keyValue&&(n=Bi(fo(e.keyValue),t)),{...e,baseline:o?bo(o):void 0,keyValue:n?bo(n):void 0}}copyForSheetId(e){const t=Gi(this.sheetId,e,this.baseline),o=Gi(this.sheetId,e,this.keyValue),n=this.getDefinitionWithSpecificRanges(t,o,e);return new Nr(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new Nr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[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}}getDefinitionForExcel(){}updateRanges(e){const t=qi(this.baseline,e),o=qi(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const n=this.getDefinitionWithSpecificRanges(t,o);return new Nr(n,this.sheetId,this.getters)}}const _r=218,Fr=182;function Dr(e){return dt(gt({h:360*e.offsetX/_r,s:100,l:100*e.offsetY/Fr,a:1}))}sn`
315
+ `;class Pi extends t.Component{constructor(){super(...arguments),this.id=Li.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1})}get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t.toString(),isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}setup(){t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){var e,t;const o=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,o),this.previousRanges=o}focus(e){this.state.isMissing=!1,this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){var t,o;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(o=(t=this.props).onSelectionConfirmed)||void 0===o||o.call(t)}onInputChanged(e,t){const o=t.target;this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o.value}),o.blur(),this.triggerChange()}disable(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const o=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===o.length&&(this.state.isMissing=!0);const n=this.env.model.getters.getActiveSheetId();this.originSheet!==n&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:n,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}Pi.template="o-spreadsheet-SelectionInput";class Ui extends t.Component{constructor(){super(...arguments),this.state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0}),this.dataSeriesRanges=[]}setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}get errorMessages(){var e,t;return[...(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.labelsDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Mi.Errors[e]||Mi.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(31))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}onUpdateDataSetsHaveTitle(e){this.props.updateChart({dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart({dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart({labelRange:this.labelRange})}}Ui.template="o-spreadsheet-LineBarPieConfigPanel",Ui.components={SelectionInput:Pi};class Vi extends Ui{onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}}Vi.template="o-spreadsheet-BarConfigPanel";class zi{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 Bi(e){return 8===(e=at(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}function Hi(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?yo(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Co(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function Wi(e,t,o,n){let i=!1;const r=[];for(let n in o){let s=o[n];if(s.labelCell){const e=Zi(s.labelCell,t);s.labelCell!==e&&(i=!0,s={...s,labelCell:e})}const a=Zi(s.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===X?(i=!0,s=void 0):a!==s.dataRange&&(i=!0,s={...s,dataRange:a}),r[n]=s}let s=n;const a=Zi(s,t);a!==s&&(i=!0,s=a);return{isStale:i,dataSets:r.filter(Ze),labelRange:s}}function Gi(e,t,o){return o.map((o=>({dataRange:uo(e,t,o.dataRange),labelCell:o.labelCell?uo(e,t,o.labelCell):void 0})))}function qi(e,t,o){return o?uo(e,t,o):void 0}function Zi(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function ji(e,t,o,n){const i=[];for(const r of t){const t=e.getRangeFromSheetXC(o,r),{unboundedZone:s,sheetId:a,invalidSheetName:l}=t;if(!l)if(s.left!==s.right&&s.top!==s.bottom){if(void 0===s.right)continue;for(let t=s.left;t<=s.right;t++){const o={...s,left:t,right:t};i.push(Xi(e,a,o,n?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else s.left===s.right&&s.top===s.bottom?n||i.push(Xi(e,a,s,void 0)):i.push(Xi(e,a,s,n?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0))}return i}function Xi(e,t,o,n){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${So(o)}`);if(n){const i=So(o),r=So(n);return{labelCell:e.getRangeFromSheetXC(t,r),dataRange:e.getRangeFromSheetXC(t,i)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,So(o))}}function Yi(e,t){var o;const n=null===(o=t.labelCell)||void 0===o?void 0:o.zone;let i=t.dataRange.zone;if(n){const{height:e,width:t}=_o(i);1===e?i={...i,left:i.left+1}:1===t&&(i={...i,top:i.top+1})}const r=t.dataRange.clone({zone:i});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(r,"forceSheetReference")}}function Ki(e,t){let o;if(e.labelRange){const n=Hi(mo(e.labelRange),t);o=n?So(n):void 0}const n=e.dataSets.map(mo).map((e=>Hi(e,t))).filter(Ze).map(So);return{...e,labelRange:o,dataSets:n}}const Qi=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class Ji{constructor(){this.graphColorIndex=0}next(){return Qi[this.graphColorIndex++%Qi.length]}}function er(e){return e&&dt(e)<.3?"#FFFFFF":"#000000"}function tr(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Et.test(e)));if(t)return 31;if(e.dataSets.map(mo).some((e=>e.top!==e.bottom&&Uo(e))))return 31}return 0}function or(e){if(e.labelRange){if(!Et.test(e.labelRange||""))return 32}return 0}function nr(e,t,o){const n=null==e?void 0:e.evaluated;if(e&&void 0!==n){if("text"===o||(null==t?void 0:t.type)!==Zo.number||n.type!==Zo.number)return e.formattedValue;{let e=t.value-n.value;if("percentage"===o&&0!==e&&(e=e/n.value*100),"percentage"!==o&&n.format)return Vt(e,n.format);const i=Math.abs(parseFloat(e.toFixed(2))).toLocaleString();return"percentage"===o?i+"%":i}}return""}function ir(e,t,o,n,i){if("text"===t||(null==e?void 0:e.type)!==Zo.number||(null==o?void 0:o.type)!==Zo.number)return;const r=o.value-e.value;return r>0?n:r<0?i:void 0}function rr(e,t,o){if("text"===o||(null==e?void 0:e.type)!==Zo.number||(null==t?void 0:t.type)!==Zo.number)return"neutral";const n=t.value-e.value;return n>0?"up":n<0?"down":"neutral"}function sr(e,t){if(t.dataRange){const o=t.labelCell?[So(t.labelCell.zone)]:[],n=Mo([So(t.dataRange.zone)],o)[0];if(void 0===n)return[];const i=e.getRangeFromSheetXC(t.dataRange.sheetId,n);return e.getRangeValues(i)}return[]}function ar(e,t){const o=Fe(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((o=>{const n=e[o],i=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[o]}));return n||i.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function lr(e){return e?e.length>K?e.substring(0,K)+"…":e:""}function cr(e,t,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:i(e.title),fontColor:o},legend:{onClick:void 0}},data:{labels:t.map(lr),datasets:[]}}}function hr(e,t,o){let n={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(n={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>null!=e?String(e):""))});else if(1===t.length)for(let o=0;o<sr(e,t[0]).length;o++)n.formattedValues.push(""),n.values.push("");else if(t[0]){n={formattedValues:Fe(0,sr(e,t[0]).length).map((e=>e.toString())),values:n.formattedValues}}return n}function dr(e,t){const o=[];for(const[n,i]of Object.entries(t)){let t;if(i.labelCell){const o=i.labelCell,r=o?e.getCell(o.sheetId,o.zone.left,o.zone.top):void 0;t=r&&o?lr(r.formattedValue):t=`${Mi.Series} ${parseInt(n)+1}`}else t=t=`${Mi.Series} ${parseInt(n)+1}`;let r=i.dataRange?sr(e,i):[];o.push({data:r,label:t})}return o}function ur(e){return 0===e?"origin":e-1}Ho.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new gr(e,t,o),getChartRuntime:function(e,t){let o=hr(t,e.dataSets,e.labelRange).formattedValues,n=dr(t,e.dataSets);({labels:o,dataSetsValues:n}=ar(o,n));const i=function(e,t){var o;const n=er(e.background),i=cr(e,t,n),r={labels:{fontColor:n}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;i.options.legend={...null===(o=i.options)||void 0===o?void 0:o.legend,...r},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0}}]},e.stacked&&(i.options.scales.xAxes[0].stacked=!0,i.options.scales.yAxes[0].stacked=!0);return i}(e,o),r=new Ji;for(let{label:e,data:t}of n){const o=r.next(),n={label:e,data:t,borderColor:o,backgroundColor:o};i.data.datasets.push(n)}return{chartJsConfig:i,background:e.background||w}},validateChartDefinition:(e,t)=>gr.validateChartDefinition(e,t),transformDefinition:(e,t)=>gr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>gr.getDefinitionFromContextCreation(e),name:r("Bar")});class gr extends zi{constructor(e,t,o){super(e,t,o),this.type="bar",this.dataSets=ji(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=go(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked}static transformDefinition(e,t){return Ki(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,tr,or)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=Gi(this.sheetId,e,this.dataSets),o=qi(this.sheetId,e,this.labelRange),n=this.getDefinitionWithSpecificDataSets(t,o,e);return new gr(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new gr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked}}getDefinitionForExcel(){const e=this.dataSets.map((e=>Yi(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Bi(this.background||w),fontColor:Bi(er(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:n}=Wi(this.getters,e,this.dataSets,this.labelRange);if(!n)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new gr(i,this.sheetId,this.getters)}}function pr(e,t){const o=Ho.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function fr(e){return e.dataRange&&!Et.test(e.dataRange)?35:0}function mr(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function vr(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?40:0}function br(e,t){if(""===e)switch(t){case"rangeMin":return 36;case"rangeMax":return 38}return 0}function Sr(e,t){if(isNaN(e))switch(t){case"rangeMin":return 37;case"rangeMax":return 39;case"lowerInflectionPointValue":return 41;case"upperInflectionPointValue":return 42}return 0}Ho.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new Cr(e,t,o),getChartRuntime:function(e,t){const o=function(e){const t=er(e.background),o=cr(e,[],t);return o.options.hover=void 0,o.options.events=[],o.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},o.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},o.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},o}(e),n=e.sectionRule.colors,i=e.sectionRule.lowerInflectionPoint,r=e.sectionRule.upperInflectionPoint,s=Number(i.value),a=Number(r.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==i.value){const e="number"===i.type?s:l+h*s/100;d.push({value:Oe(e,l,c),color:n.lowerColor})}if(""!==r.value){const e="number"===r.type?a:l+h*a/100;d.push({value:Oe(e,l,c),color:n.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(n.upperColor);const p=e.dataRange,f=h/30;let m=l-f,v=null,b=!1;if(void 0!==p){const e=t.getCell(p.sheetId,p.zone.left,p.zone.top);(null==e?void 0:e.evaluated.type)===Zo.number&&(m=Oe(null==e?void 0:e.evaluated.value,l-f,c+f),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return o.options.valueLabel.display=b,o.options.valueLabel.formatter=v,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:m,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>Cr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Cr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Cr.getDefinitionFromContextCreation(e),name:r("Gauge")});class Cr extends zi{constructor(e,t,o){super(e,t,o),this.type="gauge",this.dataRange=go(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,fr,e.chainValidations(mr(br,e.batchValidations),mr(Sr,e.batchValidations),vr),e.chainValidations((o=Sr,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=Hi(mo(e.dataRange),t)),{...e,dataRange:o?So(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=qi(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new Cr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Cr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=Zi(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new Cr(o,this.sheetId,this.getters)}}const Er={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},wr={inSeconds:function(e){return Math.floor(e/Er.second)},inMinutes:function(e){return Math.floor(e/Er.minute)},inHours:function(e){return Math.floor(e/Er.hour)},inDays:function(e){return Math.floor(e/Er.day)},inMonths:function(e){return Math.floor(e/Er.month)},inYears:function(e){return Math.floor(e/Er.year)}},yr=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function xr(e,t){const o=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),n=function(e,t){const o=e.map((e=>{var t;return null===(t=pe(e))||void 0===t?void 0:t.jsDate}));if(o.some((e=>void 0===e))||e.length<2)return;const n=o.map((e=>e.getTime())),i=Math.max(...n)-Math.min(...n),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Er.second>=Er[r]&&wr.inSeconds(i)<180)return"second";if(Er.minute>=Er[r]&&wr.inMinutes(i)<180)return"minute";if(Er.hour>=Er[r]&&wr.inHours(i)<96)return"hour";if(Er.day>=Er[r]&&wr.inDays(i)<90)return"day";if(Er.month>=Er[r]&&wr.inMonths(i)<36)return"month";return"year"}(e,o),i={};return n&&(i[n]=o),{parser:o,displayFormats:i,unit:n}}Ho.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new Rr(e,t,o),getChartRuntime:function(e,t){const o=function(e,t){if(function(e,t){return!e.labelsAsText&&Ir(e,t)}(e,t))return"time";if(function(e,t){return!e.labelsAsText&&Tr(e,t)}(e,t))return"linear";return"category"}(e,t),n=hr(t,e.dataSets,e.labelRange);let i="linear"===o?n.values:n.formattedValues,r=dr(t,e.dataSets);({labels:i,dataSetsValues:r}=ar(i,r)),"time"===o&&({labels:i,dataSetsValues:r}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],n=Ie(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=Je(o,e);for(let t of n)t.data[e]=void 0}return{labels:o,dataSetsValues:n}}(i,r));const s=function(e,t){var o;const n=er(e.background),i=cr(e,t,n),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,n]of o.entries())n.fillStyle=t.datasets[e].borderColor;return o}}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;i.options.legend={...null===(o=i.options)||void 0===o?void 0:o.legend,...r},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0}}]},e.stacked&&(i.options.scales.yAxes[0].stacked=!0);return i}(e,i),a=function(e,t){var o;if(t)return null===(o=e.getCell(t.sheetId,t.zone.left,t.zone.top))||void 0===o?void 0:o.evaluated.format}(t,e.labelRange);"time"===o?(s.options.scales.xAxes[0].type="time",s.options.scales.xAxes[0].time=xr(i,a),s.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(s.options.scales.xAxes[0].type="linear",s.options.scales.xAxes[0].ticks.callback=e=>Vt(e,a));const l=new Ji;for(let[t,{label:n,data:a}]of r.entries()){["linear","time"].includes(o)&&(a=a.map(((e,t)=>({x:i[t]||void 0,y:e}))));const r=l.next();let c=gt(r);e.stacked&&(c.a=Q);const h={label:n,data:a,lineTension:0,borderColor:r,backgroundColor:ut(c),pointBackgroundColor:r,fill:!!e.stacked&&ur(t)};s.data.datasets.push(h)}return{chartJsConfig:s,background:e.background||w}},validateChartDefinition:(e,t)=>Rr.validateChartDefinition(e,t),transformDefinition:(e,t)=>Rr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Rr.getDefinitionFromContextCreation(e),name:r("Line")});class Rr extends zi{constructor(e,t,o){super(e,t,o),this.type="line",this.dataSets=ji(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=go(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked}static validateChartDefinition(e,t){return e.checkValidations(t,tr,or)}static transformDefinition(e,t){return Ki(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:n}=Wi(this.getters,e,this.dataSets,this.labelRange);if(!n)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new Rr(i,this.sheetId,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>Yi(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Bi(this.background||w),fontColor:Bi(er(this.background)),dataSets:e}}copyForSheetId(e){const t=Gi(this.sheetId,e,this.dataSets),o=qi(this.sheetId,e,this.labelRange),n=this.getDefinitionWithSpecificDataSets(t,o,e);return new Rr(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Rr(t,e,this.getters)}}function Ir(e,t){var o;if(!e.labelRange||!e.dataSets||!Tr(e,t))return!1;const n=null===(o=t.getCell(e.labelRange.sheetId,e.labelRange.zone.left,e.labelRange.zone.top))||void 0===o?void 0:o.evaluated.format;return Boolean(n&&yr.test(n))}function Tr(e,t){if(!e.labelRange||!e.dataSets)return!1;const o=t.getRangeValues(e.labelRange);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}Ho.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new Ar(e,t,o),getChartRuntime:function(e,t){let o=hr(t,e.dataSets,e.labelRange).formattedValues,n=dr(t,e.dataSets);({labels:o,dataSetsValues:n}=ar(o,n));const i=function(e,t){var o;const n=er(e.background),i=cr(e,t,n),r={labels:{fontColor:n}};!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition;return i.options.legend={...null===(o=i.options)||void 0===o?void 0:o.legend,...r},i.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},i.options.tooltips={callbacks:{title:function(e,t){return t.datasets[e[0].datasetIndex].label}}},i}(e,o),r=new Ji;for(let{label:e,data:t}of n){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Or(r,n)};i.data.datasets.push(o)}return{chartJsConfig:i,background:e.background||w}},validateChartDefinition:(e,t)=>Ar.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ar.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ar.getDefinitionFromContextCreation(e),name:r("Pie")});class Ar extends zi{constructor(e,t,o){super(e,t,o),this.type="pie",this.dataSets=ji(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=go(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition}static transformDefinition(e,t){return Ki(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,tr,or)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title}}copyForSheetId(e){const t=Gi(this.sheetId,e,this.dataSets),o=qi(this.sheetId,e,this.labelRange),n=this.getDefinitionWithSpecificDataSets(t,o,e);return new Ar(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Ar(t,e,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>Yi(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:Bi(this.background||w),fontColor:Bi(er(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:n}=Wi(this.getters,e,this.dataSets,this.labelRange);if(!n)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new Ar(i,this.sheetId,this.getters)}}function Or(e,t){const o=[],n=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=n;t++)o.push(e.next());return o}function Mr(e){return e.keyValue&&!Et.test(e.keyValue)?33:0}function Nr(e){return e.baseline&&!Et.test(e.baseline)?34:0}Ho.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new _r(e,t,o),getChartRuntime:function(e,t){let o,n,r="",s="";if(e.keyValue){const n=e.keyValue.zone;o=t.getCell(e.keyValue.sheetId,n.left,n.top),r=(null==o?void 0:o.evaluated.value)?String(null==o?void 0:o.evaluated.value):"",s=(null==o?void 0:o.formattedValue)||""}if(e.baseline){const o=e.baseline.zone;n=t.getCell(e.baseline.sheetId,o.left,o.top)}const a=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:i(e.title),keyValue:s||r,baselineDisplay:nr(n,null==o?void 0:o.evaluated,e.baselineMode),baselineArrow:rr(null==n?void 0:n.evaluated,null==o?void 0:o.evaluated,e.baselineMode),baselineColor:ir(null==n?void 0:n.evaluated,e.baselineMode,null==o?void 0:o.evaluated,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?i(e.baselineDescr):"",fontColor:er(a),background:a,baselineStyle:"percentage"!==e.baselineMode?null==n?void 0:n.style:void 0,keyValueStyle:null==o?void 0:o.style}},validateChartDefinition:(e,t)=>_r.validateChartDefinition(e,t),transformDefinition:(e,t)=>_r.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>_r.getDefinitionFromContextCreation(e),name:r("Scorecard")});class _r extends zi{constructor(e,t,o){super(e,t,o),this.type="scorecard",this.keyValue=go(o,t,e.keyValue),this.baseline=go(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Mr,Nr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:"difference",baselineColorUp:"#00A04A",baselineColorDown:"#DC6965",baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,n;return e.baseline&&(o=Hi(mo(e.baseline),t)),e.keyValue&&(n=Hi(mo(e.keyValue),t)),{...e,baseline:o?So(o):void 0,keyValue:n?So(n):void 0}}copyForSheetId(e){const t=qi(this.sheetId,e,this.baseline),o=qi(this.sheetId,e,this.keyValue),n=this.getDefinitionWithSpecificRanges(t,o,e);return new _r(n,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new _r(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[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}}getDefinitionForExcel(){}updateRanges(e){const t=Zi(this.baseline,e),o=Zi(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const n=this.getDefinitionWithSpecificRanges(t,o);return new _r(n,this.sheetId,this.getters)}}const Fr=218,Dr=182;function kr(e){return ut(pt({h:360*e.offsetX/Fr,s:100,l:100*e.offsetY/Dr,a:1}))}an`
316
316
  .o-color-picker {
317
317
  position: absolute;
318
318
  top: calc(100% + 5px);
@@ -323,7 +323,7 @@
323
323
  line-height: 1.2;
324
324
  overflow-y: auto;
325
325
  overflow-x: hidden;
326
- width: ${_r+12}px;
326
+ width: ${Fr+12}px;
327
327
 
328
328
  .o-color-picker-section-name {
329
329
  margin: 0px ${1}px;
@@ -411,8 +411,8 @@
411
411
  hsl(1turn 100% 50%) 100%
412
412
  );
413
413
  border: ${1}px solid #c0c0c0;
414
- width: ${_r}px;
415
- height: ${Fr}px;
414
+ width: ${Fr}px;
415
+ height: ${Dr}px;
416
416
  &:hover {
417
417
  cursor: crosshair;
418
418
  }
@@ -448,7 +448,7 @@
448
448
  width: 30px;
449
449
  height: 30px;
450
450
  }
451
- `;class kr extends t.Component{constructor(){super(...arguments),this.COLORS=A,this.state=t.useState({showGradient:!1,currentColor:at(this.props.currentColor)?this.props.currentColor:"",isCurrentColorInvalid:!1,style:{display:"none",background:"#ffffff",left:"0",top:"0"}})}get colorPickerStyle(){return void 0===this.props.maxHeight?"":this.props.maxHeight<=0?ln({display:"none"}):ln({"max-height":`${this.props.maxHeight}px`})}onColorClick(e){e&&this.props.onColorPicked(e)}getCheckMarkColor(){return Ji(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!at(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);this.state.isCurrentColorInvalid=!1,this.props.onColorPicked(this.state.currentColor)}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}computeCustomColor(e){this.state.isCurrentColorInvalid=!1,this.state.currentColor=Dr(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=Dr(e);this.state.style.left=`${e.offsetX+10}px`,this.state.style.top=`${e.offsetY+10}px`}get magnifyingGlassStyle(){const{display:e,background:t,left:o,top:n}=this.state.style;return`display:${e};${"block"===e?`background-color:${t};left:${o};top:${n};`:""}`}}kr.template="o-spreadsheet-ColorPicker";class $r extends t.Component{constructor(){super(...arguments),this.state=t.useState({fillColorTool:!1})}onClick(e){this.state.fillColorTool=!1}setup(){t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}updateSelect(e,t){this.props.updateChart({[e]:t.target.value})}}$r.template="o-spreadsheet-LineBarPieDesignPanel",$r.components={ColorPicker:kr};class Lr extends $r{}Lr.template="o-spreadsheet-BarChartDesignPanel";class Pr extends t.Component{constructor(){super(...arguments),this.state=t.useState({dataRangeDispatchResult:void 0}),this.dataRange=this.props.definition.dataRange}get configurationErrorMessages(){var e;return[...(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Oi.Errors[e]||Oi.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart({dataRange:this.dataRange})}}Pr.template="o-spreadsheet-GaugeChartConfigPanel",Pr.components={SelectionInput:Li},sn`
451
+ `;class $r extends t.Component{constructor(){super(...arguments),this.COLORS=A,this.state=t.useState({showGradient:!1,currentColor:lt(this.props.currentColor)?this.props.currentColor:"",isCurrentColorInvalid:!1,style:{display:"none",background:"#ffffff",left:"0",top:"0"}})}get colorPickerStyle(){return void 0===this.props.maxHeight?"":this.props.maxHeight<=0?cn({display:"none"}):cn({"max-height":`${this.props.maxHeight}px`})}onColorClick(e){e&&this.props.onColorPicked(at(e))}getCheckMarkColor(){return er(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!lt(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);const t=at(this.state.currentColor);this.state.isCurrentColorInvalid=!1,this.props.onColorPicked(t),this.state.currentColor=t}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}computeCustomColor(e){this.state.isCurrentColorInvalid=!1,this.state.currentColor=kr(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=kr(e);this.state.style.left=`${e.offsetX+10}px`,this.state.style.top=`${e.offsetY+10}px`}get magnifyingGlassStyle(){const{display:e,background:t,left:o,top:n}=this.state.style;return`display:${e};${"block"===e?`background-color:${t};left:${o};top:${n};`:""}`}}$r.template="o-spreadsheet-ColorPicker";class Lr extends t.Component{constructor(){super(...arguments),this.state=t.useState({fillColorTool:!1})}onClick(e){this.state.fillColorTool=!1}setup(){t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}updateSelect(e,t){this.props.updateChart({[e]:t.target.value})}}Lr.template="o-spreadsheet-LineBarPieDesignPanel",Lr.components={ColorPicker:$r};class Pr extends Lr{}Pr.template="o-spreadsheet-BarChartDesignPanel";class Ur extends t.Component{constructor(){super(...arguments),this.state=t.useState({dataRangeDispatchResult:void 0}),this.dataRange=this.props.definition.dataRange}get configurationErrorMessages(){var e;return[...(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Mi.Errors[e]||Mi.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart({dataRange:this.dataRange})}}Ur.template="o-spreadsheet-GaugeChartConfigPanel",Ur.components={SelectionInput:Pi},an`
452
452
  .o-gauge-color-set {
453
453
  .o-gauge-color-set-color-button {
454
454
  display: inline-block;
@@ -488,7 +488,7 @@
488
488
  box-sizing: border-box;
489
489
  }
490
490
  }
491
- `;class Ur extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Oi.Errors[e]||Oi.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}isRangeMinInvalid(){var e,t,o;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(37))||(null===(o=this.state.sectionRuleDispatchResult)||void 0===o?void 0:o.isCancelledBecause(40)))}isRangeMaxInvalid(){var e,t,o;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(38))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(39))||(null===(o=this.state.sectionRuleDispatchResult)||void 0===o?void 0:o.isCancelledBecause(40)))}get isLowerInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(41))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(42))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}updateInflectionPointValue(e,t){const o=Ie(this.props.definition.sectionRule);o[e].value=t.target.value,this.updateSectionRule(o)}updateInflectionPointType(e,t){const o=Ie(this.props.definition.sectionRule);o[e].type=t.target.value,this.updateSectionRule(o)}updateSectionColor(e,t){const o=Ie(this.props.definition.sectionRule);o.colors[e]=t,this.updateSectionRule(o),this.closeMenus()}updateRangeMin(e){let t=Ie(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=Ie(this.props.definition.sectionRule);t={...t,rangeMax:e.target.value},this.updateSectionRule(t)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart({sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}Ur.template="o-spreadsheet-GaugeChartDesignPanel",Ur.components={ColorPicker:kr};class Vr extends Pi{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof xr)&&function(e,t){return Rr(e,t)||Ir(e,t)}(e,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart({labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}}Vr.template="o-spreadsheet-LineConfigPanel";class zr extends $r{}zr.template="o-spreadsheet-LineChartDesignPanel";class Br extends t.Component{constructor(){super(...arguments),this.state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0}),this.keyValue=this.props.definition.keyValue,this.baseline=this.props.definition.baseline}get errorMessages(){var e,t;return[...(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.baselineDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Oi.Errors[e]||Oi.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart({keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart({baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart({baselineMode:e.target.value})}}Br.template="o-spreadsheet-ScorecardChartConfigPanel",Br.components={SelectionInput:Li};class Hr extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}updateTitle(e){this.props.updateChart({title:e.target.value})}updateBaselineDescr(e){this.props.updateChart({baselineDescr:e.target.value})}openColorPicker(e){this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart({background:e});break;case"baselineColorDown":this.props.updateChart({baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart({baselineColorUp:e})}this.state.openedColorPicker=void 0}}Hr.template="o-spreadsheet-ScorecardChartDesignPanel",Hr.components={ColorPicker:kr};const Wr=new zo;Wr.add("line",{configuration:Vr,design:zr}).add("bar",{configuration:Ui,design:Lr}).add("pie",{configuration:Pi,design:$r}).add("gauge",{configuration:Pr,design:Ur}).add("scorecard",{configuration:Br,design:Hr}),sn`
491
+ `;class Vr extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Mi.Errors[e]||Mi.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}isRangeMinInvalid(){var e,t,o;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(37))||(null===(o=this.state.sectionRuleDispatchResult)||void 0===o?void 0:o.isCancelledBecause(40)))}isRangeMaxInvalid(){var e,t,o;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(38))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(39))||(null===(o=this.state.sectionRuleDispatchResult)||void 0===o?void 0:o.isCancelledBecause(40)))}get isLowerInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(41))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(42))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(43)))}updateInflectionPointValue(e,t){const o=Ie(this.props.definition.sectionRule);o[e].value=t.target.value,this.updateSectionRule(o)}updateInflectionPointType(e,t){const o=Ie(this.props.definition.sectionRule);o[e].type=t.target.value,this.updateSectionRule(o)}updateSectionColor(e,t){const o=Ie(this.props.definition.sectionRule);o.colors[e]=t,this.updateSectionRule(o),this.closeMenus()}updateRangeMin(e){let t=Ie(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=Ie(this.props.definition.sectionRule);t={...t,rangeMax:e.target.value},this.updateSectionRule(t)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart({sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}Vr.template="o-spreadsheet-GaugeChartDesignPanel",Vr.components={ColorPicker:$r};class zr extends Ui{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Rr)&&function(e,t){return Ir(e,t)||Tr(e,t)}(e,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart({labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}}zr.template="o-spreadsheet-LineConfigPanel";class Br extends Lr{}Br.template="o-spreadsheet-LineChartDesignPanel";class Hr extends t.Component{constructor(){super(...arguments),this.state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0}),this.keyValue=this.props.definition.keyValue,this.baseline=this.props.definition.baseline}get errorMessages(){var e,t;return[...(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.baselineDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Mi.Errors[e]||Mi.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart({keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart({baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart({baselineMode:e.target.value})}}Hr.template="o-spreadsheet-ScorecardChartConfigPanel",Hr.components={SelectionInput:Pi};class Wr extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}updateTitle(e){this.props.updateChart({title:e.target.value})}updateBaselineDescr(e){this.props.updateChart({baselineDescr:e.target.value})}openColorPicker(e){this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart({background:e});break;case"baselineColorDown":this.props.updateChart({baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart({baselineColorUp:e})}this.state.openedColorPicker=void 0}}Wr.template="o-spreadsheet-ScorecardChartDesignPanel",Wr.components={ColorPicker:$r};const Gr=new Bo;Gr.add("line",{configuration:zr,design:Br}).add("bar",{configuration:Vi,design:Pr}).add("pie",{configuration:Ui,design:Lr}).add("gauge",{configuration:Ur,design:Vr}).add("scorecard",{configuration:Hr,design:Wr}),an`
492
492
  .o-chart {
493
493
  .o-panel {
494
494
  display: flex;
@@ -518,7 +518,7 @@
518
518
  border-bottom: 4px solid;
519
519
  }
520
520
  }
521
- `;class Gr extends t.Component{constructor(){super(...arguments),this.shouldUpdateChart=!0}get figureId(){return this.state.figureId}get sheetId(){return this.state.sheetId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(r("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e,sheetId:this.env.model.getters.getActiveSheetId()}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId?(this.state.figureId=e,this.state.sheetId=this.env.model.getters.getActiveSheetId(),this.shouldUpdateChart=!1):this.shouldUpdateChart=!0,this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e){if(!this.shouldUpdateChart)return;const t={...this.getChartDefinition(),...e};return this.env.model.dispatch("UPDATE_CHART",{definition:t,id:this.figureId,sheetId:this.sheetId})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const o=function(e,t){return Bo.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:o,id:this.figureId,sheetId:this.sheetId})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=Wr.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of Bo.getKeys())e[t]=Bo.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Gr.template="o-spreadsheet-ChartPanel";function qr(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const Zr={arrowGood:{template:"ARROW_UP",img:qr('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:qr('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:qr('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>')},smileyGood:{template:"SMILE",img:qr('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>')},smileyNeutral:{template:"MEH",img:qr('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>')},smileyBad:{template:"FROWN",img:qr('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>')},dotGood:{template:"GREEN_DOT",img:qr('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:qr('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:qr('<svg class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')}},jr={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};sn`
521
+ `;class qr extends t.Component{constructor(){super(...arguments),this.shouldUpdateChart=!0}get figureId(){return this.state.figureId}get sheetId(){return this.state.sheetId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(r("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e,sheetId:this.env.model.getters.getActiveSheetId()}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId?(this.state.figureId=e,this.state.sheetId=this.env.model.getters.getActiveSheetId(),this.shouldUpdateChart=!1):this.shouldUpdateChart=!0,this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e){if(!this.shouldUpdateChart)return;const t={...this.getChartDefinition(),...e};return this.env.model.dispatch("UPDATE_CHART",{definition:t,id:this.figureId,sheetId:this.sheetId})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const o=function(e,t){return Ho.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:o,id:this.figureId,sheetId:this.sheetId})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=Gr.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of Ho.getKeys())e[t]=Ho.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}qr.template="o-spreadsheet-ChartPanel";function Zr(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const jr={arrowGood:{template:"ARROW_UP",img:Zr('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:Zr('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:Zr('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z"></path></svg>')},smileyGood:{template:"SMILE",img:Zr('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z"></path></svg>')},smileyNeutral:{template:"MEH",img:Zr('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z"></path></svg>')},smileyBad:{template:"FROWN",img:Zr('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z"></path></svg>')},dotGood:{template:"GREEN_DOT",img:Zr('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:Zr('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:Zr('<svg class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')}},Xr={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};an`
522
522
  .o-icon-picker {
523
523
  position: absolute;
524
524
  z-index: ${ne.IconPicker};
@@ -537,7 +537,7 @@
537
537
  outline: 1px solid gray;
538
538
  }
539
539
  }
540
- `;class Xr extends t.Component{constructor(){super(...arguments),this.icons=Zr,this.iconSets=jr}onIconClick(e){e&&this.props.onIconPicked(e)}}Xr.template="o-spreadsheet-IconPicker",sn`
540
+ `;class Yr extends t.Component{constructor(){super(...arguments),this.icons=jr,this.iconSets=Xr}onIconClick(e){e&&this.props.onIconPicked(e)}}Yr.template="o-spreadsheet-IconPicker",an`
541
541
  label {
542
542
  vertical-align: middle;
543
543
  }
@@ -804,13 +804,13 @@
804
804
  }
805
805
  }
806
806
  }
807
- `;class Yr extends t.Component{constructor(){super(...arguments),this.icons=Zr,this.cellIsOperators=Ai,this.iconSets=jr,this.getTextDecoration=an,this.colorNumberString=it}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return Ti.Errors[e]||Ti.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${an(e.style)};\n font-style:${e.style.italic?"italic":"normal"};\n color:${e.style.textColor||"none"};\n background-color:${e.style.fillColor||"none"};`}if("ColorScaleRule"===e.type){const t=it(e.minimum.color),o=e.midpoint?it(e.midpoint.color):null,n=it(e.maximum.color),i="background-image: linear-gradient(to right, ";return o?i+t+", "+o+", "+n+")":i+t+", "+n+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Ai[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?i("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Ti.ColorScale;case"IconSetRule":return Ti.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Ct))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(50))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(57)||this.state.errors.includes(49)||this.state.errors.includes(46)||this.state.errors.includes(52);case"midpoint":return this.state.errors.includes(58)||this.state.errors.includes(53)||this.state.errors.includes(48);case"maximum":return this.state.errors.includes(59)||this.state.errors.includes(54);default:return!1}}setColorScaleColor(e,t){const o=this.state.rules.colorScale[e];o&&(o.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,o=it(t.minimum.color),n=it((null===(e=t.midpoint)||void 0===e?void 0:e.color)||y),i=it(t.maximum.color),r="background-image: linear-gradient(to right, ";return void 0===t.midpoint?r+o+", "+i+")":r+o+", "+n+", "+i+")"}getThresholdColor(e){return it(e?e.color:y)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:y,value:"",...o.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(47);case"upperInflectionPoint":return this.state.errors.includes(55)||this.state.errors.includes(60)||this.state.errors.includes(47);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}Yr.template="o-spreadsheet-ConditionalFormattingPanel",Yr.components={SelectionInput:Li,IconPicker:Xr,ColorPicker:kr},sn`
807
+ `;class Kr extends t.Component{constructor(){super(...arguments),this.icons=jr,this.cellIsOperators=Oi,this.iconSets=Xr,this.getTextDecoration=ln,this.colorNumberString=rt}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return Ai.Errors[e]||Ai.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type){return`font-weight:${e.style.bold?"bold":"normal"};\n text-decoration:${ln(e.style)};\n font-style:${e.style.italic?"italic":"normal"};\n color:${e.style.textColor||"none"};\n background-color:${e.style.fillColor||"none"};`}if("ColorScaleRule"===e.type){const t=rt(e.minimum.color),o=e.midpoint?rt(e.midpoint.color):null,n=rt(e.maximum.color),i="background-image: linear-gradient(to right, ";return o?i+t+", "+o+", "+n+")":i+t+", "+n+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Oi[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?i("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Ai.ColorScale;case"IconSetRule":return Ai.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Et))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(50))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(57)||this.state.errors.includes(49)||this.state.errors.includes(46)||this.state.errors.includes(52);case"midpoint":return this.state.errors.includes(58)||this.state.errors.includes(53)||this.state.errors.includes(48);case"maximum":return this.state.errors.includes(59)||this.state.errors.includes(54);default:return!1}}setColorScaleColor(e,t){const o=this.state.rules.colorScale[e];o&&(o.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,o=rt(t.minimum.color),n=rt((null===(e=t.midpoint)||void 0===e?void 0:e.color)||y),i=rt(t.maximum.color),r="background-image: linear-gradient(to right, ";return void 0===t.midpoint?r+o+", "+i+")":r+o+", "+n+", "+i+")"}getThresholdColor(e){return rt(e?e.color:y)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:y,value:"",...o.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(47);case"upperInflectionPoint":return this.state.errors.includes(55)||this.state.errors.includes(60)||this.state.errors.includes(47);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}Kr.template="o-spreadsheet-ConditionalFormattingPanel",Kr.components={SelectionInput:Pi,IconPicker:Yr,ColorPicker:$r},an`
808
808
  .o-custom-currency {
809
809
  .o-format-proposals {
810
810
  color: black;
811
811
  }
812
812
  }
813
- `;class Kr extends t.Component{setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),o=e.position,n="before"===e.position?"after":"before",i=this.state.currencySymbol.trim()?this.state.currencySymbol:"",r=this.state.currencyCode.trim()?this.state.currencyCode:"";return r||i?[...this.createFormatProposals(t,i,r,o),...this.createFormatProposals(t,i,r,n)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===Fn.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{Fn.add(t.toString(),e)}))}const o={name:this.env._t(Ni.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[o,...Fn.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const o=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=o.code,this.state.currencySymbol=o.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],o=e?"."+"0".repeat(e):"";return o&&t.push({format:"#,##0"+o,example:"1,000"+o}),t}createFormatProposals(e,t,o,n){let i=[];if(t)for(let o of e)i.push(this.createFormatProposal(n,o.example,o.format,t));if(o)for(let r of e){const e=("after"===n?" ":"")+o+" "+t;i.push(this.createFormatProposal(n,r.example,r.format,e))}return i}createFormatProposal(e,t,o,n){const i="[$"+n+"]";return{example:"before"===e?n+t:t+n,format:"before"===e?i+o:o+i}}getCommonFormat(){var e;const t=this.env.model.getters.getSelectedZones(),o=this.env.model.getters.getActiveSheetId(),n=t.map((e=>this.env.model.getters.getCellsInZone(o,e))).flat(),i=null===(e=n[0])||void 0===e?void 0:e.format;return n.every((e=>(null==e?void 0:e.format)===i))?i:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}Kr.template="o-spreadsheet-CustomCurrencyPanel",sn`
813
+ `;class Qr extends t.Component{setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),o=e.position,n="before"===e.position?"after":"before",i=this.state.currencySymbol.trim()?this.state.currencySymbol:"",r=this.state.currencyCode.trim()?this.state.currencyCode:"";return r||i?[...this.createFormatProposals(t,i,r,o),...this.createFormatProposals(t,i,r,n)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===Dn.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{Dn.add(t.toString(),e)}))}const o={name:this.env._t(_i.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[o,...Dn.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const o=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=o.code,this.state.currencySymbol=o.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],o=e?"."+"0".repeat(e):"";return o&&t.push({format:"#,##0"+o,example:"1,000"+o}),t}createFormatProposals(e,t,o,n){let i=[];if(t)for(let o of e)i.push(this.createFormatProposal(n,o.example,o.format,t));if(o)for(let r of e){const e=("after"===n?" ":"")+o+" "+t;i.push(this.createFormatProposal(n,r.example,r.format,e))}return i}createFormatProposal(e,t,o,n){const i="[$"+n+"]";return{example:"before"===e?n+t:t+n,format:"before"===e?i+o:o+i}}getCommonFormat(){var e;const t=this.env.model.getters.getSelectedZones(),o=this.env.model.getters.getActiveSheetId(),n=t.map((e=>this.env.model.getters.getCellsInZone(o,e))).flat(),i=null===(e=n[0])||void 0===e?void 0:e.format;return n.every((e=>(null==e?void 0:e.format)===i))?i:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}Qr.template="o-spreadsheet-CustomCurrencyPanel",an`
814
814
  .o-find-and-replace {
815
815
  .o-far-item {
816
816
  display: block;
@@ -843,7 +843,7 @@
843
843
  }
844
844
  }
845
845
  }
846
- `;class Qr extends t.Component{constructor(){super(...arguments),this.state=t.useState(this.initialState()),this.showFormulaState=!1,this.findAndReplaceRef=t.useRef("findAndReplace")}get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})}))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.env.model.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.inDebounce),this.inDebounce=setTimeout((()=>this.updateSearch.call(this)),400)}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}Qr.template="o-spreadsheet-FindAndReplacePanel";const Jr=new zo;Jr.add("ConditionalFormatting",{title:r("Conditional formatting"),Body:Yr}),Jr.add("ChartPanel",{title:r("Chart"),Body:Gr}),Jr.add("FindAndReplace",{title:r("Find and Replace"),Body:Qr}),Jr.add("CustomCurrency",{title:r("Custom currency format"),Body:Kr});const es=new class extends zo{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new po}add(e,t){const o={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,o)}},ts=1.2;sn`
846
+ `;class Jr extends t.Component{constructor(){super(...arguments),this.state=t.useState(this.initialState()),this.showFormulaState=!1,this.findAndReplaceRef=t.useRef("findAndReplace")}get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})}))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.env.model.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.inDebounce),this.inDebounce=setTimeout((()=>this.updateSearch.call(this)),400)}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}Jr.template="o-spreadsheet-FindAndReplacePanel";const es=new Bo;es.add("ConditionalFormatting",{title:r("Conditional formatting"),Body:Kr}),es.add("ChartPanel",{title:r("Chart"),Body:qr}),es.add("FindAndReplace",{title:r("Find and Replace"),Body:Jr}),es.add("CustomCurrency",{title:r("Custom currency format"),Body:Qr});const ts=new class extends Bo{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new fo}add(e,t){const o={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,o)}},os=1.2;an`
847
847
  div.o-scorecard {
848
848
  user-select: none;
849
849
  background-color: white;
@@ -861,15 +861,15 @@
861
861
 
862
862
  .o-title-text {
863
863
  text-align: left;
864
- height: ${ts+"em"};
865
- line-height: ${ts+"em"};
864
+ height: ${os+"em"};
865
+ line-height: ${os+"em"};
866
866
  overflow: hidden;
867
867
  white-space: nowrap;
868
868
  }
869
869
 
870
870
  .o-key-text {
871
- line-height: ${ts+"em"};
872
- height: ${ts+"em"};
871
+ line-height: ${os+"em"};
872
+ height: ${os+"em"};
873
873
  overflow: hidden;
874
874
  white-space: nowrap;
875
875
  }
@@ -884,8 +884,8 @@
884
884
  }
885
885
 
886
886
  .o-baseline-text {
887
- line-height: ${ts+"em"};
888
- height: ${ts+"em"};
887
+ line-height: ${os+"em"};
888
+ height: ${os+"em"};
889
889
  overflow: hidden;
890
890
  white-space: nowrap;
891
891
 
@@ -894,7 +894,7 @@
894
894
  }
895
895
  }
896
896
  }
897
- `;class os extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return ht(this.primaryFontColor)<=.3?"#757575":"#bbbbbb"}get figure(){return this.props.figure}get chartStyle(){return`\n padding:${this.chartPadding}px;\n background:${this.backgroundColor};\n `}get chartContentStyle(){return`\n height:${this.getDrawableHeight()}px;\n `}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){var e,t,o;const n=.96*this.props.figure.width,i=this.getWidestElement(),r=i.getElementMaxFontSize(this.getDrawableHeight(),this);let s=function(e,t,o,n=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let r=(i+t)/2,s=o(r),a=0;for(;Math.abs(s-e)>n&&a<20;)s>=e?t=(i+t)/2:i=(i+t)/2,r=(i+t)/2,s=o(r),a++;return r}(n,r,(e=>i.getElementWidth(e,this.ctx,this)))/r;const a=(new is).getElementMaxFontSize(this.getDrawableHeight(),this)*s,l=(new ns).getElementMaxFontSize(this.getDrawableHeight(),this)*s;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:a,cellStyle:null===(e=this.runtime)||void 0===e?void 0:e.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:l}),baselineValueStyle:this.getTextStyle({fontSize:l,cellStyle:null===(t=this.runtime)||void 0===t?void 0:t.baselineStyle,color:(null===(o=this.runtime)||void 0===o?void 0:o.baselineColor)||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*l,color:this.secondaryFontColor})}}getTextStyle(e){const t=function(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),ln(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*ts:0,t}getWidestElement(){const e=new ns,t=new is;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}os.template="o-spreadsheet-ScorecardChart";class ns{getElementWidth(e,t,o){if(!o.runtime)return 0;const n=o.baseline,i="neutral"!==o.baselineArrowDirection?"A "+n:n;t.font=`${e}px ${G}`;let r=t.measureText(i).width;return t.font=`${.9*e}px ${G}`,r+=t.measureText(o.baselineDescr).width,r}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/ts}}class is{getElementWidth(e,t,o){if(!o.runtime)return 0;const n=o.keyValue||"";return t.font=`${e}px ${G}`,t.measureText(n).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/ts}}Ho.add("scorecard",os),sn`
897
+ `;class ns extends t.Component{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}get runtime(){return this.env.model.getters.getChartRuntime(this.props.figure.id)}get title(){return this.runtime.title}get keyValue(){return this.runtime.keyValue}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){const e=this.runtime.baselineDescr||"";return this.baseline&&e?" "+e:e}get baselineArrowDirection(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get primaryFontColor(){return this.runtime.fontColor}get secondaryFontColor(){return dt(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get figure(){return this.props.figure}get chartStyle(){return`\n padding:${this.chartPadding}px;\n background:${this.backgroundColor};\n `}get chartContentStyle(){return`\n height:${this.getDrawableHeight()}px;\n `}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){var e,t,o;const n=.96*this.props.figure.width,i=this.getWidestElement(),r=i.getElementMaxFontSize(this.getDrawableHeight(),this);let s=function(e,t,o,n=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let r=(i+t)/2,s=o(r),a=0;for(;Math.abs(s-e)>n&&a<20;)s>=e?t=(i+t)/2:i=(i+t)/2,r=(i+t)/2,s=o(r),a++;return r}(n,r,(e=>i.getElementWidth(e,this.ctx,this)))/r;const a=(new rs).getElementMaxFontSize(this.getDrawableHeight(),this)*s,l=(new is).getElementMaxFontSize(this.getDrawableHeight(),this)*s;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:a,cellStyle:null===(e=this.runtime)||void 0===e?void 0:e.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:l}),baselineValueStyle:this.getTextStyle({fontSize:l,cellStyle:null===(t=this.runtime)||void 0===t?void 0:t.baselineStyle,color:(null===(o=this.runtime)||void 0===o?void 0:o.baselineColor)||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*l,color:this.secondaryFontColor})}}getTextStyle(e){const t=function(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),cn(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*os:0,t}getWidestElement(){const e=new is,t=new rs;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}ns.template="o-spreadsheet-ScorecardChart";class is{getElementWidth(e,t,o){if(!o.runtime)return 0;const n=o.baseline,i="neutral"!==o.baselineArrowDirection?"A "+n:n;t.font=`${e}px ${G}`;let r=t.measureText(i).width;return t.font=`${.9*e}px ${G}`,r+=t.measureText(o.baselineDescr).width,r}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/os}}class rs{getElementWidth(e,t,o){if(!o.runtime)return 0;const n=o.keyValue||"";return t.font=`${e}px ${G}`,t.measureText(n).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/os}}Wo.add("scorecard",ns),an`
898
898
  .o-chart-container {
899
899
  width: 100%;
900
900
  height: 100%;
@@ -919,7 +919,7 @@
919
919
  }
920
920
  }
921
921
  }
922
- `;class rs extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=Sn(this.menuButtonRef),this.position=Sn(this.chartContainerRef)}getMenuItemRegistry(){const e=new Tn;return e.add("edit",{name:r("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:r("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:r("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.sidePanelIsOpen&&this.env.toggleSidePanel("ChartPanel"),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-z,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=Ho.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function ss(e,t,o=(()=>{})){const n=r=>{t(r),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",n),window.removeEventListener("dragstart",i),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function i(e){e.preventDefault()}window.addEventListener("mousedown",o),window.addEventListener("mouseup",n),window.addEventListener("dragstart",i),window.addEventListener("mousemove",e),window.addEventListener("wheel",e)}function as(e,t,o,n=!1){let i,r,s,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=bn();let g,p;const f=o=>{if(i=o,c)return;const{x:s,y:m}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let R=!1,I=Mt;const T=i.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==n){const t=r.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,o.delay),o.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-s}}const A=i.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==n){const t=r.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,o.delay),o.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+o.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-m}}R||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,i),R&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,f(i)}),Math.round(I))),r=i};ss(f,(()=>{clearTimeout(c),o()}),(e=>{r=e,s=e,a=s.clientX-u.left,l=s.clientY-u.top}))}rs.template="o-spreadsheet-ChartFigure",rs.components={Menu:En},sn`
922
+ `;class ss extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.chartContainerRef=t.useRef("chartContainer"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonPosition=Cn(this.menuButtonRef),this.position=Cn(this.chartContainerRef)}getMenuItemRegistry(){const e=new An;return e.add("edit",{name:r("Edit"),sequence:1,action:()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.openSidePanel("ChartPanel")}}),e.add("copy",{name:r("Copy"),sequence:2,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("COPY"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("cut",{name:r("Cut"),sequence:3,action:async()=>{this.env.model.dispatch("SELECT_FIGURE",{id:this.props.figure.id}),this.env.model.dispatch("CUT"),await this.env.clipboard.writeText(this.env.model.getters.getClipboardContent())}}),e.add("delete",{name:r("Delete"),sequence:10,action:()=>{this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:this.props.figure.id}),this.props.sidePanelIsOpen&&this.env.toggleSidePanel("ChartPanel"),this.props.onFigureDeleted()}}),e}get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}onContextMenu(e){const t={x:this.position.x+e.offsetX,y:this.position.y+e.offsetY};this.openContextMenu(t)}showMenu(){const e={x:this.menuButtonPosition.x-z,y:this.menuButtonPosition.y};this.openContextMenu(e)}openContextMenu(e){const t=this.getMenuItemRegistry();this.menuState.isOpen=!0,this.menuState.menuItems=t.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position=e}get chartComponent(){const e=this.chartType,t=Wo.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}function as(e,t,o=(()=>{})){const n=r=>{t(r),window.removeEventListener("mousedown",o),window.removeEventListener("mouseup",n),window.removeEventListener("dragstart",i),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function i(e){e.preventDefault()}window.addEventListener("mousedown",o),window.addEventListener("mouseup",n),window.addEventListener("dragstart",i),window.addEventListener("mousemove",e),window.addEventListener("wheel",e)}function ls(e,t,o,n=!1){let i,r,s,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Sn();let g,p;const f=o=>{if(i=o,c)return;const{x:s,y:m}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let R=!1,I=Nt;const T=i.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==n){const t=r.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,o.delay),o.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-s}}const A=i.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==n){const t=r.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(R=!0,I=Math.min(I,o.delay),o.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+o.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-m}}R||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,i),R&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,f(i)}),Math.round(I))),r=i};as(f,(()=>{clearTimeout(c),o()}),(e=>{r=e,s=e,a=s.clientX-u.left,l=s.clientY-u.top}))}ss.template="o-spreadsheet-ChartFigure",ss.components={Menu:wn},an`
923
923
  .o-autofill {
924
924
  height: 6px;
925
925
  width: 6px;
@@ -947,9 +947,9 @@
947
947
  white-space: nowrap;
948
948
  }
949
949
  }
950
- `;class ls extends t.Component{constructor(){super(...arguments),this.state=t.useState({position:{left:0,top:0},handler:!1})}get style(){const{left:e,top:t}=this.props.position;return`top:${t}px;left:${e}px`}get styleHandler(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top}px;left:${e.left}px;`}get styleNextvalue(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top+5}px;left:${e.left+15}px;`}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=cs),e}onMouseDown(e){this.state.handler=!0,this.state.position={left:0,top:0};const{scrollY:t,scrollX:o}=this.env.model.getters.getActiveSheetScrollInfo(),n=e.clientX+o,i=e.clientY+t;let r,s;ss((e=>{const t=bn(),{scrollY:o,scrollX:a}=this.env.model.getters.getActiveSheetScrollInfo();this.state.position={left:e.clientX-n+a,top:e.clientY-i+o};const l=this.env.model.getters.getColIndex(e.clientX-t.left),c=this.env.model.getters.getRowIndex(e.clientY-t.top);if(r!==l||s!==c){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getNumberCols(e),o=this.env.model.getters.getNumberRows(e);r=-1===l?r:Oe(l,0,t),s=-1===c?s:Oe(c,0,o),void 0!==r&&void 0!==s&&this.env.model.dispatch("AUTOFILL_SELECT",{col:r,row:s})}}),(()=>{this.state.handler=!1,this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}ls.template="o-spreadsheet-Autofill";class cs extends t.Component{}cs.template=t.xml`
950
+ `;class cs extends t.Component{constructor(){super(...arguments),this.state=t.useState({position:{left:0,top:0},handler:!1})}get style(){const{left:e,top:t}=this.props.position;return`top:${t}px;left:${e}px`}get styleHandler(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top}px;left:${e.left}px;`}get styleNextvalue(){let e=this.state.handler?this.state.position:{left:0,top:0};return`top:${e.top+5}px;left:${e.left+15}px;`}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=hs),e}onMouseDown(e){this.state.handler=!0,this.state.position={left:0,top:0};const{scrollY:t,scrollX:o}=this.env.model.getters.getActiveSheetScrollInfo(),n=e.clientX+o,i=e.clientY+t;let r,s;as((e=>{const t=Sn(),{scrollY:o,scrollX:a}=this.env.model.getters.getActiveSheetScrollInfo();this.state.position={left:e.clientX-n+a,top:e.clientY-i+o};const l=this.env.model.getters.getColIndex(e.clientX-t.left),c=this.env.model.getters.getRowIndex(e.clientY-t.top);if(r!==l||s!==c){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getNumberCols(e),o=this.env.model.getters.getNumberRows(e);r=-1===l?r:Oe(l,0,t),s=-1===c?s:Oe(c,0,o),void 0!==r&&void 0!==s&&this.env.model.dispatch("AUTOFILL_SELECT",{col:r,row:s})}}),(()=>{this.state.handler=!1,this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}cs.template="o-spreadsheet-Autofill";class hs extends t.Component{}hs.template=t.xml`
951
951
  <div t-esc="props.content"/>
952
- `,sn`
952
+ `,an`
953
953
  .o-client-tag {
954
954
  position: absolute;
955
955
  border-top-left-radius: 4px;
@@ -959,7 +959,7 @@
959
959
  opacity: 0;
960
960
  pointer-events: none;
961
961
  }
962
- `;class hs extends t.Component{get tagStyle(){const{col:e,row:t,color:o}=this.props,{height:n}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:i,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${n-r+15}px;left: ${i-1}px;border: 1px solid ${o};background-color: ${o};${this.props.active?"opacity:1 !important":""}`}}hs.template="o-spreadsheet-ClientTag";const ds=/(.*?)\((.*?)\)(.*)/,us=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function gs(e){let t=e.split("\n");const o=[];for(let e of t)e=e.trim(),e&&o.push(ps(e));return o}function ps(e){let t,o=e.match(ds),n=o[1].trim(),i=[],r=!1,s=!1,a=!1;for(let e of o[2].split(",")){const o=e.trim().toUpperCase();let n=us.find((e=>o===e));n?i.push(n):"RANGE<ANY>"===o?i.push("RANGE"):"OPTIONAL"===o?r=!0:"REPEATING"===o?s=!0:"LAZY"===o?a=!0:o.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:n,description:o[3].trim(),type:i};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function fs(e){let t=0,o=0,n=0;for(let i of e.args)t++,i.optional||i.repeating||i.default||o++,i.repeating&&n++;const i=e;return i.minArgRequired=o,i.maxArgPossible=n?1/0:t,i.nbrArgRepeating=n,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,n),i}const ms=["number","string","boolean","undefined"];function vs(e,t){if(!e())throw new Error(t)}const bs=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Ss(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(ro(e)||""===e)return ao(e);const t=pe(e);if(t)return t.value;throw new Error(bs(e));default:return 0}}function Cs(e){if(""===e)throw new Error(bs(e));return Ss(e)}function Es(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function ws(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const ys=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function xs(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(ys(e))}return!1;case"number":return!!e;default:return!1}}function Rs(e){return me(Ss(e))}function Is(e,t,o){for(let n of e)if(Array.isArray(n)){const e=n.length,o=n[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)t(n[o][i])}else o(n)}function Ts(e,t){Is(e,t,t)}function As(e,t){Is(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Cs(e))}))}function Os(e,t,o,n){let i=n;for(let n of e)if(Array.isArray(n)){const e=n.length,o=n[0].length;for(let r=0;r<o;r++)for(let o=0;o<e;o++)i=t(i,n[o][r])}else i=o(i,n);return i}function Ms(e,t,o){return Os(e,t,t,o)}function Ns(e,t,o){return Os(e,((e,o)=>"number"==typeof o?t(e,o):e),((e,o)=>t(e,Cs(o))),o)}function _s(e,t,o){return Os(e,((e,o)=>null!=o?t(e,"number"==typeof o?o:"boolean"==typeof o?Ss(o):0):e),((e,o)=>t(e,Ss(o))),o)}function Fs(e,t){return function(e,t,o){for(let n of e)if(Array.isArray(n)){const e=n.length,o=n[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)if(!t(n[o][i]))return}else if(!o(n))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(ys(e));return xs(e)}(e))))}function Ds(e,t){let o,n,i=e.substring(0,2);"<="===i||">="===i||"<>"===i?(o=i,n=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(o=i,n=e.substring(1)):(o="=",n=e)),ro(n)?n=Ss(n):"TRUE"!==n&&"FALSE"!==n||(n=xs(n));const r={operator:o,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){let t="",o="";for(let n of e)"?"===n&&"~"!==o?t+=".":"*"===n&&"~"!==o?t+=".*":("*"!==n&&"?"!==n||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(n)&&(t+="\\"),t+=n),o=n;return new RegExp("^"+t+"$","i")}(n)),r}function ks(e,t){const{operator:o,operand:n}=t;if(void 0===e||void 0===n)return!1;if("number"==typeof n&&"="===o)return Es(e)===Es(n);if("<>"===o||"="===o){let i;return i=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===o?i:!i}if(typeof e==typeof n)switch(o){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function $s(e,t,o=!1){const n=e.length;if(n%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const i=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Array.isArray(n)||n.length!==i||n[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Es(e[t+1]);a.push(Ds(l,o))}for(let o=0;o<i;o++)for(let i=0;i<s;i++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=ks(e[t][o][i],a[t/2]),!r)break}r&&t(o,i)}}function Ls(e,t){return ws(e[0][t])}function Ps(e,t){return ws(e[t][0])}function Us(e,t,o,n,i,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=i-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===o&&d===t?(a=d,l=h):"nextSmaller"===o&&d<=t?(void 0===a||a<d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h):"nextGreater"===o&&d>=t&&(void 0===a||a>d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h),"asc"===n&&d>t||"desc"===n&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function Vs(e,t,o,n,i,r=!1){if(null==t)return-1;const s=r?(e,t)=>i(e,n-t-1):i;let a,l=-1;for(let i=0;i<n;i++){const c=s(e,i);if(c===t)return r?n-i-1:i;"nextSmaller"===o?(!a&&zs(t,c)>=0||zs(t,c)>=0&&zs(c,a)>0)&&(a=c,l=i):"nextGreater"===o&&(!a&&zs(t,c)<=0||zs(t,c)<=0&&zs(c,a)<0)&&(a=c,l=i)}return r?n-l-1:l}function zs(e,t){let o=ms.indexOf(typeof e)-ms.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}const Bs={description:r("Apply a large number format"),args:gs(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const o=Math.abs(Ss(e.value)),n=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return Zt(n,1e3,"k");case"m":return Zt(n,1e6,"m");case"b":return Zt(n,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?Zt(n,0,""):o<1e8?Zt(n,1e3,"k"):o<1e11?Zt(n,1e6,"m"):Zt(n,1e9,"b")},compute:function(e){return Ss(e)}};var Hs=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Bs});const Ws={description:r("Absolute value of a number."),args:gs(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Ss(e))},isExported:!0},Gs={description:r("Inverse cosine of a value, in radians."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},qs={description:r("Inverse hyperbolic cosine of a number."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},Zs={description:r("Inverse cotangent of a value."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},js={description:r("Inverse hyperbolic cotangent of a value."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Xs={description:r("Inverse sine of a value, in radians."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ys={description:r("Inverse hyperbolic sine of a number."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Ss(e))},isExported:!0},Ks={description:r("Inverse tangent of a value, in radians."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Ss(e))},isExported:!0},Qs={description:r("Angle from the X axis to a point (x,y), in radians."),args:gs(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Ss(e),n=Ss(t);return vs((()=>0!==o||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,o)},isExported:!0},Js={description:r("Inverse hyperbolic tangent of a number."),args:gs(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},ea={description:r("Rounds number up to nearest multiple of factor."),args:gs(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const o=Ss(e),n=Ss(t);return vs((()=>n>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),o.toString())),n?Math.ceil(o/n)*n:0},isExported:!0},ta={description:r("Rounds number up to nearest multiple of factor."),args:gs(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,o=0){let n=Ss(t);if(0===n)return 0;const i=Ss(e);if(n=Math.abs(n),i>=0)return Math.ceil(i/n)*n;return 0===Ss(o)?-Math.floor(Math.abs(i)/n)*n:-Math.ceil(Math.abs(i)/n)*n},isExported:!0},oa={description:r("Rounds number up to nearest multiple of factor."),args:gs(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return ta.compute(e,t,0)},isExported:!0},na={description:r("Cosine of an angle provided in radians."),args:gs(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Ss(e))},isExported:!0},ia={description:r("Hyperbolic cosine of any real number."),args:gs(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Ss(e))},isExported:!0},ra={description:r("Cotangent of an angle provided in radians."),args:gs(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},sa={description:r("Hyperbolic cotangent of any real number."),args:gs(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},aa={description:r("Number of empty values."),args:gs(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Ms(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},la={description:r("A conditional count across a range."),args:gs(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return $s(e,((e,o)=>{t+=1})),t},isExported:!0},ca={description:r("Count values depending on multiple criteria."),args:gs(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return $s(e,((e,o)=>{t+=1})),t},isExported:!0};function ha(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const da={description:r("Counts number of unique values in a range."),args:gs(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Ms(e,((e,t)=>ha(t)?e.add(t):e),new Set).size}},ua={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:gs(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=new Set;return $s(t,((t,n)=>{const i=e[t][n];ha(i)&&o.add(i)})),o.size}},ga={description:r("Cosecant of an angle provided in radians."),args:gs(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},pa={description:r("Hyperbolic cosecant of any real number."),args:gs(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},fa={description:r("Converts from another base to decimal."),args:gs(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let o=Ss(t);o=Math.floor(o),vs((()=>2<=o&&o<=36),r("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const n=Es(e);if(""===n)return 0;vs((()=>!!n.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",n,o.toString()));const i=parseInt(n,o);return vs((()=>!isNaN(i)),r("The value (%s) must be a valid base %s representation.",n,o.toString())),i},isExported:!0},ma={description:r("Converts an angle value in radians to degrees."),args:gs(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Ss(e)/Math.PI},isExported:!0},va={description:r("Euler's number, e (~2.718) raised to a power."),args:gs(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Ss(e))},isExported:!0},ba={description:r("Rounds number down to nearest multiple of factor."),args:gs(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const o=Ss(e),n=Ss(t);return vs((()=>n>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),o.toString())),n?Math.floor(o/n)*n:0},isExported:!0},Sa={description:r("Rounds number down to nearest multiple of factor."),args:gs(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,o=0){let n=Ss(t);if(0===n)return 0;const i=Ss(e);if(n=Math.abs(n),i>=0)return Math.floor(i/n)*n;return 0===Ss(o)?-Math.ceil(Math.abs(i)/n)*n:-Math.floor(Math.abs(i)/n)*n},isExported:!0},Ca={description:r("Rounds number down to nearest multiple of factor."),args:gs(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Sa.compute(e,t,0)},isExported:!0},Ea={description:r("Whether the provided value is even."),args:gs(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Cs(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},wa={description:r("Rounds number up to nearest multiple of factor."),args:gs(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return ta.compute(e,t,0)},isExported:!0},ya={description:r("Whether the provided value is even."),args:gs(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Cs(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},xa={description:r("The logarithm of a number, base e (euler's number)."),args:gs(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Ss(e);return vs((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ra={description:r("Modulo (remainder) operator."),args:gs(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Ss(t);vs((()=>0!==o),r("The divisor must be different from 0."));const n=Ss(e)%o;return n>0&&o<0||n<0&&o>0?n+o:n},isExported:!0},Ia={description:r("Rounds a number up to the nearest odd integer."),args:gs(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ss(e);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},Ta={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Aa={description:r("A number raised to a power."),args:gs(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Ss(e),n=Ss(t);return vs((()=>o>=0||Number.isInteger(n)),r("The exponent (%s) must be an integer when the base is negative.",n.toString())),Math.pow(o,n)},isExported:!0},Oa={description:r("Result of multiplying a series of numbers together."),args:gs(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,o=1;for(let n of e)if(Array.isArray(n))for(let e of n)for(let n of e)"number"==typeof n&&(o*=n,t+=1);else null!=n&&(o*=Cs(n),t+=1);return 0===t?0:o},isExported:!0},Ma={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Na={description:r("Random integer between two values, inclusive."),args:gs(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let o=Ss(e);Number.isInteger(o)||(o=Math.ceil(o));let n=Ss(t);return Number.isInteger(n)||(n=Math.floor(n)),vs((()=>o<=n),r("The high (%s) must be greater than or equal to the low (%s).",n.toString(),o.toString())),o+Math.ceil((n-o+1)*Math.random())-1},isExported:!0},_a={description:r("Rounds a number according to standard rules."),args:gs(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Ss(e);let n=Ss(t);const i=Math.abs(o);let r;return 0===n?r=Math.round(i):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.round(i*Math.pow(10,n))/Math.pow(10,n)),o>=0?r:-r},isExported:!0},Fa={description:r("Rounds down a number."),args:gs(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Ss(e);let n=Ss(t);const i=Math.abs(o);let r;return 0===n?r=Math.floor(i):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.floor(i*Math.pow(10,n))/Math.pow(10,n)),o>=0?r:-r},isExported:!0},Da={description:r("Rounds up a number."),args:gs(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Ss(e);let n=Ss(t);const i=Math.abs(o);let r;return 0===n?r=Math.ceil(i):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.ceil(i*Math.pow(10,n))/Math.pow(10,n)),o>=0?r:-r},isExported:!0},ka={description:r("Secant of an angle provided in radians."),args:gs(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Ss(e))},isExported:!0},$a={description:r("Hyperbolic secant of any real number."),args:gs(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Ss(e))},isExported:!0},La={description:r("Sine of an angle provided in radians."),args:gs(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Ss(e))},isExported:!0},Pa={description:r("Hyperbolic sine of any real number."),args:gs(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Ss(e))},isExported:!0},Ua={description:r("Positive square root of a positive number."),args:gs(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Ss(e);return vs((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},Va={description:r("Sum of a series of numbers and/or cells."),args:gs(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Ns(e,((e,t)=>e+t),0)},isExported:!0},za={description:r("A conditional sum across a range."),args:gs(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let n=0;return $s([e,t],((e,t)=>{const i=o[e][t];"number"==typeof i&&(n+=i)})),n},isExported:!0},Ba={description:r("Sums a range depending on multiple criteria."),args:gs(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=0;return $s(t,((t,n)=>{const i=e[t][n];"number"==typeof i&&(o+=i)})),o},isExported:!0},Ha={description:r("Tangent of an angle provided in radians."),args:gs(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Ss(e))},isExported:!0},Wa={description:r("Hyperbolic tangent of any real number."),args:gs(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Ss(e))},isExported:!0},Ga={description:r("Truncates a number."),args:gs(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Ss(e);let n=Ss(t);return 0===n?Math.trunc(o):(Number.isInteger(n)||(n=Math.trunc(n)),Math.trunc(o*Math.pow(10,n))/Math.pow(10,n))},isExported:!0};var qa=Object.freeze({__proto__:null,ABS:Ws,ACOS:Gs,ACOSH:qs,ACOT:Zs,ACOTH:js,ASIN:Xs,ASINH:Ys,ATAN:Ks,ATAN2:Qs,ATANH:Js,CEILING:ea,CEILING_MATH:ta,CEILING_PRECISE:oa,COS:na,COSH:ia,COT:ra,COTH:sa,COUNTBLANK:aa,COUNTIF:la,COUNTIFS:ca,COUNTUNIQUE:da,COUNTUNIQUEIFS:ua,CSC:ga,CSCH:pa,DECIMAL:fa,DEGREES:ma,EXP:va,FLOOR:ba,FLOOR_MATH:Sa,FLOOR_PRECISE:Ca,ISEVEN:Ea,ISO_CEILING:wa,ISODD:ya,LN:xa,MOD:Ra,ODD:Ia,PI:Ta,POWER:Aa,PRODUCT:Oa,RAND:Ma,RANDBETWEEN:Na,ROUND:_a,ROUNDDOWN:Fa,ROUNDUP:Da,SEC:ka,SECH:$a,SIN:La,SINH:Pa,SQRT:Ua,SUM:Va,SUMIF:za,SUMIFS:Ba,TAN:Ha,TANH:Wa,TRUNC:Ga});function Za(e,t,o){let n=[],i=[],s=0,a=0;Ts([e],(e=>{n.push(e),s+=1})),Ts([t],(e=>{i.push(e),a+=1})),vs((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=n[e],o=i[e];"number"==typeof t&&"number"==typeof o&&(l+=1,c+=t,h+=o)}vs((()=>0!==l&&(!o||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<s;e++){const t=n[e],o=i[e];"number"==typeof t&&"number"==typeof o&&(g+=(t-d)*(o-u))}return g/(l-(o?1:0))}function ja(e,t,o){let n=0,i=0;const s=o?_s:Ns;i=s(e,((e,t)=>(n+=1,e+t)),0),vs((()=>0!==n&&(!t||1!==n)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=i/n;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(n-(t?1:0))}function Xa(e,t,o){const n=Ss(t);vs((()=>o?0<=n&&n<=1:0<n&&n<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let i,s=[],a=0;return Ts(e,(e=>{"number"==typeof e&&(i=Us(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(i+1,0,e),a++)})),vs((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),o||vs((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),lo(s,n,o)}const Ya={description:r("Average magnitude of deviations from mean."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const o=Ns(e,((e,o)=>(t+=1,e+o)),0);vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=o/t;return Ns(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},Ka={description:r("Numerical average value in a dataset, ignoring text."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const o=Ns(e,((e,o)=>(t+=1,e+o)),0);return vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Qa=r("[[FUNCTION_NAME]] has mismatched range sizes."),Ja=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),el={description:r("Weighted average."),args:gs(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,o,n=0,i=0;vs((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],o=e[s+1],Array.isArray(t)){vs((()=>Array.isArray(o)),Qa);let e=t.length,s=t[0].length;vs((()=>e===o.length&&s===o[0].length),Qa);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=o[a][e],c="number"==typeof s,h="number"==typeof l;vs((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(vs((()=>l>=0),Ja),n+=s*l,i+=l)}}else o=Ss(o),t=Ss(t),vs((()=>o>=0),Ja),n+=t*o,i+=o;return vs((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i}},tl={description:r("Numerical average value in a dataset."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const o=_s(e,((e,o)=>(t+=1,e+o)),0);return vs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},ol={description:r("Average of values depending on criteria."),args:gs(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,o){null==o&&(o=e);let n=0,i=0;return $s([e,t],((t,r)=>{const s=(o||e)[t][r];"number"==typeof s&&(n+=1,i+=s)})),vs((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/n},isExported:!0},nl={description:r("Average of values depending on multiple criteria."),args:gs(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=0,n=0;return $s(t,((t,i)=>{const r=e[t][i];"number"==typeof r&&(o+=1,n+=r)})),vs((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},il={description:r("The number of numeric values in dataset."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||ro(o)||pe(o))&&(t+=1);return t},isExported:!0},rl={description:r("The number of values in a dataset."),args:gs(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Ms(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},sl={description:r("The covariance of a dataset."),args:gs(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return Za(e,t,!1)},isExported:!0},al={description:r("The covariance of a dataset."),args:gs(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return Za(e,t,!1)},isExported:!0},ll={description:r("The sample covariance of a dataset."),args:gs(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return Za(e,t,!0)},isExported:!0},cl={description:r("Nth largest element from a data set."),args:gs(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const o=Math.trunc(Ss(t));let n,i=[],s=0;Ts([e],(e=>{"number"==typeof e&&(n=Us(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t])),i.splice(n+1,0,e),s++,s>o&&(i.shift(),s--))}));const a=i.shift();return vs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),vs((()=>s>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},hl={description:r("Maximum value in a numeric dataset."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ns(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},dl={description:r("Maximum numeric value in a dataset."),args:gs(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=_s(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},ul={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:gs(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return $s(t,((t,n)=>{const i=e[t][n];"number"==typeof i&&(o=o<i?i:o)})),o===-1/0?0:o},isExported:!0},gl={description:r("Median value in a numeric dataset."),args:gs(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return As(e,(e=>{t.push(e)})),Xa(t,.5,!0)},isExported:!0},pl={description:r("Minimum value in a numeric dataset."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ns(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},fl={description:r("Minimum numeric value in a dataset."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=_s(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},ml={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:gs(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=1/0;return $s(t,((t,n)=>{const i=e[t][n];"number"==typeof i&&(o=o>i?i:o)})),o===1/0?0:o},isExported:!0},vl={description:r("Value at a given percentile of a dataset."),args:gs(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Sl.compute(e,t)},isExported:!0},bl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:gs(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Xa([e],t,!1)},isExported:!0},Sl={description:r("Value at a given percentile of a dataset."),args:gs(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Xa([e],t,!0)},isExported:!0},Cl={description:r("Value nearest to a specific quartile of a dataset."),args:gs(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return wl.compute(e,t)},isExported:!0},El={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:gs(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Xa([e],.25*Math.trunc(Ss(t)),!1)},isExported:!0},wl={description:r("Value nearest to a specific quartile of a dataset."),args:gs(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Xa([e],.25*Math.trunc(Ss(t)),!0)},isExported:!0},yl={description:r("Nth smallest element in a data set."),args:gs(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const o=Math.trunc(Ss(t));let n,i=[],s=0;Ts([e],(e=>{"number"==typeof e&&(n=Us(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t])),i.splice(n+1,0,e),s++,s>o&&(i.pop(),s--))}));const a=i.pop();return vs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),vs((()=>s>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},xl={description:r("Standard deviation."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ml.compute(...e))},isExported:!0},Rl={description:r("Standard deviation of entire population."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Nl.compute(...e))},isExported:!0},Il={description:r("Standard deviation."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(_l.compute(...e))},isExported:!0},Tl={description:r("Standard deviation of sample (text as 0)."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Fl.compute(...e))},isExported:!0},Al={description:r("Standard deviation of entire population."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Dl.compute(...e))},isExported:!0},Ol={description:r("Standard deviation of entire population (text as 0)."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(kl.compute(...e))},isExported:!0},Ml={description:r("Variance."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return ja(e,!0,!1)},isExported:!0},Nl={description:r("Variance of entire population."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return ja(e,!1,!1)},isExported:!0},_l={description:r("Variance."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return ja(e,!0,!1)},isExported:!0},Fl={description:r("Variance of sample (text as 0)."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return ja(e,!0,!0)},isExported:!0},Dl={description:r("Variance of entire population."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return ja(e,!1,!1)},isExported:!0},kl={description:r("Variance of entire population (text as 0)."),args:gs(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return ja(e,!1,!0)},isExported:!0};var $l=Object.freeze({__proto__:null,AVEDEV:Ya,AVERAGE:Ka,AVERAGE_WEIGHTED:el,AVERAGEA:tl,AVERAGEIF:ol,AVERAGEIFS:nl,COUNT:il,COUNTA:rl,COVAR:sl,COVARIANCE_P:al,COVARIANCE_S:ll,LARGE:cl,MAX:hl,MAXA:dl,MAXIFS:ul,MEDIAN:gl,MIN:pl,MINA:fl,MINIFS:ml,PERCENTILE:vl,PERCENTILE_EXC:bl,PERCENTILE_INC:Sl,QUARTILE:Cl,QUARTILE_EXC:El,QUARTILE_INC:wl,SMALL:yl,STDEV:xl,STDEV_P:Rl,STDEV_S:Il,STDEVA:Tl,STDEVP:Al,STDEVPA:Ol,VAR:Ml,VAR_P:Nl,VAR_S:_l,VARA:Fl,VARP:Dl,VARPA:kl});function Ll(e,t,o){var n;const i=new Map,s=e.length;for(let t=s-1;t>=0;t--)i.set(Es(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||s-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),s.toString()))}else{const e=Es(t).toUpperCase();if(a=null!==(n=i.get(e))&&void 0!==n?n:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",Es(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new Error(r("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let n=[],r=!0;for(let s=0;s<o.length;s++){const a=Es(o[s][0]).toUpperCase(),l=i.get(a),c=o[s][t];if(void 0!==c){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}$s(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const Pl=gs(`\n database (range) ${r("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),Ul={description:r("Average of a set of values from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return Ka.compute([n])},isExported:!0},Vl={description:r("Counts values from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return il.compute([n])},isExported:!0},zl={description:r("Counts values and text from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return rl.compute([n])},isExported:!0},Bl={description:r("Single value from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return vs((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},Hl={description:r("Maximum of values from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return hl.compute([n])},isExported:!0},Wl={description:r("Minimum of values from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return pl.compute([n])},isExported:!0},Gl={description:r("Product of values from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return Oa.compute([n])},isExported:!0},ql={description:r("Standard deviation of population sample from table."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return xl.compute([n])},isExported:!0},Zl={description:r("Standard deviation of entire population from table."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return Al.compute([n])},isExported:!0},jl={description:r("Sum of values from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return Va.compute([n])},isExported:!0},Xl={description:r("Variance of population sample from table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return Ml.compute([n])},isExported:!0},Yl={description:r("Variance of a population from a table-like range."),args:Pl,returns:["NUMBER"],compute:function(e,t,o){const n=Ll(e,t,o);return Dl.compute([n])},isExported:!0};var Kl=Object.freeze({__proto__:null,DAVERAGE:Ul,DCOUNT:Vl,DCOUNTA:zl,DGET:Bl,DMAX:Hl,DMIN:Wl,DPRODUCT:Gl,DSTDEV:ql,DSTDEVP:Zl,DSUM:jl,DVAR:Xl,DVARP:Yl});const Ql={description:r("Converts year/month/day into a date."),args:gs(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o){let n=Math.trunc(Ss(e));const i=Math.trunc(Ss(t)),s=Math.trunc(Ss(o));vs((()=>0<=n&&n<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",n.toString())),n<1900&&(n+=1900);const a=ve(new Date(n,i-1,s));return vs((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Jl={description:r("Converts a date string to a date value."),args:gs(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=Es(e),o=pe(t);return vs((()=>null!==o),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},ec={description:r("Day of the month that a specific date falls on."),args:gs(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Rs(e).getDate()},isExported:!0},tc={description:r("Number of days between two dates."),args:gs(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Rs(e),n=Rs(t),i=o.getTime()-n.getTime();return Math.round(i/ae)},isExported:!0},oc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:gs(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,o=0){const n=Ss(e),i=Ss(t),r=xs(o)?4:0,s=wc.compute(e,t,r);return Math.sign(i-n)*Math.round(360*s)},isExported:!0},nc={description:r("Date a number of months before/after another date."),args:gs(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return ve(Ce(Rs(e),Math.trunc(Ss(t)),!1))},isExported:!0},ic={description:r("Last day of a month before or after a date."),args:gs(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const o=Rs(e),n=Math.trunc(Ss(t)),i=o.getFullYear(),r=o.getMonth();return ve(new Date(i,r+n+1,0))},isExported:!0},rc={description:r("Hour component of a specific time."),args:gs(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Rs(e).getHours()},isExported:!0},sc={description:r("ISO week number of the year."),args:gs(`\n date (date) ${r("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n `),returns:["NUMBER"],compute:function(e){const t=Rs(e),o=t.getFullYear();let n=1;for(;4!==new Date(o,0,n).getDay();)n+=1;const i=new Date(o,0,n-3);let r=31;for(;4!==new Date(o,11,r).getDay();)r-=1;const s=new Date(o,11,r+3);let a,l;switch(a=i.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=i;break;case 1:l=new Date(o,11,r+3+1);break;case-1:let e=1;for(;4!==new Date(o-1,0,e).getDay();)e+=1;l=new Date(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/ae;return Math.floor(c/7)+1},isExported:!0},ac={description:r("Minute component of a specific time."),args:gs(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Rs(e).getMinutes()},isExported:!0},lc={description:r("Month of the year a specific date falls in"),args:gs(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Rs(e).getMonth()+1},isExported:!0},cc={description:r("Net working days between two provided days."),args:gs(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,o){return dc.compute(e,t,1,o)},isExported:!0};function hc(e){if("string"==typeof e){vs((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return vs((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const dc={description:r("Net working days between two dates (specifying weekends)."),args:gs(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1,n){const i=Rs(e),r=Rs(t),s=hc(o);let a=new Set;void 0!==n&&Ts([n],(e=>{const t=Rs(e);a.add(t.getTime())}));const l=i.getTime()>r.getTime(),c=new Date((l?i:r).getTime());let h=new Date((l?r:i).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},uc={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-se.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ae)+o},isExported:!0},gc={description:r("Minute component of a specific time."),args:gs(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Rs(e).getSeconds()},isExported:!0},pc={description:r("Converts hour/minute/second into a time."),args:gs(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,o){let n=Math.trunc(Ss(e)),i=Math.trunc(Ss(t)),s=Math.trunc(Ss(o));return i+=Math.floor(s/60),s=s%60+(s<0?60:0),n+=Math.floor(i/60),i=i%60+(i<0?60:0),n%=24,vs((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+i/1440+s/86400},isExported:!0},fc={description:r("Converts a time string into its serial number representation."),args:gs(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=Es(e),o=pe(t);vs((()=>null!==o),r("The time_string (%s) cannot be parsed to date/time.",t));const n=o.value-Math.trunc(o.value);return n<0?1+n:n},isExported:!0},mc={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return ve(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},vc={description:r("Day of the week of the date provided (as number)."),args:gs(`\n date (date) ${r("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const o=Rs(e),n=Math.round(Ss(t)),i=o.getDay();return vs((()=>[1,2,3].includes(n)),r("The type (%s) must be 1, 2 or 3.",n.toString())),1===n?i+1:2===n?0===i?7:i:0===i?6:i-1},isExported:!0},bc={description:r("Week number of the year."),args:gs(`\n date (date) ${r("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const o=Rs(e),n=Math.round(Ss(t));if(vs((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return sc.compute(e);let i;i=1===n||2===n?n-1:n-10==7?0:n-10;const s=o.getFullYear();let a=1,l=new Date(s,0,a);for(;l.getDay()!==i;)a+=1,l=new Date(s,0,a);const c=(o.getTime()-l.getTime())/ae;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Sc={description:r("Date after a number of workdays."),args:gs(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o){return Cc.compute(e,t,1,o)},isExported:!0},Cc={description:r("Date after a number of workdays (specifying weekends)."),args:gs(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o=1,n){let i=Rs(e),s=Math.trunc(Ss(t));"string"==typeof o&&vs((()=>"1111111"!==o),r("The weekend (%s) must be different from '1111111'.",o));const a=hc(o);let l=new Set;void 0!==n&&Ts([n],(e=>{const t=Rs(e);l.add(t.getTime())}));let c=new Date(i.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-se.getTime();return Math.round(g/ae)},isExported:!0},Ec={description:r("Year specified by a given date."),args:gs(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Rs(e).getFullYear()},isExported:!0},wc={description:r("Exact number of years between two dates."),args:gs(`\n start_date (date) ${r("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n end_date (date) ${r("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o=0){let n=Math.trunc(Ss(e)),i=Math.trunc(Ss(t));const s=Math.trunc(Ss(o));return vs((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),vs((()=>i>=0),r("The end_date (%s) must be positive or null.",i.toString())),vs((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),we(n,i,s)}},yc={description:r("First day of the month preceding a date."),args:gs(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Rs(e),o=t.getFullYear(),n=t.getMonth();return ve(new Date(o,n,1))}},xc={description:r("Last day of the month following a date."),args:gs(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return ic.compute(e,0)}},Rc={description:r("Quarter of the year a specific date falls in"),args:gs(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Rs(e).getMonth()+1)/3)}},Ic={description:r("First day of the quarter of the year a specific date falls in."),args:gs(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Rc.compute(e),o=Ec.compute(e);return ve(new Date(o,3*(t-1),1))}},Tc={description:r("Last day of the quarter of the year a specific date falls in."),args:gs(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Rc.compute(e),o=Ec.compute(e);return ve(new Date(o,3*t,0))}},Ac={description:r("First day of the year a specific date falls in."),args:gs(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Ec.compute(e);return ve(new Date(t,0,1))}},Oc={description:r("Last day of the year a specific date falls in."),args:gs(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Ec.compute(e);return ve(new Date(t+1,0,0))}};var Mc=Object.freeze({__proto__:null,DATE:Ql,DATEVALUE:Jl,DAY:ec,DAYS:tc,DAYS360:oc,EDATE:nc,EOMONTH:ic,HOUR:rc,ISOWEEKNUM:sc,MINUTE:ac,MONTH:lc,NETWORKDAYS:cc,NETWORKDAYS_INTL:dc,NOW:uc,SECOND:gc,TIME:pc,TIMEVALUE:fc,TODAY:mc,WEEKDAY:vc,WEEKNUM:bc,WORKDAY:Sc,WORKDAY_INTL:Cc,YEAR:Ec,YEARFRAC:wc,MONTH_START:yc,MONTH_END:xc,QUARTER:Rc,QUARTER_START:Ic,QUARTER_END:Tc,YEAR_START:Ac,YEAR_END:Oc});const Nc={description:r("Compare two numeric values, returning 1 if they're equal."),args:gs(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Ss(e)===Ss(t)?1:0},isExported:!0};var _c=Object.freeze({__proto__:null,DELTA:Nc});function Fc(e,t){vs((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function Dc(e,t){vs((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function kc(e){vs((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function $c(e){vs((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function Lc(e){vs((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function Pc(e){vs((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function Uc(e){vs((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function Vc(e){vs((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function zc(e){vs((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function Bc(e){vs((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function Hc(e){vs((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function Wc(e){vs((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function Gc(e){vs((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function qc(e,t){vs((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function Zc(e){vs((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function jc(e){vs((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function Xc(e){vs((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function Yc(e){vs((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Kc(e,t){const o=Rs(e),n=Rs(t),i=new Date(o);i.setFullYear(o.getFullYear()+1),vs((()=>n.getTime()<=i.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Qc(e,t,o){Uc(o),vs((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),vs((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),vs((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),vs((()=>t<=o),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Jc(e){vs((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function eh(e,t){vs((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function th(e){vs((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const oh=gs(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function nh(e,t,o,n,i=1e-10,s){let a,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(vs((()=>g<n&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<i||Math.abs(c)<i,vs((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const ih={description:r("Accrued interest of security paying at maturity."),args:gs(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Ss(e)),s=Math.trunc(Ss(t)),a=Ss(n),l=Ss(o),c=Math.trunc(Ss(i));Dc(s,r),$c(c),Lc(a),Vc(l);return a*l*wc.compute(r,s,i)},isExported:!0},rh={description:r("Depreciation for an accounting period."),args:gs(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s,a=0){a=a||0;const l=Ss(e),c=Math.trunc(Ss(t)),h=Math.trunc(Ss(o)),d=Ss(n),u=Ss(i),g=Ss(s),p=Math.trunc(Ss(a));!function(e){vs((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),Wc(d),function(e,t){vs((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){vs((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),Vc(g),$c(p),vs((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const f=u<1&&u>0?1:Math.trunc(u),m=l*g,v=wc.compute(c,h,p),b=c===h?m:m*v,S=l-b-m*f;return S>=d?0===f?b:m:d-S<m?m-(d-S):0},isExported:!0},sh={description:r("Days in coupon period containing settlement date."),args:oh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Ss(e)),r=Math.trunc(Ss(t)),s=Math.trunc(Ss(o)),a=Math.trunc(Ss(n));if(Fc(i,r),kc(s),$c(a),1===a){const i=dh.compute(e,t,o,n);return ch.compute(e,t,o,n)-i}return(3===a?365:360)/s},isExported:!0},ah={description:r("Days from settlement until next coupon."),args:oh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Ss(e)),r=Math.trunc(Ss(t)),s=Math.trunc(Ss(o)),a=Math.trunc(Ss(n));Fc(i,r),kc(s),$c(a);const l=dh.compute(i,r,o,n);if([1,2,3].includes(a))return i-l;if(4===a){const e=we(l,i,a);return Math.round(360*e)}const c=Rs(i),h=Rs(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let f=h.getDate(),m=c.getDate();return 2===g&&2===p&&Se(h)&&Se(c)&&(m=30),31!==m||30!==f&&31!==f||(m=30),2===g&&Se(h)&&(f=30),31===f&&(f=30),360*(u-d)+30*(p-g)+(m-f)},isExported:!0},lh={description:r("Days from settlement until next coupon."),args:oh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Ss(e)),r=Math.trunc(Ss(t)),s=Math.trunc(Ss(o)),a=Math.trunc(Ss(n));Fc(i,r),kc(s),$c(a);const l=ch.compute(i,r,o,n);if([1,2,3].includes(a))return l-i;if(4===a){const e=we(i,l,a);return Math.round(360*e)}const c=ah.compute(e,t,o,a);return sh.compute(e,t,o,a)-c},isExported:!0},ch={description:r("Next coupon date after the settlement date."),args:oh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Ss(e)),r=Math.trunc(Ss(t)),s=Math.trunc(Ss(o)),a=Math.trunc(Ss(n));Fc(i,r),kc(s),$c(a);const l=12/s,c=hh.compute(e,t,o,n);return ve(Ce(Rs(r),-(c-1)*l,!0))},isExported:!0},hh={description:r("Number of coupons between settlement and maturity."),args:oh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Ss(e)),r=Math.trunc(Ss(t)),s=Math.trunc(Ss(o)),a=Math.trunc(Ss(n));Fc(i,r),kc(s),$c(a);let l=1,c=r;const h=12/s;for(;c>i;)c=ve(Ce(Rs(c),-h,!1)),l++;return l-1},isExported:!0},dh={description:r("Last coupon date prior to or on the settlement date."),args:oh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Ss(e)),r=Math.trunc(Ss(t)),s=Math.trunc(Ss(o)),a=Math.trunc(Ss(n));Fc(i,r),kc(s),$c(a);const l=12/s,c=hh.compute(e,t,o,n);return ve(Ce(Rs(r),-c*l,!0))},isExported:!0},uh={description:r("Cumulative interest paid over a set of periods."),args:gs(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,r=0){const s=Ss(n),a=Ss(i),l=Ss(e),c=Ss(o),h=Ss(t);Qc(s,a,h),Vc(l),Gc(c);let d=0;for(let t=s;t<=a;t++){d+=xh.compute(e,t,h,o,0,r)}return d},isExported:!0},gh={description:r("Cumulative principal paid over a set of periods."),args:gs(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,r=0){const s=Ss(n),a=Ss(i),l=Ss(e),c=Ss(o),h=Ss(t);Qc(s,a,h),Vc(l),Gc(c);let d=0;for(let t=s;t<=a;t++){d+=Dh.compute(e,t,h,o,0,r)}return d},isExported:!0},ph={description:r("Depreciation via declining balance method."),args:gs(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,...i){const s=Ss(e),a=Ss(t),l=Ss(o),c=Math.trunc(Ss(n)),h=i.length?Math.trunc(Ss(i[0])):12,d=l+(12===h?0:1);Bc(s),Wc(a),Hc(c),zc(l),vs((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),vs((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,f=s*(1-g*u);for(let e=1;e<c;e++)p=f,f=p*(1-g),e===l&&(f=p*(1-g*(1-u)));return p-f},isExported:!0},fh={description:r("Depreciation via double-declining balance method."),args:gs(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,i=2){i=i||0;const r=Ss(e),s=Ss(t),a=Ss(o),l=Ss(n),c=Ss(i);if(Bc(r),Wc(s),Hc(l),zc(a),qc(l,a),Yc(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===n?r-s:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<s?d-s:d-u;return Math.max(g,0)},isExported:!0},mh={description:r("Discount rate of a security based on price."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Ss(e)),s=Math.trunc(Ss(t)),a=Ss(o),l=Ss(n),c=Math.trunc(Ss(i));Fc(r,s),$c(c),Pc(a),Lc(l);return(l-a)/l/wc.compute(r,s,c)},isExported:!0},vh={description:r("Convert a decimal fraction to decimal value."),args:gs(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Ss(e),n=Math.trunc(Ss(t));vs((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const i=Math.trunc(o);return i+(o-i)*(10**Math.ceil(Math.log10(n))/n)},isExported:!0},bh={description:r("Convert a decimal value to decimal fraction."),args:gs(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Ss(e),n=Math.trunc(Ss(t));vs((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const i=Math.trunc(o);return i+(o-i)*(n/10**Math.ceil(Math.log10(n)))},isExported:!0},Sh={description:r("Number of periods for an investment to reach a value."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=0){s=s||0;const a=Math.trunc(Ss(e)),l=Math.trunc(Ss(t)),c=Ss(o),h=Ss(n),d=Math.trunc(Ss(i)),u=Math.trunc(Ss(s));Fc(a,l),kc(d),$c(u),vs((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),vs((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=wc.compute(a,l,u),p=g-Math.trunc(g)||1/d,f=Math.ceil(g*d),m=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=f;e++){const t=(m+(e===f?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Ch={description:r("Annual effective interest rate."),args:gs(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Ss(e),n=Math.trunc(Ss(t));return vs((()=>o>0),r("The nominal rate (%s) must be strictly greater than 0.",o.toString())),vs((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),Math.pow(1+o/n,n)-1},isExported:!0},Eh={description:r("Future value of an annuity investment."),args:gs(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Ss(e),s=Ss(t),a=Ss(o),l=Ss(n),c=xs(i)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},wh={description:r("Future value of principal from series of rates."),args:gs(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Ms([t],((e,t)=>e*(1+Ss(t))),Ss(e))},isExported:!0},yh={description:r("Calculates effective interest rate."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){const r=Math.trunc(Ss(e)),s=Math.trunc(Ss(t)),a=Ss(n),l=Ss(o);Fc(r,s),Zc(l),Lc(a);return(a-l)/l/wc.compute(r,s,i)},isExported:!0},xh={description:r("Payment on the principal of an investment."),args:gs(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,i=0,r=0){return Fh.compute(e,o,n,i,r)-Dh.compute(e,t,o,n,i,r)},isExported:!0},Rh={description:r("Internal rate of return given periodic cashflows."),args:gs(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const o=Ss(t);Jc(o);let n=!1,i=!1,s=[];As([e],(e=>{e>0&&(n=!0),e<0&&(i=!0),s.push(e)})),vs((()=>n&&i),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return nh((function(e){return function(e,t,o){const n=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*e**(n-i))),t*e**n)}(e,a,s)}),(function(e){return function(e,t,o){const n=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*(n-i)*e**(n-i-1))),t*n*e**(n-1))}(e,a,s)}),o+1,20,1e-5)-1},isExported:!0},Ih={description:r("Returns the interest paid at a particular period of an investment."),args:gs(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n){const i=Ss(e),s=Ss(t),a=Ss(o),l=Ss(n);vs((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*i},isExported:!0},Th={description:r("Modified Macaulay duration."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,r=0){return Sh.compute(e,t,o,n,i,r)/(1+Ss(n)/Math.trunc(Ss(i)))},isExported:!0},Ah={description:r("Modified internal rate of return."),args:gs(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Ss(t),i=Ss(o),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Ze).map(Ss);var a;const l=s.length;let c=0,h=0;for(const e of Fe(0,l)){const t=s[e];t>=0?c+=t*(i+1)**(l-e-1):h+=t/(n+1)**e}vs((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Oh={description:r("Annual nominal interest rate."),args:gs(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Ss(e),n=Math.trunc(Ss(t));return vs((()=>o>0),r("The effective rate (%s) must must strictly greater than 0.",o.toString())),vs((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),(Math.pow(o+1,1/n)-1)*n},isExported:!0},Mh={description:r("Number of payment periods for an investment."),args:gs(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Ss(e),s=Ss(t),a=Ss(o),l=Ss(n),c=xs(i)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const Nh={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:gs(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=Ss(e);return vs((()=>-1!==o),r("The discount (%s) must be different from -1.",o.toString())),function(e,t,o){let n=0;return Ns(o,((t,o)=>(n++,t+o/(1+e)**n)),t)}(o,0,t)},isExported:!0},_h={description:r("Computes the number of periods needed for an investment to reach a value."),args:gs(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Ss(e),i=Ss(t),s=Ss(o);return Vc(n),vs((()=>i>0),r("The present_value (%s) must be strictly positive.",i.toString())),vs((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(i))/Math.log(1+n)},isExported:!0},Fh={description:r("Periodic payment for an annuity investment."),args:gs(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Ss(t),s=Ss(e),a=xs(i)?1:0;let l=Ss(n),c=Ss(o);if(Uc(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},Dh={description:r("Payment on the principal of an investment."),args:gs(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,i=0,s=0){i=i||0,s=s||0;const a=Ss(o),l=Ss(e),c=Ss(t),h=xs(s)?1:0,d=Ss(i),u=Ss(n);Uc(a),vs((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=Fh.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-Eh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},kh={description:r("Present value of an annuity investment."),args:gs(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Ss(e),s=Ss(t),a=Ss(o),l=Ss(n),c=xs(i)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},$h={description:r("Price of a security paying periodic interest."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s,a=0){a=a||0;const l=Math.trunc(Ss(e)),c=Math.trunc(Ss(t)),h=Ss(o),d=Ss(n),u=Ss(i),g=Math.trunc(Ss(s)),p=Math.trunc(Ss(a));Fc(l,c),kc(g),$c(p),vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),vs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),Lc(u);const f=wc.compute(l,c,p)*g,m=Math.ceil(f),v=f-Math.floor(f)||1,b=1+d/g,S=100*h/g;if(1===m)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=m;e++)C+=S/b**(e-1+v);return u/b**(m-1+v)+C-S*(1-v)},isExported:!0},Lh={description:r("Price of a discount security."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Ss(e)),s=Math.trunc(Ss(t)),a=Ss(o),l=Ss(n),c=Math.trunc(Ss(i));Fc(r,s),$c(c),jc(a),Lc(l);return l-a*l*wc.compute(r,s,c)},isExported:!0},Ph={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=0){s=s||0;const a=Math.trunc(Ss(e)),l=Math.trunc(Ss(t)),c=Math.trunc(Ss(o)),h=Ss(n),d=Ss(i),u=Math.trunc(Ss(s));Dc(a,c),Fc(a,l),$c(u),vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),vs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=wc.compute(a,l,u),p=wc.compute(a,c,u);return(100+wc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},Uh=.1,Vh={description:r("Interest rate of an annuity investment."),args:gs(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,n=0,i=0,s=.1){n=n||0,i=i||0,s=s||Uh;const a=Ss(e),l=Ss(t),c=xs(i)?1:0,h=Ss(s);let d=Ss(n),u=Ss(o);Uc(a),vs((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Jc(h),d-=l*c,u+=l*c;return nh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),o=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},zh={description:r("Amount received at maturity for a security."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Ss(e)),s=Math.trunc(Ss(t)),a=Ss(o),l=Ss(n),c=Math.trunc(Ss(i));Fc(r,s),$c(c),Zc(a),jc(l);return a/(1-l*wc.compute(r,s,c))},isExported:!0},Bh={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:gs(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Ss(e),i=Ss(t),r=Ss(o);return Uc(n),(r/i)**(1/n)-1},isExported:!0},Hh={description:r("Depreciation of an asset using the straight-line method."),args:gs(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(Ss(e)-Ss(t))/Ss(o)},isExported:!0},Wh={description:r("Depreciation via sum of years digit method."),args:gs(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n){const i=Ss(e),r=Ss(t),s=Ss(o),a=Ss(n);Hc(a),zc(s),qc(a,s);return(s-a+1)/(s*(s+1)/2)*(i-r)},isExported:!0},Gh={description:r("Price of a US Treasury bill."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Math.trunc(Ss(e)),i=Math.trunc(Ss(t)),r=Ss(o);Fc(n,i),Kc(n,i),jc(r),Xc(r);return 100*(1-r*wc.compute(n,i,2))},isExported:!0},qh={description:r("Equivalent rate of return for a US Treasury bill."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Math.trunc(Ss(e)),i=Math.trunc(Ss(t)),r=Ss(o);Fc(n,i),Kc(n,i),jc(r),Xc(r);const s=tc.compute(i,n);if(s<=182)return 365*r/(360-r*s);const a=Gh.compute(n,i,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},Zh={description:r("The yield of a US Treasury bill based on price."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Math.trunc(Ss(e)),i=Math.trunc(Ss(t)),r=Ss(o);Fc(n,i),Kc(n,i),Pc(r);return(100-r)/r*(1/wc.compute(n,i,2))},isExported:!0},jh={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:gs(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=2,a=false){s=s||0;const l=Ss(e),c=Ss(t),h=Ss(o),d=Math.trunc(Ss(n)),u=Math.trunc(Ss(i)),g=Ss(s),p=xs(a);if(Bc(l),Wc(c),function(e,t,o){zc(o),vs((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),vs((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),vs((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),vs((()=>t<=o),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),Yc(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const f=g/h;if(f>=1)return d<1?l-c:0;let m=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=m*f,o=(m-c)/(h-e);!p&&o>t?(S=!0,v=o):v=t}const t=Math.max(m-v,c);e>=d&&(b+=m-t),m=t}return b},isExported:!0},Xh={description:r("Internal rate of return given non-periodic cash flows."),args:gs(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,o=.1){const n=Ss(o=o||0),i=e.flat().map(Ss),s=t.flat().map(Ss);var a;eh(e,t),a=i,vs((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),th(s),Jc(n);const l=new Map;for(const e of Fe(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+i[e]):l.set(t,i[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return nh((e=>{let t=h[0];for(const o of Fe(1,h.length)){const n=(c[0]-c[o])/365;t+=h[o]*(1+e)**n}return t}),(e=>{let t=0;for(const o of Fe(1,h.length)){const n=(c[0]-c[o])/365;t+=n*h[o]*(1+e)**(n-1)}return t}),n,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Yh={description:r("Net present value given to non-periodic cash flows.."),args:gs(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Ss(e),i=Array.isArray(t)?t.flat().map(Cs):[Cs(t)],s=Array.isArray(o)?o.flat().map(Cs):[Cs(o)];if(Array.isArray(o)&&Array.isArray(t)?eh(t,o):vs((()=>i.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),th(s),Vc(n),1===i.length)return i[0];const a=new Map;for(const e of Fe(0,s.length)){const t=s[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)));let h=c[0];for(const e of Fe(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+n)**t}return h},isExported:!0},Kh={description:r("Annual yield of a security paying periodic interest."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s,a=0){a=a||0;const l=Math.trunc(Ss(e)),c=Math.trunc(Ss(t)),h=Ss(o),d=Ss(n),u=Ss(i),g=Math.trunc(Ss(s)),p=Math.trunc(Ss(a));Fc(l,c),kc(g),$c(p),vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Pc(d),Lc(u);const f=wc.compute(l,c,p)*g,m=Math.ceil(f),v=f-Math.floor(f)||1,b=100*h/g;if(1===m){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=nh((function(e){return function(e,t,o,n,i,r){let s=r-(e+i*(1-t))*n**(o-1+t);for(let e=1;e<=o;e++)s+=i*n**(e-1);return s}(d,v,m,e,b,u)}),(function(e){return function(e,t,o,n,i){let r=-(e+i*(1-t))*(o-1+t)*n**(o-2+t);for(let e=1;e<=o;e++)r+=i*(e-1)*n**(e-2);return r}(d,v,m,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Qh={description:r("Annual yield of a discount security."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Ss(e)),s=Math.trunc(Ss(t)),a=Ss(o),l=Ss(n),c=Math.trunc(Ss(i));Fc(r,s),$c(c),Pc(a),Lc(l);return(l/a-1)/wc.compute(e,t,i)},isExported:!0},Jh={description:r("Annual yield of a security paying interest at maturity."),args:gs(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=0){s=s||0;const a=Math.trunc(Ss(e)),l=Math.trunc(Ss(t)),c=Math.trunc(Ss(o)),h=Ss(n),d=Ss(i),u=Math.trunc(Ss(s));Fc(a,l),$c(u),vs((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),vs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Pc(d);const g=wc.compute(c,l,u),p=wc.compute(c,a,u),f=wc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/f},isExported:!0};var ed=Object.freeze({__proto__:null,ACCRINTM:ih,AMORLINC:rh,COUPDAYS:sh,COUPDAYBS:ah,COUPDAYSNC:lh,COUPNCD:ch,COUPNUM:hh,COUPPCD:dh,CUMIPMT:uh,CUMPRINC:gh,DB:ph,DDB:fh,DISC:mh,DOLLARDE:vh,DOLLARFR:bh,DURATION:Sh,EFFECT:Ch,FV:Eh,FVSCHEDULE:wh,INTRATE:yh,IPMT:xh,IRR:Rh,ISPMT:Ih,MDURATION:Th,MIRR:Ah,NOMINAL:Oh,NPER:Mh,NPV:Nh,PDURATION:_h,PMT:Fh,PPMT:Dh,PV:kh,PRICE:$h,PRICEDISC:Lh,PRICEMAT:Ph,RATE:Vh,RECEIVED:zh,RRI:Bh,SLN:Hh,SYD:Wh,TBILLPRICE:Gh,TBILLEQ:qh,TBILLYIELD:Zh,VDB:jh,XIRR:Xh,XNPV:Yh,YIELD:Kh,YIELDDISC:Qh,YIELDMAT:Jh});const td={description:r("Whether a value is an error other than #N/A."),args:gs(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},od={description:r("Whether a value is an error."),args:gs(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},nd={description:r("Whether a value is `true` or `false`."),args:gs(`value (any, lazy) ${r("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},id={description:r("Whether a value is the error #N/A."),args:gs(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},rd={description:r("Whether a value is non-textual."),args:gs(`value (any, lazy) ${r("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},sd={description:r("Whether a value is a number."),args:gs(`value (any, lazy) ${r("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},ad={description:r("Whether a value is text."),args:gs(`value (any, lazy) ${r("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},ld={description:r("Whether the referenced cell is empty"),args:gs(`value (any, lazy) ${r("Reference to the cell that will be checked for emptiness.")}`),returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},cd={description:r("Returns the error value #N/A."),args:gs(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var hd=Object.freeze({__proto__:null,ISERR:td,ISERROR:od,ISLOGICAL:nd,ISNA:id,ISNONTEXT:rd,ISNUMBER:sd,ISTEXT:ad,ISBLANK:ld,NA:cd});const dd={description:r("Logical `and` operator."),args:gs(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return Fs(e,(e=>(t=!0,o=o&&e,o))),vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},ud={description:r("Returns value depending on logical expression."),args:gs(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,o=(()=>!1)){const n=xs(e)?t():o();return null==n?"":n},isExported:!0},gd={description:r("Value if it is not an error, otherwise 2nd argument."),args:gs(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var o;try{return e().format}catch(e){return null===(o=t())||void 0===o?void 0:o.format}},compute:function(e,t=(()=>"")){let o;try{o=e()}catch(e){o=t()}return null==o?"":o},isExported:!0},pd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:gs(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let o;try{o=e()}catch(n){o=n.errorType===a.NotAvailable?t():e()}return null==o?"":o},isExported:!0},fd={description:r("Returns a value depending on multiple logical expressions."),args:gs(`\n condition1 (boolean, lazy) ${r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){vs((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(xs(e[t]())){const o=e[t+1]();return null!==o?o:""}throw new Error(r("No match."))},isExported:!0},md={description:r("Returns opposite of provided logical value."),args:gs(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!xs(e)},isExported:!0},vd={description:r("Logical `or` operator."),args:gs(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Fs(e,(e=>(t=!0,o=o||e,!o))),vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},bd={description:r("Logical `xor` operator."),args:gs(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Fs(e,(e=>(t=!0,o=o?!e:e,!0))),vs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Sd=Object.freeze({__proto__:null,AND:dd,IF:ud,IFERROR:gd,IFNA:pd,IFS:fd,NOT:md,OR:vd,XOR:bd});const Cd={description:r("Column number of a specified cell."),args:gs(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const o=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));vs((()=>!!o),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return mo(o).left+1},isExported:!0},Ed={description:r("Number of columns in a specified array or range."),args:gs(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=mo(e);return t.right-t.left+1},isExported:!0},wd={description:r("Horizontal lookup"),args:gs(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,o,n=true){const i=Math.trunc(Ss(o)),s=ws(e);vs((()=>1<=i&&i<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=xs(n);let l;return l=a?Us(t,s,"nextSmaller","asc",t.length,Ps):Vs(t,s,"strict",t.length,Ps),vs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Es(e))),t[l][i-1]},isExported:!0},yd={description:r("Look up a value."),args:gs(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${r("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")}\n result_range (range, optional) ${r("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")}\n `),returns:["ANY"],compute:function(e,t,o){let n=t.length,i=t[0].length;const s=ws(e),a=i>=n,l=Us(t,s,"nextSmaller","asc",a?i:n,a?Ls:Ps);return vs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Es(e))),void 0===o?a?t[n-1][l]:t[l][i-1]:(n=o.length,i=o[0].length,vs((()=>1===n||1===i),r("The result_range must be a single row or a single column.")),n>1?(vs((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),o[l][0]):(vs((()=>l<=i-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),o[0][l]))},isExported:!0},xd={description:r("Position of item in range that matches value."),args:gs(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${r("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1){let n=Ss(o);const i=ws(e),s=t.length,a=t[0].length;vs((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?Ls:Ps,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=Us(t,i,"nextSmaller","asc",h,c);break;case 0:l=Vs(t,i,"strict",h,c);break;case-1:l=Us(t,i,"nextGreater","desc",h,c)}return vs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Es(e))),l+1},isExported:!0},Rd={description:r("Row number of a specified cell."),args:gs(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),vs((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return mo(e).top+1},isExported:!0},Id={description:r("Number of rows in a specified array or range."),args:gs(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=mo(e);return t.bottom-t.top+1},isExported:!0},Td={description:r("Vertical lookup."),args:gs(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,o,n=true){const i=Math.trunc(Ss(o)),s=ws(e);vs((()=>1<=i&&i<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=xs(n);let l;return l=a?Us(t,s,"nextSmaller","asc",t[0].length,Ls):Vs(t,s,"strict",t[0].length,Ls),vs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Es(e))),t[i-1][l]},isExported:!0},Ad={description:r("Search a range for a match and return the corresponding item from a second range."),args:gs(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n match_mode (any, default=0) ${r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")}\n search_mode (any, default=1) ${r("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. ")}\n\n `),returns:["ANY"],compute:function(e,t,o,n,i=0,s=1){const a=Math.trunc(Ss(i)),l=Math.trunc(Ss(s)),c=ws(e);vs((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),vs((()=>1===o.length||1===o[0].length),r("return_range should be either a single row or single column.")),vs((()=>o.length===t.length&&o[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),vs((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),vs((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?Ls:Ps,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=Us(t,c,u,2===l?"asc":"desc",d,h)}else p=Vs(t,c,u,d,h,g);if(-1!==p)return 1===t.length?o[0][p]:o[p][0];const f=null==n?void 0:n();return vs((()=>!!f),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Es(e))),f},isExported:!0};var Od=Object.freeze({__proto__:null,COLUMN:Cd,COLUMNS:Ed,HLOOKUP:wd,LOOKUP:yd,MATCH:xd,ROW:Rd,ROWS:Id,VLOOKUP:Td,XLOOKUP:Ad});const Md={description:r("Sum of two numbers."),args:gs(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ss(e)+Ss(t)}},Nd={description:r("Concatenation of two values."),args:gs(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return Es(e)+Es(t)},isExported:!0},_d={description:r("One number divided by another."),args:gs(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const o=Ss(t);return vs((()=>0!==o),r("The divisor must be different from zero.")),Ss(e)/o}};function Fd(e){return null==e}const Dd={number:0,string:"",boolean:!1},kd={description:r("Equal."),args:gs(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=Fd(e)?Dd[typeof t]:e,t=Fd(t)?Dd[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function $d(e,t,o){e=Fd(e)?Dd[typeof t]:e,t=Fd(t)?Dd[typeof e]:t,"number"!=typeof e&&(e=Es(e).toUpperCase()),"number"!=typeof t&&(t=Es(t).toUpperCase());const n=typeof e,i=typeof t;return"string"===n&&"number"===i||("string"!==i||"number"!==n)&&o(e,t)}const Ld={description:r("Strictly greater than."),args:gs(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return $d(e,t,((e,t)=>e>t))}},Pd={description:r("Greater than or equal to."),args:gs(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return $d(e,t,((e,t)=>e>=t))}},Ud={description:r("Less than."),args:gs(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Pd.compute(e,t)}},Vd={description:r("Less than or equal to."),args:gs(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Ld.compute(e,t)}},zd={description:r("Difference of two numbers."),args:gs(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ss(e)-Ss(t)}},Bd={description:r("Product of two numbers"),args:gs(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Ss(e)*Ss(t)}},Hd={description:r("Not equal."),args:gs(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!kd.compute(e,t)}},Wd={description:r("A number raised to a power."),args:gs(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Aa.compute(e,t)}},Gd={description:r("A number with the sign reversed."),args:gs(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Ss(e)}},qd={description:r("Value interpreted as a percentage."),args:gs(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Ss(e)/100}},Zd={description:r("A specified number, unchanged."),args:gs(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var jd=Object.freeze({__proto__:null,ADD:Md,CONCAT:Nd,DIVIDE:_d,EQ:kd,GT:Ld,GTE:Pd,LT:Ud,LTE:Vd,MINUS:zd,MULTIPLY:Bd,NE:Hd,POW:Wd,UMINUS:Gd,UNARY_PERCENT:qd,UPLUS:Zd});const Xd=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Yd={description:r("Gets character associated with number."),args:gs(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Ss(e));return vs((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Kd={description:r("Remove non-printable characters from a piece of text."),args:gs(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=Es(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Qd={description:r("Appends strings to one another."),args:gs(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Ms(e,((e,t)=>e+Es(t)),"")},isExported:!0},Jd={description:r("Tests whether two strings are identical."),args:gs(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Es(e)===Es(t)},isExported:!0},eu={description:r("First position of string found in text, case-sensitive."),args:gs(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1){const n=Es(e),i=Es(t),s=Ss(o);vs((()=>""!==i),r("The text_to_search must be non-empty.")),vs((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=i.indexOf(n,s-1);return vs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),i)),a+1},isExported:!0},tu={description:r("Concatenates elements of arrays with delimiter."),args:gs(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const o=Es(e);return Ms(t,((e,t)=>(e?e+o:"")+Es(t)),"")}},ou={description:r("Substring from beginning of specified string."),args:gs(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const o=t.length?Ss(t[0]):1;return vs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString())),Es(e).substring(0,o)},isExported:!0},nu={description:r("Length of a string."),args:gs(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return Es(e).length},isExported:!0},iu={description:r("Converts a specified string to lowercase."),args:gs(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return Es(e).toLowerCase()},isExported:!0},ru={description:r("A segment of a string."),args:gs(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,o){const n=Es(e),i=Ss(t),s=Ss(o);return vs((()=>i>=1),r("The starting_at argument (%s) must be positive greater than one.",i.toString())),vs((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(i-1,i+s-1)},isExported:!0},su={description:r("Capitalizes each word in a specified string."),args:gs(`\n text_to_capitalize (string) ${r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")}\n `),returns:["STRING"],compute:function(e){return Es(e).replace(Xd,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},au={description:r("Replaces part of a text string with different text."),args:gs(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,o,n){const i=Ss(t);vs((()=>i>=1),r("The position (%s) must be greater than or equal to 1.",i.toString()));const s=Es(e),a=Ss(o),l=Es(n);return s.substring(0,i-1)+l+s.substring(i-1+a)},isExported:!0},lu={description:r("A substring from the end of a specified string."),args:gs(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const o=t.length?Ss(t[0]):1;vs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString()));const n=Es(e),i=n.length;return n.substring(i-o,i)},isExported:!0},cu={description:r("First position of string found in text, ignoring case."),args:gs(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1){const n=Es(e).toLowerCase(),i=Es(t).toLowerCase(),s=Ss(o);vs((()=>""!==i),r("The text_to_search must be non-empty.")),vs((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=i.indexOf(n,s-1);return vs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,i)),a+1},isExported:!0},hu={description:r("Replaces existing text with new text in a string."),args:gs(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n occurrence_number (number, optional) ${r("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n){const i=Ss(n);vs((()=>i>=0),r("The occurrenceNumber (%s) must be positive or null.",i.toString()));const s=Es(e),a=Es(t);if(""===a)return s;const l=Es(o),c=new RegExp(Re(a),"g");if(0===i)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===i?l:e))},isExported:!0},du={description:r("Combines text from multiple strings and/or arrays."),args:gs(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...o){const n=Es(e),i=xs(t);let r=0;return Ms(o,((e,t)=>i&&""===Es(t)?e:(r++?e+n:"")+Es(t)),"")},isExported:!0},uu={description:r("Removes space characters."),args:gs(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return Es(e).trim()},isExported:!0},gu={description:r("Converts a specified string to uppercase."),args:gs(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return Es(e).toUpperCase()},isExported:!0},pu={description:r("Converts a number to text according to a specified format."),args:gs(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return Ut(Ss(e),Es(t))},isExported:!0};const fu={database:Kl,date:Mc,financial:ed,info:hd,lookup:Od,logical:Sd,math:qa,misc:Hs,operators:jd,statistical:$l,text:Object.freeze({__proto__:null,CHAR:Yd,CLEAN:Kd,CONCATENATE:Qd,EXACT:Jd,FIND:eu,JOIN:tu,LEFT:ou,LEN:nu,LOWER:iu,MID:ru,PROPER:su,REPLACE:au,RIGHT:lu,SEARCH:cu,SUBSTITUTE:hu,TEXTJOIN:du,TRIM:uu,UPPER:gu,TEXT:pu}),engineering:_c},mu=/^[A-Z0-9\_\.]+$/;function vu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>bu(e()):bu(e)}))}function bu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Su=new class extends zo{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(mu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=fs(t);return function(e){let t=!1,o=!1,n=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(r("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!i.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||n,s=!(i.optional||i.repeating||i.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,n=i.default}}(o.args),this.mapping[e]=function(...e){const t=o.compute.bind(this),n=o.computeFormat?o.computeFormat.bind(this):()=>{};return{value:t(...vu(e)),format:n(...e)}},super.add(e,o),this}};for(let e in fu){const t=fu[e];for(let o in t){const n=t[o];n.category=e,o=o.replace(/_/g,"."),Su.add(o,{isExported:!1,...n})}}const Cu=Su.content,Eu=["%"],wu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Eu);function yu(e){const t=e.split(""),o=[];for(;t.length;){let e=Du(t)||Iu(t)||Au(t)||Mu(t)||xu(t)||ku(t)||Ou(t)||_u(t);e||(e={type:"UNKNOWN",value:t.shift()}),o.push(e)}return o}function xu(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Ru={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Iu(e){if(e[0]in Ru){const t=e.shift();return{type:Ru[t],value:t}}return null}function Tu(e,t){for(let o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function Au(e){for(let t of wu)if(Tu(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Ou(e){const t=Ye(e).match(Jt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Mu(e){if('"'===e[0]){const t=e.shift();let o=t;for(;e[0]&&(e[0]!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e[0]&&(o+=e.shift()),{type:"STRING",value:o}}return null}const Nu=/\w|\.|!|\$/;function _u(e){let t="";if("'"===e[0]){let o=e.shift();for(t+=o;e[0];)if(o=e.shift(),t+=o,"'"===o){if(!e[0]||"'"!==e[0])break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Nu);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Cu)return{type:"FUNCTION",value:e};return e.match(Ct)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const Fu=/\s/;function Du(e){let t=0;for(;e[0]&&e[0].match(Fu);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function ku(e){return Tu(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}const $u=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Lu=["-","+"],Pu=["%"],Uu=["*","+","&"],Vu={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},zu=6;function Bu(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return Vu[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function Hu(e,t,o){if("OPERATOR"===t.type){const n=Bu(t);if(Pu.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const i=Wu(o,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:i}}}throw new Error(oe)}function Wu(e,t){const o=e.shift();if(!o)throw new Error(oe);let n=function(e,t){var o,n,i,s;switch(e.type){case"DEBUGGER":const a=Wu(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:ao(e.value)};case"STRING":return{type:"STRING",value:xe(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const n=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?n.push({type:"UNKNOWN",value:""}):n.push(Wu(t,zu));"COMMA"===(null===(o=t[0])||void 0===o?void 0:o.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){n.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?n.push({type:"UNKNOWN",value:""}):n.push(Wu(t,zu))}const i=t.shift();if(!i||"RIGHT_PAREN"!==i.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:n}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(n=t[0])||void 0===n?void 0:n.value)&&"REFERENCE"===(null===(i=t[1])||void 0===i?void 0:i.type)){t.shift();const o=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==o?void 0:o.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if($u.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=Wu(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&Lu.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:Wu(t,Vu[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(o,e);for(;e[0]&&Bu(e[0])>t;)n=Hu(n,e.shift(),e);return n}function Gu(e){return qu(yu(e))}function qu(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=Wu(e,0);if(e.length)throw new Error(oe);return t}function Zu(e,t,o){switch(t===e.type&&(e=o(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Zu(e,t,o)))};case"UNARY_OPERATION":return{...e,operand:Zu(e.operand,t,o)};case"BIN_OPERATION":return{...e,right:Zu(e.right,t,o),left:Zu(e.left,t,o)};default:return e}}function ju(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>ju(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?Xu(e)+e.value:e.value+Yu(e);case"BIN_OPERATION":return Xu(e)+e.value+Yu(e)}}function Xu(e){const t=e.value,o="left"in e?e.left:e.operand,n=o.value;return"BIN_OPERATION"===o.type&&Vu[n]<Vu[t]?`(${ju(o)})`:ju(o)}function Yu(e){const t=e.value,o="right"in e?e.right:e.operand,n=Vu[o.value],i=Vu[t];let r=!1;return"BIN_OPERATION"!==o.type?r=!1:n<i?r=!0:n!==i||Uu.includes(t)||(r=!0),r?`(${ju(o)})`:ju(o)}var Ku;!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"}(Ku||(Ku={}));const Qu=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Ju=(e,t=(()=>!0))=>({goTo:e,guard:t}),eg={[Ku.LeftRef]:{REFERENCE:Qu(Ku.Separator),NUMBER:Qu(Ku.FullRowSeparator),SYMBOL:[Ju(Ku.FullColumnSeparator,(e=>Et(e.value))),Ju(Ku.FullRowSeparator,(e=>wt(e.value)))]},[Ku.FullColumnSeparator]:{SPACE:Qu(Ku.FullColumnSeparator),OPERATOR:Qu(Ku.RightColumnRef,(e=>":"===e.value))},[Ku.FullRowSeparator]:{SPACE:Qu(Ku.FullRowSeparator),OPERATOR:Qu(Ku.RightRowRef,(e=>":"===e.value))},[Ku.Separator]:{SPACE:Qu(Ku.Separator),OPERATOR:Qu(Ku.RightRef,(e=>":"===e.value))},[Ku.RightRef]:{SPACE:Qu(Ku.RightRef),NUMBER:Qu(Ku.Found),REFERENCE:Qu(Ku.Found,(e=>xt(e.value))),SYMBOL:Qu(Ku.Found,(e=>yt(e.value)))},[Ku.RightColumnRef]:{SPACE:Qu(Ku.RightColumnRef),SYMBOL:Qu(Ku.Found,(e=>yt(e.value))),REFERENCE:Qu(Ku.Found,(e=>xt(e.value)))},[Ku.RightRowRef]:{SPACE:Qu(Ku.RightRowRef),NUMBER:Qu(Ku.Found),REFERENCE:Qu(Ku.Found,(e=>xt(e.value)))},[Ku.Found]:{}};function tg(e){var t;let o=0,n=eg[Ku.LeftRef];const i=[];for(;void 0!==n;){const r=e[o++];if(!r)return null;const s=null===(t=n[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case Ku.Found:return i.push(r),e.splice(0,o),{type:"REFERENCE",value:Ye(i.map((e=>e.value)))};default:n=eg[a],i.push(r)}}return null}function og(e){const t=yu(e),o=[];for(;t.length;)o.push(tg(t)||t.shift());return o}const ng=Su.content,ig={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},rg={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function sg(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const ag={};function lg(e){const t=og(e),{dependencies:o,constantValues:n}=function(e){const t={numbers:[],strings:[]},o=[];for(const n of e)switch(n.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(n.value);break;case"STRING":const e=xe(n.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=ao(n.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:o,constantValues:t}}(t),i=function(e,t,o){return Ye(e.map((e=>{switch(e.type){case"STRING":const n=xe(e.value);return`|S${o.strings.indexOf(n)}|`;case"NUMBER":return`|N${o.numbers.indexOf(ao(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,o,n);if(!ag[i]){const s=qu([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=sg([`// ${i}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=ng[e.value.toUpperCase()],o=e.args,n=o.length;if(n<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),n.toString()));if(n>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),n.toString()));const i=t.nbrArgRepeating;if(i>1){const o=t.args.length-i;if((n-o)%i!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),o.toString(),i.toString()))}let s=[];for(let i=0;i<n;i++){const n=t.getArgToFocus(i+1)-1;if(0<=n&&n<t.args.length){const a=o[i],l=t.args[n],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(i+1).toString(),a.type.toLowerCase()));const f=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:i+1});s.push(f)}}return s}function u(e,t=!1,i=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&i)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${n.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${n.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=o.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${i?"true":"false"}, "${l.functionName||ig["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const f=d(e);c.push(f.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${f.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=rg[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=ig[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),o=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(o.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${o.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${sg(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}ag[i]={execute:h}}return{execute:ag[i].execute,dependencies:o,constantValues:n,tokens:t}}function cg(e){return function(e){let t=[],o="";return e.map(((e,n)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"FUNCTION":o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0}),o="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}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,n=Object.assign({},e,{start:t,end:t+o,length:o});return t=n.end,n}))}(og(e))))}function hg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Rt(e.value),[n,i]=t.split(":"),r=o?`${Ae(o)}!`:"",s=dg(n),a=i?`:${dg(i)}`:"";return{...e,value:r+s+a}}function dg(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=ug(e,"colrow");break;case"colrow":e=ug(e,"row");break;case"row":e=ug(e,"col");break;case"col":e=ug(e,"none")}return e}function ug(e,t){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]/),"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}class gg{constructor(e,t,o){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const n=e.filter((e=>0!==e));if(n.length)return n}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}gg.getters=[];class pg extends gg{constructor(e,t,o,n,i){super(t,o,n),this.getters=e,this.ui=n,this.selection=i}drawGrid(e,t){}}pg.layers=[];const fg=r("The cell you are trying to edit has been deleted.");class mg extends pg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),o=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(o.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:n}=Rt(e.value),i=n||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==i)return!1;const s=this.getters.getRangeFromSheetXC(r,o);return Ro(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const n=this.getters.getRangeFromRangeData(e.range),i=this.getRangeReference(n,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(i),this.previousRef=i,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Lo({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:n})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:fg}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}unsubscribe(){this.mode="inactive"}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(hg).map((e=>e.value)).join(""),n=this.currentContent,i=e[0].start,r=e[e.length-1].end,s=n.slice(0,i)+o+n.slice(r),a=s.length-n.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:l})}validateSelection(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e?0:45}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:fg});const{top:t,left:o}=Eo({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:fg});const{top:t,left:o}=Eo({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=Co({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Lo({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var o;const n=this.getters.getActiveCell();e&&(null===(o=null==n?void 0:n.format)||void 0===o?void 0:o.includes("%"))&&ro(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==n?void 0:n.composerContent)||"",this.mode="editing";const{col:i,row:r}=this.getters.getPosition();this.col=i,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Lo({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:o}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let n=this.currentContent;if(!(this.initialContent!==n))return;if(n){const i=this.getters.getCell(e,t,o);if(n.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,o=e-t;o>0&&(n+=Ye(new Array(o).fill(")")))}else(null==i?void 0:i.isLink())&&(n=ze(n,i.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:o,content:n})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:o});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const n=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(n||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?cg(e):[],this.currentTokens.length>100&&o&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const o=this.getters.getActiveSheetId();let n=this.getters.zoneToXC(o,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){n=`${Ae(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${n}`}return n}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&Uo(e.zone)>1?t.push({...t[0]}):2===t.length&&1===Uo(e.zone)&&t.pop();const o=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(o,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),n=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:n,end:n}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const n=new Set(Object.values(o));let i=0;const r=()=>{for(;n.has(i);)i++;return n.add(i),i};for(const e of t){const t=e in o?o[e]:r();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return nt[t%nt.length]};return this.getReferencedRanges().map((o=>{const n=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(n),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,n=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(n.type)||Eu.includes(n.value);){if("SPACE"!==n.type||o<1)return!1;o--,n=this.currentTokens[o]}for(o=t+1,n=this.currentTokens[o];n&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(n.type);){if("SPACE"!==n.type)return!1;o++,n=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}mg.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const vg=Su.content,bg=new zo;bg.add("functions",(()=>Object.keys(vg).map((e=>({text:e,description:vg[e].description}))))),sn`
962
+ `;class ds extends t.Component{get tagStyle(){const{col:e,row:t,color:o}=this.props,{height:n}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:i,y:r}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return`bottom: ${n-r+15}px;left: ${i-1}px;border: 1px solid ${o};background-color: ${o};${this.props.active?"opacity:1 !important":""}`}}ds.template="o-spreadsheet-ClientTag";const us=/(.*?)\((.*?)\)(.*)/,gs=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function ps(e){let t=e.split("\n");const o=[];for(let e of t)e=e.trim(),e&&o.push(fs(e));return o}function fs(e){let t,o=e.match(us),n=o[1].trim(),i=[],r=!1,s=!1,a=!1;for(let e of o[2].split(",")){const o=e.trim().toUpperCase();let n=gs.find((e=>o===e));n?i.push(n):"RANGE<ANY>"===o?i.push("RANGE"):"OPTIONAL"===o?r=!0:"REPEATING"===o?s=!0:"LAZY"===o?a=!0:o.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}const l={name:n,description:o[3].trim(),type:i};return r&&(l.optional=!0),s&&(l.repeating=!0),a&&(l.lazy=!0),void 0!==t&&(l.default=!0,l.defaultValue=t),l}function ms(e){let t=0,o=0,n=0;for(let i of e.args)t++,i.optional||i.repeating||i.default||o++,i.repeating&&n++;const i=e;return i.minArgRequired=o,i.maxArgPossible=n?1/0:t,i.nbrArgRepeating=n,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,n),i}const vs=["number","string","boolean","undefined"];function bs(e,t){if(!e())throw new Error(t)}const Ss=e=>r("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Cs(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(so(e)||""===e)return lo(e);const t=pe(e);if(t)return t.value;throw new Error(Ss(e));default:return 0}}function Es(e){if(""===e)throw new Error(Ss(e));return Cs(e)}function ws(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function ys(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const xs=e=>r("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Rs(e){switch(typeof e){case"boolean":return e;case"string":if(e){let t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1;throw new Error(xs(e))}return!1;case"number":return!!e;default:return!1}}function Is(e){return me(Cs(e))}function Ts(e,t,o){for(let n of e)if(Array.isArray(n)){const e=n.length,o=n[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)t(n[o][i])}else o(n)}function As(e,t){Ts(e,t,t)}function Os(e,t){Ts(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Es(e))}))}function Ms(e,t,o,n){let i=n;for(let n of e)if(Array.isArray(n)){const e=n.length,o=n[0].length;for(let r=0;r<o;r++)for(let o=0;o<e;o++)i=t(i,n[o][r])}else i=o(i,n);return i}function Ns(e,t,o){return Ms(e,t,t,o)}function _s(e,t,o){return Ms(e,((e,o)=>"number"==typeof o?t(e,o):e),((e,o)=>t(e,Es(o))),o)}function Fs(e,t,o){return Ms(e,((e,o)=>null!=o?t(e,"number"==typeof o?o:"boolean"==typeof o?Cs(o):0):e),((e,o)=>t(e,Cs(o))),o)}function Ds(e,t){return function(e,t,o){for(let n of e)if(Array.isArray(n)){const e=n.length,o=n[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)if(!t(n[o][i]))return}else if(!o(n))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(xs(e));return Rs(e)}(e))))}function ks(e,t){let o,n,i=e.substring(0,2);"<="===i||">="===i||"<>"===i?(o=i,n=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(o=i,n=e.substring(1)):(o="=",n=e)),so(n)?n=Cs(n):"TRUE"!==n&&"FALSE"!==n||(n=Rs(n));const r={operator:o,operand:n};return"string"==typeof n&&(t&&(n+="*"),r.regexp=function(e){let t="",o="";for(let n of e)"?"===n&&"~"!==o?t+=".":"*"===n&&"~"!==o?t+=".*":("*"!==n&&"?"!==n||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(n)&&(t+="\\"),t+=n),o=n;return new RegExp("^"+t+"$","i")}(n)),r}function $s(e,t){const{operator:o,operand:n}=t;if(void 0===e||void 0===n)return!1;if("number"==typeof n&&"="===o)return ws(e)===ws(n);if("<>"===o||"="===o){let i;return i=typeof e==typeof n&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===n),"="===o?i:!i}if(typeof e==typeof n)switch(o){case"<":return e<n;case">":return e>n;case"<=":return e<=n;case">=":return e>=n}return!1}function Ls(e,t,o=!1){const n=e.length;if(n%2==1)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const i=e[0].length,s=e[0][0].length;let a=[];for(let t=0;t<n-1;t+=2){const n=e[t];if(!Array.isArray(n)||n.length!==i||n[0].length!==s)throw new Error(r("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=ws(e[t+1]);a.push(ks(l,o))}for(let o=0;o<i;o++)for(let i=0;i<s;i++){let r=!0;for(let t=0;t<n-1;t+=2){if(r=$s(e[t][o][i],a[t/2]),!r)break}r&&t(o,i)}}function Ps(e,t){return ys(e[0][t])}function Us(e,t){return ys(e[t][0])}function Vs(e,t,o,n,i,r){if(null==t)return-1;const s=typeof t;let a,l,c,h,d,u,g=0,p=i-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=r(e,h),u=typeof d;g<h&&s!==u;)h--,d=r(e,h),u=typeof d;u===s&&void 0!==d?("strict"===o&&d===t?(a=d,l=h):"nextSmaller"===o&&d<=t?(void 0===a||a<d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h):"nextGreater"===o&&d>=t&&(void 0===a||a>d||a===d&&"asc"===n&&l<h||a===d&&"desc"===n&&l>h)&&(a=d,l=h),"asc"===n&&d>t||"desc"===n&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function zs(e,t,o,n,i,r=!1){if(null==t)return-1;const s=r?(e,t)=>i(e,n-t-1):i;let a,l=-1;for(let i=0;i<n;i++){const c=s(e,i);if(c===t)return r?n-i-1:i;"nextSmaller"===o?(!a&&Bs(t,c)>=0||Bs(t,c)>=0&&Bs(c,a)>0)&&(a=c,l=i):"nextGreater"===o&&(!a&&Bs(t,c)<=0||Bs(t,c)<=0&&Bs(c,a)<0)&&(a=c,l=i)}return r?n-l-1:l}function Bs(e,t){let o=vs.indexOf(typeof e)-vs.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}const Hs={description:r("Apply a large number format"),args:ps(`\n value (number) ${r("The number.")}\n unit (string, optional) ${r("The formatting unit. Use 'k', 'm', or 'b' to force the unit")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>{const o=Math.abs(Cs(e.value)),n=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return jt(n,1e3,"k");case"m":return jt(n,1e6,"m");case"b":return jt(n,1e9,"b");default:throw new Error(r("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?jt(n,0,""):o<1e8?jt(n,1e3,"k"):o<1e11?jt(n,1e6,"m"):jt(n,1e9,"b")},compute:function(e){return Cs(e)}};var Ws=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Hs});const Gs={description:r("Absolute value of a number."),args:ps(`\n value (number) ${r("The number of which to return the absolute value.")}\n `),returns:["NUMBER"],compute:function(e){return Math.abs(Cs(e))},isExported:!0},qs={description:r("Inverse cosine of a value, in radians."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},Zs={description:r("Inverse hyperbolic cosine of a number."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>t>=1),r("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},js={description:r("Inverse cotangent of a value."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse cotangent.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Xs={description:r("Inverse hyperbolic cotangent of a value."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>Math.abs(t)>1),r("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Ys={description:r("Inverse sine of a value, in radians."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>Math.abs(t)<=1),r("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ks={description:r("Inverse hyperbolic sine of a number."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic sine.")}\n `),returns:["NUMBER"],compute:function(e){return Math.asinh(Cs(e))},isExported:!0},Qs={description:r("Inverse tangent of a value, in radians."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse tangent.")}\n `),returns:["NUMBER"],compute:function(e){return Math.atan(Cs(e))},isExported:!0},Js={description:r("Angle from the X axis to a point (x,y), in radians."),args:ps(`\n x (number) ${r("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n y (number) ${r("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Cs(e),n=Cs(t);return bs((()=>0!==o||0!==n),r("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(n,o)},isExported:!0},ea={description:r("Inverse hyperbolic tangent of a number."),args:ps(`\n value (number) ${r("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>Math.abs(t)<1),r("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},ta={description:r("Rounds number up to nearest multiple of factor."),args:ps(`\n value (number) ${r("The value to round up to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const o=Cs(e),n=Cs(t);return bs((()=>n>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),o.toString())),n?Math.ceil(o/n)*n:0},isExported:!0},oa={description:r("Rounds number up to nearest multiple of factor."),args:ps(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,o=0){let n=Cs(t);if(0===n)return 0;const i=Cs(e);if(n=Math.abs(n),i>=0)return Math.ceil(i/n)*n;return 0===Cs(o)?-Math.floor(Math.abs(i)/n)*n:-Math.ceil(Math.abs(i)/n)*n},isExported:!0},na={description:r("Rounds number up to nearest multiple of factor."),args:ps(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return oa.compute(e,t,0)},isExported:!0},ia={description:r("Cosine of an angle provided in radians."),args:ps(`\n angle (number) ${r("The angle to find the cosine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cos(Cs(e))},isExported:!0},ra={description:r("Hyperbolic cosine of any real number."),args:ps(`\n value (number) ${r("Any real value to calculate the hyperbolic cosine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.cosh(Cs(e))},isExported:!0},sa={description:r("Cotangent of an angle provided in radians."),args:ps(`\n angle (number) ${r("The angle to find the cotangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},aa={description:r("Hyperbolic cotangent of any real number."),args:ps(`\n value (number) ${r("Any real value to calculate the hyperbolic cotangent of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},la={description:r("Number of empty values."),args:ps(`\n value1 (any, range) ${r("The first value or range in which to count the number of blanks.")}\n value2 (any, range, repeating) ${r("Additional values or ranges in which to count the number of blanks.")}\n `),returns:["NUMBER"],compute:function(...e){return Ns(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},ca={description:r("A conditional count across a range."),args:ps(`\n range (range) ${r("The range that is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return Ls(e,((e,o)=>{t+=1})),t},isExported:!0},ha={description:r("Count values depending on multiple criteria."),args:ps(`\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;return Ls(e,((e,o)=>{t+=1})),t},isExported:!0};function da(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const ua={description:r("Counts number of unique values in a range."),args:ps(`\n value1 (any, range) ${r("The first value or range to consider for uniqueness.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider for uniqueness.")}\n `),returns:["NUMBER"],compute:function(...e){return Ns(e,((e,t)=>da(t)?e.add(t):e),new Set).size}},ga={description:r("Counts number of unique values in a range, filtered by a set of criteria."),args:ps(`\n range (range) ${r("The range of cells from which the number of unique values will be counted.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=new Set;return Ls(t,((t,n)=>{const i=e[t][n];da(i)&&o.add(i)})),o.size}},pa={description:r("Cosecant of an angle provided in radians."),args:ps(`\n angle (number) ${r("The angle to find the cosecant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},fa={description:r("Hyperbolic cosecant of any real number."),args:ps(`\n value (number) ${r("Any real value to calculate the hyperbolic cosecant of.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},ma={description:r("Converts from another base to decimal."),args:ps(`\n value (string) ${r("The number to convert.")},\n base (number) ${r("The base to convert the value from.")},\n `),returns:["NUMBER"],compute:function(e,t){let o=Cs(t);o=Math.floor(o),bs((()=>2<=o&&o<=36),r("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const n=ws(e);if(""===n)return 0;bs((()=>!!n.match(/^-?[a-z0-9]+$/i)),r("The value (%s) must be a valid base %s representation.",n,o.toString()));const i=parseInt(n,o);return bs((()=>!isNaN(i)),r("The value (%s) must be a valid base %s representation.",n,o.toString())),i},isExported:!0},va={description:r("Converts an angle value in radians to degrees."),args:ps(`\n angle (number) ${r("The angle to convert from radians to degrees.")}\n `),returns:["NUMBER"],compute:function(e){return 180*Cs(e)/Math.PI},isExported:!0},ba={description:r("Euler's number, e (~2.718) raised to a power."),args:ps(`\n value (number) ${r("The exponent to raise e.")}\n `),returns:["NUMBER"],compute:function(e){return Math.exp(Cs(e))},isExported:!0},Sa={description:r("Rounds number down to nearest multiple of factor."),args:ps(`\n value (number) ${r("The value to round down to the nearest integer multiple of factor.")}\n factor (number, default=1) ${r("The number to whose multiples value will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const o=Cs(e),n=Cs(t);return bs((()=>n>=0||o<=0),r("The factor (%s) must be positive when the value (%s) is positive.",n.toString(),o.toString())),n?Math.floor(o/n)*n:0},isExported:!0},Ca={description:r("Rounds number down to nearest multiple of factor."),args:ps(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded. The sign of significance will be ignored.")}\n mode (number, default=0) ${r("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,o=0){let n=Cs(t);if(0===n)return 0;const i=Cs(e);if(n=Math.abs(n),i>=0)return Math.floor(i/n)*n;return 0===Cs(o)?-Math.ceil(Math.abs(i)/n)*n:-Math.floor(Math.abs(i)/n)*n},isExported:!0},Ea={description:r("Rounds number down to nearest multiple of factor."),args:ps(`\n number (number) ${r("The value to round down to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ca.compute(e,t,0)},isExported:!0},wa={description:r("Whether the provided value is even."),args:ps(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Es(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},ya={description:r("Rounds number up to nearest multiple of factor."),args:ps(`\n number (number) ${r("The value to round up to the nearest integer multiple of significance.")}\n significance (number, default=1) ${r("The number to whose multiples number will be rounded.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return oa.compute(e,t,0)},isExported:!0},xa={description:r("Whether the provided value is even."),args:ps(`\n value (number) ${r("The value to be verified as even.")}\n `),returns:["BOOLEAN"],compute:function(e){const t=Es(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Ra={description:r("The logarithm of a number, base e (euler's number)."),args:ps(`\n value (number) ${r("The value for which to calculate the logarithm, base e.")}\n `),returns:["NUMBER"],compute:function(e){const t=Cs(e);return bs((()=>t>0),r("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ia={description:r("Modulo (remainder) operator."),args:ps(`\n dividend (number) ${r("The number to be divided to find the remainder.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Cs(t);bs((()=>0!==o),r("The divisor must be different from 0."));const n=Cs(e)%o;return n>0&&o<0||n<0&&o>0?n+o:n},isExported:!0},Ta={description:r("Rounds a number up to the nearest odd integer."),args:ps(`\n value (number) ${r("The value to round to the next greatest odd number.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Cs(e);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},Aa={description:r("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Oa={description:r("A number raised to a power."),args:ps(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Cs(e),n=Cs(t);return bs((()=>o>=0||Number.isInteger(n)),r("The exponent (%s) must be an integer when the base is negative.",n.toString())),Math.pow(o,n)},isExported:!0},Ma={description:r("Result of multiplying a series of numbers together."),args:ps(`\n factor1 (number, range<number>) ${r("The first number or range to calculate for the product.")}\n factor2 (number, range<number>, repeating) ${r("More numbers or ranges to calculate for the product.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,o=1;for(let n of e)if(Array.isArray(n))for(let e of n)for(let n of e)"number"==typeof n&&(o*=n,t+=1);else null!=n&&(o*=Es(n),t+=1);return 0===t?0:o},isExported:!0},Na={description:r("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},_a={description:r("Random integer between two values, inclusive."),args:ps(`\n low (number) ${r("The low end of the random range.")}\n high (number) ${r("The high end of the random range.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let o=Cs(e);Number.isInteger(o)||(o=Math.ceil(o));let n=Cs(t);return Number.isInteger(n)||(n=Math.floor(n)),bs((()=>o<=n),r("The high (%s) must be greater than or equal to the low (%s).",n.toString(),o.toString())),o+Math.ceil((n-o+1)*Math.random())-1},isExported:!0},Fa={description:r("Rounds a number according to standard rules."),args:ps(`\n value (number) ${r("The value to round to places number of places.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Cs(e);let n=Cs(t);const i=Math.abs(o);let r;return 0===n?r=Math.round(i):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.round(i*Math.pow(10,n))/Math.pow(10,n)),o>=0?r:-r},isExported:!0},Da={description:r("Rounds down a number."),args:ps(`\n value (number) ${r("The value to round to places number of places, always rounding down.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Cs(e);let n=Cs(t);const i=Math.abs(o);let r;return 0===n?r=Math.floor(i):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.floor(i*Math.pow(10,n))/Math.pow(10,n)),o>=0?r:-r},isExported:!0},ka={description:r("Rounds up a number."),args:ps(`\n value (number) ${r("The value to round to places number of places, always rounding up.")}\n places (number, default=0) ${r("The number of decimal places to which to round.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Cs(e);let n=Cs(t);const i=Math.abs(o);let r;return 0===n?r=Math.ceil(i):(Number.isInteger(n)||(n=Math.trunc(n)),r=Math.ceil(i*Math.pow(10,n))/Math.pow(10,n)),o>=0?r:-r},isExported:!0},$a={description:r("Secant of an angle provided in radians."),args:ps(`\n angle (number) ${r("The angle to find the secant of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cos(Cs(e))},isExported:!0},La={description:r("Hyperbolic secant of any real number."),args:ps(`\n value (number) ${r("Any real value to calculate the hyperbolic secant of.")}\n `),returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Cs(e))},isExported:!0},Pa={description:r("Sine of an angle provided in radians."),args:ps(`\n angle (number) ${r("The angle to find the sine of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sin(Cs(e))},isExported:!0},Ua={description:r("Hyperbolic sine of any real number."),args:ps(`\n value (number) ${r("Any real value to calculate the hyperbolic sine of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.sinh(Cs(e))},isExported:!0},Va={description:r("Positive square root of a positive number."),args:ps(`\n value (number) ${r("The number for which to calculate the positive square root.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Cs(e);return bs((()=>t>=0),r("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},za={description:r("Sum of a series of numbers and/or cells."),args:ps(`\n value1 (number, range<number>) ${r("The first number or range to add together.")}\n value2 (number, range<number>, repeating) ${r("Additional numbers or ranges to add to value1.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return _s(e,((e,t)=>e+t),0)},isExported:!0},Ba={description:r("A conditional sum across a range."),args:ps(`\n criteria_range (range) ${r("The range which is tested against criterion.")}\n criterion (string) ${r("The pattern or test to apply to range.")}\n sum_range (range, default=criteria_range) ${r("The range to be summed, if different from range.")}\n `),returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let n=0;return Ls([e,t],((e,t)=>{const i=o[e][t];"number"==typeof i&&(n+=i)})),n},isExported:!0},Ha={description:r("Sums a range depending on multiple criteria."),args:ps(`\n sum_range (range) ${r("The range to sum.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges to check.")}\n criterion2 (string, repeating) ${r("Additional criteria to check.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=0;return Ls(t,((t,n)=>{const i=e[t][n];"number"==typeof i&&(o+=i)})),o},isExported:!0},Wa={description:r("Tangent of an angle provided in radians."),args:ps(`\n angle (number) ${r("The angle to find the tangent of, in radians.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tan(Cs(e))},isExported:!0},Ga={description:r("Hyperbolic tangent of any real number."),args:ps(`\n value (number) ${r("Any real value to calculate the hyperbolic tangent of.")}\n `),returns:["NUMBER"],compute:function(e){return Math.tanh(Cs(e))},isExported:!0},qa={description:r("Truncates a number."),args:ps(`\n value (number) ${r("The value to be truncated.")}\n places (number, default=0) ${r("The number of significant digits to the right of the decimal point to retain.")}\n `),returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const o=Cs(e);let n=Cs(t);return 0===n?Math.trunc(o):(Number.isInteger(n)||(n=Math.trunc(n)),Math.trunc(o*Math.pow(10,n))/Math.pow(10,n))},isExported:!0};var Za=Object.freeze({__proto__:null,ABS:Gs,ACOS:qs,ACOSH:Zs,ACOT:js,ACOTH:Xs,ASIN:Ys,ASINH:Ks,ATAN:Qs,ATAN2:Js,ATANH:ea,CEILING:ta,CEILING_MATH:oa,CEILING_PRECISE:na,COS:ia,COSH:ra,COT:sa,COTH:aa,COUNTBLANK:la,COUNTIF:ca,COUNTIFS:ha,COUNTUNIQUE:ua,COUNTUNIQUEIFS:ga,CSC:pa,CSCH:fa,DECIMAL:ma,DEGREES:va,EXP:ba,FLOOR:Sa,FLOOR_MATH:Ca,FLOOR_PRECISE:Ea,ISEVEN:wa,ISO_CEILING:ya,ISODD:xa,LN:Ra,MOD:Ia,ODD:Ta,PI:Aa,POWER:Oa,PRODUCT:Ma,RAND:Na,RANDBETWEEN:_a,ROUND:Fa,ROUNDDOWN:Da,ROUNDUP:ka,SEC:$a,SECH:La,SIN:Pa,SINH:Ua,SQRT:Va,SUM:za,SUMIF:Ba,SUMIFS:Ha,TAN:Wa,TANH:Ga,TRUNC:qa});function ja(e,t,o){let n=[],i=[],s=0,a=0;As([e],(e=>{n.push(e),s+=1})),As([t],(e=>{i.push(e),a+=1})),bs((()=>s===a),r("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",s.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<s;e++){const t=n[e],o=i[e];"number"==typeof t&&"number"==typeof o&&(l+=1,c+=t,h+=o)}bs((()=>0!==l&&(!o||1!==l)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<s;e++){const t=n[e],o=i[e];"number"==typeof t&&"number"==typeof o&&(g+=(t-d)*(o-u))}return g/(l-(o?1:0))}function Xa(e,t,o){let n=0,i=0;const s=o?Fs:_s;i=s(e,((e,t)=>(n+=1,e+t)),0),bs((()=>0!==n&&(!t||1!==n)),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=i/n;return s(e,((e,t)=>e+Math.pow(t-a,2)),0)/(n-(t?1:0))}function Ya(e,t,o){const n=Cs(t);bs((()=>o?0<=n&&n<=1:0<n&&n<1),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let i,s=[],a=0;return As(e,(e=>{"number"==typeof e&&(i=Vs(s,e,"nextSmaller","asc",s.length,((e,t)=>e[t])),s.splice(i+1,0,e),a++)})),bs((()=>0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),o||bs((()=>1/(a+1)<=n&&n<=a/(a+1)),r("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),co(s,n,o)}const Ka={description:r("Average magnitude of deviations from mean."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;const o=_s(e,((e,o)=>(t+=1,e+o)),0);bs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const n=o/t;return _s(e,((e,t)=>e+Math.abs(n-t)),0)/t},isExported:!0},Qa={description:r("Numerical average value in a dataset, ignoring text."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const o=_s(e,((e,o)=>(t+=1,e+o)),0);return bs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},Ja=r("[[FUNCTION_NAME]] has mismatched range sizes."),el=r("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),tl={description:r("Weighted average."),args:ps(`\n values (number, range<number>) ${r("Values to average.")}\n weights (number, range<number>) ${r("Weights for each corresponding value.")}\n additional_values (number, range<number>, repeating) ${r("Additional values to average.")}\n additional_weights (number, range<number>, repeating) ${r("Additional weights.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,o,n=0,i=0;bs((()=>e.length%2==0),r("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let s=0;s<e.length-1;s+=2)if(t=e[s],o=e[s+1],Array.isArray(t)){bs((()=>Array.isArray(o)),Ja);let e=t.length,s=t[0].length;bs((()=>e===o.length&&s===o[0].length),Ja);for(let a=0;a<e;a++)for(let e=0;e<s;e++){let s=t[a][e],l=o[a][e],c="number"==typeof s,h="number"==typeof l;bs((()=>c===h),r("[[FUNCTION_NAME]] expects number values.")),h&&(bs((()=>l>=0),el),n+=s*l,i+=l)}}else o=Cs(o),t=Cs(t),bs((()=>o>=0),el),n+=t*o,i+=o;return bs((()=>0!==i),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i}},ol={description:r("Numerical average value in a dataset."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the average value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the average value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const o=Fs(e,((e,o)=>(t+=1,e+o)),0);return bs((()=>0!==t),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},nl={description:r("Average of values depending on criteria."),args:ps(`\n criteria_range (range) ${r("The range to check against criterion.")}\n criterion (string) ${r("The pattern or test to apply to criteria_range.")}\n average_range (range, default=criteria_range) ${r("The range to average. If not included, criteria_range is used for the average instead.")}\n `),returns:["NUMBER"],compute:function(e,t,o){null==o&&(o=e);let n=0,i=0;return Ls([e,t],((t,r)=>{const s=(o||e)[t][r];"number"==typeof s&&(n+=1,i+=s)})),bs((()=>0!==n),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/n},isExported:!0},il={description:r("Average of values depending on multiple criteria."),args:ps(`\n average_range (range) ${r("The range to average.")}\n criteria_range1 (range) ${r("The range to check against criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1.")}\n criteria_range2 (any, range, repeating) ${r("Additional criteria_range and criterion to check.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=0,n=0;return Ls(t,((t,i)=>{const r=e[t][i];"number"==typeof r&&(o+=1,n+=r)})),bs((()=>0!==o),r("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},rl={description:r("The number of numeric values in dataset."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range to consider when counting.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||so(o)||pe(o))&&(t+=1);return t},isExported:!0},sl={description:r("The number of values in a dataset."),args:ps(`\n value1 (any, range) ${r("The first value or range to consider when counting.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when counting.")}\n `),returns:["NUMBER"],compute:function(...e){return Ns(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},al={description:r("The covariance of a dataset."),args:ps(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ja(e,t,!1)},isExported:!0},ll={description:r("The covariance of a dataset."),args:ps(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ja(e,t,!1)},isExported:!0},cl={description:r("The sample covariance of a dataset."),args:ps(`\n data_y (any, range) ${r("The range representing the array or matrix of dependent data.")}\n data_x (any, range) ${r("The range representing the array or matrix of independent data.")}\n `),returns:["NUMBER"],compute:function(e,t){return ja(e,t,!0)},isExported:!0},hl={description:r("Nth largest element from a data set."),args:ps(`\n data (any, range) ${r("Array or range containing the dataset to consider.")}\n n (number) ${r("The rank from largest to smallest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const o=Math.trunc(Cs(t));let n,i=[],s=0;As([e],(e=>{"number"==typeof e&&(n=Vs(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t])),i.splice(n+1,0,e),s++,s>o&&(i.shift(),s--))}));const a=i.shift();return bs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),bs((()=>s>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},dl={description:r("Maximum value in a numeric dataset."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=_s(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},ul={description:r("Maximum numeric value in a dataset."),args:ps(`\n value1 (any, range) ${r("The first value or range to consider when calculating the maximum value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the maximum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Fs(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},gl={description:r("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:ps(`\n range (range) ${r("The range of cells from which the maximum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return Ls(t,((t,n)=>{const i=e[t][n];"number"==typeof i&&(o=o<i?i:o)})),o===-1/0?0:o},isExported:!0},pl={description:r("Median value in a numeric dataset."),args:ps(`\n value1 (any, range) ${r("The first value or range to consider when calculating the median value.")}\n value2 (any, range, repeating) ${r("Additional values or ranges to consider when calculating the median value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return Os(e,(e=>{t.push(e)})),Ya(t,.5,!0)},isExported:!0},fl={description:r("Minimum value in a numeric dataset."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=_s(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},ml={description:r("Minimum numeric value in a dataset."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range to consider when calculating the minimum value.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to consider when calculating the minimum value.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Fs(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},vl={description:r("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:ps(`\n range (range) ${r("The range of cells from which the minimum will be determined.")}\n criteria_range1 (range) ${r("The range of cells over which to evaluate criterion1.")}\n criterion1 (string) ${r("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")}\n criteria_range2 (any, range, repeating) ${r("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")}\n criterion2 (string, repeating) ${r("The pattern or test to apply to criteria_range2.")}\n `),returns:["NUMBER"],compute:function(e,...t){let o=1/0;return Ls(t,((t,n)=>{const i=e[t][n];"number"==typeof i&&(o=o>i?i:o)})),o===1/0?0:o},isExported:!0},bl={description:r("Value at a given percentile of a dataset."),args:ps(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Cl.compute(e,t)},isExported:!0},Sl={description:r("Value at a given percentile of a dataset exclusive of 0 and 1."),args:ps(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ya([e],t,!1)},isExported:!0},Cl={description:r("Value at a given percentile of a dataset."),args:ps(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n percentile (number) ${r("The percentile whose value within data will be calculated and returned.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ya([e],t,!0)},isExported:!0},El={description:r("Value nearest to a specific quartile of a dataset."),args:ps(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return yl.compute(e,t)},isExported:!0},wl={description:r("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:ps(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value, exclusive of 0 and 4, to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ya([e],.25*Math.trunc(Cs(t)),!1)},isExported:!0},yl={description:r("Value nearest to a specific quartile of a dataset."),args:ps(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n quartile_number (number) ${r("Which quartile value to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Ya([e],.25*Math.trunc(Cs(t)),!0)},isExported:!0},xl={description:r("Nth smallest element in a data set."),args:ps(`\n data (any, range) ${r("The array or range containing the dataset to consider.")}\n n (number) ${r("The rank from smallest to largest of the element to return.")}\n `),returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const o=Math.trunc(Cs(t));let n,i=[],s=0;As([e],(e=>{"number"==typeof e&&(n=Vs(i,e,"nextSmaller","asc",i.length,((e,t)=>e[t])),i.splice(n+1,0,e),s++,s>o&&(i.pop(),s--))}));const a=i.pop();return bs((()=>void 0!==a),r("[[FUNCTION_NAME]] has no valid input data.")),bs((()=>s>=o),r("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},Rl={description:r("Standard deviation."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Nl.compute(...e))},isExported:!0},Il={description:r("Standard deviation of entire population."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(_l.compute(...e))},isExported:!0},Tl={description:r("Standard deviation."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Fl.compute(...e))},isExported:!0},Al={description:r("Standard deviation of sample (text as 0)."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(Dl.compute(...e))},isExported:!0},Ol={description:r("Standard deviation of entire population."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt(kl.compute(...e))},isExported:!0},Ml={description:r("Standard deviation of entire population (text as 0)."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Math.sqrt($l.compute(...e))},isExported:!0},Nl={description:r("Variance."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Xa(e,!0,!1)},isExported:!0},_l={description:r("Variance of entire population."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Xa(e,!1,!1)},isExported:!0},Fl={description:r("Variance."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Xa(e,!0,!1)},isExported:!0},Dl={description:r("Variance of sample (text as 0)."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the sample.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the sample.")}\n `),returns:["NUMBER"],compute:function(...e){return Xa(e,!0,!0)},isExported:!0},kl={description:r("Variance of entire population."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Xa(e,!1,!1)},isExported:!0},$l={description:r("Variance of entire population (text as 0)."),args:ps(`\n value1 (number, range<number>) ${r("The first value or range of the population.")}\n value2 (number, range<number>, repeating) ${r("Additional values or ranges to include in the population.")}\n `),returns:["NUMBER"],compute:function(...e){return Xa(e,!1,!0)},isExported:!0};var Ll=Object.freeze({__proto__:null,AVEDEV:Ka,AVERAGE:Qa,AVERAGE_WEIGHTED:tl,AVERAGEA:ol,AVERAGEIF:nl,AVERAGEIFS:il,COUNT:rl,COUNTA:sl,COVAR:al,COVARIANCE_P:ll,COVARIANCE_S:cl,LARGE:hl,MAX:dl,MAXA:ul,MAXIFS:gl,MEDIAN:pl,MIN:fl,MINA:ml,MINIFS:vl,PERCENTILE:bl,PERCENTILE_EXC:Sl,PERCENTILE_INC:Cl,QUARTILE:El,QUARTILE_EXC:wl,QUARTILE_INC:yl,SMALL:xl,STDEV:Rl,STDEV_P:Il,STDEV_S:Tl,STDEVA:Al,STDEVP:Ol,STDEVPA:Ml,VAR:Nl,VAR_P:_l,VAR_S:Fl,VARA:Dl,VARP:kl,VARPA:$l});function Pl(e,t,o){var n;const i=new Map,s=e.length;for(let t=s-1;t>=0;t--)i.set(ws(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(r("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||s-1<a)throw new Error(r("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),s.toString()))}else{const e=ws(t).toUpperCase();if(a=null!==(n=i.get(e))&&void 0!==n?n:-1,-1===a)throw new Error(r("The field (%s) must be one of %s.",ws(t),[...i.keys()].toString()))}const l=o[0].length;if(l<2)throw new Error(r("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let n=[],r=!0;for(let s=0;s<o.length;s++){const a=ws(o[s][0]).toUpperCase(),l=i.get(a),c=o[s][t];if(void 0!==c){if(void 0===l){r=!1;break}n.push([e[l].slice(1,h)]),n.push(c)}}if(r){if(!(n.length>0)){c=new Set(Array(h-1).keys());break}Ls(n,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const Ul=ps(`\n database (range) ${r("The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.")}\n field (any) ${r("Indicates which column in database contains the values to be extracted and operated on.")}\n criteria (range) ${r("An array or range containing zero or more criteria to filter the database values by before operating.")}\n`),Vl={description:r("Average of a set of values from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return Qa.compute([n])},isExported:!0},zl={description:r("Counts values from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return rl.compute([n])},isExported:!0},Bl={description:r("Counts values and text from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return sl.compute([n])},isExported:!0},Hl={description:r("Single value from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return bs((()=>1===n.length),r("More than one match found in DGET evaluation.")),n[0]},isExported:!0},Wl={description:r("Maximum of values from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return dl.compute([n])},isExported:!0},Gl={description:r("Minimum of values from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return fl.compute([n])},isExported:!0},ql={description:r("Product of values from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return Ma.compute([n])},isExported:!0},Zl={description:r("Standard deviation of population sample from table."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return Rl.compute([n])},isExported:!0},jl={description:r("Standard deviation of entire population from table."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return Ol.compute([n])},isExported:!0},Xl={description:r("Sum of values from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return za.compute([n])},isExported:!0},Yl={description:r("Variance of population sample from table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return Nl.compute([n])},isExported:!0},Kl={description:r("Variance of a population from a table-like range."),args:Ul,returns:["NUMBER"],compute:function(e,t,o){const n=Pl(e,t,o);return kl.compute([n])},isExported:!0};var Ql=Object.freeze({__proto__:null,DAVERAGE:Vl,DCOUNT:zl,DCOUNTA:Bl,DGET:Hl,DMAX:Wl,DMIN:Gl,DPRODUCT:ql,DSTDEV:Zl,DSTDEVP:jl,DSUM:Xl,DVAR:Yl,DVARP:Kl});const Jl={description:r("Converts year/month/day into a date."),args:ps(`\n year (number) ${r("The year component of the date.")}\n month (number) ${r("The month component of the date.")}\n day (number) ${r("The day component of the date.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o){let n=Math.trunc(Cs(e));const i=Math.trunc(Cs(t)),s=Math.trunc(Cs(o));bs((()=>0<=n&&n<=9999),r("The year (%s) must be between 0 and 9999 inclusive.",n.toString())),n<1900&&(n+=1900);const a=ve(new Date(n,i-1,s));return bs((()=>a>=0),r("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},ec={description:r("Converts a date string to a date value."),args:ps(`\n date_string (string) ${r("The string representing the date.")}\n `),returns:["NUMBER"],compute:function(e){const t=ws(e),o=pe(t);return bs((()=>null!==o),r("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},tc={description:r("Day of the month that a specific date falls on."),args:ps(`\n date (string) ${r("The date from which to extract the day.")}\n `),returns:["NUMBER"],compute:function(e){return Is(e).getDate()},isExported:!0},oc={description:r("Number of days between two dates."),args:ps(`\n end_date (date) ${r("The end of the date range.")}\n start_date (date) ${r("The start of the date range.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Is(e),n=Is(t),i=o.getTime()-n.getTime();return Math.round(i/ae)},isExported:!0},nc={description:r("Number of days between two dates on a 360-day year (months of 30 days)."),args:ps(`\n start_date (date) ${r("The start date to consider in the calculation.")}\n end_date (date) ${r("The end date to consider in the calculation.")}\n method (number, default=0) ${r("An indicator of what day count method to use. (0) US NASD method (1) European method")}\n `),returns:["NUMBER"],compute:function(e,t,o=0){const n=Cs(e),i=Cs(t),r=Rs(o)?4:0,s=yc.compute(e,t,r);return Math.sign(i-n)*Math.round(360*s)},isExported:!0},ic={description:r("Date a number of months before/after another date."),args:ps(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to calculate.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return ve(Ce(Is(e),Math.trunc(Cs(t)),!1))},isExported:!0},rc={description:r("Last day of a month before or after a date."),args:ps(`\n start_date (date) ${r("The date from which to calculate the result.")}\n months (number) ${r("The number of months before (negative) or after (positive) 'start_date' to consider.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const o=Is(e),n=Math.trunc(Cs(t)),i=o.getFullYear(),r=o.getMonth();return ve(new Date(i,r+n+1,0))},isExported:!0},sc={description:r("Hour component of a specific time."),args:ps(`\n time (date) ${r("The time from which to calculate the hour component.")}\n `),returns:["NUMBER"],compute:function(e){return Is(e).getHours()},isExported:!0},ac={description:r("ISO week number of the year."),args:ps(`\n date (date) ${r("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n `),returns:["NUMBER"],compute:function(e){const t=Is(e),o=t.getFullYear();let n=1;for(;4!==new Date(o,0,n).getDay();)n+=1;const i=new Date(o,0,n-3);let r=31;for(;4!==new Date(o,11,r).getDay();)r-=1;const s=new Date(o,11,r+3);let a,l;switch(a=i.getTime()<=t.getTime()?t.getTime()<=s.getTime()?0:1:-1,a){case 0:l=i;break;case 1:l=new Date(o,11,r+3+1);break;case-1:let e=1;for(;4!==new Date(o-1,0,e).getDay();)e+=1;l=new Date(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/ae;return Math.floor(c/7)+1},isExported:!0},lc={description:r("Minute component of a specific time."),args:ps(`\n time (date) ${r("The time from which to calculate the minute component.")}\n `),returns:["NUMBER"],compute:function(e){return Is(e).getMinutes()},isExported:!0},cc={description:r("Month of the year a specific date falls in"),args:ps(`\n date (date) ${r("The date from which to extract the month.")}\n `),returns:["NUMBER"],compute:function(e){return Is(e).getMonth()+1},isExported:!0},hc={description:r("Net working days between two provided days."),args:ps(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the date serial numbers to consider holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,o){return uc.compute(e,t,1,o)},isExported:!0};function dc(e){if("string"==typeof e){bs((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),r('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return bs((()=>1<=e&&e<=7||11<=e&&e<=17),r("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(r("The weekend must be a number or a string."))}const uc={description:r("Net working days between two dates (specifying weekends)."),args:ps(`\n start_date (date) ${r("The start date of the period from which to calculate the number of net working days.")}\n end_date (date) ${r("The end date of the period from which to calculate the number of net working days.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider as holidays.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1,n){const i=Is(e),r=Is(t),s=dc(o);let a=new Set;void 0!==n&&As([n],(e=>{const t=Is(e);a.add(t.getTime())}));const l=i.getTime()>r.getTime(),c=new Date((l?i:r).getTime());let h=new Date((l?r:i).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)s.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},gc={description:r("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-se.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ae)+o},isExported:!0},pc={description:r("Minute component of a specific time."),args:ps(`\n time (date) ${r("The time from which to calculate the second component.")}\n `),returns:["NUMBER"],compute:function(e){return Is(e).getSeconds()},isExported:!0},fc={description:r("Converts hour/minute/second into a time."),args:ps(`\n hour (number) ${r("The hour component of the time.")}\n minute (number) ${r("The minute component of the time.")}\n second (number) ${r("The second component of the time.")}\n `),returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,o){let n=Math.trunc(Cs(e)),i=Math.trunc(Cs(t)),s=Math.trunc(Cs(o));return i+=Math.floor(s/60),s=s%60+(s<0?60:0),n+=Math.floor(i/60),i=i%60+(i<0?60:0),n%=24,bs((()=>n>=0),r("The function [[FUNCTION_NAME]] result cannot be negative")),n/24+i/1440+s/86400},isExported:!0},mc={description:r("Converts a time string into its serial number representation."),args:ps(`\n time_string (string) ${r("The string that holds the time representation.")}\n `),returns:["NUMBER"],compute:function(e){const t=ws(e),o=pe(t);bs((()=>null!==o),r("The time_string (%s) cannot be parsed to date/time.",t));const n=o.value-Math.trunc(o.value);return n<0?1+n:n},isExported:!0},vc={description:r("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return ve(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},bc={description:r("Day of the week of the date provided (as number)."),args:ps(`\n date (date) ${r("The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const o=Is(e),n=Math.round(Cs(t)),i=o.getDay();return bs((()=>[1,2,3].includes(n)),r("The type (%s) must be 1, 2 or 3.",n.toString())),1===n?i+1:2===n?0===i?7:i:0===i?6:i-1},isExported:!0},Sc={description:r("Week number of the year."),args:ps(`\n date (date) ${r("The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n type (number, default=1) ${r("A number representing the day that a week starts on. Sunday = 1.")}\n `),returns:["NUMBER"],compute:function(e,t=1){const o=Is(e),n=Math.round(Cs(t));if(bs((()=>1===n||2===n||11<=n&&n<=17||21===n),r("The type (%s) is out of range.",n.toString())),21===n)return ac.compute(e);let i;i=1===n||2===n?n-1:n-10==7?0:n-10;const s=o.getFullYear();let a=1,l=new Date(s,0,a);for(;l.getDay()!==i;)a+=1,l=new Date(s,0,a);const c=(o.getTime()-l.getTime())/ae;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Cc={description:r("Date after a number of workdays."),args:ps(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o){return Ec.compute(e,t,1,o)},isExported:!0},Ec={description:r("Date after a number of workdays (specifying weekends)."),args:ps(`\n start_date (date) ${r("The date from which to begin counting.")}\n num_days (number) ${r("The number of working days to advance from start_date. If negative, counts backwards.")}\n weekend (any, default=1) ${r("A number or string representing which days of the week are considered weekends.")}\n holidays (date, range<date>, optional) ${r("A range or array constant containing the dates to consider holidays.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o=1,n){let i=Is(e),s=Math.trunc(Cs(t));"string"==typeof o&&bs((()=>"1111111"!==o),r("The weekend (%s) must be different from '1111111'.",o));const a=dc(o);let l=new Set;void 0!==n&&As([n],(e=>{const t=Is(e);l.add(t.getTime())}));let c=new Date(i.getTime()),h=c.getTime();const d=Math.sign(s);let u=Math.abs(s);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-se.getTime();return Math.round(g/ae)},isExported:!0},wc={description:r("Year specified by a given date."),args:ps(`\n date (date) ${r("The date from which to extract the year.")}\n `),returns:["NUMBER"],compute:function(e){return Is(e).getFullYear()},isExported:!0},yc={description:r("Exact number of years between two dates."),args:ps(`\n start_date (date) ${r("The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n end_date (date) ${r("The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.")}\n day_count_convention (number, default=0) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o=0){let n=Math.trunc(Cs(e)),i=Math.trunc(Cs(t));const s=Math.trunc(Cs(o));return bs((()=>n>=0),r("The start_date (%s) must be positive or null.",n.toString())),bs((()=>i>=0),r("The end_date (%s) must be positive or null.",i.toString())),bs((()=>0<=s&&s<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",s.toString())),we(n,i,s)}},xc={description:r("First day of the month preceding a date."),args:ps(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Is(e),o=t.getFullYear(),n=t.getMonth();return ve(new Date(o,n,1))}},Rc={description:r("Last day of the month following a date."),args:ps(`\n date (date) ${r("The date from which to calculate the result.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return rc.compute(e,0)}},Ic={description:r("Quarter of the year a specific date falls in"),args:ps(`\n date (date) ${r("The date from which to extract the quarter.")}\n `),returns:["NUMBER"],compute:function(e){return Math.ceil((Is(e).getMonth()+1)/3)}},Tc={description:r("First day of the quarter of the year a specific date falls in."),args:ps(`\n date (date) ${r("The date from which to calculate the start of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Ic.compute(e),o=wc.compute(e);return ve(new Date(o,3*(t-1),1))}},Ac={description:r("Last day of the quarter of the year a specific date falls in."),args:ps(`\n date (date) ${r("The date from which to calculate the end of quarter.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Ic.compute(e),o=wc.compute(e);return ve(new Date(o,3*t,0))}},Oc={description:r("First day of the year a specific date falls in."),args:ps(`\n date (date) ${r("The date from which to calculate the start of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=wc.compute(e);return ve(new Date(t,0,1))}},Mc={description:r("Last day of the year a specific date falls in."),args:ps(`\n date (date) ${r("The date from which to calculate the end of the year.")}\n `),returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=wc.compute(e);return ve(new Date(t+1,0,0))}};var Nc=Object.freeze({__proto__:null,DATE:Jl,DATEVALUE:ec,DAY:tc,DAYS:oc,DAYS360:nc,EDATE:ic,EOMONTH:rc,HOUR:sc,ISOWEEKNUM:ac,MINUTE:lc,MONTH:cc,NETWORKDAYS:hc,NETWORKDAYS_INTL:uc,NOW:gc,SECOND:pc,TIME:fc,TIMEVALUE:mc,TODAY:vc,WEEKDAY:bc,WEEKNUM:Sc,WORKDAY:Cc,WORKDAY_INTL:Ec,YEAR:wc,YEARFRAC:yc,MONTH_START:xc,MONTH_END:Rc,QUARTER:Ic,QUARTER_START:Tc,QUARTER_END:Ac,YEAR_START:Oc,YEAR_END:Mc});const _c={description:r("Compare two numeric values, returning 1 if they're equal."),args:ps(`\n number1 (number) ${r("The first number to compare.")}\n number2 (number, default=0) ${r("The second number to compare.")}\n `),returns:["NUMBER"],compute:function(e,t=0){return Cs(e)===Cs(t)?1:0},isExported:!0};var Fc=Object.freeze({__proto__:null,DELTA:_c});function Dc(e,t){bs((()=>e<t),r("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function kc(e,t){bs((()=>t<e),r("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function $c(e){bs((()=>[1,2,4].includes(e)),r("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function Lc(e){bs((()=>0<=e&&e<=4),r("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function Pc(e){bs((()=>e>0),r("The redemption (%s) must be strictly positive.",e.toString()))}function Uc(e){bs((()=>e>0),r("The price (%s) must be strictly positive.",e.toString()))}function Vc(e){bs((()=>e>0),r("The number_of_periods (%s) must be greater than 0.",e.toString()))}function zc(e){bs((()=>e>0),r("The rate (%s) must be strictly positive.",e.toString()))}function Bc(e){bs((()=>e>0),r("The life (%s) must be strictly positive.",e.toString()))}function Hc(e){bs((()=>e>=0),r("The cost (%s) must be positive or null.",e.toString()))}function Wc(e){bs((()=>e>0),r("The period (%s) must be strictly positive.",e.toString()))}function Gc(e){bs((()=>e>=0),r("The salvage (%s) must be positive or null.",e.toString()))}function qc(e){bs((()=>e>0),r("The present value (%s) must be strictly positive.",e.toString()))}function Zc(e,t){bs((()=>e<=t),r("The period (%s) must be less than or equal life (%.",e.toString(),t.toString()))}function jc(e){bs((()=>e>0),r("The investment (%s) must be strictly positive.",e.toString()))}function Xc(e){bs((()=>e>0),r("The discount (%s) must be strictly positive.",e.toString()))}function Yc(e){bs((()=>e<1),r("The discount (%s) must be smaller than 1.",e.toString()))}function Kc(e){bs((()=>e>0),r("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Qc(e,t){const o=Is(e),n=Is(t),i=new Date(o);i.setFullYear(o.getFullYear()+1),bs((()=>n.getTime()<=i.getTime()),r("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Jc(e,t,o){Vc(o),bs((()=>e>0),r("The first_period (%s) must be strictly positive.",e.toString())),bs((()=>t>0),r("The last_period (%s) must be strictly positive.",t.toString())),bs((()=>e<=t),r("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),bs((()=>t<=o),r("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function eh(e){bs((()=>e>-1),r("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function th(e,t){bs((()=>e.length===t.length&&e[0].length===t[0].length),r("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function oh(e){bs((()=>e.every((t=>t>=e[0]))),r("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const nh=ps(`\nsettlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\nmaturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\nfrequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\nday_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n`);function ih(e,t,o,n,i=1e-10,s){let a,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(bs((()=>g<n&&void 0!==s),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=s(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<i||Math.abs(c)<i,bs((()=>g<n),r("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const rh={description:r("Accrued interest of security paying at maturity."),args:ps(`\n issue (date) ${r("The date the security was initially issued.")}\n maturity (date) ${r("The maturity date of the security.")}\n rate (number) ${r("The annualized rate of interest.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Cs(e)),s=Math.trunc(Cs(t)),a=Cs(n),l=Cs(o),c=Math.trunc(Cs(i));kc(s,r),Lc(c),Pc(a),zc(l);return a*l*yc.compute(r,s,i)},isExported:!0},sh={description:r("Depreciation for an accounting period."),args:ps(`\n cost (number) ${r("The initial cost of the asset.")}\n purchase_date (date) ${r("The date the asset was purchased.")}\n first_period_end (date) ${r("The date the first period ended.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n rate (number) ${r("The deprecation rate.")}\n day_count_convention (number, optional) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s,a=0){a=a||0;const l=Cs(e),c=Math.trunc(Cs(t)),h=Math.trunc(Cs(o)),d=Cs(n),u=Cs(i),g=Cs(s),p=Math.trunc(Cs(a));!function(e){bs((()=>e>0),r("The cost (%s) must be strictly positive.",e.toString()))}(l),Gc(d),function(e,t){bs((()=>e<=t),r("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){bs((()=>e>=0),r("The period (%s) must be positive or null.",e.toString()))}(u),zc(g),Lc(p),bs((()=>c<=h),r("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const f=u<1&&u>0?1:Math.trunc(u),m=l*g,v=yc.compute(c,h,p),b=c===h?m:m*v,S=l-b-m*f;return S>=d?0===f?b:m:d-S<m?m-(d-S):0},isExported:!0},ah={description:r("Days in coupon period containing settlement date."),args:nh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Cs(e)),r=Math.trunc(Cs(t)),s=Math.trunc(Cs(o)),a=Math.trunc(Cs(n));if(Dc(i,r),$c(s),Lc(a),1===a){const i=uh.compute(e,t,o,n);return hh.compute(e,t,o,n)-i}return(3===a?365:360)/s},isExported:!0},lh={description:r("Days from settlement until next coupon."),args:nh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Cs(e)),r=Math.trunc(Cs(t)),s=Math.trunc(Cs(o)),a=Math.trunc(Cs(n));Dc(i,r),$c(s),Lc(a);const l=uh.compute(i,r,o,n);if([1,2,3].includes(a))return i-l;if(4===a){const e=we(l,i,a);return Math.round(360*e)}const c=Is(i),h=Is(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let f=h.getDate(),m=c.getDate();return 2===g&&2===p&&Se(h)&&Se(c)&&(m=30),31!==m||30!==f&&31!==f||(m=30),2===g&&Se(h)&&(f=30),31===f&&(f=30),360*(u-d)+30*(p-g)+(m-f)},isExported:!0},ch={description:r("Days from settlement until next coupon."),args:nh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Cs(e)),r=Math.trunc(Cs(t)),s=Math.trunc(Cs(o)),a=Math.trunc(Cs(n));Dc(i,r),$c(s),Lc(a);const l=hh.compute(i,r,o,n);if([1,2,3].includes(a))return l-i;if(4===a){const e=we(i,l,a);return Math.round(360*e)}const c=lh.compute(e,t,o,a);return ah.compute(e,t,o,a)-c},isExported:!0},hh={description:r("Next coupon date after the settlement date."),args:nh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Cs(e)),r=Math.trunc(Cs(t)),s=Math.trunc(Cs(o)),a=Math.trunc(Cs(n));Dc(i,r),$c(s),Lc(a);const l=12/s,c=dh.compute(e,t,o,n);return ve(Ce(Is(r),-(c-1)*l,!0))},isExported:!0},dh={description:r("Number of coupons between settlement and maturity."),args:nh,returns:["NUMBER"],compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Cs(e)),r=Math.trunc(Cs(t)),s=Math.trunc(Cs(o)),a=Math.trunc(Cs(n));Dc(i,r),$c(s),Lc(a);let l=1,c=r;const h=12/s;for(;c>i;)c=ve(Ce(Is(c),-h,!1)),l++;return l-1},isExported:!0},uh={description:r("Last coupon date prior to or on the settlement date."),args:nh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,n=0){n=n||0;const i=Math.trunc(Cs(e)),r=Math.trunc(Cs(t)),s=Math.trunc(Cs(o)),a=Math.trunc(Cs(n));Dc(i,r),$c(s),Lc(a);const l=12/s,c=dh.compute(e,t,o,n);return ve(Ce(Is(r),-c*l,!0))},isExported:!0},gh={description:r("Cumulative interest paid over a set of periods."),args:ps(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,r=0){const s=Cs(n),a=Cs(i),l=Cs(e),c=Cs(o),h=Cs(t);Jc(s,a,h),zc(l),qc(c);let d=0;for(let t=s;t<=a;t++){d+=Rh.compute(e,t,h,o,0,r)}return d},isExported:!0},ph={description:r("Cumulative principal paid over a set of periods."),args:ps(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n first_period (number) ${r("The number of the payment period to begin the cumulative calculation.")}\n last_period (number) ${r("The number of the payment period to end the cumulative calculation.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,r=0){const s=Cs(n),a=Cs(i),l=Cs(e),c=Cs(o),h=Cs(t);Jc(s,a,h),zc(l),qc(c);let d=0;for(let t=s;t<=a;t++){d+=kh.compute(e,t,h,o,0,r)}return d},isExported:!0},fh={description:r("Depreciation via declining balance method."),args:ps(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n month (number, optional) ${r("The number of months in the first year of depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,...i){const s=Cs(e),a=Cs(t),l=Cs(o),c=Math.trunc(Cs(n)),h=i.length?Math.trunc(Cs(i[0])):12,d=l+(12===h?0:1);Hc(s),Gc(a),Wc(c),Bc(l),bs((()=>1<=h&&h<=12),r("The month (%s) must be between 1 and 12 inclusive.",h.toString())),bs((()=>c<=d),r("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/s,1/l);g=Math.round(1e3*g)/1e3;let p=s,f=s*(1-g*u);for(let e=1;e<c;e++)p=f,f=p*(1-g),e===l&&(f=p*(1-g*(1-u)));return p-f},isExported:!0},mh={description:r("Depreciation via double-declining balance method."),args:ps(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n factor (number, default=2) ${r("The factor by which depreciation decreases.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,i=2){i=i||0;const r=Cs(e),s=Cs(t),a=Cs(o),l=Cs(n),c=Cs(i);if(Hc(r),Gc(s),Wc(l),Bc(a),Zc(l,a),Kc(c),0===r||s>=r)return 0;const h=c/a;if(h>1)return 1===n?r-s:0;if(l<=1)return r*h;const d=r*Math.pow(1-h,l-1),u=r*Math.pow(1-h,l),g=u<s?d-s:d-u;return Math.max(g,0)},isExported:!0},vh={description:r("Discount rate of a security based on price."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Cs(e)),s=Math.trunc(Cs(t)),a=Cs(o),l=Cs(n),c=Math.trunc(Cs(i));Dc(r,s),Lc(c),Uc(a),Pc(l);return(l-a)/l/yc.compute(r,s,c)},isExported:!0},bh={description:r("Convert a decimal fraction to decimal value."),args:ps(`\n fractional_price (number) ${r("The price quotation given using fractional decimal conventions.")}\n unit (number) ${r("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Cs(e),n=Math.trunc(Cs(t));bs((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const i=Math.trunc(o);return i+(o-i)*(10**Math.ceil(Math.log10(n))/n)},isExported:!0},Sh={description:r("Convert a decimal value to decimal fraction."),args:ps(`\n decimal_price (number) ${r("The price quotation given as a decimal value.")}\n unit (number) ${r("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Cs(e),n=Math.trunc(Cs(t));bs((()=>n>0),r("The unit (%s) must be strictly positive.",n.toString()));const i=Math.trunc(o);return i+(o-i)*(n/10**Math.ceil(Math.log10(n)))},isExported:!0},Ch={description:r("Number of periods for an investment to reach a value."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=0){s=s||0;const a=Math.trunc(Cs(e)),l=Math.trunc(Cs(t)),c=Cs(o),h=Cs(n),d=Math.trunc(Cs(i)),u=Math.trunc(Cs(s));Dc(a,l),$c(d),Lc(u),bs((()=>c>=0),r("The rate (%s) must be positive or null.",c.toString())),bs((()=>h>=0),r("The yield (%s) must be positive or null.",h.toString()));const g=yc.compute(a,l,u),p=g-Math.trunc(g)||1/d,f=Math.ceil(g*d),m=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=f;e++){const t=(m+(e===f?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Eh={description:r("Annual effective interest rate."),args:ps(`\n nominal_rate (number) ${r("The nominal interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Cs(e),n=Math.trunc(Cs(t));return bs((()=>o>0),r("The nominal rate (%s) must be strictly greater than 0.",o.toString())),bs((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),Math.pow(1+o/n,n)-1},isExported:!0},wh={description:r("Future value of an annuity investment."),args:ps(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n present_value (number, default=0) ${r("The current value of the annuity.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Cs(e),s=Cs(t),a=Cs(o),l=Cs(n),c=Rs(i)?1:0;return r?-l*(1+r)**s-a*(1+r*c)*((1+r)**s-1)/r:-(l+a*s)},isExported:!0},yh={description:r("Future value of principal from series of rates."),args:ps(`\n principal (number) ${r("The amount of initial capital or value to compound against.")}\n rate_schedule (number, range<number>) ${r("A series of interest rates to compound against the principal.")}\n `),returns:["NUMBER"],compute:function(e,t){return Ns([t],((e,t)=>e*(1+Cs(t))),Cs(e))},isExported:!0},xh={description:r("Calculates effective interest rate."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested in the security.")}\n redemption (number) ${r("The amount to be received at maturity.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){const r=Math.trunc(Cs(e)),s=Math.trunc(Cs(t)),a=Cs(n),l=Cs(o);Dc(r,s),jc(l),Pc(a);return(a-l)/l/yc.compute(r,s,i)},isExported:!0},Rh={description:r("Payment on the principal of an investment."),args:ps(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,i=0,r=0){return Dh.compute(e,o,n,i,r)-kh.compute(e,t,o,n,i,r)},isExported:!0},Ih={description:r("Internal rate of return given periodic cashflows."),args:ps(`\n cashflow_amounts (number, range<number>) ${r("An array or range containing the income or payments associated with the investment.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const o=Cs(t);eh(o);let n=!1,i=!1,s=[];Os([e],(e=>{e>0&&(n=!0),e<0&&(i=!0),s.push(e)})),bs((()=>n&&i),r("The cashflow_amounts must include negative and positive values."));const a=s.shift();return ih((function(e){return function(e,t,o){const n=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*e**(n-i))),t*e**n)}(e,a,s)}),(function(e){return function(e,t,o){const n=o.length;let i=0;return o.reduce(((t,o)=>(i++,t+o*(n-i)*e**(n-i-1))),t*n*e**(n-1))}(e,a,s)}),o+1,20,1e-5)-1},isExported:!0},Th={description:r("Returns the interest paid at a particular period of an investment."),args:ps(`\n rate (number) ${r("The interest rate.")}\n period (number) ${r("The period for which you want to view the interest payment.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n){const i=Cs(e),s=Cs(t),a=Cs(o),l=Cs(n);bs((()=>0!==a),r("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(s/a))*i},isExported:!0},Ah={description:r("Modified Macaulay duration."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,r=0){return Ch.compute(e,t,o,n,i,r)/(1+Cs(n)/Math.trunc(Cs(i)))},isExported:!0},Oh={description:r("Modified internal rate of return."),args:ps(`\n cashflow_amounts (range<number>) ${r("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")}\n financing_rate (number) ${r("The interest rate paid on funds invested.")}\n reinvestment_return_rate (number) ${r("The return (as a percentage) earned on reinvestment of income received from the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Cs(t),i=Cs(o),s=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(Ze).map(Cs);var a;const l=s.length;let c=0,h=0;for(const e of Fe(0,l)){const t=s[e];t>=0?c+=t*(i+1)**(l-e-1):h+=t/(n+1)**e}bs((()=>0!==h&&0!==c),r("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},Mh={description:r("Annual nominal interest rate."),args:ps(`\n effective_rate (number) ${r("The effective interest rate per year.")}\n periods_per_year (number) ${r("The number of compounding periods per year.")}\n `),returns:["NUMBER"],compute:function(e,t){const o=Cs(e),n=Math.trunc(Cs(t));return bs((()=>o>0),r("The effective rate (%s) must must strictly greater than 0.",o.toString())),bs((()=>n>0),r("The number of periods by year (%s) must strictly greater than 0.",n.toString())),(Math.pow(o+1,1/n)-1)*n},isExported:!0},Nh={description:r("Number of payment periods for an investment."),args:ps(`\n rate (number) ${r("The interest rate.")}\n payment_amount (number) ${r("The amount of each payment made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Cs(e),s=Cs(t),a=Cs(o),l=Cs(n),c=Rs(i)?1:0;if(0===r)return-(l+a)/s;const h=s*(1+r*c)/r;return Math.log((h-l)/(a+h))/Math.log(1+r)},isExported:!0};const _h={description:r("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:ps(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow1 (number, range<number>) ${r("The first future cash flow.")}\n cashflow2 (number, range<number>, repeating) ${r("Additional future cash flows.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=Cs(e);return bs((()=>-1!==o),r("The discount (%s) must be different from -1.",o.toString())),function(e,t,o){let n=0;return _s(o,((t,o)=>(n++,t+o/(1+e)**n)),t)}(o,0,t)},isExported:!0},Fh={description:r("Computes the number of periods needed for an investment to reach a value."),args:ps(`\n rate (number) ${r("The rate at which the investment grows each period.")}\n present_value (number) ${r("The investment's current value.")}\n future_value (number) ${r("The investment's desired future value.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Cs(e),i=Cs(t),s=Cs(o);return zc(n),bs((()=>i>0),r("The present_value (%s) must be strictly positive.",i.toString())),bs((()=>s>0),r("The future_value (%s) must be strictly positive.",s.toString())),(Math.log(s)-Math.log(i))/Math.log(1+n)},isExported:!0},Dh={description:r("Periodic payment for an annuity investment."),args:ps(`\n rate (number) ${r("The annualized rate of interest.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Cs(t),s=Cs(e),a=Rs(i)?1:0;let l=Cs(n),c=Cs(o);if(Vc(r),0===s)return-(l+c)/r;let h=-(c*(1+s)**r+l);return h=h*s/((1+s*a)*((1+s)**r-1)),h},isExported:!0},kh={description:r("Payment on the principal of an investment."),args:ps(`\n rate (number) ${r("The annualized rate of interest.")}\n period (number) ${r("The amortization period, in terms of number of periods.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n,i=0,s=0){i=i||0,s=s||0;const a=Cs(o),l=Cs(e),c=Cs(t),h=Rs(s)?1:0,d=Cs(i),u=Cs(n);Vc(a),bs((()=>c>0&&c<=a),r("The period must be between 1 and number_of_periods",a.toString()));const g=Dh.compute(l,a,u,d,s);if(1===h&&1===c)return g;return g+-wh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},$h={description:r("Present value of an annuity investment."),args:ps(`\n rate (number) ${r("The interest rate.")}\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_amount (number) ${r("The amount per period to be paid.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n=0,i=0){n=n||0,i=i||0;const r=Cs(e),s=Cs(t),a=Cs(o),l=Cs(n),c=Rs(i)?1:0;return r?-(a*(1+r*c)*((1+r)**s-1)/r+l)/(1+r)**s:-(l+a*s)},isExported:!0},Lh={description:r("Price of a security paying periodic interest."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s,a=0){a=a||0;const l=Math.trunc(Cs(e)),c=Math.trunc(Cs(t)),h=Cs(o),d=Cs(n),u=Cs(i),g=Math.trunc(Cs(s)),p=Math.trunc(Cs(a));Dc(l,c),$c(g),Lc(p),bs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),bs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString())),Pc(u);const f=yc.compute(l,c,p)*g,m=Math.ceil(f),v=f-Math.floor(f)||1,b=1+d/g,S=100*h/g;if(1===m)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=m;e++)C+=S/b**(e-1+v);return u/b**(m-1+v)+C-S*(1-v)},isExported:!0},Ph={description:r("Price of a discount security."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the security at time of purchase.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Cs(e)),s=Math.trunc(Cs(t)),a=Cs(o),l=Cs(n),c=Math.trunc(Cs(i));Dc(r,s),Lc(c),Xc(a),Pc(l);return l-a*l*yc.compute(r,s,c)},isExported:!0},Uh={description:r("Calculates the price of a security paying interest at maturity, based on expected yield."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n yield (number) ${r("The expected annual yield of the security.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=0){s=s||0;const a=Math.trunc(Cs(e)),l=Math.trunc(Cs(t)),c=Math.trunc(Cs(o)),h=Cs(n),d=Cs(i),u=Math.trunc(Cs(s));kc(a,c),Dc(a,l),Lc(u),bs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),bs((()=>d>=0),r("The yield (%s) must be positive or null.",d.toString()));const g=yc.compute(a,l,u),p=yc.compute(a,c,u);return(100+yc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},Vh=.1,zh={description:r("Interest rate of an annuity investment."),args:ps(`\n number_of_periods (number) ${r("The number of payments to be made.")}\n payment_per_period (number) ${r("The amount per period to be paid.")}\n present_value (number) ${r("The current value of the annuity.")}\n future_value (number, default=0) ${r("The future value remaining after the final payment has been made.")}\n end_or_beginning (number, default=0) ${r("Whether payments are due at the end (0) or beginning (1) of each period.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the interest rate will be.")}\n `),returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,n=0,i=0,s=.1){n=n||0,i=i||0,s=s||Vh;const a=Cs(e),l=Cs(t),c=Rs(i)?1:0,h=Cs(s);let d=Cs(n),u=Cs(o);Vc(a),bs((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),r("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),eh(h),d-=l*c,u+=l*c;return ih((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),o=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},Bh={description:r("Amount received at maturity for a security."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n investment (number) ${r("The amount invested (irrespective of face value of each security).")}\n discount (number) ${r("The discount rate of the security invested in.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Cs(e)),s=Math.trunc(Cs(t)),a=Cs(o),l=Cs(n),c=Math.trunc(Cs(i));Dc(r,s),Lc(c),jc(a),Xc(l);return a/(1-l*yc.compute(r,s,c))},isExported:!0},Hh={description:r("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:ps(`\n number_of_periods (number) ${r("The number of periods.")}\n present_value (number) ${r("The present value of the investment.")}\n future_value (number) ${r("The future value of the investment.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Cs(e),i=Cs(t),r=Cs(o);return Vc(n),(r/i)**(1/n)-1},isExported:!0},Wh={description:r("Depreciation of an asset using the straight-line method."),args:ps(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(Cs(e)-Cs(t))/Cs(o)},isExported:!0},Gh={description:r("Depreciation via sum of years digit method."),args:ps(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n period (number) ${r("The single period within life for which to calculate depreciation.")}\n `),returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,n){const i=Cs(e),r=Cs(t),s=Cs(o),a=Cs(n);Wc(a),Bc(s),Zc(a,s);return(s-a+1)/(s*(s+1)/2)*(i-r)},isExported:!0},qh={description:r("Price of a US Treasury bill."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Math.trunc(Cs(e)),i=Math.trunc(Cs(t)),r=Cs(o);Dc(n,i),Qc(n,i),Xc(r),Yc(r);return 100*(1-r*yc.compute(n,i,2))},isExported:!0},Zh={description:r("Equivalent rate of return for a US Treasury bill."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n discount (number) ${r("The discount rate of the bill at time of purchase.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Math.trunc(Cs(e)),i=Math.trunc(Cs(t)),r=Cs(o);Dc(n,i),Qc(n,i),Xc(r),Yc(r);const s=oc.compute(i,n);if(s<=182)return 365*r/(360-r*s);const a=qh.compute(n,i,r)/100,l=s/(366===s?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},jh={description:r("The yield of a US Treasury bill based on price."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Math.trunc(Cs(e)),i=Math.trunc(Cs(t)),r=Cs(o);Dc(n,i),Qc(n,i),Uc(r);return(100-r)/r*(1/yc.compute(n,i,2))},isExported:!0},Xh={description:r("Variable declining balance. WARNING : does not handle decimal periods."),args:ps(`\n cost (number) ${r("The initial cost of the asset.")}\n salvage (number) ${r("The value of the asset at the end of depreciation.")}\n life (number) ${r("The number of periods over which the asset is depreciated.")}\n start (number) ${r("Starting period to calculate depreciation.")}\n end (number) ${r("Ending period to calculate depreciation.")}\n factor (number, default=2) ${r("The number of months in the first year of depreciation.")}\n no_switch (number, default=false) ${r("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=2,a=false){s=s||0;const l=Cs(e),c=Cs(t),h=Cs(o),d=Math.trunc(Cs(n)),u=Math.trunc(Cs(i)),g=Cs(s),p=Rs(a);if(Hc(l),Gc(c),function(e,t,o){Bc(o),bs((()=>e>=0),r("The start_period (%s) must be greater or equal than 0.",e.toString())),bs((()=>t>=0),r("The end_period (%s) must be greater or equal than 0.",t.toString())),bs((()=>e<=t),r("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),bs((()=>t<=o),r("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),Kc(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const f=g/h;if(f>=1)return d<1?l-c:0;let m=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=m*f,o=(m-c)/(h-e);!p&&o>t?(S=!0,v=o):v=t}const t=Math.max(m-v,c);e>=d&&(b+=m-t),m=t}return b},isExported:!0},Yh={description:r("Internal rate of return given non-periodic cash flows."),args:ps(`\n cashflow_amounts (range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n rate_guess (number, default=0.1) ${r("An estimate for what the internal rate of return will be.")}\n `),returns:["NUMBER"],compute:function(e,t,o=.1){const n=Cs(o=o||0),i=e.flat().map(Cs),s=t.flat().map(Cs);var a;th(e,t),a=i,bs((()=>a.some((e=>e>0))&&a.some((e=>e<0))),r("There must be both positive and negative values in cashflow_amounts.")),oh(s),eh(n);const l=new Map;for(const e of Fe(0,s.length)){const t=s[e];l.has(t)?l.set(t,l.get(t)+i[e]):l.set(t,i[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return ih((e=>{let t=h[0];for(const o of Fe(1,h.length)){const n=(c[0]-c[o])/365;t+=h[o]*(1+e)**n}return t}),(e=>{let t=0;for(const o of Fe(1,h.length)){const n=(c[0]-c[o])/365;t+=n*h[o]*(1+e)**(n-1)}return t}),n,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Kh={description:r("Net present value given to non-periodic cash flows.."),args:ps(`\n discount (number) ${r("The discount rate of the investment over one period.")}\n cashflow_amounts (number, range<number>) ${r("An range containing the income or payments associated with the investment.")}\n cashflow_dates (number, range<number>) ${r("An range with dates corresponding to the cash flows in cashflow_amounts.")}\n `),returns:["NUMBER"],compute:function(e,t,o){const n=Cs(e),i=Array.isArray(t)?t.flat().map(Es):[Es(t)],s=Array.isArray(o)?o.flat().map(Es):[Es(o)];if(Array.isArray(o)&&Array.isArray(t)?th(t,o):bs((()=>i.length===s.length),r("There must be the same number of values in cashflow_amounts and cashflow_dates.")),oh(s),zc(n),1===i.length)return i[0];const a=new Map;for(const e of Fe(0,s.length)){const t=s[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)));let h=c[0];for(const e of Fe(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+n)**t}return h},isExported:!0},Qh={description:r("Annual yield of a security paying periodic interest."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n frequency (number) ${r("The number of interest or coupon payments per year (1, 2, or 4).")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s,a=0){a=a||0;const l=Math.trunc(Cs(e)),c=Math.trunc(Cs(t)),h=Cs(o),d=Cs(n),u=Cs(i),g=Math.trunc(Cs(s)),p=Math.trunc(Cs(a));Dc(l,c),$c(g),Lc(p),bs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Uc(d),Pc(u);const f=yc.compute(l,c,p)*g,m=Math.ceil(f),v=f-Math.floor(f)||1,b=100*h/g;if(1===m){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=ih((function(e){return function(e,t,o,n,i,r){let s=r-(e+i*(1-t))*n**(o-1+t);for(let e=1;e<=o;e++)s+=i*n**(e-1);return s}(d,v,m,e,b,u)}),(function(e){return function(e,t,o,n,i){let r=-(e+i*(1-t))*(o-1+t)*n**(o-2+t);for(let e=1;e<=o;e++)r+=i*(e-1)*n**(e-2);return r}(d,v,m,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Jh={description:r("Annual yield of a discount security."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n price (number) ${r("The price at which the security is bought per 100 face value.")}\n redemption (number) ${r("The redemption amount per 100 face value, or par.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i=0){i=i||0;const r=Math.trunc(Cs(e)),s=Math.trunc(Cs(t)),a=Cs(o),l=Cs(n),c=Math.trunc(Cs(i));Dc(r,s),Lc(c),Uc(a),Pc(l);return(l/a-1)/yc.compute(e,t,i)},isExported:!0},ed={description:r("Annual yield of a security paying interest at maturity."),args:ps(`\n settlement (date) ${r("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")}\n maturity (date) ${r("The maturity or end date of the security, when it can be redeemed at face, or par value.")}\n issue (date) ${r("The date the security was initially issued.")}\n rate (number) ${r("The annualized rate of interest.")}\n price (number) ${r("The price at which the security is bought.")}\n day_count_convention (number, default=0 ) ${r("An indicator of what day count method to use.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n,i,s=0){s=s||0;const a=Math.trunc(Cs(e)),l=Math.trunc(Cs(t)),c=Math.trunc(Cs(o)),h=Cs(n),d=Cs(i),u=Math.trunc(Cs(s));Dc(a,l),Lc(u),bs((()=>a>=c),r("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),bs((()=>h>=0),r("The rate (%s) must be positive or null.",h.toString())),Uc(d);const g=yc.compute(c,l,u),p=yc.compute(c,a,u),f=yc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/f},isExported:!0};var td=Object.freeze({__proto__:null,ACCRINTM:rh,AMORLINC:sh,COUPDAYS:ah,COUPDAYBS:lh,COUPDAYSNC:ch,COUPNCD:hh,COUPNUM:dh,COUPPCD:uh,CUMIPMT:gh,CUMPRINC:ph,DB:fh,DDB:mh,DISC:vh,DOLLARDE:bh,DOLLARFR:Sh,DURATION:Ch,EFFECT:Eh,FV:wh,FVSCHEDULE:yh,INTRATE:xh,IPMT:Rh,IRR:Ih,ISPMT:Th,MDURATION:Ah,MIRR:Oh,NOMINAL:Mh,NPER:Nh,NPV:_h,PDURATION:Fh,PMT:Dh,PPMT:kh,PV:$h,PRICE:Lh,PRICEDISC:Ph,PRICEMAT:Uh,RATE:zh,RECEIVED:Bh,RRI:Hh,SLN:Wh,SYD:Gh,TBILLPRICE:qh,TBILLEQ:Zh,TBILLYIELD:jh,VDB:Xh,XIRR:Yh,XNPV:Kh,YIELD:Qh,YIELDDISC:Jh,YIELDMAT:ed});const od={description:r("Whether a value is an error other than #N/A."),args:ps(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},nd={description:r("Whether a value is an error."),args:ps(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},id={description:r("Whether a value is `true` or `false`."),args:ps(`value (any, lazy) ${r("The value to be verified as a logical TRUE or FALSE.")}`),returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},rd={description:r("Whether a value is the error #N/A."),args:ps(`value (any, lazy) ${r("The value to be verified as an error type.")}`),returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},sd={description:r("Whether a value is non-textual."),args:ps(`value (any, lazy) ${r("The value to be checked.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},ad={description:r("Whether a value is a number."),args:ps(`value (any, lazy) ${r("The value to be verified as a number.")}`),returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},ld={description:r("Whether a value is text."),args:ps(`value (any, lazy) ${r("The value to be verified as text.")}`),returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},cd={description:r("Whether the referenced cell is empty"),args:ps(`value (any, lazy) ${r("Reference to the cell that will be checked for emptiness.")}`),returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},hd={description:r("Returns the error value #N/A."),args:ps(""),returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var dd=Object.freeze({__proto__:null,ISERR:od,ISERROR:nd,ISLOGICAL:id,ISNA:rd,ISNONTEXT:sd,ISNUMBER:ad,ISTEXT:ld,ISBLANK:cd,NA:hd});const ud={description:r("Logical `and` operator."),args:ps(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that represent logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return Ds(e,(e=>(t=!0,o=o&&e,o))),bs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},gd={description:r("Returns value depending on logical expression."),args:ps(`\n logical_expression (boolean) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")}\n value_if_true (any, lazy) ${r("The value the function returns if logical_expression is TRUE.")}\n value_if_false (any, lazy, default=FALSE) ${r("The value the function returns if logical_expression is FALSE.")}\n `),returns:["ANY"],compute:function(e,t,o=(()=>!1)){const n=Rs(e)?t():o();return null==n?"":n},isExported:!0},pd={description:r("Value if it is not an error, otherwise 2nd argument."),args:ps(`\n value (any, lazy) ${r("The value to return if value itself is not an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an error.")}\n `),returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var o;try{return e().format}catch(e){return null===(o=t())||void 0===o?void 0:o.format}},compute:function(e,t=(()=>"")){let o;try{o=e()}catch(e){o=t()}return null==o?"":o},isExported:!0},fd={description:r("Value if it is not an #N/A error, otherwise 2nd argument."),args:ps(`\n value (any, lazy) ${r("The value to return if value itself is not #N/A an error.")}\n value_if_error (any, lazy, default=${r("An empty value")}) ${r("The value the function returns if value is an #N/A error.")}\n `),returns:["ANY"],compute:function(e,t=(()=>"")){let o;try{o=e()}catch(n){o=n.errorType===a.NotAvailable?t():e()}return null==o?"":o},isExported:!0},md={description:r("Returns a value depending on multiple logical expressions."),args:ps(`\n condition1 (boolean, lazy) ${r("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")}\n value1 (any, lazy) ${r("The returned value if condition1 is TRUE.")}\n condition2 (boolean, lazy, repeating) ${r("Additional conditions to be evaluated if the previous ones are FALSE.")}\n value2 (any, lazy, repeating) ${r("Additional values to be returned if their corresponding conditions are TRUE.")}\n `),returns:["ANY"],compute:function(...e){bs((()=>e.length%2==0),r("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Rs(e[t]())){const o=e[t+1]();return null!==o?o:""}throw new Error(r("No match."))},isExported:!0},vd={description:r("Returns opposite of provided logical value."),args:ps(`logical_expression (boolean) ${r("An expression or reference to a cell holding an expression that represents some logical value.")}\n `),returns:["BOOLEAN"],compute:function(e){return!Rs(e)},isExported:!0},bd={description:r("Logical `or` operator."),args:ps(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Ds(e,(e=>(t=!0,o=o||e,!o))),bs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Sd={description:r("Logical `xor` operator."),args:ps(`\n logical_expression1 (boolean, range<boolean>) ${r("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")}\n logical_expression2 (boolean, range<boolean>, repeating) ${r("More expressions that evaluate to logical values.")}\n `),returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Ds(e,(e=>(t=!0,o=o?!e:e,!0))),bs((()=>t),r("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Cd=Object.freeze({__proto__:null,AND:ud,IF:gd,IFERROR:pd,IFNA:fd,IFS:md,NOT:vd,OR:bd,XOR:Sd});const Ed={description:r("Column number of a specified cell."),args:ps(`cell_reference (meta, default=${r("The cell in which the formula is entered")}) ${r("The cell whose column number will be returned. Column A corresponds to 1.")}\n `),returns:["NUMBER"],compute:function(e){var t;const o=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));bs((()=>!!o),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return vo(o).left+1},isExported:!0},wd={description:r("Number of columns in a specified array or range."),args:ps(`range (meta) ${r("The range whose column count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=vo(e);return t.right-t.left+1},isExported:!0},yd={description:r("Horizontal lookup"),args:ps(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (range) ${r("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")}\n index (number) ${r("The row index of the value to be returned, where the first row in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,o,n=true){const i=Math.trunc(Cs(o)),s=ys(e);bs((()=>1<=i&&i<=t[0].length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Rs(n);let l;return l=a?Vs(t,s,"nextSmaller","asc",t.length,Us):zs(t,s,"strict",t.length,Us),bs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ws(e))),t[l][i-1]},isExported:!0},xd={description:r("Look up a value."),args:ps(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n search_array (range) ${r("One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.")}\n result_range (range, optional) ${r("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.")}\n `),returns:["ANY"],compute:function(e,t,o){let n=t.length,i=t[0].length;const s=ys(e),a=i>=n,l=Vs(t,s,"nextSmaller","asc",a?i:n,a?Ps:Us);return bs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ws(e))),void 0===o?a?t[n-1][l]:t[l][i-1]:(n=o.length,i=o[0].length,bs((()=>1===n||1===i),r("The result_range must be a single row or a single column.")),n>1?(bs((()=>l<=n-1),r("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),o[l][0]):(bs((()=>l<=i-1),r("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),o[0][l]))},isExported:!0},Rd={description:r("Position of item in range that matches value."),args:ps(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The one-dimensional array to be searched.")}\n search_type (number, default=1) ${r("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1){let n=Cs(o);const i=ys(e),s=t.length,a=t[0].length;bs((()=>1===s||1===a),r("The range must be a single row or a single column."));let l=-1;const c=1===s?Ps:Us,h=1===s?t[0].length:t.length;switch(n=Math.sign(n),n){case 1:l=Vs(t,i,"nextSmaller","asc",h,c);break;case 0:l=zs(t,i,"strict",h,c);break;case-1:l=Vs(t,i,"nextGreater","desc",h,c)}return bs((()=>l>=0),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ws(e))),l+1},isExported:!0},Id={description:r("Row number of a specified cell."),args:ps(`cell_reference (meta, default=${r("The cell in which the formula is entered by default")}) ${r("The cell whose row number will be returned.")}`),returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),bs((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return vo(e).top+1},isExported:!0},Td={description:r("Number of rows in a specified array or range."),args:ps(`range (meta) ${r("The range whose row count will be returned.")}`),returns:["NUMBER"],compute:function(e){const t=vo(e);return t.bottom-t.top+1},isExported:!0},Ad={description:r("Vertical lookup."),args:ps(`\n search_key (any) ${r("The value to search for. For example, 42, 'Cats', or I24.")}\n range (any, range) ${r("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")}\n index (number) ${r("The column index of the value to be returned, where the first column in range is numbered 1.")}\n is_sorted (boolean, default=true) ${r("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.")}\n `),returns:["ANY"],compute:function(e,t,o,n=true){const i=Math.trunc(Cs(o)),s=ys(e);bs((()=>1<=i&&i<=t.length),r("[[FUNCTION_NAME]] evaluates to an out of bounds range."));const a=Rs(n);let l;return l=a?Vs(t,s,"nextSmaller","asc",t[0].length,Ps):zs(t,s,"strict",t[0].length,Ps),bs((()=>l>-1),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ws(e))),t[i-1][l]},isExported:!0},Od={description:r("Search a range for a match and return the corresponding item from a second range."),args:ps(`\n search_key (any) ${r("The value to search for.")}\n lookup_range (any, range) ${r("The range to consider for the search. Should be a single column or a single row.")}\n return_range (any, range) ${r("The range containing the return value. Should have the same dimensions as lookup_range.")}\n if_not_found (any, lazy, optional) ${r("If a valid match is not found, return this value.")}\n match_mode (any, default=0) ${r("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")}\n search_mode (any, default=1) ${r("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. ")}\n\n `),returns:["ANY"],compute:function(e,t,o,n,i=0,s=1){const a=Math.trunc(Cs(i)),l=Math.trunc(Cs(s)),c=ys(e);bs((()=>1===t.length||1===t[0].length),r("lookup_range should be either a single row or single column.")),bs((()=>1===o.length||1===o[0].length),r("return_range should be either a single row or single column.")),bs((()=>o.length===t.length&&o[0].length===t[0].length),r("return_range should have the same dimensions as lookup_range.")),bs((()=>[-1,1,-2,2].includes(l)),r("searchMode should be a value in [-1, 1, -2, 2].")),bs((()=>[-1,0,1].includes(a)),r("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?Ps:Us,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=Vs(t,c,u,2===l?"asc":"desc",d,h)}else p=zs(t,c,u,d,h,g);if(-1!==p)return 1===t.length?o[0][p]:o[p][0];const f=null==n?void 0:n();return bs((()=>!!f),r("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",ws(e))),f},isExported:!0};var Md=Object.freeze({__proto__:null,COLUMN:Ed,COLUMNS:wd,HLOOKUP:yd,LOOKUP:xd,MATCH:Rd,ROW:Id,ROWS:Td,VLOOKUP:Ad,XLOOKUP:Od});const Nd={description:r("Sum of two numbers."),args:ps(`\n value1 (number) ${r("The first addend.")}\n value2 (number) ${r("The second addend.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Cs(e)+Cs(t)}},_d={description:r("Concatenation of two values."),args:ps(`\n value1 (string) ${r("The value to which value2 will be appended.")}\n value2 (string) ${r("The value to append to value1.")}\n `),returns:["STRING"],compute:function(e,t){return ws(e)+ws(t)},isExported:!0},Fd={description:r("One number divided by another."),args:ps(`\n dividend (number) ${r("The number to be divided.")}\n divisor (number) ${r("The number to divide by.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const o=Cs(t);return bs((()=>0!==o),r("The divisor must be different from zero.")),Cs(e)/o}};function Dd(e){return null==e}const kd={number:0,string:"",boolean:!1},$d={description:r("Equal."),args:ps(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for equality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return e=Dd(e)?kd[typeof t]:e,t=Dd(t)?kd[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function Ld(e,t,o){e=Dd(e)?kd[typeof t]:e,t=Dd(t)?kd[typeof e]:t,"number"!=typeof e&&(e=ws(e).toUpperCase()),"number"!=typeof t&&(t=ws(t).toUpperCase());const n=typeof e,i=typeof t;return"string"===n&&"number"===i||("string"!==i||"number"!==n)&&o(e,t)}const Pd={description:r("Strictly greater than."),args:ps(`\n value1 (any) ${r("The value to test as being greater than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Ld(e,t,((e,t)=>e>t))}},Ud={description:r("Greater than or equal to."),args:ps(`\n value1 (any) ${r("The value to test as being greater than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Ld(e,t,((e,t)=>e>=t))}},Vd={description:r("Less than."),args:ps(`\n value1 (any) ${r("The value to test as being less than value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Ud.compute(e,t)}},zd={description:r("Less than or equal to."),args:ps(`\n value1 (any) ${r("The value to test as being less than or equal to value2.")}\n value2 (any) ${r("The second value.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!Pd.compute(e,t)}},Bd={description:r("Difference of two numbers."),args:ps(`\n value1 (number) ${r("The minuend, or number to be subtracted from.")}\n value2 (number) ${r("The subtrahend, or number to subtract from value1.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Cs(e)-Cs(t)}},Hd={description:r("Product of two numbers"),args:ps(`\n factor1 (number) ${r("The first multiplicand.")}\n factor2 (number) ${r("The second multiplicand.")}\n `),returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Cs(e)*Cs(t)}},Wd={description:r("Not equal."),args:ps(`\n value1 (any) ${r("The first value.")}\n value2 (any) ${r("The value to test against value1 for inequality.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return!$d.compute(e,t)}},Gd={description:r("A number raised to a power."),args:ps(`\n base (number) ${r("The number to raise to the exponent power.")}\n exponent (number) ${r("The exponent to raise base to.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return Oa.compute(e,t)}},qd={description:r("A number with the sign reversed."),args:ps(`\n value (number) ${r("The number to have its sign reversed. Equivalently, the number to multiply by -1.")}\n `),computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Cs(e)}},Zd={description:r("Value interpreted as a percentage."),args:ps(`\n percentage (number) ${r("The value to interpret as a percentage.")}\n `),returns:["NUMBER"],compute:function(e){return Cs(e)/100}},jd={description:r("A specified number, unchanged."),args:ps(`\n value (any) ${r("The number to return.")}\n `),returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var Xd=Object.freeze({__proto__:null,ADD:Nd,CONCAT:_d,DIVIDE:Fd,EQ:$d,GT:Pd,GTE:Ud,LT:Vd,LTE:zd,MINUS:Bd,MULTIPLY:Hd,NE:Wd,POW:Gd,UMINUS:qd,UNARY_PERCENT:Zd,UPLUS:jd});const Yd=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Kd={description:r("Gets character associated with number."),args:ps(`\n table_number (number) ${r("The number of the character to look up from the current Unicode table in decimal format.")}\n `),returns:["STRING"],compute:function(e){const t=Math.trunc(Cs(e));return bs((()=>t>=1),r("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Qd={description:r("Remove non-printable characters from a piece of text."),args:ps(`\n text (string) ${r("The text whose non-printable characters are to be removed.")}\n `),returns:["STRING"],compute:function(e){const t=ws(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Jd={description:r("Appends strings to one another."),args:ps(`\n string1 (string, range<string>) ${r("The initial string.")}\n string2 (string, range<string>, repeating) ${r("More strings to append in sequence.")}\n `),returns:["STRING"],compute:function(...e){return Ns(e,((e,t)=>e+ws(t)),"")},isExported:!0},eu={description:r("Tests whether two strings are identical."),args:ps(`\n string1 (string) ${r("The first string to compare.")}\n string2 (string) ${r("The second string to compare.")}\n `),returns:["BOOLEAN"],compute:function(e,t){return ws(e)===ws(t)},isExported:!0},tu={description:r("First position of string found in text, case-sensitive."),args:ps(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1){const n=ws(e),i=ws(t),s=Cs(o);bs((()=>""!==i),r("The text_to_search must be non-empty.")),bs((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=i.indexOf(n,s-1);return bs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n.toString(),i)),a+1},isExported:!0},ou={description:r("Concatenates elements of arrays with delimiter."),args:ps(`\n delimiter (string) ${r("The character or string to place between each concatenated value.")}\n value_or_array1 (string, range<string>) ${r("The value or values to be appended using delimiter.")}\n value_or_array2 (string, range<string>, repeating) ${r("More values to be appended using delimiter.")}\n `),returns:["STRING"],compute:function(e,...t){const o=ws(e);return Ns(t,((e,t)=>(e?e+o:"")+ws(t)),"")}},nu={description:r("Substring from beginning of specified string."),args:ps(`\n text (string) ${r("The string from which the left portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the left side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const o=t.length?Cs(t[0]):1;return bs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString())),ws(e).substring(0,o)},isExported:!0},iu={description:r("Length of a string."),args:ps(`\n text (string) ${r("The string whose length will be returned.")}\n `),returns:["NUMBER"],compute:function(e){return ws(e).length},isExported:!0},ru={description:r("Converts a specified string to lowercase."),args:ps(`\n text (string) ${r("The string to convert to lowercase.")}\n `),returns:["STRING"],compute:function(e){return ws(e).toLowerCase()},isExported:!0},su={description:r("A segment of a string."),args:ps(`\n text (string) ${r("The string to extract a segment from.")}\n starting_at (number) ${r("The index from the left of string from which to begin extracting. The first character in string has the index 1.")}\n extract_length (number) ${r("The length of the segment to extract.")}\n `),returns:["STRING"],compute:function(e,t,o){const n=ws(e),i=Cs(t),s=Cs(o);return bs((()=>i>=1),r("The starting_at argument (%s) must be positive greater than one.",i.toString())),bs((()=>s>=0),r("The extract_length argument (%s) must be positive or null.",s.toString())),n.slice(i-1,i+s-1)},isExported:!0},au={description:r("Capitalizes each word in a specified string."),args:ps(`\n text_to_capitalize (string) ${r("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.")}\n `),returns:["STRING"],compute:function(e){return ws(e).replace(Yd,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},lu={description:r("Replaces part of a text string with different text."),args:ps(`\n text (string) ${r("The text, a part of which will be replaced.")}\n position (number) ${r("The position where the replacement will begin (starting from 1).")}\n length (number) ${r("The number of characters in the text to be replaced.")}\n new_text (string) ${r("The text which will be inserted into the original text.")}\n `),returns:["STRING"],compute:function(e,t,o,n){const i=Cs(t);bs((()=>i>=1),r("The position (%s) must be greater than or equal to 1.",i.toString()));const s=ws(e),a=Cs(o),l=ws(n);return s.substring(0,i-1)+l+s.substring(i-1+a)},isExported:!0},cu={description:r("A substring from the end of a specified string."),args:ps(`\n text (string) ${r("The string from which the right portion will be returned.")}\n number_of_characters (number, optional) ${r("The number of characters to return from the right side of string.")}\n `),returns:["STRING"],compute:function(e,...t){const o=t.length?Cs(t[0]):1;bs((()=>o>=0),r("The number_of_characters (%s) must be positive or null.",o.toString()));const n=ws(e),i=n.length;return n.substring(i-o,i)},isExported:!0},hu={description:r("First position of string found in text, ignoring case."),args:ps(`\n search_for (string) ${r("The string to look for within text_to_search.")}\n text_to_search (string) ${r("The text to search for the first occurrence of search_for.")}\n starting_at (number, default=1) ${r("The character within text_to_search at which to start the search.")}\n `),returns:["NUMBER"],compute:function(e,t,o=1){const n=ws(e).toLowerCase(),i=ws(t).toLowerCase(),s=Cs(o);bs((()=>""!==i),r("The text_to_search must be non-empty.")),bs((()=>s>=1),r("The starting_at (%s) must be greater than or equal to 1.",s.toString()));const a=i.indexOf(n,s-1);return bs((()=>a>=0),r("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",n,i)),a+1},isExported:!0},du={description:r("Replaces existing text with new text in a string."),args:ps(`\n text_to_search (string) ${r("The text within which to search and replace.")}\n search_for (string) ${r("The string to search for within text_to_search.")}\n replace_with (string) ${r("The string that will replace search_for.")}\n occurrence_number (number, optional) ${r("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.")}\n `),returns:["NUMBER"],compute:function(e,t,o,n){const i=Cs(n);bs((()=>i>=0),r("The occurrenceNumber (%s) must be positive or null.",i.toString()));const s=ws(e),a=ws(t);if(""===a)return s;const l=ws(o),c=new RegExp(Re(a),"g");if(0===i)return s.replace(c,l);let h=0;return s.replace(c,(e=>++h===i?l:e))},isExported:!0},uu={description:r("Combines text from multiple strings and/or arrays."),args:ps(`\n delimiter (string) ${r(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")}\n ignore_empty (boolean) ${r("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")}\n text1 (string, range<string>) ${r("Any text item. This could be a string, or an array of strings in a range.")}\n text2 (string, range<string>, repeating) ${r("Additional text item(s).")}\n `),returns:["STRING"],compute:function(e,t,...o){const n=ws(e),i=Rs(t);let r=0;return Ns(o,((e,t)=>i&&""===ws(t)?e:(r++?e+n:"")+ws(t)),"")},isExported:!0},gu={description:r("Removes space characters."),args:ps(`\n text (string) ${r("The text or reference to a cell containing text to be trimmed.")}\n `),returns:["STRING"],compute:function(e){return ws(e).trim()},isExported:!0},pu={description:r("Converts a specified string to uppercase."),args:ps(`\n text (string) ${r("The string to convert to uppercase.")}\n `),returns:["STRING"],compute:function(e){return ws(e).toUpperCase()},isExported:!0},fu={description:r("Converts a number to text according to a specified format."),args:ps(`\n number (number) ${r("The number, date or time to format.")}\n format (string) ${r("The pattern by which to format the number, enclosed in quotation marks.")}\n `),returns:["STRING"],compute:function(e,t){return Vt(Cs(e),ws(t))},isExported:!0};const mu={database:Ql,date:Nc,financial:td,info:dd,lookup:Md,logical:Cd,math:Za,misc:Ws,operators:Xd,statistical:Ll,text:Object.freeze({__proto__:null,CHAR:Kd,CLEAN:Qd,CONCATENATE:Jd,EXACT:eu,FIND:tu,JOIN:ou,LEFT:nu,LEN:iu,LOWER:ru,MID:su,PROPER:au,REPLACE:lu,RIGHT:cu,SEARCH:hu,SUBSTITUTE:du,TEXTJOIN:uu,TRIM:gu,UPPER:pu,TEXT:fu}),engineering:Fc},vu=/^[A-Z0-9\_\.]+$/;function bu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Su(e()):Su(e)}))}function Su(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Cu=new class extends Bo{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(vu))throw new Error(r("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=ms(t);return function(e){let t=!1,o=!1,n=!1;for(let i of e){if(i.type.includes("META")&&i.type.length>1)throw new Error(r("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!i.repeating)throw new Error(r("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=o||t||n,s=!(i.optional||i.repeating||i.default);if(e&&s)throw new Error(r("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=i.repeating,o=i.optional,n=i.default}}(o.args),this.mapping[e]=function(...e){const t=o.compute.bind(this),n=o.computeFormat?o.computeFormat.bind(this):()=>{};return{value:t(...bu(e)),format:n(...e)}},super.add(e,o),this}};for(let e in mu){const t=mu[e];for(let o in t){const n=t[o];n.category=e,o=o.replace(/_/g,"."),Cu.add(o,{isExported:!1,...n})}}const Eu=Cu.content,wu=["%"],yu="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(wu);function xu(e){const t=e.split(""),o=[];for(;t.length;){let e=ku(t)||Tu(t)||Ou(t)||Nu(t)||Ru(t)||$u(t)||Mu(t)||Fu(t);e||(e={type:"UNKNOWN",value:t.shift()}),o.push(e)}return o}function Ru(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Iu={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Tu(e){if(e[0]in Iu){const t=e.shift();return{type:Iu[t],value:t}}return null}function Au(e,t){for(let o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function Ou(e){for(let t of yu)if(Au(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Mu(e){const t=Ke(e).match(eo);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Nu(e){if('"'===e[0]){const t=e.shift();let o=t;for(;e[0]&&(e[0]!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e[0]&&(o+=e.shift()),{type:"STRING",value:o}}return null}const _u=/\w|\.|!|\$/;function Fu(e){let t="";if("'"===e[0]){let o=e.shift();for(t+=o;e[0];)if(o=e.shift(),t+=o,"'"===o){if(!e[0]||"'"!==e[0])break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(_u);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Eu)return{type:"FUNCTION",value:e};return e.match(Et)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}const Du=/\s/;function ku(e){let t=0;for(;e[0]&&e[0].match(Du);)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function $u(e){return Au(e,X)?(e.splice(0,X.length),{type:"INVALID_REFERENCE",value:X}):null}const Lu=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Pu=["-","+"],Uu=["%"],Vu=["*","+","&"],zu={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10},Bu=6;function Hu(e){switch(e.type){case"NUMBER":case"SYMBOL":case"REFERENCE":return 0;case"COMMA":return 3;case"LEFT_PAREN":case"RIGHT_PAREN":return 5;case"OPERATOR":return zu[e.value]||15}throw new Error(r("Unknown token: %s",e.value))}function Wu(e,t,o){if("OPERATOR"===t.type){const n=Hu(t);if(Uu.includes(t.value))return{type:"UNARY_OPERATION",value:t.value,operand:e,postfix:!0};{const i=Gu(o,n);return{type:"BIN_OPERATION",value:t.value,left:e,right:i}}}throw new Error(oe)}function Gu(e,t){const o=e.shift();if(!o)throw new Error(oe);let n=function(e,t){var o,n,i,s;switch(e.type){case"DEBUGGER":const a=Gu(t,1e3);return a.debug=!0,a;case"NUMBER":return{type:"NUMBER",value:lo(e.value)};case"STRING":return{type:"STRING",value:xe(e.value)};case"FUNCTION":if("LEFT_PAREN"!==t.shift().type)throw new Error(r("Wrong function call"));{const n=[];if(t[0]&&"RIGHT_PAREN"!==t[0].type)for("COMMA"===t[0].type?n.push({type:"UNKNOWN",value:""}):n.push(Gu(t,Bu));"COMMA"===(null===(o=t[0])||void 0===o?void 0:o.type);){t.shift();const e=t[0];if("RIGHT_PAREN"===(null==e?void 0:e.type)){n.push({type:"UNKNOWN",value:""});break}"COMMA"===(null==e?void 0:e.type)?n.push({type:"UNKNOWN",value:""}):n.push(Gu(t,Bu))}const i=t.shift();if(!i||"RIGHT_PAREN"!==i.type)throw new Error(r("Wrong function call"));return{type:"FUNCALL",value:e.value,args:n}}case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(n=t[0])||void 0===n?void 0:n.value)&&"REFERENCE"===(null===(i=t[1])||void 0===i?void 0:i.type)){t.shift();const o=t.shift();return{type:"REFERENCE",value:`${e.value}:${null==o?void 0:o.value}`}}return{type:"REFERENCE",value:e.value};case"SYMBOL":if(["TRUE","FALSE"].includes(e.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===e.value.toUpperCase()};if(e.value){if(Lu.test(e.value)&&"LEFT_PAREN"===(null===(s=t[0])||void 0===s?void 0:s.type))throw new p(e.value);throw new Error(r("Invalid formula"))}return{type:"STRING",value:e.value};case"LEFT_PAREN":const l=Gu(t,5);if(!t.length||"RIGHT_PAREN"!==t[0].type)throw new Error(r("Unmatched left parenthesis"));return t.shift(),l;default:if("OPERATOR"===e.type&&Pu.includes(e.value))return{type:"UNARY_OPERATION",value:e.value,operand:Gu(t,zu[e.value])};throw new Error(r("Unexpected token: %s",e.value))}}(o,e);for(;e[0]&&Hu(e[0])>t;)n=Wu(n,e.shift(),e);return n}function qu(e){return Zu(xu(e))}function Zu(e){"OPERATOR"===(e=e.filter((e=>"SPACE"!==e.type)))[0].type&&"="===e[0].value&&e.splice(0,1);const t=Gu(e,0);if(e.length)throw new Error(oe);return t}function ju(e,t,o){switch(t===e.type&&(e=o(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>ju(e,t,o)))};case"UNARY_OPERATION":return{...e,operand:ju(e.operand,t,o)};case"BIN_OPERATION":return{...e,right:ju(e.right,t,o),left:ju(e.left,t,o)};default:return e}}function Xu(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Xu(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?Yu(e)+e.value:e.value+Ku(e);case"BIN_OPERATION":return Yu(e)+e.value+Ku(e)}}function Yu(e){const t=e.value,o="left"in e?e.left:e.operand,n=o.value;return"BIN_OPERATION"===o.type&&zu[n]<zu[t]?`(${Xu(o)})`:Xu(o)}function Ku(e){const t=e.value,o="right"in e?e.right:e.operand,n=zu[o.value],i=zu[t];let r=!1;return"BIN_OPERATION"!==o.type?r=!1:n<i?r=!0:n!==i||Vu.includes(t)||(r=!0),r?`(${Xu(o)})`:Xu(o)}var Qu;!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"}(Qu||(Qu={}));const Ju=(e,t=(()=>!0))=>[{goTo:e,guard:t}],eg=(e,t=(()=>!0))=>({goTo:e,guard:t}),tg={[Qu.LeftRef]:{REFERENCE:Ju(Qu.Separator),NUMBER:Ju(Qu.FullRowSeparator),SYMBOL:[eg(Qu.FullColumnSeparator,(e=>wt(e.value))),eg(Qu.FullRowSeparator,(e=>yt(e.value)))]},[Qu.FullColumnSeparator]:{SPACE:Ju(Qu.FullColumnSeparator),OPERATOR:Ju(Qu.RightColumnRef,(e=>":"===e.value))},[Qu.FullRowSeparator]:{SPACE:Ju(Qu.FullRowSeparator),OPERATOR:Ju(Qu.RightRowRef,(e=>":"===e.value))},[Qu.Separator]:{SPACE:Ju(Qu.Separator),OPERATOR:Ju(Qu.RightRef,(e=>":"===e.value))},[Qu.RightRef]:{SPACE:Ju(Qu.RightRef),NUMBER:Ju(Qu.Found),REFERENCE:Ju(Qu.Found,(e=>Rt(e.value))),SYMBOL:Ju(Qu.Found,(e=>xt(e.value)))},[Qu.RightColumnRef]:{SPACE:Ju(Qu.RightColumnRef),SYMBOL:Ju(Qu.Found,(e=>xt(e.value))),REFERENCE:Ju(Qu.Found,(e=>Rt(e.value)))},[Qu.RightRowRef]:{SPACE:Ju(Qu.RightRowRef),NUMBER:Ju(Qu.Found),REFERENCE:Ju(Qu.Found,(e=>Rt(e.value)))},[Qu.Found]:{}};function og(e){var t;let o=0,n=tg[Qu.LeftRef];const i=[];for(;void 0!==n;){const r=e[o++];if(!r)return null;const s=null===(t=n[r.type])||void 0===t?void 0:t.find((e=>e.guard(r))),a=s?s.goTo:void 0;switch(a){case void 0:return null;case Qu.Found:return i.push(r),e.splice(0,o),{type:"REFERENCE",value:Ke(i.map((e=>e.value)))};default:n=tg[a],i.push(r)}}return null}function ng(e){const t=xu(e),o=[];for(;t.length;)o.push(og(t)||t.shift());return o}const ig=Cu.content,rg={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},sg={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"};function ag(e){return e.join("\n").split("\n").filter((e=>""!==e.trim()))}const lg={};function cg(e){const t=ng(e),{dependencies:o,constantValues:n}=function(e){const t={numbers:[],strings:[]},o=[];for(const n of e)switch(n.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(n.value);break;case"STRING":const e=xe(n.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=lo(n.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:o,constantValues:t}}(t),i=function(e,t,o){return Ke(e.map((e=>{switch(e.type){case"STRING":const n=xe(e.value);return`|S${o.strings.indexOf(n)}|`;case"NUMBER":return`|N${o.numbers.indexOf(lo(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,o,n);if(!lg[i]){const s=Zu([...t]);let a=1;if("BIN_OPERATION"===s.type&&":"===s.value)throw new Error(r("Invalid formula"));if("UNKNOWN"===s.type)throw new Error(r("Invalid formula"));const l=u(s),c=ag([`// ${i}`,l.code,`return ${l.id};`]).join("\n");let h=new Function("deps","ref","range","ctx",c);function d(e){const t=ig[e.value.toUpperCase()],o=e.args,n=o.length;if(n<t.minArgRequired)throw new Error(r("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),n.toString()));if(n>t.maxArgPossible)throw new Error(r("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),n.toString()));const i=t.nbrArgRepeating;if(i>1){const o=t.args.length-i;if((n-o)%i!=0)throw new Error(r("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),o.toString(),i.toString()))}let s=[];for(let i=0;i<n;i++){const n=t.getArgToFocus(i+1)-1;if(0<=n&&n<t.args.length){const a=o[i],l=t.args[n],c=l.type||[],h=c.includes("META"),d=l.lazy,g=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),p=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(p&&"REFERENCE"!==a.type)throw new Error(r("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(i+1).toString(),a.type.toLowerCase()));const f=u(a,d,h,g,{functionName:e.value.toUpperCase(),paramIndex:i+1});s.push(f)}}return s}function u(e,t=!1,i=!1,s=!1,l={}){const c=[];let h,g,p;if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&i)throw new Error(r("Argument must be a reference to a cell or range."));switch(e.debug&&c.push("debugger;"),e.type){case"BOOLEAN":if(!t)return{id:`{ value: ${e.value} }`,code:""};h=a++,p=`{ value: ${e.value} }`;break;case"NUMBER":h=a++,p=`{ value: this.constantValues.numbers[${n.numbers.indexOf(e.value)}] }`;break;case"STRING":h=a++,p=`{ value: this.constantValues.strings[${n.strings.indexOf(e.value)}] }`;break;case"REFERENCE":const r=o.indexOf(e.value);h=a++,p=s?`range(deps[${r}])`:`ref(deps[${r}], ${i?"true":"false"}, "${l.functionName||rg["="]}", ${l.paramIndex})`;break;case"FUNCALL":h=a++;const f=d(e);c.push(f.map((e=>e.code)).join("\n")),g=e.value.toUpperCase(),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${f.map((e=>e.id))})`;break;case"UNARY_OPERATION":{h=a++,g=sg[e.value];const t=u(e.operand,!1,!1,!1,{functionName:g});c.push(t.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id})`;break}case"BIN_OPERATION":{h=a++,g=rg[e.value];const t=u(e.left,!1,!1,!1,{functionName:g}),o=u(e.right,!1,!1,!1,{functionName:g});c.push(t.code),c.push(o.code),c.push(`ctx.__lastFnCalled = '${g}';`),p=`ctx['${g}'](${t.id}, ${o.id})`;break}case"UNKNOWN":if(!t)return{id:"undefined",code:""};h=a++,p="undefined"}if(t){return{id:`_${h}`,code:`const _${h} = () => {\n\t${ag(c).join("\n\t")}\n\treturn ${p};\n}`}}return c.push(`let _${h} = ${p};`),{id:`_${h}`,code:c.join("\n")}}lg[i]={execute:h}}return{execute:lg[i].execute,dependencies:o,constantValues:n,tokens:t}}function hg(e){return function(e){let t=[],o="";return e.map(((e,n)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"FUNCTION":o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0}),o="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}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,n=Object.assign({},e,{start:t,end:t+o,length:o});return t=n.end,n}))}(ng(e))))}function dg(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=It(e.value),[n,i]=t.split(":"),r=o?`${Ae(o)}!`:"",s=ug(n),a=i?`:${ug(i)}`:"";return{...e,value:r+s+a}}function ug(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=gg(e,"colrow");break;case"colrow":e=gg(e,"row");break;case"row":e=gg(e,"col");break;case"col":e=gg(e,"none")}return e}function gg(e,t){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]/),"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}class pg{constructor(e,t,o){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const n=e.filter((e=>0!==e));if(n.length)return n}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}pg.getters=[];class fg extends pg{constructor(e,t,o,n,i){super(t,o,n),this.getters=e,this.ui=n,this.selection=i}drawGrid(e,t){}}fg.layers=[];const mg=r("The cell you are trying to edit has been deleted.");class vg extends fg{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=this.getters.getActiveCell(),o=e.text||(null==t?void 0:t.composerContent)||"";return this.validateSelection(o.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:n}=It(e.value),i=n||this.getters.getSheetName(this.sheetId),r=this.getters.getActiveSheetId();if(this.getters.getSheetName(r)!==i)return!1;const s=this.getters.getRangeFromSheetXC(r,o);return Io(this.getters.expandZone(r,s.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const n=this.getters.getRangeFromRangeData(e.range),i=this.getRangeReference(n,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(i),this.previousRef=i,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Po({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:n})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:mg}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}unsubscribe(){this.mode="inactive"}getEditionMode(){return this.mode}getCurrentContent(){if("inactive"===this.mode){const e=this.getters.getActiveCell();return(null==e?void 0:e.composerContent)||""}return this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(dg).map((e=>e.value)).join(""),n=this.currentContent,i=e[0].start,r=e[e.length-1].end,s=n.slice(0,i)+o+n.slice(r),a=s.length-n.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:s,selection:l})}validateSelection(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e?0:45}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:mg});const{top:t,left:o}=wo({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:mg});const{top:t,left:o}=wo({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=Eo({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Po({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var o;const n=this.getters.getActiveCell();e&&(null===(o=null==n?void 0:n.format)||void 0===o?void 0:o.includes("%"))&&so(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`),this.initialContent=(null==n?void 0:n.composerContent)||"",this.mode="editing";const{col:i,row:r}=this.getters.getPosition();this.col=i,this.row=r,this.sheetId=this.getters.getActiveSheetId(),this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const s=Po({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:s},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){const e=this.getters.getActiveSheetId();this.cancelEditionAndActivateSheet();const{col:t,row:o}=this.getters.getMainCellPosition(this.sheetId,this.col,this.row);let n=this.currentContent;if(!(this.initialContent!==n))return;if(n){const i=this.getters.getCell(e,t,o);if(n.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,o=e-t;o>0&&(n+=Ke(new Array(o).fill(")")))}else(null==i?void 0:i.isLink())&&(n=ze(n,i.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:t,row:o,content:n})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:t,row:o});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const n=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(n||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?hg(e):[],this.currentTokens.length>100&&o&&this.ui.notifyUI({type:"ERROR",text:r("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const o=this.getters.getActiveSheetId();let n=this.getters.zoneToXC(o,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){n=`${Ae(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${n}`}return n}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){1===t.length&&Vo(e.zone)>1?t.push({...t[0]}):2===t.length&&1===Vo(e.zone)&&t.pop();const o=e.clone({parts:this.previousRange.parts});return this.getters.getSelectionRangeString(o,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),n=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:n,end:n}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const n=new Set(Object.values(o));let i=0;const r=()=>{for(;n.has(i);)i++;return n.add(i),i};for(const e of t){const t=e in o?o[e]:r();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return it[t%it.length]};return this.getReferencedRanges().map((o=>{const n=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(n),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,n=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(n.type)||wu.includes(n.value);){if("SPACE"!==n.type||o<1)return!1;o--,n=this.currentTokens[o]}for(o=t+1,n=this.currentTokens[o];n&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(n.type);){if("SPACE"!==n.type)return!1;o++,n=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}vg.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights"];const bg=Cu.content,Sg=new Bo;Sg.add("functions",(()=>Object.keys(bg).map((e=>({text:e,description:bg[e].description}))))),an`
963
963
  .o-autocomplete-dropdown {
964
964
  pointer-events: auto;
965
965
  background-color: #fff;
@@ -983,7 +983,7 @@
983
983
  }
984
984
  }
985
985
  }
986
- `;class Sg extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}setup(){t.onMounted((()=>this.filter(this.props.search))),t.onWillUpdateProps((e=>this.checkUpdateProps(e))),this.props.exposeAPI({getValueToFill:()=>this.getValueToFill(),moveDown:()=>this.moveDown(),moveUp:()=>this.moveUp()})}checkUpdateProps(e){e.search!==this.props.search&&this.filter(e.search)}async filter(e){let t=bg.get(this.props.provider)();t=this.props.filter?this.props.filter(e,t):t.filter((t=>t.text.toUpperCase().startsWith(e.toUpperCase()))).sort(((e,t)=>e.text<t.text?-1:e.text>t.text?1:0)),this.state.values=t.slice(0,10),this.state.selectedIndex=0}fillValue(e){this.state.selectedIndex=e,this.props.onCompleted(this.getValueToFill())}moveDown(){this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.values.length}moveUp(){this.state.selectedIndex--,this.state.selectedIndex<0&&(this.state.selectedIndex=this.state.values.length-1)}getValueToFill(){if(this.state.values.length)return this.state.values[this.state.selectedIndex].text}}Sg.template="o-spreadsheet-TextValueProvider";class Cg{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let o=window.getSelection();this.removeSelection();let n=document.createRange();if(e==t&&0===e)n.setStart(this.el,0),n.setEnd(this.el,0),o.addRange(n);else{(e<0||t>this.el.textContent.length)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${this.el.textContent.length}`),e<0&&(e=0),t>this.el.textContent.length&&(t=this.el.textContent.length));let i=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);n.setStart(i.node,i.offset),o.addRange(n),o.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,o,n=this.iterateChildren(this.el),i=e;do{t=n.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<i?i-=t.value.textContent.length:n.return(t.value),o=t.value)}while(!t.done);return t.value?{node:t.value,offset:i}:{node:o,offset:i}}*iterateChildren(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*this.iterateChildren(t)}setText(e){if(0!==e.length)for(const t of e){const e=document.createElement("span");e.innerText=t.value,t.color&&(e.style.color=t.color),t.class&&e.classList.add(t.class),this.el.appendChild(e)}}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:o,endSelectionOffset:n}=this.getStartAndEndSelection();return{start:this.findSizeBeforeElement(e)+o,end:this.findSizeBeforeElement(t)+n}}findSizeBeforeElement(e){let t=this.iterateChildren(this.el),o=0,n=t.next();for(;!n.done&&n.value!==e;)n.value.hasChildNodes()||n.value.textContent&&(o+=n.value.textContent.length),n=t.next();return o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}sn`
986
+ `;class Cg extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],selectedIndex:0})}setup(){t.onMounted((()=>this.filter(this.props.search))),t.onWillUpdateProps((e=>this.checkUpdateProps(e))),this.props.exposeAPI({getValueToFill:()=>this.getValueToFill(),moveDown:()=>this.moveDown(),moveUp:()=>this.moveUp()})}checkUpdateProps(e){e.search!==this.props.search&&this.filter(e.search)}async filter(e){let t=Sg.get(this.props.provider)();t=this.props.filter?this.props.filter(e,t):t.filter((t=>t.text.toUpperCase().startsWith(e.toUpperCase()))).sort(((e,t)=>e.text<t.text?-1:e.text>t.text?1:0)),this.state.values=t.slice(0,10),this.state.selectedIndex=0}fillValue(e){this.state.selectedIndex=e,this.props.onCompleted(this.getValueToFill())}moveDown(){this.state.selectedIndex=(this.state.selectedIndex+1)%this.state.values.length}moveUp(){this.state.selectedIndex--,this.state.selectedIndex<0&&(this.state.selectedIndex=this.state.values.length-1)}getValueToFill(){if(this.state.values.length)return this.state.values[this.state.selectedIndex].text}}Cg.template="o-spreadsheet-TextValueProvider";class Eg{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let o=window.getSelection();this.removeSelection();let n=document.createRange();if(e==t&&0===e)n.setStart(this.el,0),n.setEnd(this.el,0),o.addRange(n);else{(e<0||t>this.el.textContent.length)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${this.el.textContent.length}`),e<0&&(e=0),t>this.el.textContent.length&&(t=this.el.textContent.length));let i=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);n.setStart(i.node,i.offset),o.addRange(n),o.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,o,n=this.iterateChildren(this.el),i=e;do{t=n.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<i?i-=t.value.textContent.length:n.return(t.value),o=t.value)}while(!t.done);return t.value?{node:t.value,offset:i}:{node:o,offset:i}}*iterateChildren(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*this.iterateChildren(t)}setText(e){if(0!==e.length)for(const t of e){const e=document.createElement("span");e.innerText=t.value,t.color&&(e.style.color=t.color),t.class&&e.classList.add(t.class),this.el.appendChild(e)}}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:o,endSelectionOffset:n}=this.getStartAndEndSelection();return{start:this.findSizeBeforeElement(e)+o,end:this.findSizeBeforeElement(t)+n}}findSizeBeforeElement(e){let t=this.iterateChildren(this.el),o=0,n=t.next();for(;!n.done&&n.value!==e;)n.value.hasChildNodes()||n.value.textContent&&(o+=n.value.textContent.length),n=t.next();return o}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}}an`
987
987
  .o-formula-assistant {
988
988
  white-space: normal;
989
989
  background-color: #fff;
@@ -1030,7 +1030,7 @@
1030
1030
  .o-formula-assistant-transparency {
1031
1031
  opacity: 0.3;
1032
1032
  }
1033
- `;class Eg extends t.Component{constructor(){super(...arguments),this.assistantState=t.useState({allowCellSelectionBehind:!1}),this.timeOutId=0}setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}Eg.template="o-spreadsheet-FunctionDescriptionProvider";const wg=Su.content,yg="#4a4e4d",xg="#3da4ab",Rg="#02c39a",Ig="selector-flag",Tg={OPERATOR:xg,NUMBER:Rg,STRING:"#00a82d",FUNCTION:yg,DEBUGGER:xg,LEFT_PAREN:yg,RIGHT_PAREN:yg,COMMA:yg};sn`
1033
+ `;class wg extends t.Component{constructor(){super(...arguments),this.assistantState=t.useState({allowCellSelectionBehind:!1}),this.timeOutId=0}setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}wg.template="o-spreadsheet-FunctionDescriptionProvider";const yg=Cu.content,xg="#4a4e4d",Rg="#3da4ab",Ig="#02c39a",Tg="selector-flag",Ag={OPERATOR:Rg,NUMBER:Ig,STRING:"#00a82d",FUNCTION:xg,DEBUGGER:Rg,LEFT_PAREN:xg,RIGHT_PAREN:xg,COMMA:xg};an`
1034
1034
  .o-composer-container {
1035
1035
  padding: 0;
1036
1036
  margin: 0;
@@ -1051,7 +1051,7 @@
1051
1051
  }
1052
1052
  span {
1053
1053
  white-space: pre;
1054
- &.${Ig}:after {
1054
+ &.${Tg}:after {
1055
1055
  content: "${"␣"}";
1056
1056
  color: ${"darkgrey"};
1057
1057
  }
@@ -1068,14 +1068,14 @@
1068
1068
  .o-topbar-toolbar .o-composer-container:focus-within {
1069
1069
  border: 1px solid ${E};
1070
1070
  }
1071
- `;class Ag extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Cg(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,provider:"functions",search:""}),this.functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,this.borderStyle="box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15);",this.shouldProcessInputEvents=!1,this.tokens=[],this.keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:this.processF4Key,Tab:e=>this.processTabKey(e)}}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let n="";return t>this.props.delimitation.height-(t+o)&&(n+="\n top: -8px;\n transform: translate(0, -100%);\n "),e+300>this.props.delimitation.width&&(n+="right:0px;"),n+="width:300px;"}return"width:300px;"}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent()})),t.onWillUnmount((()=>{var e,t;null===(t=(e=this.props).onComposerUnmounted)||void 0===t||t.call(e)})),t.onPatched((()=>{this.isKeyStillDown||this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,void e.preventDefault();const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&this.autocompleteAPI&&(e.preventDefault(),"ArrowUp"===e.key?this.autocompleteAPI.moveUp():this.autocompleteAPI.moveDown())):this.env.model.dispatch("STOP_EDITION")}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),this.isKeyStillDown=!1,this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):e.stopPropagation();const{start:o,end:n}=this.contentHelper.getCurrentSelection();this.env.model.getters.isSelectingForComposer()||(this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:n}),this.isKeyStillDown=!0)}onInput(){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const e=this.composerRef.el;this.env.model.dispatch("SET_CURRENT_CONTENT",{content:e.childNodes.length?e.textContent:"",selection:this.contentHelper.getCurrentSelection()})}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Shift","Tab","Enter","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.autoCompleteState.search="",this.autoCompleteState.showProvider=!0,void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:o}=this.env.model.getters.getComposerSelection(),{start:n,end:i}=this.contentHelper.getCurrentSelection();n===t&&i===o||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onCompleted(e){e&&this.autoComplete(e)}processContent(){if(this.compositionActive)return;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.selectRange(0,0);const e=this.getContent();if(0!==e.length){this.contentHelper.setText(e);const{start:t,end:o}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,o)}this.shouldProcessInputEvents=!0}getContent(){let e;const t=this.env.model.getters.getCurrentContent(),o=t.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return e=""===t?[]:o&&"inactive"!==this.props.focus?this.getColoredTokens():[{value:t}],e}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{start:n,end:i}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":o.push({value:r.value,color:Tg[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:n}=Rt(r.value);o.push({value:r.value,color:this.rangeColor(e,n)||"#000"});break;case"SYMBOL":let i=r.value;["TRUE","FALSE"].includes(i.toUpperCase())?o.push({value:r.value,color:Rg}):o.push({value:r.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===r.parenIndex?o.push({value:r.value,color:"black"}):o.push({value:r.value,color:Tg[r.type]||"#000"});break;default:o.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===n&&i===r.end&&(o[o.length-1].class=Ig)}return o}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),n=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),i=o.find((t=>{if(t.sheetId!==n)return!1;let o=this.env.model.getters.getRangeFromSheetXC(n,e).zone;const{height:i,width:r}=No(o);return o=i*r==1?this.env.model.getters.expandZone(n,o):o,Ro(o,t.zone)}));return i&&i.color?i.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=Rt(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Ct.test(t))this.autoCompleteState.search=e.value,this.autoCompleteState.showProvider=!0;else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,o=t.parent.toUpperCase(),n=wg[o],i=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=n,this.functionDescriptionState.argToFocus=n.getArgToFocus(i+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,n=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const i=this.env.model.getters.getCurrentTokens();if(this.autoCompleteState.provider&&i.length){e+="(";const o=i.map((e=>e.start)).indexOf(t.start);if(o+1<i.length){"LEFT_PAREN"===i[o+1].type&&n++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:n})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Ag.template="o-spreadsheet-Composer",Ag.components={TextValueProvider:Sg,FunctionDescriptionProvider:Eg},Ag.defaultProps={inputStyle:"",focus:"inactive"};const Og=3*.4*window.devicePixelRatio||1;sn`
1071
+ `;class Og extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Eg(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,provider:"functions",search:""}),this.functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,this.borderStyle="box-shadow: 0 1px 4px 3px rgba(60, 64, 67, 0.15);",this.shouldProcessInputEvents=!1,this.tokens=[],this.keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:this.processF4Key,Tab:e=>this.processTabKey(e)}}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:o}=this.props.rect;let n="";return t>this.props.delimitation.height-(t+o)&&(n+="\n top: -8px;\n transform: translate(0, -100%);\n "),e+300>this.props.delimitation.width&&(n+="right:0px;"),n+="width:300px;"}return"width:300px;"}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent()})),t.onWillUnmount((()=>{var e,t;null===(t=(e=this.props).onComposerUnmounted)||void 0===t||t.call(e)})),t.onPatched((()=>{this.isKeyStillDown||this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,void e.preventDefault();const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&this.autocompleteAPI&&(e.preventDefault(),"ArrowUp"===e.key?this.autocompleteAPI.moveUp():this.autocompleteAPI.moveDown())):this.env.model.dispatch("STOP_EDITION")}processTabKey(e){if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(t,1)}processEnterKey(e){if(e.preventDefault(),e.stopPropagation(),this.isKeyStillDown=!1,this.autoCompleteState.showProvider&&this.autocompleteAPI){const e=this.autocompleteAPI.getValueToFill();if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const t=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(t,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):e.stopPropagation();const{start:o,end:n}=this.contentHelper.getCurrentSelection();this.env.model.getters.isSelectingForComposer()||(this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:n}),this.isKeyStillDown=!0)}onInput(){if("inactive"===this.props.focus||!this.shouldProcessInputEvents)return;this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const e=this.composerRef.el;this.env.model.dispatch("SET_CURRENT_CONTENT",{content:e.childNodes.length?e.textContent:"",selection:this.contentHelper.getCurrentSelection()})}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Shift","Tab","Enter","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.autoCompleteState.search="",this.autoCompleteState.showProvider=!0,void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:o}=this.env.model.getters.getComposerSelection(),{start:n,end:i}=this.contentHelper.getCurrentSelection();n===t&&i===o||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}onCompleted(e){e&&this.autoComplete(e)}processContent(){if(this.compositionActive)return;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&this.contentHelper.selectRange(0,0);const e=this.getContent();if(0!==e.length){this.contentHelper.setText(e);const{start:t,end:o}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,o)}this.shouldProcessInputEvents=!0}getContent(){let e;const t=this.env.model.getters.getCurrentContent(),o=t.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return e=""===t?[]:o&&"inactive"!==this.props.focus?this.getColoredTokens():[{value:t}],e}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),o=[],{start:n,end:i}=this.env.model.getters.getComposerSelection();for(const r of e){switch(r.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":o.push({value:r.value,color:Ag[r.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:n}=It(r.value);o.push({value:r.value,color:this.rangeColor(e,n)||"#000"});break;case"SYMBOL":let i=r.value;["TRUE","FALSE"].includes(i.toUpperCase())?o.push({value:r.value,color:Ig}):o.push({value:r.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===r.parenIndex?o.push({value:r.value,color:"black"}):o.push({value:r.value,color:Ag[r.type]||"#000"});break;default:o.push({value:r.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===n&&i===r.end&&(o[o.length-1].class=Tg)}return o}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),n=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),i=o.find((t=>{if(t.sheetId!==n)return!1;let o=this.env.model.getters.getRangeFromSheetXC(n,e).zone;const{height:i,width:r}=_o(o);return o=i*r==1?this.env.model.getters.expandZone(n,o):o,Io(o,t.zone)}));return i&&i.color?i.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=It(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Et.test(t))this.autoCompleteState.search=e.value,this.autoCompleteState.showProvider=!0;else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,o=t.parent.toUpperCase(),n=yg[o],i=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=n,this.functionDescriptionState.argToFocus=n.getArgToFocus(i+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,n=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const i=this.env.model.getters.getCurrentTokens();if(this.autoCompleteState.provider&&i.length){e+="(";const o=i.map((e=>e.start)).indexOf(t.start);if(o+1<i.length){"LEFT_PAREN"===i[o+1].type&&n++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:n})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Og.template="o-spreadsheet-Composer",Og.components={TextValueProvider:Cg,FunctionDescriptionProvider:wg},Og.defaultProps={inputStyle:"",focus:"inactive"};const Mg=3*.4*window.devicePixelRatio||1;an`
1072
1072
  div.o-grid-composer {
1073
1073
  z-index: ${ne.Composer};
1074
1074
  box-sizing: border-box;
1075
1075
  position: absolute;
1076
- border: ${Og}px solid ${E};
1076
+ border: ${Mg}px solid ${E};
1077
1077
  }
1078
- `;class Mg extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:null,delimitation:null});const{col:e,row:o}=this.env.model.getters.getPosition();this.zone=this.env.model.getters.expandZone(this.env.model.getters.getActiveSheetId(),{left:e,right:e,top:o,bottom:o}),this.rect=this.env.model.getters.getVisibleRect(this.zone),t.onMounted((()=>{const e=this.gridComposerRef.el,t=e.parentElement.clientHeight-this.rect.y-15;e.style.maxHeight=t+"px";const o=e.parentElement.clientWidth-this.rect.x-14;e.style.maxWidth=o+"px",this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}}))}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell();let o={};if(t){const e=this.env.model.getters.getCellPosition(t.id);o=this.env.model.getters.getCellComputedStyle(e.sheetId,e.col,e.row)}const{x:n,y:i,width:r,height:s}=this.rect,a=!e&&o.fillColor||"#ffffff",l=!e&&o.textColor||"#000000",c=!e&&o.fontSize||10,h=!e&&o.bold?"bold":500,d=!e&&o.italic?"italic":"normal",u=e?"none":an(o);let g="left";return e||(g=o.align||(null==t?void 0:t.defaultAlign)||"left"),`\n left: ${n-1}px;\n top: ${i}px;\n min-width: ${r+2}px;\n min-height: ${s+1}px;\n\n background: ${a};\n color: ${l};\n\n font-size: ${re[c]}px;\n font-weight: ${h};\n font-style: ${d};\n text-decoration: ${u};\n\n text-align: ${g};\n `}get composerStyle(){return`\n line-height: ${_}px;\n max-height: inherit;\n overflow: hidden;\n `}}Mg.template="o-spreadsheet-GridComposer",Mg.components={Composer:Ag};const Ng=sn`
1078
+ `;class Ng extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:null,delimitation:null});const{col:e,row:o}=this.env.model.getters.getPosition();this.zone=this.env.model.getters.expandZone(this.env.model.getters.getActiveSheetId(),{left:e,right:e,top:o,bottom:o}),this.rect=this.env.model.getters.getVisibleRect(this.zone),t.onMounted((()=>{const e=this.gridComposerRef.el,t=e.parentElement.clientHeight-this.rect.y-15;e.style.maxHeight=t+"px";const o=e.parentElement.clientWidth-this.rect.x-14;e.style.maxWidth=o+"px",this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}}))}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell();let o={};if(t){const e=this.env.model.getters.getCellPosition(t.id);o=this.env.model.getters.getCellComputedStyle(e.sheetId,e.col,e.row)}const{x:n,y:i,width:r,height:s}=this.rect,a=!e&&o.fillColor||"#ffffff",l=!e&&o.textColor||"#000000",c=!e&&o.fontSize||10,h=!e&&o.bold?"bold":500,d=!e&&o.italic?"italic":"normal",u=e?"none":ln(o);let g="left";return e||(g=o.align||(null==t?void 0:t.defaultAlign)||"left"),`\n left: ${n-1}px;\n top: ${i}px;\n min-width: ${r+2}px;\n min-height: ${s+1}px;\n\n background: ${a};\n color: ${l};\n\n font-size: ${re[c]}px;\n font-weight: ${h};\n font-style: ${d};\n text-decoration: ${u};\n\n text-align: ${g};\n `}get composerStyle(){return`\n line-height: ${_}px;\n max-height: inherit;\n overflow: hidden;\n `}}Ng.template="o-spreadsheet-GridComposer",Ng.components={Composer:Og};const _g=an`
1079
1079
  .o-filter-icon {
1080
1080
  color: ${R};
1081
1081
  position: absolute;
@@ -1099,7 +1099,7 @@
1099
1099
  }
1100
1100
  }
1101
1101
  }
1102
- `;class _g extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}_g.style=Ng,_g.template="o-spreadsheet-FilterIcon";const Fg=sn``;class Dg extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRowDimensionsInViewport(t,e.row),n=this.env.model.getters.getColDimensionsInViewport(t,e.col),i=Math.floor((o.size-V)/2);return{x:n.end-V+this.props.gridPosition.x-2-1,y:o.end-V+this.props.gridPosition.y-i}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive(t,e.col,e.row)}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:o,row:n}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:o,row:n,popoverType:"FilterMenu"})}isPositionVisible(e,t){const o=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===o.width||0===o.height)}}Dg.style=Fg,Dg.template="o-spreadsheet-FilterIconsOverlay",Dg.components={FilterIcon:_g},Dg.defaultProps={gridPosition:{x:0,y:0}};sn`
1102
+ `;class Fg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Fg.style=_g,Fg.template="o-spreadsheet-FilterIcon";const Dg=an``;class kg extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRowDimensionsInViewport(t,e.row),n=this.env.model.getters.getColDimensionsInViewport(t,e.col),i=Math.floor((o.size-V)/2);return{x:n.end-V+this.props.gridPosition.x-2-1,y:o.end-V+this.props.gridPosition.y-i}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive(t,e.col,e.row)}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:o,row:n}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:o,row:n,popoverType:"FilterMenu"})}isPositionVisible(e,t){const o=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===o.width||0===o.height)}}kg.style=Dg,kg.template="o-spreadsheet-FilterIconsOverlay",kg.components={FilterIcon:Fg},kg.defaultProps={gridPosition:{x:0,y:0}};an`
1103
1103
  div.o-figure {
1104
1104
  box-sizing: border-box;
1105
1105
  position: absolute;
@@ -1154,7 +1154,7 @@
1154
1154
  }
1155
1155
  }
1156
1156
  }
1157
- `;class kg extends t.Component{constructor(){super(...arguments),this.figureRegistry=Dn,this.figureRef=t.useRef("figure")}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:1}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:o,height:n}=this.props.figure;return ln({left:`${e}px`,top:`${t}px`,width:`${o}px`,height:`${n}px`,"z-index":String(ne.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t="";return e.includes("top")?t+="top: -3px;":e.includes("bottom")?t+="bottom: -3px;":t+=" bottom: calc(50% - 3px);",e.includes("left")?t+="left: -3px;":e.includes("right")?t+="right: -3px;":t+=" right: calc(50% - 3px);",t}setup(){t.useEffect(((e,t,o)=>{e===t&&(null==o||o.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,o){this.props.onClickAnchor(e,t,o)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const o={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+o[0],y:t.y+o[1]}),e.preventDefault()}}}kg.template="o-spreadsheet-FigureComponent",kg.components={},kg.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},kg.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};class $g extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const n=e.filter((e=>this.getFigureContainer(e)===o));n.length>0&&t.push({type:o,figures:n,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:n,y:i}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?n:0,s=t-r,a=["bottomRight","bottomLeft"].includes(e)?i:0;return ln({left:`${r}px`,top:`${a}px`,width:`${s}px`,height:`${o-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:n,y:i}=this.env.model.getters.getMainViewportCoordinates();return ln({left:`${["bottomRight","topRight"].includes(e)?-(n+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(i+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),n=t.clientX,i=t.clientY,{x:r,y:s}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=s,this.dnd.width=e.width,this.dnd.height=e.height;ss((t=>{const{x:o,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=o?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-n;this.dnd.x=Math.max(r+u,h);let g=t.clientY-i;this.dnd.y=Math.max(s+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:n,y:i}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:n,y:i})}))}startResize(e,t,o,n){n.stopPropagation();const i=n.clientX,r=n.clientY,{x:s,y:a}=this.internalToScreenCoordinates(e);let l;this.dnd.x=s,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height,l=n=>{this.dnd.figId=e.id;const l=Math.max(t*(n.clientX-i),80-e.width),c=Math.max(o*(n.clientY-r),80-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+c,t<0&&(this.dnd.x=s-l),o<0&&(this.dnd.y=a-c)};ss(l,(n=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:i,y:r}=this.screenCoordinatesToInternal(this.dnd);const s={x:i,y:r};t&&(s.width=this.dnd.width),o&&(s.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...s})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":ln({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:i,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<o?e:e-i,y:t=t<n?t:t-r}}screenCoordinatesToInternal({x:e,y:t}){const{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:i,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=o&&e<o?e:e+i,y:t=n&&t<n?t:t+r}}}function Lg(e,o,n){let i={col:void 0,row:void 0};const{Date:r}=window;let s=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(s),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,o){let n;const{setInterval:i,clearInterval:r}=window;return t.useEffect((()=>(n=i(e,o),()=>r(n))),(()=>[o])),{pause:()=>{r(n),n=void 0},resume:()=>{void 0===n&&(n=i(e,o))}}}((function(){const{col:e,row:t}=c(),o=r.now()-l;o>300&&(e!==i.col||t!==i.row)&&p(void 0,void 0);if(o>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){s=e.offsetX,a=e.offsetY,l=r.now()}function g(){const{col:e,row:t}=c();e===i.col&&t===i.row||p(void 0,void 0)}function p(e,t){e===i.col&&t===i.row||(i.col=e,i.row=t,n({col:e,row:t}))}return t.onMounted((()=>{const e=o.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=o.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),i}$g.template="o-spreadsheet-FiguresContainer",$g.components={FigureComponent:kg},Dn.add("chart",{Component:rs,SidePanelComponent:"ChartPanel"});class Pg extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),Lg(this.env,this.gridOverlay,this.props.onCellHovered),t.useEffect((()=>this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})),(()=>[this.gridOverlayEl.clientHeight,this.gridOverlayEl.clientWidth])),function(e,o,n){let i=null,r=null;function s(e){1===e.touches.length&&(i=e.touches[0].clientX,r=e.touches[0].clientY)}function a(){i=null,r=null}function l(e){if(1!==e.touches.length)return;n()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,s=e.touches[0].clientY;o(i-t,r-s),i=t,r=s}t.onMounted((()=>{e.el.addEventListener("touchstart",s),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",s),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){e.preventDefault();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Pg.template="o-spreadsheet-GridOverlay",Pg.components={FiguresContainer:$g},Pg.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{},sidePanelIsOpen:!1};class Ug extends t.Component{get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.coordinates;return{...e,coordinates:{x:t.x+this.props.gridPosition.x,y:t.y+this.props.gridPosition.y}}}}Ug.template="o-spreadsheet-GridPopover",Ug.components={Popover:Cn};class Vg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const n=this._getDimensionsInViewport(o);t-n.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.start,this.state.activeElement=this._getPreviousVisibleElement(o)):n.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),n=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();o.has(n)&&n<=t&&t<=i?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,n=this._getElementSize(this.state.activeElement),i=o-n+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();ss((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<i&&(this.state.draggerLinePosition=i,this.state.delta=this.MIN_ELEMENT_SIZE-n),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),n=t.start;this.state.draggerLinePosition=n,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=n,this.state.draggerShadowThickness=o.end-t.start;as(this.env,((e,o)=>{let n="COL"===this._getType()?e:o;if(n>=0){const e=this._getDimensionsInViewport(n);n<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=n):this._getSelectedZoneEnd()<n?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=n+1):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;as(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}sn`
1157
+ `;class $g extends t.Component{constructor(){super(...arguments),this.figureRegistry=kn,this.figureRef=t.useRef("figure")}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:1}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:o,height:n}=this.props.figure;return cn({left:`${e}px`,top:`${t}px`,width:`${o}px`,height:`${n}px`,"z-index":String(ne.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t="";return e.includes("top")?t+="top: -3px;":e.includes("bottom")?t+="bottom: -3px;":t+=" bottom: calc(50% - 3px);",e.includes("left")?t+="left: -3px;":e.includes("right")?t+="right: -3px;":t+=" right: calc(50% - 3px);",t}setup(){t.useEffect(((e,t,o)=>{e===t&&(null==o||o.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,o){this.props.onClickAnchor(e,t,o)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const o={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+o[0],y:t.y+o[1]}),e.preventDefault()}}}$g.template="o-spreadsheet-FigureComponent",$g.components={},$g.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},$g.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}};class Lg extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const n=e.filter((e=>this.getFigureContainer(e)===o));n.length>0&&t.push({type:o,figures:n,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:n,y:i}=this.env.model.getters.getMainViewportCoordinates(),r=["bottomRight","topRight"].includes(e)?n:0,s=t-r,a=["bottomRight","bottomLeft"].includes(e)?i:0;return cn({left:`${r}px`,top:`${a}px`,width:`${s}px`,height:`${o-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:n,y:i}=this.env.model.getters.getMainViewportCoordinates();return cn({left:`${["bottomRight","topRight"].includes(e)?-(n+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(i+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),n=t.clientX,i=t.clientY,{x:r,y:s}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=s,this.dnd.width=e.width,this.dnd.height=e.height;as((t=>{const{x:o,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=o?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-n;this.dnd.x=Math.max(r+u,h);let g=t.clientY-i;this.dnd.y=Math.max(s+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:n,y:i}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:n,y:i})}))}startResize(e,t,o,n){n.stopPropagation();const i=n.clientX,r=n.clientY,{x:s,y:a}=this.internalToScreenCoordinates(e);let l;this.dnd.x=s,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height,l=n=>{this.dnd.figId=e.id;const l=Math.max(t*(n.clientX-i),80-e.width),c=Math.max(o*(n.clientY-r),80-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+c,t<0&&(this.dnd.x=s-l),o<0&&(this.dnd.y=a-c)};as(l,(n=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:i,y:r}=this.screenCoordinatesToInternal(this.dnd);const s={x:i,y:r};t&&(s.width=this.dnd.width),o&&(s.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...s})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":cn({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:i,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<o?e:e-i,y:t=t<n?t:t-r}}screenCoordinatesToInternal({x:e,y:t}){const{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:i,scrollY:r}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=o&&e<o?e:e+i,y:t=n&&t<n?t:t+r}}}function Pg(e,o,n){let i={col:void 0,row:void 0};const{Date:r}=window;let s=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(s),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,o){let n;const{setInterval:i,clearInterval:r}=window;return t.useEffect((()=>(n=i(e,o),()=>r(n))),(()=>[o])),{pause:()=>{r(n),n=void 0},resume:()=>{void 0===n&&(n=i(e,o))}}}((function(){const{col:e,row:t}=c(),o=r.now()-l;o>300&&(e!==i.col||t!==i.row)&&p(void 0,void 0);if(o>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){s=e.offsetX,a=e.offsetY,l=r.now()}function g(){const{col:e,row:t}=c();e===i.col&&t===i.row||p(void 0,void 0)}function p(e,t){e===i.col&&t===i.row||(i.col=e,i.row=t,n({col:e,row:t}))}return t.onMounted((()=>{const e=o.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=o.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),i}Lg.template="o-spreadsheet-FiguresContainer",Lg.components={FigureComponent:$g},kn.add("chart",{Component:ss,SidePanelComponent:"ChartPanel"});class Ug extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),Pg(this.env,this.gridOverlay,this.props.onCellHovered),t.useEffect((()=>this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})),(()=>[this.gridOverlayEl.clientHeight,this.gridOverlayEl.clientWidth])),function(e,o,n){let i=null,r=null;function s(e){1===e.touches.length&&(i=e.touches[0].clientX,r=e.touches[0].clientY)}function a(){i=null,r=null}function l(e){if(1!==e.touches.length)return;n()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,s=e.touches[0].clientY;o(i-t,r-s),i=t,r=s}t.onMounted((()=>{e.el.addEventListener("touchstart",s),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",s),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){e.preventDefault();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Ug.template="o-spreadsheet-GridOverlay",Ug.components={FiguresContainer:Lg},Ug.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{},sidePanelIsOpen:!1};class Vg extends t.Component{get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.coordinates;return{...e,coordinates:{x:t.x+this.props.gridPosition.x,y:t.y+this.props.gridPosition.y}}}}Vg.template="o-spreadsheet-GridPopover",Vg.components={Popover:En};class zg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const n=this._getDimensionsInViewport(o);t-n.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.start,this.state.activeElement=this._getPreviousVisibleElement(o)):n.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=n.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),n=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();o.has(n)&&n<=t&&t<=i?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),o=this.state.draggerLinePosition,n=this._getElementSize(this.state.activeElement),i=o-n+this.MIN_ELEMENT_SIZE,r=this._getMaxSize();as((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<i&&(this.state.draggerLinePosition=i,this.state.delta=this.MIN_ELEMENT_SIZE-n),this.state.draggerLinePosition>r&&(this.state.draggerLinePosition=r,this.state.delta=r-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),n=t.start;this.state.draggerLinePosition=n,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=n,this.state.draggerShadowThickness=o.end-t.start;ls(this.env,((e,o)=>{let n="COL"===this._getType()?e:o;if(n>=0){const e=this._getDimensionsInViewport(n);n<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=n):this._getSelectedZoneEnd()<n?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=n+1):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;ls(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}an`
1158
1158
  .o-col-resizer {
1159
1159
  position: absolute;
1160
1160
  top: 0;
@@ -1213,7 +1213,7 @@
1213
1213
  top: calc(${k}px / 2 - ${D}px / 2);
1214
1214
  }
1215
1215
  }
1216
- `;class zg extends Vg{setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let n=t;n<=o;n++)e.push(n);const n=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!n.isSuccessful&&n.reasons.includes(2)&&this.env.raiseError(_i)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isColHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}zg.template="o-spreadsheet-ColResizer",sn`
1216
+ `;class Bg extends zg{setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let n=t;n<=o;n++)e.push(n);const n=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!n.isSuccessful&&n.reasons.includes(2)&&this.env.raiseError(Fi)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isColHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Bg.template="o-spreadsheet-ColResizer",an`
1217
1217
  .o-row-resizer {
1218
1218
  position: absolute;
1219
1219
  top: ${O}px;
@@ -1274,7 +1274,7 @@
1274
1274
  background-color: lightgrey;
1275
1275
  }
1276
1276
  }
1277
- `;class Bg extends Vg{setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let n=t;n<=o;n++)e.push(n);const n=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!n.isSuccessful&&n.reasons.includes(2)&&this.env.raiseError(_i)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isRowHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Bg.template="o-spreadsheet-RowResizer",sn`
1277
+ `;class Hg extends zg{setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let n=t;n<=o;n++)e.push(n);const n=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!n.isSuccessful&&n.reasons.includes(2)&&this.env.raiseError(Fi)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isRowHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Hg.template="o-spreadsheet-RowResizer",an`
1278
1278
  .o-overlay {
1279
1279
  .all {
1280
1280
  position: absolute;
@@ -1285,7 +1285,7 @@
1285
1285
  height: ${O}px;
1286
1286
  }
1287
1287
  }
1288
- `;class Hg extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function Wg(e,o,n){const i=t.useRef(e);t.useEffect((function(){const e=i.el,t=window.devicePixelRatio||1,r=e.getContext("2d",{alpha:!1}),s={ctx:r,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=n();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),r.translate(-f,-f),r.scale(t,t),o.drawGrid(s)}))}function Gg(e){function t(e,t){return e*(0===t?1:_)}return o=>{const n=t(o.shiftKey?o.deltaY:o.deltaX,o.deltaMode),i=t(o.shiftKey?o.deltaX:o.deltaY,o.deltaMode);e(n,i)}}Hg.template="o-spreadsheet-HeadersOverlay",Hg.components={ColResizer:zg,RowResizer:Bg},sn`
1288
+ `;class Wg extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function Gg(e,o,n){const i=t.useRef(e);t.useEffect((function(){const e=i.el,t=window.devicePixelRatio||1,r=e.getContext("2d",{alpha:!1}),s={ctx:r,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=n();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),r.translate(-f,-f),r.scale(t,t),o.drawGrid(s)}))}function qg(e){function t(e,t){return e*(0===t?1:_)}return o=>{const n=t(o.shiftKey?o.deltaY:o.deltaX,o.deltaMode),i=t(o.shiftKey?o.deltaX:o.deltaY,o.deltaMode);e(n,i)}}Wg.template="o-spreadsheet-HeadersOverlay",Wg.components={ColResizer:Bg,RowResizer:Hg},an`
1289
1289
  .o-border {
1290
1290
  position: absolute;
1291
1291
  &:hover {
@@ -1295,7 +1295,7 @@
1295
1295
  .o-moving {
1296
1296
  cursor: grabbing;
1297
1297
  }
1298
- `;class qg extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),o=["n","s"].includes(this.props.orientation),n=["w","e"].includes(this.props.orientation),i=this.props.zone,r=this.env.model.getters.getVisibleRect(i),s=r.x,a=r.x+r.width-4,l=r.y,c=r.y+r.height-4;return`\n left:${t?s:a}px;\n top:${e?l:c}px;\n width:${o?a-s:4}px;\n height:${n?c-l:4}px;\n `}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}qg.template="o-spreadsheet-Border",sn`
1298
+ `;class Zg extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),o=["n","s"].includes(this.props.orientation),n=["w","e"].includes(this.props.orientation),i=this.props.zone,r=this.env.model.getters.getVisibleRect(i),s=r.x,a=r.x+r.width-4,l=r.y,c=r.y+r.height-4;return`\n left:${t?s:a}px;\n top:${e?l:c}px;\n width:${o?a-s:4}px;\n height:${n?c-l:4}px;\n `}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}Zg.template="o-spreadsheet-Border",an`
1299
1299
  .o-corner {
1300
1300
  position: absolute;
1301
1301
  height: 6px;
@@ -1317,11 +1317,11 @@
1317
1317
  .o-resizing {
1318
1318
  cursor: grabbing;
1319
1319
  }
1320
- `;class Zg extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,o=this.isTop?e.top:e.bottom,n=this.env.model.getters.getVisibleRect({left:t,right:t,top:o,bottom:o});if(n.width*n.height==0)return"display:none";return`\n left:${(this.isLeft?n.x:n.x+n.width)-4}px;\n top:${(this.isTop?n.y:n.y+n.height)-4}px;\n background-color:${this.props.color};\n `}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}Zg.template="o-spreadsheet-Corner",sn`
1320
+ `;class jg extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,o=this.isTop?e.top:e.bottom,n=this.env.model.getters.getVisibleRect({left:t,right:t,top:o,bottom:o});if(n.width*n.height==0)return"display:none";return`\n left:${(this.isLeft?n.x:n.x+n.width)-4}px;\n top:${(this.isTop?n.y:n.y+n.height)-4}px;\n background-color:${this.props.color};\n `}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}jg.template="o-spreadsheet-Corner",an`
1321
1321
  .o-highlight {
1322
1322
  z-index: ${ne.Highlight};
1323
1323
  }
1324
- `;class jg extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const o=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const n=this.props.zone,i=e?n.right:n.left,r=t?n.bottom:n.top;let s=e?n.left:n.right,a=t?n.top:n.bottom,l=n;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o.id,l)});as(this.env,((e,t)=>{if(s!==e||a!==t){const n=this.env.model.getters.getActiveSheetId();s=Oe(-1===e?s:e,0,this.env.model.getters.getNumberCols(n)-1),a=Oe(-1===t?a:t,0,this.env.model.getters.getNumberRows(n)-1);let c={left:Math.min(i,s),top:Math.min(r,a),right:Math.max(i,s),bottom:Math.max(r,a)};c=this.env.model.getters.expandZone(n,c),Ro(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const o=this.props.zone,n=bn(),i=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getColIndex(e-n.left),s=this.env.model.getters.getRowIndex(t-n.top),a=-o.left,l=this.env.model.getters.getNumberCols(i)-o.right-1,c=-o.top,h=this.env.model.getters.getNumberRows(i)-o.bottom-1;let d=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i,d)});let u=r,g=s;as(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const n=Oe(u-r,a,l),p=Oe(g-s,c,h);let f={left:o.left+n,top:o.top+p,right:o.right+n,bottom:o.bottom+p};f=this.env.model.getters.expandZone(i,f),Ro(f,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i,f)}),d=f)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}jg.template="o-spreadsheet-Highlight",jg.components={Corner:Zg,Border:qg};class Xg{constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}sn`
1324
+ `;class Xg extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const o=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const n=this.props.zone,i=e?n.right:n.left,r=t?n.bottom:n.top;let s=e?n.left:n.right,a=t?n.top:n.bottom,l=n;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o.id,l)});ls(this.env,((e,t)=>{if(s!==e||a!==t){const n=this.env.model.getters.getActiveSheetId();s=Oe(-1===e?s:e,0,this.env.model.getters.getNumberCols(n)-1),a=Oe(-1===t?a:t,0,this.env.model.getters.getNumberRows(n)-1);let c={left:Math.min(i,s),top:Math.min(r,a),right:Math.max(i,s),bottom:Math.max(r,a)};c=this.env.model.getters.expandZone(n,c),Io(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const o=this.props.zone,n=Sn(),i=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getColIndex(e-n.left),s=this.env.model.getters.getRowIndex(t-n.top),a=-o.left,l=this.env.model.getters.getNumberCols(i)-o.right-1,c=-o.top,h=this.env.model.getters.getNumberRows(i)-o.bottom-1;let d=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i,d)});let u=r,g=s;ls(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const n=Oe(u-r,a,l),p=Oe(g-s,c,h);let f={left:o.left+n,top:o.top+p,right:o.right+n,bottom:o.bottom+p};f=this.env.model.getters.expandZone(i,f),Io(f,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i,f)}),d=f)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}Xg.template="o-spreadsheet-Highlight",Xg.components={Corner:jg,Border:Zg};class Yg{constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}an`
1325
1325
  .o-scrollbar {
1326
1326
  position: absolute;
1327
1327
  overflow: auto;
@@ -1337,7 +1337,7 @@
1337
1337
  border-left: 1px solid #e2e3e3;
1338
1338
  }
1339
1339
  }
1340
- `;class Yg extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new Xg(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return ln({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return ln(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}Yg.template=t.xml`
1340
+ `;class Kg extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new Yg(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return cn({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return cn(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}Kg.template=t.xml`
1341
1341
  <div
1342
1342
  t-attf-class="o-scrollbar {{props.direction}}"
1343
1343
  t-on-scroll="onScroll"
@@ -1345,7 +1345,7 @@
1345
1345
  t-att-style="positionCss">
1346
1346
  <div t-att-style="sizeCss"/>
1347
1347
  </div>
1348
- `,Yg.defaultProps={width:1,height:1};class Kg extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.position.left+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}Kg.components={ScrollBar:Yg},Kg.template=t.xml`
1348
+ `,Kg.defaultProps={width:1,height:1};class Qg extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.position.left+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}Qg.components={ScrollBar:Kg},Qg.template=t.xml`
1349
1349
  <ScrollBar
1350
1350
  t-if="isDisplayed"
1351
1351
  width="width"
@@ -1353,7 +1353,7 @@
1353
1353
  offset="offset"
1354
1354
  direction="'horizontal'"
1355
1355
  onScroll.bind="onScroll"
1356
- />`,Kg.defaultProps={position:{left:0}};class Qg extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.position.top+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}Qg.components={ScrollBar:Yg},Qg.template=t.xml`
1356
+ />`,Qg.defaultProps={position:{left:0}};class Jg extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.position.top+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}Jg.components={ScrollBar:Kg},Jg.template=t.xml`
1357
1357
  <ScrollBar
1358
1358
  t-if="isDisplayed"
1359
1359
  height="height"
@@ -1361,9 +1361,9 @@
1361
1361
  offset="offset"
1362
1362
  direction="'vertical'"
1363
1363
  onScroll.bind="onScroll"
1364
- />`,Qg.defaultProps={position:{top:0}};const Jg={ROW:xi,COL:yi,CELL:wi};class ep extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=O,this.HEADER_WIDTH=M,this.keyDownMapping={ENTER:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+S":()=>{var e,t;null===(t=(e=this.props).onSaveRequested)||void 0===t||t.call(e)},"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"ALT+=":()=>{var e;const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getSelectedZone(),{anchor:n}=this.env.model.getters.getSelection(),i=this.env.model.getters.getAutomaticSums(t,o,n.cell);if(this.env.model.getters.isSingleCellOrMerge(t,o)||this.env.model.getters.isEmpty(t,o)&&i.length<=1){const o=(null===(e=i[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,i[0].zone):"",n=`=SUM(${o})`;this.props.onGridComposerCellFocused(n,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition(e,0,0);this.env.model.selection.selectCell(t,o)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",Fe(0,this.env.model.getters.getNumberCols(e)).reverse()),o=this.env.model.getters.findVisibleHeader(e,"ROW",Fe(0,this.env.model.getters.getNumberRows(e)).reverse());this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},o=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP")}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=Sn(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),Wg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=Gg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return"\n top: 26px;\n left: 48px;\n height: calc(100% - 41px);\n width: calc(100% - 63px);\n "}onClosePopover(){this.closeOpenedPopover(),this.focus()}focus(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.hiddenInput.el.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}isAutoFillActive(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:M,gridOffsetY:O})}moveCanvas(e,t){const{scrollX:o,scrollY:n}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:Math.max(o+e,0),offsetY:Math.max(n+t,0)})}getClientPositionKey(e){var t,o,n;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(o=e.position)||void 0===o?void 0:o.col}-${null===(n=e.position)||void 0===n?void 0:n.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}onCellClicked(e,t,{ctrlKey:o,shiftKey:n}){o&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),n?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let i=e,r=t;as(this.env,((e,t)=>{(e!==i&&-1!=e||t!==r&&-1!=t)&&(i=-1===e?i:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(i,r))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition(o,e,t));const n=this.env.model.getters.getCell(o,e,t);!n||n.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.closeOpenedPopover();const t={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"}[e.key];e.shiftKey?this.env.model.selection.resizeAnchorZone(t,e.ctrlKey?"end":1):this.env.model.selection.moveAnchorCell(t,e.ctrlKey?"end":1),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):void 0}onInput(e){e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:o,top:n}=t;let i="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?i="COL":this.env.model.getters.getActiveRows().has(n)&&(i="ROW");const{x:r,y:s,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(i,r+a,s+l)}onCellRightClicked(e,t,{x:o,y:n}){const i=this.env.model.getters.getSelectedZones();let r="CELL";To(e,t,i[i.length-1])?this.env.model.getters.getActiveCols().has(e)?r="COL":this.env.model.getters.getActiveRows().has(t)&&(r="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(r,o,n)}toggleContextMenu(e,t,o){this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=Jg[e].getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;if("inactive"!==this.env.model.getters.getEditionMode())return;e?Vn(this.env):this.env.model.dispatch("COPY");const o=this.env.model.getters.getClipboardContent();t.clipboardData.setData("text/plain",o),t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t.types.indexOf("text/plain")>-1){const e=t.getData("text/plain"),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardContent()===e?Gn(this.env,o):qn(this.env,o,e)}}closeMenu(){this.menuState.isOpen=!1,this.focus()}}ep.template="o-spreadsheet-Grid",ep.components={GridComposer:Mg,GridOverlay:Pg,GridPopover:Ug,HeadersOverlay:Hg,Menu:En,Autofill:ls,ClientTag:hs,Highlight:jg,Popover:Cn,VerticalScrollBar:Qg,HorizontalScrollBar:Kg,FilterIconsOverlay:Dg};class tp{constructor(e,t,o){this.id=e,this.style=o.style,this.format=o.format,this.lazyEvaluated=t.map((e=>({...e,format:o.format||e.format})))}isFormula(){return!1}isLink(){return!1}isEmpty(){return!1}get evaluated(){return this.lazyEvaluated()}get formattedValue(){return Ut(this.evaluated.value,this.evaluated.format)}get composerContent(){return this.content}get defaultAlign(){switch(this.evaluated.type){case qo.number:case qo.empty:return"right";case qo.boolean:case qo.error:return"center";case qo.text:return"left"}}get isAutoSummable(){var e;switch(this.evaluated.type){case qo.empty:case qo.text:return!0;case qo.number:return!(null===(e=this.evaluated.format)||void 0===e?void 0:e.match(j));case qo.error:case qo.boolean:return!1}}}class op extends tp{constructor(e,t={}){super(e,Ke({value:"",type:qo.empty}),t),this.content=""}isEmpty(){return!0}}class np extends tp{constructor(e,t,o={}){super(e,Ke({value:t,type:qo.number}),o),this.content=Ut(this.evaluated.value)}get composerContent(){var e;return(null===(e=this.format)||void 0===e?void 0:e.includes("%"))?100*this.evaluated.value+"%":super.composerContent}}class ip extends tp{constructor(e,t,o={}){super(e,Ke({value:t,type:qo.boolean}),o),this.content=this.evaluated.value?"TRUE":"FALSE"}}class rp extends tp{constructor(e,t,o={}){super(e,Ke({value:t,type:qo.text}),o),this.content=this.evaluated.value}}class sp extends np{constructor(e,t,o){super(e,t,o),this.format=o.format}get composerContent(){return Ut(this.evaluated.value,this.format)}}class ap extends tp{constructor(e,t,o={}){var n;const r=Be(t);o={...o,style:{...o.style,textColor:(null===(n=o.style)||void 0===n?void 0:n.textColor)||x}},r.label=i(r.label),super(e,Ke({value:r.label,type:qo.text}),o),this.link=r,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class lp extends ap{constructor(e,t,o={}){super(e,t,o),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=ze(this.link.label,this.link.url),this.urlRepresentation=this.link.url,this.isUrlEditable=!0}action(e){window.open(this.link.url,"_blank")}withHttp(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}}class cp extends ap{constructor(e,t,o={},n){super(e,t,o),this.sheetName=n,this.sheetId=qe(this.link.url),this.isUrlEditable=!1}action(e){e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.model.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}get urlRepresentation(){return this.sheetName(this.sheetId)||r("Invalid sheet")}}class hp extends tp{constructor(e,t,o,n,i){super(t,Ke({value:"Loading...",type:qo.text}),i),this.buildFormulaString=e,this.compiledFormula=o,this.dependencies=n}get content(){return this.buildFormulaString(this)}isFormula(){return!0}assignEvaluation(e){this.lazyEvaluated=e.map((e=>{if(e instanceof c)return{value:e.errorType,type:qo.error,error:e};const{value:t,format:o}=e;switch(typeof t){case"number":return{value:t||0,format:o,type:qo.number};case"boolean":return{value:t,format:o,type:qo.boolean};case"string":return{value:t,format:o,type:qo.text};case"object":return{value:0,format:o,type:qo.number};default:return{value:"",type:qo.empty}}}))}}class dp extends tp{constructor(e,t,o,n){super(e,Ke({value:o.errorType,type:qo.error,error:o}),n),this.content=t}}function up(e){return""===e?"":ro(e)?ao(e):$e(e)?"TRUE"===e.toUpperCase():Le(e)?pe(e).value:e}_n.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,o,n,i)=>{const r=lg(t),s=r.dependencies.map((e=>i.getRangeFromSheetXC(n,e)));return new hp((e=>i.buildFormulaContent(n,e)),e,r,s,o)}}).add("Empty",{sequence:20,match:e=>""===e,createCell:(e,t,o)=>new op(e,o)}).add("NumberWithDateTimeFormat",{sequence:25,match:(e,t)=>!!t&&ro(e)&&function(e){try{return Ht(1,e),!0}catch(e){return!1}}(t),createCell:(e,t,o)=>{const n=o.format;return new sp(e,ao(t),{...o,format:n})}}).add("Number",{sequence:30,match:e=>ro(e),createCell:(e,t,o)=>(o.format||(o.format=function(e){const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const n=e.match(/[\d]/),i="[$"+o.values().next().value+"]";return n.index<o.index?"#,##"+t+i:i+"#,##"+t}if(e.includes("%"))return t+"%";return}(t)),new np(e,ao(t),o))}).add("Boolean",{sequence:40,match:e=>$e(e),createCell:(e,t,o)=>new ip(e,"TRUE"===t.toUpperCase(),o)}).add("DateTime",{sequence:50,match:e=>Le(e),createCell:(e,t,o)=>{const n=pe(t),i=o.format||n.format;return new sp(e,n.value,{...o,format:i})}}).add("MarkdownSheetLink",{sequence:60,match:e=>We(e),createCell:(e,t,o,n,i)=>new cp(e,t,o,(e=>i.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>Ve(e),createCell:(e,t,o)=>new lp(e,t,o)}).add("WebLink",{sequence:80,match:e=>{return t=e,Ue.test(t);var t},createCell:(e,t,o)=>new lp(e,ze(t,t),o)});class gp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const pp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],fp="000000",mp={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},vp={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",table:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",revision:"http://schemas.microsoft.com/office/spreadsheetml/2014/revision",revision3:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3",markupCompatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006"},bp="http://schemas.openxmlformats.org/drawingml/2006/main",Sp="http://schemas.openxmlformats.org/drawingml/2006/chart",Cp={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",themes:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",pivot:"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",externalLink:"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"},Ep={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",sharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",drawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"},wp="http://schemas.openxmlformats.org/officeDocument/2006/relationships",yp=.75,xp=.1317,Rp=8.43,Ip=12.75,Tp=30,Ap=100,Op=164,Mp={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},Np=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"],_p="[Content_Types].xml";var Fp;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(Fp||(Fp={}));class Dp{constructor(){this._parsingWarnings=new Set,this._conversionWarnings=new Set}addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,o){let n=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(n+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(n)||this._conversionWarnings.add(n)}}const kp=["thin"],$p=["general","left","center","right"],Lp=["Arial"],Pp=["solid"],Up=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Vp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},zp={dashDot:"thin",dashDotDot:"thin",dashed:"thin",dotted:"thin",double:"thin",hair:"thin",medium:"thin",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thin",thin:"thin"},Bp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Hp={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},Wp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},Gp={NoIcons:void 0,"3Arrows":"arrows","3ArrowsGray":"arrows","3Symbols":"smiley","3Symbols2":"smiley","3Signs":"dots","3Flags":"dots","3TrafficLights1":"dots","3TrafficLights2":"dots","4Arrows":"arrows","4ArrowsGray":"arrows","4RedToBlack":"dots","4Rating":"smiley","4TrafficLights":"dots","5Arrows":"arrows","5ArrowsGray":"arrows","5Rating":"smiley","5Quarters":"dots","3Stars":"smiley","3Triangles":"arrows","5Boxes":"dots"},qp={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},Zp={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},jp={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV",8:"STDEVP",9:"SUM",10:"VAR",11:"VARP",101:"AVERAGE",102:"COUNT",103:"COUNTA",104:"MAX",105:"MIN",106:"PRODUCT",107:"STDEV",108:"STDEVP",109:"SUM",110:"VAR",111:"VARP"},Xp={0:"",1:"0",2:"0.00",3:"#,#00",4:"#,##0.00",9:"0%",10:"0.00%",11:void 0,12:void 0,13:void 0,14:"m/d/yyyy",15:"m/d/yyyy",16:"m/d/yyyy",17:"m/d/yyyy",18:"hh:mm:ss a",19:"hh:mm:ss a",20:"hhhh:mm:ss",21:"hhhh:mm:ss",22:"m/d/yy h:mm",37:void 0,38:void 0,39:void 0,40:void 0,45:"hhhh:mm:ss",46:"hhhh:mm:ss",47:"hhhh:mm:ss",48:void 0,49:void 0},Yp={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Kp={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"};function Qp(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=fp;else{if(!e.indexed)return;t=Kp[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=ut(e),n=pt(o);t<0&&(n.l=n.l*(1+t));t>0&&(n.l=n.l*(1-t)+(100-100*(1-t)));return dt(gt(n))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function Jp(e,t){const o=e.split("/"),n=t.split("/");let i="",r=0;for(let e=0;e<o.length-1;e++)o[e]===n[e]?r++:i+="../";return i+=n.slice(r).join("/"),i}function ef(e,t=0){const o={};for(let n=0;n<e.length;n++)e[n]&&(o[n+t]=e[n]);return o}function tf(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function of(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}function nf(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(Fp.DiagonalBorderNotSupported)}(e,t);const o={top:rf(e.top,t),bottom:rf(e.bottom,t),left:rf(e.left,t),right:rf(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return ef(o,1)}function rf(e,t){if(!e)return;!function(e,t){kp.includes(e.style)||t.generateNotSupportedWarning(Fp.BorderStyleNotSupported,e.style,kp)}(e,t);const o=zp[e.style];return o?[o,Qp(e.color)]:void 0}function sf(e,t){return ef(e.styles.map((o=>af({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function af(e,t){var o,n,i,r,s,a,l,c,h,d,u,g;return function(e,t,o){e&&e.name&&!Lp.includes(e.name)&&o.generateNotSupportedWarning(Fp.FontNotSupported,e.name,Lp);t&&t.patternType&&!Pp.includes(t.patternType)&&o.generateNotSupportedWarning(Fp.FillStyleNotSupported,t.patternType,Pp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!$p.includes(e)&&t.generateNotSupportedWarning(Fp.HorizontalAlignmentNotSupported,e,$p)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(Fp.VerticalAlignmentNotSupported)}(null===(n=null==e?void 0:e.alignment)||void 0===n?void 0:n.vertical,t),{bold:null===(i=e.fontStyle)||void 0===i?void 0:i.bold,italic:null===(r=e.fontStyle)||void 0===r?void 0:r.italic,strikethrough:null===(s=e.fontStyle)||void 0===s?void 0:s.strike,underline:null===(a=e.fontStyle)||void 0===a?void 0:a.underline,align:(null===(l=e.alignment)||void 0===l?void 0:l.horizontal)?Bp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?Qp(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):Qp(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:Qp(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:(null===(g=e.fontStyle)||void 0===g?void 0:g.size)?hf(e.fontStyle.size):void 0}}function lf(e,t){const o=[];for(let n of e.styles){const i=cf(n.numFmtId,e.numFmts,t);i&&(o[n.numFmtId]=i)}return ef(o,1)}function cf(e,t,o){var n,i,r;if(0===e)return;let s=Xp[e]||(null===(n=t.find((t=>t.id===e)))||void 0===n?void 0:n.format);if(s)try{let e=s.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(i=e.match(/"/g))||void 0===i?void 0:i.length)||0;if(t/2+((null===(r=e.match(/\[/g))||void 0===r?void 0:r.length)||0)>1)throw new Error("Multiple escaped blocks in format");return e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),Ut(0,e),e}catch(e){}o.generateNotSupportedWarning(Fp.NumFmtIdNotSupported,s||`nmFmtId ${e}`)}function hf(e){return Object.keys(re).map(Number).reduce(((t,o)=>Math.abs(o-e)<Math.abs(t-e)?o:t))}function df(e,t,o){const n=[];let i=1;for(let s of e){if(0===s.cfRules.length)continue;ff(s,t,o);const e=s.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=uf(i++,s);t&&n.push(t);continue;case"iconSet":const c=gf(i++,s,o);c&&n.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Hp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Hp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(r=e.operator).slice(0,1).toUpperCase()+r.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&n.push({id:(i++).toString(),ranges:s.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:af({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var r;return n}function uf(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const n=[];for(let e=0;e<o.cfvos.length;e++)n.push({color:(i=Qp(o.colors[e])||"#FFFFFF",9===i.length&&(i=i.slice(0,7)),parseInt(i.replace("#",""),16)),type:Wp[o.cfvos[e].type],value:o.cfvos[e].value});var i;const r=n[0],s=2===n.length?n[1]:n[2],a=3===n.length?n[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:s}}}function gf(e,t,o){const n=t.cfRules[0].iconSet;if(!n)return;let i=n.cfvos,r=n.cfIcons;if(i.length<3||r&&r.length<3)return;i.length>3&&(i=[i[0],i[Math.floor(i.length/2)],i[i.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const s=[];for(let e=1;e<=2;e++){const t=Wp[i[e].type];if("value"===t)return;s.push({value:i[e].value||"",operator:i[e].gte?"ge":"gt",type:t})}let a={lower:r?pf(r[0].iconSet,r[0].iconId):pf(n.iconSet,0),middle:r?pf(r[1].iconSet,r[1].iconId):pf(n.iconSet,1),upper:r?pf(r[2].iconSet,r[2].iconId):pf(n.iconSet,2)};n.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(Fp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=jr.dots.good;break;case"middle":a[e]=jr.dots.neutral;break;case"lower":a[e]=jr.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:s[1],lowerInflectionPoint:s[0]}}}function pf(e,t){const o=Gp[e];return o?0===t?jr[o].bad:1===t?jr[o].neutral:jr[o].good:""}function ff(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(Fp.MultipleRulesCfNotSupported),Up.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(Fp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const n=t[e.cfRules[0].dxfId];n.border&&o.generateNotSupportedWarning(Fp.CfFormatBorderNotSupported),n.alignment&&o.generateNotSupportedWarning(Fp.CfFormatAlignmentNotSupported),n.numFmt&&o.generateNotSupportedWarning(Fp.CfFormatNumFmtNotSupported)}}function mf(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function vf(e){return Math.round(yp*e*window.devicePixelRatio*100)/100}function bf(e){return Math.round(xp*e*100)/100}function Sf(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function Cf(e,t){let o={};e.style&&(o=t.styles[e.style]);const n=e.format?t.formats[e.format]:void 0,i={};if(e.border){const o=t.borders[e.border];i.left=Sf(o.left),i.right=Sf(o.right),i.bottom=Sf(o.bottom),i.top=Sf(o.top)}const r={font:{size:(null==o?void 0:o.fontSize)||W,color:{rgb:(null==o?void 0:o.textColor)?o.textColor:"000000"},family:2,name:"Arial"},fill:(null==o?void 0:o.fillColor)?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:n?{format:n,id:0}:void 0,border:i||{},alignment:{vertical:"center",horizontal:o.align}};return r.font.strike=!!(null==o?void 0:o.strikethrough)||void 0,r.font.underline=!!(null==o?void 0:o.underline)||void 0,r.font.bold=!!(null==o?void 0:o.bold)||void 0,r.font.italic=!!(null==o?void 0:o.italic)||void 0,r}function Ef(e,t){const{id:o}=yf(t.font,e.fonts),{id:n}=yf(t.fill,e.fills),{id:i}=yf(t.border,e.borders),r=function(e,t){if(!e)return 0;let o=Yp[e.format];if(!o){const{id:n}=yf(e,t);o=n+Op}return o}(t.numFmt,e.numFmts),s={fontId:o,fillId:n,borderId:i,numFmtId:r,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=yf(s,e.styles);return a}function wf(e,t,o){let n,i=e.find((e=>e.path===t));return i?(n=`rId${(i.rels.length+1).toString()}`,i.rels.push({...o,id:n})):(n="rId1",e.push({path:t,rels:[{...o,id:n}]})),n}function yf(e,t){for(let[o,n]of Object.entries(t))if(JSON.stringify(n)===JSON.stringify(e))return{id:parseInt(o,10),list:t};let o=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===o&&(t.push(e),o=t.length-1),{id:o,list:t}}const xf=[];function Rf(e){const t=xf.findIndex((t=>t===e));return-1===t?(xf.push(e),xf.length):t+1}function If(e){return Math.round(914400*e/96)}function Tf(e,t,o){let n,i,r=e;if(({xc:r,sheetName:n}=Rt(e)),n){const e=o.sheets.findIndex((e=>e.name===n));if(e<0)throw new Error("Unable to find a sheet with the name "+n);i=e}else i=Number(t);const s=fo(r);return void 0===s.right&&(s.right=o.sheets[i].colNumber),void 0===s.bottom&&(s.bottom=o.sheets[i].rowNumber),(s.right-s.left+1)*(s.bottom-s.top+1)}function Af(e){return Math.round(96*e/914400)}function Of(e,t){var o;let n=0;for(let i=0;i<e;i++){const e=t.cols.find((e=>i>=e.min&&i<=e.max));(null==e?void 0:e.width)?n+=e.width:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?n+=t.sheetFormat.defaultColWidth:n+=Rp}return n/xp}function Mf(e,t){var o;let n=0;for(let i=0;i<e;i++){const e=t.rows[i];(null==e?void 0:e.height)?n+=e.height:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?n+=t.sheetFormat.defaultRowHeight:n+=Ip}return n/yp}function Nf(e){let t=1;return e.figures.map((o=>function(e,t,o){const n=Of(e.anchors[0].col,o)+Af(e.anchors[0].colOffset),i=Of(e.anchors[1].col,o)+Af(e.anchors[1].colOffset),r=Mf(e.anchors[0].row,o)+Af(e.anchors[0].rowOffset),s=Mf(e.anchors[1].row,o)+Af(e.anchors[1].rowOffset),a=i-n,l=s-r,c=_f(e.data);return c?{id:t,x:n,y:r,width:a,height:l,tag:"chart",data:_f(e.data)}:void 0}(o,(t++).toString(),e))).filter(Ze)}function _f(e){var t;const o=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let n=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&n.reverse(),{dataSets:n,dataSetsHaveTitle:!1,labelRange:o,title:e.title||"",type:e.type,background:Qp({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,labelsAsText:!1}}const Ff=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Df=new RegExp(/SUBTOTAL\(([0-9]*),/g),kf=new RegExp(ft.source,"ig");function $f(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let n of e.rows.map((e=>e.cells)).flat())(null==n?void 0:n.formula)&&(n.formula.content=void 0===n.formula.sharedIndex||n.formula.content?"="+n.formula.content:"="+Pf(n.xc,o[n.formula.sharedIndex]),n.formula.content=Lf(n.formula.content,t))}function Lf(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(Df,((e,t)=>{const o=jp[t];return o?o+"(":e}))).replace(Ff,((e,o,n,i)=>{var r;o=Number(o)-1,i=i.replace(/\$/g,"");const s=t.externalBooks[o].sheetNames.findIndex((e=>e===n));if(-1===s)return e;const a=null===(r=t.externalBooks[o].datasets.find((e=>e.sheetId===s)))||void 0===r?void 0:r.data;if(!a)return e;const l=a&&a[i];return(Number(l)?l:`"${l}"`)||e}))}function Pf(e,t){const o=At(t.refCellXc);let n,i=t.formula.slice();do{if(n=kf.exec(i),n){const t=At(n[0].replace("$","")),r=At(e),s={colFixed:n[0].startsWith("$"),rowFixed:n[0].includes("$",1)},a={col:r.col-o.col,row:r.row-o.row},l={col:s.colFixed?t.col:t.col+a.col,row:s.rowFixed?t.row:t.row+a.row};i=i.slice(0,n.index)+Ot(l.col,l.row,s)+i.slice(n.index+n[0].length)}}while(n);return i}function Uf(e,t){return e.sheets.map((o=>{$f(o,e);const n=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],...o.cells.map((e=>At(e.xc).col))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],Tp),t[1]=Math.max(t[1],Ap),t}(o),i=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!i||i.showGridLines,name:o.sheetName,colNumber:n[0],rowNumber:n[1],cells:Bf(o,e,n,t),merges:o.merges,cols:Vf(o,n[0]),rows:zf(o,n[1]),conditionalFormats:df(o.cfs,e.dxfs,t),figures:Nf(o),isVisible:o.isVisible,panes:i?{xSplit:i.pane.xSplit,ySplit:i.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Vf(e,t){var o;const n={};for(let r=1;r<t+1;r++){const t=e.cols.find((e=>e.min<=r&&r<=e.max));let s;s=t&&t.width?t.width:(null===(o=e.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?e.sheetFormat.defaultColWidth:Rp,n[r-1]={size:(i=s,i?Math.round(i/xp*100)/100:i),isHidden:null==t?void 0:t.hidden}}var i;return n}function zf(e,t){var o;const n={};for(let r=1;r<t+1;r++){const t=e.rows.find((e=>e.index===r));let s;s=t&&t.height?t.height:(null===(o=e.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?e.sheetFormat.defaultRowHeight:Ip,n[r-1]={size:(i=s,i?Math.round(i/yp*100)/100:i),isHidden:null==t?void 0:t.hidden}}var i;return n}function Bf(e,t,o,n){const i={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const s=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let o of e.rows)for(let e of o.cells)i[e.xc]={content:Hf(e,s,r,n),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let n of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=Ot(e-1,n.index-1);let r=i[o];r||(r={},i[o]=r),r.style=r.style?r.style:n.styleIndex+1,r.border=r.border?r.border:t.styles[n.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[n.styleIndex].numFmtId+1}for(let n of e.cols.filter((e=>e.styleIndex)))for(let e=n.min;e<=Math.min(n.max,o[0]);e++)for(let r=1;r<=o[1];r++){const o=Ot(e-1,r-1);let s=i[o];s||(s={},i[o]=s),s.style=s.style?s.style:n.styleIndex+1,s.border=s.border?s.border:t.styles[n.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[n.styleIndex].numFmtId+1}return i}function Hf(e,t,o,n){let i;switch(e.type){case"sharedString":i=o[parseInt(e.value,10)];break;case"boolean":i=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":i=e.value}return i&&t[e.xc]&&(i=function(e,t,o){const n=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(Fp.BadlyFormattedHyperlink);const i=e.relTarget?e.relTarget:Ge(Rt(e.location).sheetName);return ze(n,i)}(t[e.xc],i,n)),e.formula&&(i=e.formula.content),i}const Wf={fillColor:"#000000",textColor:"#ffffff",bold:!0},Gf={bold:!0},qf=["thin","#000000FF"];function Zf(e,t){for(const o of t.sheets)for(const t of o.tables){const n=e.sheets.find((e=>e.name===o.sheetName));n&&t.autoFilter&&(n.filterTables||(n.filterTables=[]),n.filterTables.push({range:t.ref}))}!function(e,t){var o,n,i,r;const s=tf(e.styles),a=tf(e.borders);for(let l of t.sheets)for(let t of l.tables){const c=e.sheets.find((e=>e.name===l.sheetName));if(!c)continue;const h=mo(t.ref);for(let e=0;e<t.headerRowCount;e++)jf(Wf,{...h,bottom:h.top+e},c.cells,s);for(let e=0;e<t.totalsRowCount;e++)jf(Gf,{...h,top:h.bottom-e},c.cells,s);(null===(o=t.style)||void 0===o?void 0:o.showFirstColumn)&&jf(Gf,{...h,right:h.left},c.cells,s),(null===(n=t.style)||void 0===n?void 0:n.showLastColumn)&&jf(Gf,{...h,left:h.right},c.cells,s);for(let e=h.left;e<=h.right;e++)for(let o=h.top;o<=h.bottom;o++){const n=Ot(e,o),s=c.cells[n],l={left:e===h.left||(null===(i=t.style)||void 0===i?void 0:i.showColumnStripes)?qf:void 0,right:e===h.right?qf:void 0,top:o===h.top||(null===(r=t.style)||void 0===r?void 0:r.showRowStripes)||o>h.bottom-t.totalsRowCount?qf:void 0,bottom:o===h.bottom?qf:void 0},d=(null==s?void 0:s.border)?{...a[s.border],...l}:l;let u=a.findIndex((e=>et(e,d)));-1===u&&(u=a.length,a.push(d)),s?s.border=u:c.cells[n]={border:u}}}e.styles=ef(s),e.borders=ef(a)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let n of Fo(mo(t.ref))){const i=Ot(n.col,n.row),r=o.cells[i];if(r&&r.content&&r.content.startsWith("=")){let o;for(;-1!==(o=r.content.indexOf(e));){let n=r.content.slice(o+e.length),s=n.indexOf("]");n.startsWith("[")&&(s=n.indexOf("]",s+1),s=n.indexOf("]",s+1)),n=n.slice(0,s);const a=Xf(n,t,i);r.content=r.content.slice(0,o)+a+r.content.slice(e.length+o+s+1)}}}}}}(e.sheets,t.sheets)}function jf(e,t,o,n){for(let i=t.left;i<=t.right;i++)for(let r=t.top;r<=t.bottom;r++){const t=Ot(i,r),s=o[t],a=(null==s?void 0:s.style)?{...n[s.style],...e}:e;let l=n.findIndex((e=>et(e,a)));-1===l&&(l=n.length,n.push(a)),s?s.style=l:o[t]={style:l}}}function Xf(e,t,o){const n=e.split(","),i=mo(t.ref),r={...i};let s=!0;if(1===n.length){const e=t.cols.findIndex((e=>e.name===n[0]));r.left=r.right=e+i.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(n[0].slice(1,n[0].length-1)){case"#All":r.top=t.headerRowCount?i.top+t.headerRowCount:i.top,r.bottom=i.bottom;break;case"#Data":r.top=t.headerRowCount?i.top+t.headerRowCount:i.top,r.bottom=t.totalsRowCount?i.bottom+1:i.bottom;break;case"#This Row":r.top=r.bottom=At(o).row;break;case"#Headers":r.top=r.bottom=i.top,t.headerRowCount||(s=!1);break;case"#Totals":r.top=r.bottom=i.bottom,t.totalsRowCount||(s=!1)}const e=n[1].slice(1,n[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+i.left}return s?r.top!==r.bottom?bo(r):Ot(r.left,r.top):X}function Yf(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function Kf(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function Qf(e){return new gp(e.map((([e,t])=>`${e}="${Kf(t)}"`)).join(" "))}function Jf(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),o=t.querySelector("parsererror");if(o){const t=o.innerHTML,n=parseInt(t.split(":")[0],10),i=e.toString().trim().split("\n"),r=i.slice(Math.max(n-3,0),Math.min(n+2,i.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return t}function em(e,t){return om`
1364
+ />`,Jg.defaultProps={position:{top:0}};const ep={ROW:Ri,COL:xi,CELL:yi};class tp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=O,this.HEADER_WIDTH=M,this.keyDownMapping={ENTER:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{const e=this.env.model.getters.getActiveCell();!e||e.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},"CTRL+A":()=>this.env.model.selection.loopSelection(),"CTRL+S":()=>{var e,t;null===(t=(e=this.props).onSaveRequested)||void 0===t||t.call(e)},"CTRL+Z":()=>this.env.model.dispatch("REQUEST_UNDO"),"CTRL+Y":()=>this.env.model.dispatch("REQUEST_REDO"),"CTRL+B":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"CTRL+I":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"CTRL+U":()=>this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"ALT+=":()=>{var e;const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getSelectedZone(),{anchor:n}=this.env.model.getters.getSelection(),i=this.env.model.getters.getAutomaticSums(t,o,n.cell);if(this.env.model.getters.isSingleCellOrMerge(t,o)||this.env.model.getters.isEmpty(t,o)&&i.length<=1){const o=(null===(e=i[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,i[0].zone):"",n=`=SUM(${o})`;this.props.onGridComposerCellFocused(n,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition(e,0,0);this.env.model.selection.selectCell(t,o)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",Fe(0,this.env.model.getters.getNumberCols(e)).reverse()),o=this.env.model.getters.findVisibleHeader(e,"ROW",Fe(0,this.env.model.getters.getNumberRows(e)).reverse());this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},o=this.env.model.getters.getPosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP")}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=Cn(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),Gg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=qg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return"\n top: 26px;\n left: 48px;\n height: calc(100% - 41px);\n width: calc(100% - 63px);\n "}onClosePopover(){this.closeOpenedPopover(),this.focus()}focus(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.hiddenInput.el.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}isAutoFillActive(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:M,gridOffsetY:O})}moveCanvas(e,t){const{scrollX:o,scrollY:n}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:Math.max(o+e,0),offsetY:Math.max(n+t,0)})}getClientPositionKey(e){var t,o,n;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(o=e.position)||void 0===o?void 0:o.col}-${null===(n=e.position)||void 0===n?void 0:n.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}onCellClicked(e,t,{ctrlKey:o,shiftKey:n}){o&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),n?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let i=e,r=t;ls(this.env,((e,t)=>{(e!==i&&-1!=e||t!==r&&-1!=t)&&(i=-1===e?i:e,r=-1===t?r:t,this.env.model.selection.setAnchorCorner(i,r))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition(o,e,t));const n=this.env.model.getters.getCell(o,e,t);!n||n.isEmpty()?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.closeOpenedPopover();const t={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"}[e.key];e.shiftKey?this.env.model.selection.resizeAnchorZone(t,e.ctrlKey?"end":1):this.env.model.selection.moveAnchorCell(t,e.ctrlKey?"end":1),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):void 0}onInput(e){e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:o,top:n}=t;let i="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?i="COL":this.env.model.getters.getActiveRows().has(n)&&(i="ROW");const{x:r,y:s,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(i,r+a,s+l)}onCellRightClicked(e,t,{x:o,y:n}){const i=this.env.model.getters.getSelectedZones();let r="CELL";Ao(e,t,i[i.length-1])?this.env.model.getters.getActiveCols().has(e)?r="COL":this.env.model.getters.getActiveRows().has(t)&&(r="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(r,o,n)}toggleContextMenu(e,t,o){this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=ep[e].getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;if("inactive"!==this.env.model.getters.getEditionMode())return;e?zn(this.env):this.env.model.dispatch("COPY");const o=this.env.model.getters.getClipboardContent();t.clipboardData.setData("text/plain",o),t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t.types.indexOf("text/plain")>-1){const e=t.getData("text/plain"),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardContent()===e?qn(this.env,o):Zn(this.env,o,e)}}closeMenu(){this.menuState.isOpen=!1,this.focus()}}tp.template="o-spreadsheet-Grid",tp.components={GridComposer:Ng,GridOverlay:Ug,GridPopover:Vg,HeadersOverlay:Wg,Menu:wn,Autofill:cs,ClientTag:ds,Highlight:Xg,Popover:En,VerticalScrollBar:Jg,HorizontalScrollBar:Qg,FilterIconsOverlay:kg};class op{constructor(e,t,o){this.id=e,this.style=o.style,this.format=o.format,this.lazyEvaluated=t.map((e=>({...e,format:o.format||e.format})))}isFormula(){return!1}isLink(){return!1}isEmpty(){return!1}get evaluated(){return this.lazyEvaluated()}get formattedValue(){return Vt(this.evaluated.value,this.evaluated.format)}get composerContent(){return this.content}get defaultAlign(){switch(this.evaluated.type){case Zo.number:case Zo.empty:return"right";case Zo.boolean:case Zo.error:return"center";case Zo.text:return"left"}}get isAutoSummable(){var e;switch(this.evaluated.type){case Zo.empty:case Zo.text:return!0;case Zo.number:return!(null===(e=this.evaluated.format)||void 0===e?void 0:e.match(j));case Zo.error:case Zo.boolean:return!1}}}class np extends op{constructor(e,t={}){super(e,Qe({value:"",type:Zo.empty}),t),this.content=""}isEmpty(){return!0}}class ip extends op{constructor(e,t,o={}){super(e,Qe({value:t,type:Zo.number}),o),this.content=Vt(this.evaluated.value)}get composerContent(){var e;return(null===(e=this.format)||void 0===e?void 0:e.includes("%"))?100*this.evaluated.value+"%":super.composerContent}}class rp extends op{constructor(e,t,o={}){super(e,Qe({value:t,type:Zo.boolean}),o),this.content=this.evaluated.value?"TRUE":"FALSE"}}class sp extends op{constructor(e,t,o={}){super(e,Qe({value:t,type:Zo.text}),o),this.content=this.evaluated.value}}class ap extends ip{constructor(e,t,o){super(e,t,o),this.format=o.format}get composerContent(){return Vt(this.evaluated.value,this.format)}}class lp extends op{constructor(e,t,o={}){var n;const r=Be(t);o={...o,style:{...o.style,textColor:(null===(n=o.style)||void 0===n?void 0:n.textColor)||x}},r.label=i(r.label),super(e,Qe({value:r.label,type:Zo.text}),o),this.link=r,this.content=t}isLink(){return!0}get composerContent(){return this.link.label}}class cp extends lp{constructor(e,t,o={}){super(e,t,o),this.link.url=this.withHttp(this.link.url),this.link.isExternal=!0,this.content=ze(this.link.label,this.link.url),this.urlRepresentation=this.link.url,this.isUrlEditable=!0}action(e){window.open(this.link.url,"_blank")}withHttp(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}}class hp extends lp{constructor(e,t,o={},n){super(e,t,o),this.sheetName=n,this.sheetId=qe(this.link.url),this.isUrlEditable=!1}action(e){e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.model.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}get urlRepresentation(){return this.sheetName(this.sheetId)||r("Invalid sheet")}}class dp extends op{constructor(e,t,o,n,i){super(t,Qe({value:"Loading...",type:Zo.text}),i),this.buildFormulaString=e,this.compiledFormula=o,this.dependencies=n}get content(){return this.buildFormulaString(this)}isFormula(){return!0}assignEvaluation(e){this.lazyEvaluated=e.map((e=>{if(e instanceof c)return{value:e.errorType,type:Zo.error,error:e};const{value:t,format:o}=e;switch(typeof t){case"number":return{value:t||0,format:o,type:Zo.number};case"boolean":return{value:t,format:o,type:Zo.boolean};case"string":return{value:t,format:o,type:Zo.text};case"object":return{value:0,format:o,type:Zo.number};default:return{value:"",type:Zo.empty}}}))}}class up extends op{constructor(e,t,o,n){super(e,Qe({value:o.errorType,type:Zo.error,error:o}),n),this.content=t}}function gp(e){return""===e?"":so(e)?lo(e):$e(e)?"TRUE"===e.toUpperCase():Le(e)?pe(e).value:e}Fn.add("Formula",{sequence:10,match:e=>e.startsWith("="),createCell:(e,t,o,n,i)=>{const r=cg(t),s=r.dependencies.map((e=>i.getRangeFromSheetXC(n,e)));return new dp((e=>i.buildFormulaContent(n,e)),e,r,s,o)}}).add("Empty",{sequence:20,match:e=>""===e,createCell:(e,t,o)=>new np(e,o)}).add("NumberWithDateTimeFormat",{sequence:25,match:(e,t)=>!!t&&so(e)&&function(e){try{return Wt(1,e),!0}catch(e){return!1}}(t),createCell:(e,t,o)=>{const n=o.format;return new ap(e,lo(t),{...o,format:n})}}).add("Number",{sequence:30,match:e=>so(e),createCell:(e,t,o)=>(o.format||(o.format=function(e){const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const n=e.match(/[\d]/),i="[$"+o.values().next().value+"]";return n.index<o.index?"#,##"+t+i:i+"#,##"+t}if(e.includes("%"))return t+"%";return}(t)),new ip(e,lo(t),o))}).add("Boolean",{sequence:40,match:e=>$e(e),createCell:(e,t,o)=>new rp(e,"TRUE"===t.toUpperCase(),o)}).add("DateTime",{sequence:50,match:e=>Le(e),createCell:(e,t,o)=>{const n=pe(t),i=o.format||n.format;return new ap(e,n.value,{...o,format:i})}}).add("MarkdownSheetLink",{sequence:60,match:e=>We(e),createCell:(e,t,o,n,i)=>new hp(e,t,o,(e=>i.tryGetSheetName(e)))}).add("MarkdownLink",{sequence:70,match:e=>Ve(e),createCell:(e,t,o)=>new cp(e,t,o)}).add("WebLink",{sequence:80,match:e=>{return t=e,Ue.test(t);var t},createCell:(e,t,o)=>new cp(e,ze(t,t),o)});class pp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const fp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],mp="000000",vp={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},bp={styleSheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",sst:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",Relationships:"http://schemas.openxmlformats.org/package/2006/relationships",Types:"http://schemas.openxmlformats.org/package/2006/content-types",worksheet:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",workbook:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",drawing:"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",table:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",revision:"http://schemas.microsoft.com/office/spreadsheetml/2014/revision",revision3:"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3",markupCompatibility:"http://schemas.openxmlformats.org/markup-compatibility/2006"},Sp="http://schemas.openxmlformats.org/drawingml/2006/main",Cp="http://schemas.openxmlformats.org/drawingml/2006/chart",Ep={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",sharedStrings:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml",styles:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml",drawing:"application/vnd.openxmlformats-officedocument.drawing+xml",chart:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",themes:"application/vnd.openxmlformats-officedocument.theme+xml",table:"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml",pivot:"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml",externalLink:"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml"},wp={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",sharedStrings:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",styles:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",drawing:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",chart:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",theme:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",table:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",hyperlink:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"},yp="http://schemas.openxmlformats.org/officeDocument/2006/relationships",xp=.75,Rp=.1317,Ip=8.43,Tp=12.75,Ap=30,Op=100,Mp=164,Np={FLOOR:[{type:"NUMBER",value:1}],CEILING:[{type:"NUMBER",value:1}],ROUND:[{type:"NUMBER",value:0}],ROUNDUP:[{type:"NUMBER",value:0}],ROUNDDOWN:[{type:"NUMBER",value:0}]},_p=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","FILTERXML","FLOOR.MATH","FLOOR.PRECISE","FORECAST.ETS","FORECAST.ETS.CONFINT","FORECAST.ETS.SEASONALITY","FORECAST.ETS.STAT","FORECAST.LINEAR","FORMULATEXT","GAMMA","GAMMA.DIST","GAMMA.INV","GAMMALN.PRECISE","GAUSS","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","MAXIFS","MINIFS","MODE.MULT","MODE.SNGL","MUNIT","NEGBINOM.DIST","NORM.DIST","NORM.INV","NORM.S.DIST","NORM.S.INV","NUMBERVALUE","PDURATION","PERCENTILE.EXC","PERCENTILE.INC","PERCENTRANK.EXC","PERCENTRANK.INC","PERMUTATIONA","PHI","POISSON.DIST","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"],Fp="[Content_Types].xml";var Dp;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(Dp||(Dp={}));class kp{constructor(){this._parsingWarnings=new Set,this._conversionWarnings=new Set}addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,o){let n=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(n+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(n)||this._conversionWarnings.add(n)}}const $p=["thin"],Lp=["general","left","center","right"],Pp=["Arial"],Up=["solid"],Vp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],zp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},Bp={dashDot:"thin",dashDotDot:"thin",dashed:"thin",dotted:"thin",double:"thin",hair:"thin",medium:"thin",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thin",thin:"thin"},Hp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Wp={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},Gp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},qp={NoIcons:void 0,"3Arrows":"arrows","3ArrowsGray":"arrows","3Symbols":"smiley","3Symbols2":"smiley","3Signs":"dots","3Flags":"dots","3TrafficLights1":"dots","3TrafficLights2":"dots","4Arrows":"arrows","4ArrowsGray":"arrows","4RedToBlack":"dots","4Rating":"smiley","4TrafficLights":"dots","5Arrows":"arrows","5ArrowsGray":"arrows","5Rating":"smiley","5Quarters":"dots","3Stars":"smiley","3Triangles":"arrows","5Boxes":"dots"},Zp={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},jp={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},Xp={1:"AVERAGE",2:"COUNT",3:"COUNTA",4:"MAX",5:"MIN",6:"PRODUCT",7:"STDEV",8:"STDEVP",9:"SUM",10:"VAR",11:"VARP",101:"AVERAGE",102:"COUNT",103:"COUNTA",104:"MAX",105:"MIN",106:"PRODUCT",107:"STDEV",108:"STDEVP",109:"SUM",110:"VAR",111:"VARP"},Yp={0:"",1:"0",2:"0.00",3:"#,#00",4:"#,##0.00",9:"0%",10:"0.00%",11:void 0,12:void 0,13:void 0,14:"m/d/yyyy",15:"m/d/yyyy",16:"m/d/yyyy",17:"m/d/yyyy",18:"hh:mm:ss a",19:"hh:mm:ss a",20:"hhhh:mm:ss",21:"hhhh:mm:ss",22:"m/d/yy h:mm",37:void 0,38:void 0,39:void 0,40:void 0,45:"hhhh:mm:ss",46:"hhhh:mm:ss",47:"hhhh:mm:ss",48:void 0,49:void 0},Kp={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Qp={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"};function Jp(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=mp;else{if(!e.indexed)return;t=Qp[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=gt(e),n=ft(o);t<0&&(n.l=n.l*(1+t));t>0&&(n.l=n.l*(1-t)+(100-100*(1-t)));return ut(pt(n))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function ef(e,t){const o=e.split("/"),n=t.split("/");let i="",r=0;for(let e=0;e<o.length-1;e++)o[e]===n[e]?r++:i+="../";return i+=n.slice(r).join("/"),i}function tf(e,t=0){const o={};for(let n=0;n<e.length;n++)e[n]&&(o[n+t]=e[n]);return o}function of(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function nf(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}function rf(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(Dp.DiagonalBorderNotSupported)}(e,t);const o={top:sf(e.top,t),bottom:sf(e.bottom,t),left:sf(e.left,t),right:sf(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return tf(o,1)}function sf(e,t){if(!e)return;!function(e,t){$p.includes(e.style)||t.generateNotSupportedWarning(Dp.BorderStyleNotSupported,e.style,$p)}(e,t);const o=Bp[e.style];return o?[o,Jp(e.color)]:void 0}function af(e,t){return tf(e.styles.map((o=>lf({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function lf(e,t){var o,n,i,r,s,a,l,c,h,d,u,g;return function(e,t,o){e&&e.name&&!Pp.includes(e.name)&&o.generateNotSupportedWarning(Dp.FontNotSupported,e.name,Pp);t&&t.patternType&&!Up.includes(t.patternType)&&o.generateNotSupportedWarning(Dp.FillStyleNotSupported,t.patternType,Up)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!Lp.includes(e)&&t.generateNotSupportedWarning(Dp.HorizontalAlignmentNotSupported,e,Lp)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(Dp.VerticalAlignmentNotSupported)}(null===(n=null==e?void 0:e.alignment)||void 0===n?void 0:n.vertical,t),{bold:null===(i=e.fontStyle)||void 0===i?void 0:i.bold,italic:null===(r=e.fontStyle)||void 0===r?void 0:r.italic,strikethrough:null===(s=e.fontStyle)||void 0===s?void 0:s.strike,underline:null===(a=e.fontStyle)||void 0===a?void 0:a.underline,align:(null===(l=e.alignment)||void 0===l?void 0:l.horizontal)?Hp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?Jp(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):Jp(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:Jp(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:(null===(g=e.fontStyle)||void 0===g?void 0:g.size)?df(e.fontStyle.size):void 0}}function cf(e,t){const o=[];for(let n of e.styles){const i=hf(n.numFmtId,e.numFmts,t);i&&(o[n.numFmtId]=i)}return tf(o,1)}function hf(e,t,o){var n,i,r;if(0===e)return;let s=Yp[e]||(null===(n=t.find((t=>t.id===e)))||void 0===n?void 0:n.format);if(s)try{let e=s.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(i=e.match(/"/g))||void 0===i?void 0:i.length)||0;if(t/2+((null===(r=e.match(/\[/g))||void 0===r?void 0:r.length)||0)>1)throw new Error("Multiple escaped blocks in format");return e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),Vt(0,e),e}catch(e){}o.generateNotSupportedWarning(Dp.NumFmtIdNotSupported,s||`nmFmtId ${e}`)}function df(e){return Object.keys(re).map(Number).reduce(((t,o)=>Math.abs(o-e)<Math.abs(t-e)?o:t))}function uf(e,t,o){const n=[];let i=1;for(let s of e){if(0===s.cfRules.length)continue;mf(s,t,o);const e=s.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=gf(i++,s);t&&n.push(t);continue;case"iconSet":const c=pf(i++,s,o);c&&n.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Wp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Wp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(r=e.operator).slice(0,1).toUpperCase()+r.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&n.push({id:(i++).toString(),ranges:s.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:lf({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var r;return n}function gf(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const n=[];for(let e=0;e<o.cfvos.length;e++)n.push({color:(i=Jp(o.colors[e])||"#FFFFFF",9===i.length&&(i=i.slice(0,7)),parseInt(i.replace("#",""),16)),type:Gp[o.cfvos[e].type],value:o.cfvos[e].value});var i;const r=n[0],s=2===n.length?n[1]:n[2],a=3===n.length?n[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:r,midpoint:a,maximum:s}}}function pf(e,t,o){const n=t.cfRules[0].iconSet;if(!n)return;let i=n.cfvos,r=n.cfIcons;if(i.length<3||r&&r.length<3)return;i.length>3&&(i=[i[0],i[Math.floor(i.length/2)],i[i.length-1]]),r&&r.length>3&&(r=[r[0],r[Math.floor(r.length/2)],r[r.length-1]]);const s=[];for(let e=1;e<=2;e++){const t=Gp[i[e].type];if("value"===t)return;s.push({value:i[e].value||"",operator:i[e].gte?"ge":"gt",type:t})}let a={lower:r?ff(r[0].iconSet,r[0].iconId):ff(n.iconSet,0),middle:r?ff(r[1].iconSet,r[1].iconId):ff(n.iconSet,1),upper:r?ff(r[2].iconSet,r[2].iconId):ff(n.iconSet,2)};n.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(Dp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=Xr.dots.good;break;case"middle":a[e]=Xr.dots.neutral;break;case"lower":a[e]=Xr.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:s[1],lowerInflectionPoint:s[0]}}}function ff(e,t){const o=qp[e];return o?0===t?Xr[o].bad:1===t?Xr[o].neutral:Xr[o].good:""}function mf(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(Dp.MultipleRulesCfNotSupported),Vp.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(Dp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const n=t[e.cfRules[0].dxfId];n.border&&o.generateNotSupportedWarning(Dp.CfFormatBorderNotSupported),n.alignment&&o.generateNotSupportedWarning(Dp.CfFormatAlignmentNotSupported),n.numFmt&&o.generateNotSupportedWarning(Dp.CfFormatNumFmtNotSupported)}}function vf(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function bf(e){return Math.round(xp*e*window.devicePixelRatio*100)/100}function Sf(e){return Math.round(Rp*e*100)/100}function Cf(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function Ef(e,t){let o={};e.style&&(o=t.styles[e.style]);const n=e.format?t.formats[e.format]:void 0,i={};if(e.border){const o=t.borders[e.border];i.left=Cf(o.left),i.right=Cf(o.right),i.bottom=Cf(o.bottom),i.top=Cf(o.top)}const r={font:{size:(null==o?void 0:o.fontSize)||W,color:{rgb:(null==o?void 0:o.textColor)?o.textColor:"000000"},family:2,name:"Arial"},fill:(null==o?void 0:o.fillColor)?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:n?{format:n,id:0}:void 0,border:i||{},alignment:{vertical:"center",horizontal:o.align}};return r.font.strike=!!(null==o?void 0:o.strikethrough)||void 0,r.font.underline=!!(null==o?void 0:o.underline)||void 0,r.font.bold=!!(null==o?void 0:o.bold)||void 0,r.font.italic=!!(null==o?void 0:o.italic)||void 0,r}function wf(e,t){const{id:o}=xf(t.font,e.fonts),{id:n}=xf(t.fill,e.fills),{id:i}=xf(t.border,e.borders),r=function(e,t){if(!e)return 0;let o=Kp[e.format];if(!o){const{id:n}=xf(e,t);o=n+Mp}return o}(t.numFmt,e.numFmts),s={fontId:o,fillId:n,borderId:i,numFmtId:r,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=xf(s,e.styles);return a}function yf(e,t,o){let n,i=e.find((e=>e.path===t));return i?(n=`rId${(i.rels.length+1).toString()}`,i.rels.push({...o,id:n})):(n="rId1",e.push({path:t,rels:[{...o,id:n}]})),n}function xf(e,t){for(let[o,n]of Object.entries(t))if(JSON.stringify(n)===JSON.stringify(e))return{id:parseInt(o,10),list:t};let o=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===o&&(t.push(e),o=t.length-1),{id:o,list:t}}const Rf=[];function If(e){const t=Rf.findIndex((t=>t===e));return-1===t?(Rf.push(e),Rf.length):t+1}function Tf(e){return Math.round(914400*e/96)}function Af(e,t,o){let n,i,r=e;if(({xc:r,sheetName:n}=It(e)),n){const e=o.sheets.findIndex((e=>e.name===n));if(e<0)throw new Error("Unable to find a sheet with the name "+n);i=e}else i=Number(t);const s=mo(r);return void 0===s.right&&(s.right=o.sheets[i].colNumber),void 0===s.bottom&&(s.bottom=o.sheets[i].rowNumber),(s.right-s.left+1)*(s.bottom-s.top+1)}function Of(e){return Math.round(96*e/914400)}function Mf(e,t){var o;let n=0;for(let i=0;i<e;i++){const e=t.cols.find((e=>i>=e.min&&i<=e.max));(null==e?void 0:e.width)?n+=e.width:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?n+=t.sheetFormat.defaultColWidth:n+=Ip}return n/Rp}function Nf(e,t){var o;let n=0;for(let i=0;i<e;i++){const e=t.rows[i];(null==e?void 0:e.height)?n+=e.height:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?n+=t.sheetFormat.defaultRowHeight:n+=Tp}return n/xp}function _f(e){let t=1;return e.figures.map((o=>function(e,t,o){const n=Mf(e.anchors[0].col,o)+Of(e.anchors[0].colOffset),i=Mf(e.anchors[1].col,o)+Of(e.anchors[1].colOffset),r=Nf(e.anchors[0].row,o)+Of(e.anchors[0].rowOffset),s=Nf(e.anchors[1].row,o)+Of(e.anchors[1].rowOffset),a=i-n,l=s-r,c=Ff(e.data);return c?{id:t,x:n,y:r,width:a,height:l,tag:"chart",data:Ff(e.data)}:void 0}(o,(t++).toString(),e))).filter(Ze)}function Ff(e){var t;const o=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let n=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&n.reverse(),{dataSets:n,dataSetsHaveTitle:!1,labelRange:o,title:e.title||"",type:e.type,background:Jp({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,labelsAsText:!1}}const Df=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),kf=new RegExp(/SUBTOTAL\(([0-9]*),/g),$f=new RegExp(mt.source,"ig");function Lf(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let n of e.rows.map((e=>e.cells)).flat())(null==n?void 0:n.formula)&&(n.formula.content=void 0===n.formula.sharedIndex||n.formula.content?"="+n.formula.content:"="+Uf(n.xc,o[n.formula.sharedIndex]),n.formula.content=Pf(n.formula.content,t))}function Pf(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(kf,((e,t)=>{const o=Xp[t];return o?o+"(":e}))).replace(Df,((e,o,n,i)=>{var r;o=Number(o)-1,i=i.replace(/\$/g,"");const s=t.externalBooks[o].sheetNames.findIndex((e=>e===n));if(-1===s)return e;const a=null===(r=t.externalBooks[o].datasets.find((e=>e.sheetId===s)))||void 0===r?void 0:r.data;if(!a)return e;const l=a&&a[i];return(Number(l)?l:`"${l}"`)||e}))}function Uf(e,t){const o=Ot(t.refCellXc);let n,i=t.formula.slice();do{if(n=$f.exec(i),n){const t=Ot(n[0].replace("$","")),r=Ot(e),s={colFixed:n[0].startsWith("$"),rowFixed:n[0].includes("$",1)},a={col:r.col-o.col,row:r.row-o.row},l={col:s.colFixed?t.col:t.col+a.col,row:s.rowFixed?t.row:t.row+a.row};i=i.slice(0,n.index)+Mt(l.col,l.row,s)+i.slice(n.index+n[0].length)}}while(n);return i}function Vf(e,t){return e.sheets.map((o=>{Lf(o,e);const n=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],...o.cells.map((e=>Ot(e.xc).col))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],Ap),t[1]=Math.max(t[1],Op),t}(o),i=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!i||i.showGridLines,name:o.sheetName,colNumber:n[0],rowNumber:n[1],cells:Hf(o,e,n,t),merges:o.merges,cols:zf(o,n[0]),rows:Bf(o,n[1]),conditionalFormats:uf(o.cfs,e.dxfs,t),figures:_f(o),isVisible:o.isVisible,panes:i?{xSplit:i.pane.xSplit,ySplit:i.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function zf(e,t){var o;const n={};for(let r=1;r<t+1;r++){const t=e.cols.find((e=>e.min<=r&&r<=e.max));let s;s=t&&t.width?t.width:(null===(o=e.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?e.sheetFormat.defaultColWidth:Ip,n[r-1]={size:(i=s,i?Math.round(i/Rp*100)/100:i),isHidden:null==t?void 0:t.hidden}}var i;return n}function Bf(e,t){var o;const n={};for(let r=1;r<t+1;r++){const t=e.rows.find((e=>e.index===r));let s;s=t&&t.height?t.height:(null===(o=e.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?e.sheetFormat.defaultRowHeight:Tp,n[r-1]={size:(i=s,i?Math.round(i/xp*100)/100:i),isHidden:null==t?void 0:t.hidden}}var i;return n}function Hf(e,t,o,n){const i={},r=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const s=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let o of e.rows)for(let e of o.cells)i[e.xc]={content:Wf(e,s,r,n),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let n of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=Mt(e-1,n.index-1);let r=i[o];r||(r={},i[o]=r),r.style=r.style?r.style:n.styleIndex+1,r.border=r.border?r.border:t.styles[n.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[n.styleIndex].numFmtId+1}for(let n of e.cols.filter((e=>e.styleIndex)))for(let e=n.min;e<=Math.min(n.max,o[0]);e++)for(let r=1;r<=o[1];r++){const o=Mt(e-1,r-1);let s=i[o];s||(s={},i[o]=s),s.style=s.style?s.style:n.styleIndex+1,s.border=s.border?s.border:t.styles[n.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[n.styleIndex].numFmtId+1}return i}function Wf(e,t,o,n){let i;switch(e.type){case"sharedString":i=o[parseInt(e.value,10)];break;case"boolean":i=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":i=e.value}return i&&t[e.xc]&&(i=function(e,t,o){const n=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(Dp.BadlyFormattedHyperlink);const i=e.relTarget?e.relTarget:Ge(It(e.location).sheetName);return ze(n,i)}(t[e.xc],i,n)),e.formula&&(i=e.formula.content),i}const Gf={fillColor:"#000000",textColor:"#ffffff",bold:!0},qf={bold:!0},Zf=["thin","#000000FF"];function jf(e,t){for(const o of t.sheets)for(const t of o.tables){const n=e.sheets.find((e=>e.name===o.sheetName));n&&t.autoFilter&&(n.filterTables||(n.filterTables=[]),n.filterTables.push({range:t.ref}))}!function(e,t){var o,n,i,r;const s=of(e.styles),a=of(e.borders);for(let l of t.sheets)for(let t of l.tables){const c=e.sheets.find((e=>e.name===l.sheetName));if(!c)continue;const h=vo(t.ref);for(let e=0;e<t.headerRowCount;e++)Xf(Gf,{...h,bottom:h.top+e},c.cells,s);for(let e=0;e<t.totalsRowCount;e++)Xf(qf,{...h,top:h.bottom-e},c.cells,s);(null===(o=t.style)||void 0===o?void 0:o.showFirstColumn)&&Xf(qf,{...h,right:h.left},c.cells,s),(null===(n=t.style)||void 0===n?void 0:n.showLastColumn)&&Xf(qf,{...h,left:h.right},c.cells,s);for(let e=h.left;e<=h.right;e++)for(let o=h.top;o<=h.bottom;o++){const n=Mt(e,o),s=c.cells[n],l={left:e===h.left||(null===(i=t.style)||void 0===i?void 0:i.showColumnStripes)?Zf:void 0,right:e===h.right?Zf:void 0,top:o===h.top||(null===(r=t.style)||void 0===r?void 0:r.showRowStripes)||o>h.bottom-t.totalsRowCount?Zf:void 0,bottom:o===h.bottom?Zf:void 0},d=(null==s?void 0:s.border)?{...a[s.border],...l}:l;let u=a.findIndex((e=>tt(e,d)));-1===u&&(u=a.length,a.push(d)),s?s.border=u:c.cells[n]={border:u}}}e.styles=tf(s),e.borders=tf(a)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let n of Do(vo(t.ref))){const i=Mt(n.col,n.row),r=o.cells[i];if(r&&r.content&&r.content.startsWith("=")){let o;for(;-1!==(o=r.content.indexOf(e));){let n=r.content.slice(o+e.length),s=n.indexOf("]");n.startsWith("[")&&(s=n.indexOf("]",s+1),s=n.indexOf("]",s+1)),n=n.slice(0,s);const a=Yf(n,t,i);r.content=r.content.slice(0,o)+a+r.content.slice(e.length+o+s+1)}}}}}}(e.sheets,t.sheets)}function Xf(e,t,o,n){for(let i=t.left;i<=t.right;i++)for(let r=t.top;r<=t.bottom;r++){const t=Mt(i,r),s=o[t],a=(null==s?void 0:s.style)?{...n[s.style],...e}:e;let l=n.findIndex((e=>tt(e,a)));-1===l&&(l=n.length,n.push(a)),s?s.style=l:o[t]={style:l}}}function Yf(e,t,o){const n=e.split(","),i=vo(t.ref),r={...i};let s=!0;if(1===n.length){const e=t.cols.findIndex((e=>e.name===n[0]));r.left=r.right=e+i.left,t.headerRowCount&&(r.top+=t.headerRowCount),t.totalsRowCount&&(r.bottom-=1)}else{switch(n[0].slice(1,n[0].length-1)){case"#All":r.top=t.headerRowCount?i.top+t.headerRowCount:i.top,r.bottom=i.bottom;break;case"#Data":r.top=t.headerRowCount?i.top+t.headerRowCount:i.top,r.bottom=t.totalsRowCount?i.bottom+1:i.bottom;break;case"#This Row":r.top=r.bottom=Ot(o).row;break;case"#Headers":r.top=r.bottom=i.top,t.headerRowCount||(s=!1);break;case"#Totals":r.top=r.bottom=i.bottom,t.totalsRowCount||(s=!1)}const e=n[1].slice(1,n[1].length-1),a=t.cols.findIndex((t=>t.name===e));r.left=r.right=a+i.left}return s?r.top!==r.bottom?So(r):Mt(r.left,r.top):X}function Kf(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function Qf(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function Jf(e){return new pp(e.map((([e,t])=>`${e}="${Qf(t)}"`)).join(" "))}function em(e){const t=(new DOMParser).parseFromString(e.toString(),"text/xml"),o=t.querySelector("parsererror");if(o){const t=o.innerHTML,n=parseInt(t.split(":")[0],10),i=e.toString().trim().split("\n"),r=i.slice(Math.max(n-3,0),Math.min(n+2,i.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${r}`)}return t}function tm(e,t){return nm`
1365
1365
  <Override ContentType="${t}" PartName="${e}" />
1366
- `}function tm(e){return new gp(e.join("\n"))}function om(e,...t){let o=[e[0]];for(let n=0;n<t.length;n++){const i=t[n]instanceof gp?t[n]:Kf(t[n]);o.push(i+e[n+1])}return new gp(Ye(o))}function nm(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function im(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class rm{constructor(e){this.value=e}asString(){return of(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class sm{constructor(e,t,o){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(Ze)}mapOnElements(e,t){var o;const n=[],i=this.currentFile;let r;if(e.children){const t=null===(o=this.querySelector(e.parent,e.query))||void 0===o?void 0:o.children;r=t||[]}else r=this.querySelectorAll(e.parent,e.query);if(r)for(let e of r)try{n.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=i,n}catchErrorOnElement(e,t){const o=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([o,e.message].join("\n"))}extractAttr(e,t,o){const n=e.attributes[t];n||this.handleMissingValue(e,`attribute "${t}"`,o);const i=(null==n?void 0:n.value)?n.value:null==o?void 0:o.default;return void 0===i?void 0:new rm(i)}extractTextContent(e,t){var o;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const n="preserve"===(null===(o=null==e?void 0:e.attributes["xml:space"])||void 0===o?void 0:o.value);let i=null==e?void 0:e.textContent;return e&&null!==i||this.handleMissingValue(e,"text content",t),i&&(i=n?i:i.trim()),i?of(i):null==t?void 0:t.default}extractChildAttr(e,t,o,n){var i;let r;r="number"==typeof t?e.children[t]:this.querySelector(e,t),r||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,n);const s=r?null===(i=this.extractAttr(r,o,n))||void 0===i?void 0:i.asString():null==n?void 0:n.default;return void 0!==s?new rm(s):void 0}extractChildTextContent(e,t,o){if(void 0!==(null==o?void 0:o.default)&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let n=this.querySelector(e,t);return n||this.handleMissingValue(e,`child <${t}>`,o),n?this.extractTextContent(n,o):null==o?void 0:o.default}handleMissingValue(e,t,o){if(null==o?void 0:o.required){if(!(null==o?void 0:o.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${o.default}`)}}extractColor(e,t,o){var n,i,r,s,a;if(!e)return o?{rgb:o}:void 0;const l=null===(n=this.extractAttr(e,"theme"))||void 0===n?void 0:n.asString();let c;if(void 0!==l){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");c=this.getThemeColor(l,t.clrScheme)}else c=null===(i=this.extractAttr(e,"rgb"))||void 0===i?void 0:i.asString();return{rgb:c,auto:null===(r=this.extractAttr(e,"auto"))||void 0===r?void 0:r.asBool(),indexed:null===(s=this.extractAttr(e,"indexed"))||void 0===s?void 0:s.asNum(),tint:null===(a=this.extractAttr(e,"tint"))||void 0===a?void 0:a.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const o=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}querySelector(e,t){return t=this.areNamespaceIgnored?nm(t):im(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?nm(t):im(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class am extends sm{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:fp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:fp}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class lm extends sm{constructor(e,t,o,n){super(e,t,o),this.theme=n}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var o,n,i,r,s,a,l,c,h,d,u;const g=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===g)throw new Error("Databars conditional formats are not supported.");return{type:g,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:null===(o=this.extractAttr(e,"dxfId"))||void 0===o?void 0:o.asNum(),stopIfTrue:null===(n=this.extractAttr(e,"stopIfTrue"))||void 0===n?void 0:n.asBool(),aboveAverage:null===(i=this.extractAttr(e,"aboveAverage"))||void 0===i?void 0:i.asBool(),percent:null===(r=this.extractAttr(e,"percent"))||void 0===r?void 0:r.asBool(),bottom:null===(s=this.extractAttr(e,"bottom"))||void 0===s?void 0:s.asBool(),operator:null===(a=this.extractAttr(e,"operator"))||void 0===a?void 0:a.asString(),text:null===(l=this.extractAttr(e,"text"))||void 0===l?void 0:l.asString(),timePeriod:null===(c=this.extractAttr(e,"timePeriod"))||void 0===c?void 0:c.asString(),rank:null===(h=this.extractAttr(e,"rank"))||void 0===h?void 0:h.asNum(),stdDev:null===(d=this.extractAttr(e,"stdDev"))||void 0===d?void 0:d.asNum(),equalAverage:null===(u=this.extractAttr(e,"equalAverage"))||void 0===u?void 0:u.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){var t,o;const n=this.querySelector(e,"iconSet, x14:iconSet");if(n)return{iconSet:this.extractAttr(n,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(n,"showValue",{default:!0}).asBool(),percent:this.extractAttr(n,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(n,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(o=this.extractAttr(n,"custom"))||void 0===o?void 0:o.asBool(),cfvos:this.extractCFVos(n),cfIcons:this.extractCfIcons(n)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,o;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(o=this.extractAttr(e,"val"))||void 0===o?void 0:o.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class cm extends sm{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!Zp[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),n=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:Zp[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:qp[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===n,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:cat c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=nm(e.tagName);if(pp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class hm extends sm{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==nm(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),n=new cm(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!n)throw new Error("Unable to extract chart definition");return n}}class dm extends sm{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class um extends sm{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,o,n,i,r;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(o=this.extractAttr(e,"showFirstColumn"))||void 0===o?void 0:o.asBool(),showLastColumn:null===(n=this.extractAttr(e,"showLastColumn"))||void 0===n?void 0:n.asBool(),showRowStripes:null===(i=this.extractAttr(e,"showRowStripes"))||void 0===i?void 0:i.asBool(),showColumnStripes:null===(r=this.extractAttr(e,"showColumnStripes"))||void 0===r?void 0:r.asBool()}}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class gm extends sm{constructor(e,t,o,n){super(e,t,o),this.theme=n}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=Jp(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=Jp(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new lm(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),n=this.getTargetXmlFile(this.relationships[o]);return new hm(n,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),n=this.getTargetXmlFile(this.relationships[o]);return new um(n,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new dm(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:Rp.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:Ip.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,o,n,i,r,s,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(o=this.extractAttr(e,"customWidth"))||void 0===o?void 0:o.asBool(),bestFit:null===(n=this.extractAttr(e,"bestFit"))||void 0===n?void 0:n.asBool(),hidden:null===(i=this.extractAttr(e,"hidden"))||void 0===i?void 0:i.asBool(),min:null===(r=this.extractAttr(e,"min",{required:!0}))||void 0===r?void 0:r.asNum(),max:null===(s=this.extractAttr(e,"max",{required:!0}))||void 0===s?void 0:s.asNum(),styleIndex:null===(a=this.extractAttr(e,"style"))||void 0===a?void 0:a.asNum()}}))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>{var t,o,n,i,r;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(o=this.extractAttr(e,"ht"))||void 0===o?void 0:o.asNum(),customHeight:null===(n=this.extractAttr(e,"customHeight"))||void 0===n?void 0:n.asBool(),hidden:null===(i=this.extractAttr(e,"hidden"))||void 0===i?void 0:i.asBool(),styleIndex:null===(r=this.extractAttr(e,"s"))||void 0===r?void 0:r.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,o,n;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(o=this.extractAttr(e,"s"))||void 0===o?void 0:o.asNum(),type:Vp[null===(n=this.extractAttr(e,"t",{default:"n"}))||void 0===n?void 0:n.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,o;const n=this.querySelector(e,"f");if(n)return{content:this.extractTextContent(n),sharedIndex:null===(t=this.extractAttr(n,"si"))||void 0===t?void 0:t.asNum(),ref:null===(o=this.extractAttr(n,"ref"))||void 0===o?void 0:o.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,o,n,i;const r=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(o=this.extractAttr(e,"ref",{required:!0}))||void 0===o?void 0:o.asString(),location:null===(n=this.extractAttr(e,"location"))||void 0===n?void 0:n.asString(),display:null===(i=this.extractAttr(e,"display"))||void 0===i?void 0:i.asString(),relTarget:r?this.relationships[r].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),n=this.extractTextContent(e,{required:!0});o[t]=n}const n=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?n.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),n.push(""));return n}}class pm extends sm{constructor(e,t,o){super(e.styles,e,t),this.theme=o}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,o,n,i;const r=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),s=this.extractChildAttr(e,"sz","val",{default:W.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(o=h.attributes.val)||void 0===o?void 0:o.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(n=u.attributes.val)||void 0===n?void 0:n.value),p=this.querySelector(e,"u")||void 0;return{name:r,size:s,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(i=p.attributes.val)||void 0===i?void 0:i.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const o=e.children[0];return"patternFill"===o.tagName?{patternType:null===(t=o.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(o,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(o,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(o,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,o;const n={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return n.diagonal&&(n.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),n.diagonalDown=null===(o=this.extractAttr(e,"diagonalDown"))||void 0===o?void 0:o.asBool()),n}extractSingleBorder(e,t,o){const n=this.querySelector(e,t);if(n&&n.attributes.style)return{style:this.extractAttr(n,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(n.children[0],o,"000000")}}extractAlignment(e){var t,o,n,i,r,s,a;return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"center"}).asString(),textRotation:null===(t=this.extractAttr(e,"textRotation"))||void 0===t?void 0:t.asNum(),wrapText:null===(o=this.extractAttr(e,"wrapText"))||void 0===o?void 0:o.asBool(),indent:null===(n=this.extractAttr(e,"indent"))||void 0===n?void 0:n.asNum(),relativeIndent:null===(i=this.extractAttr(e,"relativeIndent"))||void 0===i?void 0:i.asNum(),justifyLastLine:null===(r=this.extractAttr(e,"justifyLastLine"))||void 0===r?void 0:r.asBool(),shrinkToFit:null===(s=this.extractAttr(e,"shrinkToFit"))||void 0===s?void 0:s.asBool(),readingOrder:null===(a=this.extractAttr(e,"readingOrder"))||void 0===a?void 0:a.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),o=this.querySelector(e,"fill"),n=this.querySelector(e,"border"),i=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:i?this.extractNumFormats(i):void 0,alignment:r?this.extractAlignment(r):void 0,border:n?this.extractBorder(n):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class fm extends sm{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function mm(e,t){const o=function(e,t){const o=t[_p],n=o.querySelectorAll(`Override[ContentType="${e}"]`),i=[];for(let e of n){const t=null==e?void 0:e.attributes.PartName.value;i.push(t.substring(1))}return i}(e,t);return function(e,t){const o=[];for(let n of e){const e=vm(n,t);o.push({file:{fileName:n,xml:t[n]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function vm(e,t){if(e===_p)return"_rels/.rels";let o="";const n=e.split("/");for(let e=0;e<n.length-1;e++)o+=n[e]+"/";return o+="_rels/",o+=n[n.length-1]+".rels",t[o]||(o=void 0),o}class bm{constructor(e){this.warningManager=new Dp,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=Jf(new gp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new am(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new am(e.sharedStrings,e,this.warningManager).getSharedStrings():[],n=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new gm(o,e,this.warningManager,t).getSheet())),i=e.externalLinks.map((t=>new fm(t,e,this.warningManager).getExternalBook())),r=new pm(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:n,sharedStrings:o,externalBooks:i}}buildXlsxFileStructure(){const e={sheets:mm(Cp.sheet,this.xmls),workbook:mm(Cp.workbook,this.xmls)[0],styles:mm(Cp.styles,this.xmls)[0],sharedStrings:mm(Cp.sharedStrings,this.xmls)[0],theme:mm(Cp.themes,this.xmls)[0],charts:mm(Cp.chart,this.xmls),figures:mm(Cp.drawing,this.xmls),tables:mm(Cp.table,this.xmls),pivots:mm(Cp.pivot,this.xmls),externalLinks:mm(Cp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Uf(e,this.warningManager),styles:sf(e,this.warningManager),formats:lf(e,this.warningManager),borders:nf(e,this.warningManager),entities:{},revisionId:Y};return Zf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=tt(e.styles[t])})),t}}function Sm(e){const t=og(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&ft.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${te}${o.indexOf(t)}${te}`}return e.value}))),dependencies:o}}const Cm=12,Em="Sheet1";function wm(e,t){if(!e)return Tm();if(e["[Content_Types].xml"]){const o=new bm(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<Cm&&(e=function(e){for(let t=ym.findIndex((t=>t.from===e.version));t<ym.length;t++)e=ym[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new po;for(const n of e.sheets||[])for(const e of n.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Tm(),e,{version:Cm}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(Im(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(Im(Em,"Sheet1"));return e}(e),e}(e),e}const ym=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=Sm(o.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:o,...n}=t.figures[e].data,i=[];for(let e of o)if(e.labelCell){const t=mo(e.dataRange),o=e.labelCell+":"+Ot(t.right,t.bottom);i.push(o)}else i.push(e.dataRange);n.dataSetsHaveTitle=Boolean(o[0].labelCell),n.dataSets=i,t.figures[e].data=n}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const o=[],n=new RegExp(ee,"g");for(let i of e.sheets||[]){if(!i.name)continue;const e=i.name,r=e.replace(n,"_");let s=1,a=r;for(;o.includes(a);)a=`${r}${s}`,s++;i.name=a,o.push(a);const l=t=>{if(void 0===t)return t;let o=t.replace(e,a),n=t;for(;n!==o;)n=o,o=n.replace(e,a);return n};for(let e in i.cells){const t=i.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of i.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),o=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of i.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const o of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[o])||void 0===t?void 0:t.type)&&(e.rule[o].value=l(e.rule[o].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,n]of Object.entries(t)){const t=`\\${te}${o}\\${te}`;e=e.replace(new RegExp(t,"g"),n)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const n=o.cells[e];n.format&&(n.format=Xe(n.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}];function xm(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],n=[],i=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:Em};return e};for(const e of t)"REMOTE_REVISION"===e.type?n.push({...e,commands:e.commands.map(i)}):n.push(e);return n}(e,t),t=Rm(t,"SORT_CELLS"),t=function(e,t){var o;const n=[],i={};for(const t of e.sheets||[])null===(o=t.figures)||void 0===o||o.forEach((e=>{"chart"===e.tag&&(i[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":i[o.id]=o.definition;break;case"UPDATE_CHART":if(!i[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...i[o.id],...o.definition};e={...o,definition:t},i[o.id]=t}t.push(e)}n.push({...e,commands:t})}else n.push(e);return n}(e,t=Rm(t,"SET_DECIMAL")),t}function Rm(e,t){const o=[];for(const n of e)"REMOTE_REVISION"===n.type?o.push({...n,commands:n.commands.filter((e=>e.type!==t))}):o.push(n);return o}function Im(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Tm(e="Sheet1"){return{version:Cm,sheets:[Im(Em,e)],entities:{},styles:{},formats:{},borders:{},revisionId:Y,uniqueFigureIds:!0}}function Am(e,t){return{...Im(e,t),charts:[]}}class Om extends gg{constructor(e,t,o,n,i,r){super(t,n,i),this.dispatch=n,this.range=o,o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=r}import(e){}export(e){}adaptRanges(e,t){}}class Mm extends Om{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const o=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder(e,t,o){var n,i,r,s,a,l,c,h,d,u,g,p;const f={top:null===(r=null===(i=null===(n=this.borders[e])||void 0===n?void 0:n[t])||void 0===i?void 0:i[o])||void 0===r?void 0:r.horizontal,bottom:null===(l=null===(a=null===(s=this.borders[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[o+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[o])||void 0===p?void 0:p.vertical};return f.bottom||f.left||f.right||f.top?f:null}ensureColumnBorderContinuity(e,t,o){const n=Fe(t+1,o);for(let i=0;i<this.getters.getNumberRows(e);i++){const r=this.getCellBorder(e,t,i),s=this.getCellBorder(e,o,i);if(r&&s){const t=this.getCommonSides(r,s);for(let o of n)this.addBorder(e,o,i,t)}}}ensureRowBorderContinuity(e,t,o){const n=Fe(t+1,o);for(let i=0;i<this.getters.getNumberCols(e);i++){const r=this.getCellBorder(e,i,t),s=this.getCellBorder(e,i,o);if(r&&s){const t=this.getCommonSides(r,s);for(let o of n)this.addBorder(e,i,o,t)}}}getCommonSides(e,t){const o={};for(let n of["top","bottom","left","right"])e[n]&&e[n]===t[n]&&(o[n]=e[n]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?Fe(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:n}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((i=>{(i===t&&n||i!==t)&&this.moveBordersOfColumn(e,i,o,"vertical"),this.moveBordersOfColumn(e,i,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:n}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((i=>{(i===t&&n||i!==t)&&this.moveBordersOfRow(e,i,o,"horizontal"),this.moveBordersOfRow(e,i,o,"vertical")})))}moveBordersOfRow(e,t,o,n,{destructive:i}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[s])||void 0===a?void 0:a[t+o])||void 0===l?void 0:l[n],u=null===(h=null===(c=r[s])||void 0===c?void 0:c[t])||void 0===h?void 0:h[n];this.history.update("borders",e,s,t+o,n,i?u:u||d),this.history.update("borders",e,s,t,n,void 0)}))}moveBordersOfColumn(e,t,o,n,{destructive:i}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[t+o])||void 0===a?void 0:a[s])||void 0===l?void 0:l[n],u=null===(h=null===(c=r[t])||void 0===c?void 0:c[s])||void 0===h?void 0:h[n];this.history.update("borders",e,t+o,s,n,i?u:u||d),this.history.update("borders",e,t,s,n,void 0)}))}setBorder(e,t,o,n,i=!0){var r,s,a,l,c,h,d,u,g,p,f,m,v,b,S,C;!i&&(null===(l=null===(a=null===(s=null===(r=this.borders)||void 0===r?void 0:r[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[o])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,o,"vertical",null==n?void 0:n.left),!i&&(null===(u=null===(d=null===(h=null===(c=this.borders)||void 0===c?void 0:c[e])||void 0===h?void 0:h[t])||void 0===d?void 0:d[o])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,o,"horizontal",null==n?void 0:n.top),!i&&(null===(m=null===(f=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===f?void 0:f[o])||void 0===m?void 0:m.vertical)||this.history.update("borders",e,t+1,o,"vertical",null==n?void 0:n.right),!i&&(null===(C=null===(S=null===(b=null===(v=this.borders)||void 0===v?void 0:v[e])||void 0===b?void 0:b[t])||void 0===S?void 0:S[o+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,o+1,"horizontal",null==n?void 0:n.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let n=o.left;n<=o.right;n++)this.history.update("borders",e,n,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,n){this.setBorder(e,t,o,{...this.getCellBorder(e,t,o),...n})}setBorders(e,t,o){if("clear"===o)return this.clearBorders(e,t);for(let n of t){if("h"===o||"hv"===o||"all"===o)for(let t=n.top+1;t<=n.bottom;t++)for(let o=n.left;o<=n.right;o++)this.addBorder(e,o,t,{top:q});if("v"===o||"hv"===o||"all"===o)for(let t=n.top;t<=n.bottom;t++)for(let o=n.left+1;o<=n.right;o++)this.addBorder(e,o,t,{left:q});if("left"===o||"all"===o||"external"===o)for(let t=n.top;t<=n.bottom;t++)this.addBorder(e,n.left,t,{left:q});if("right"===o||"all"===o||"external"===o)for(let t=n.top;t<=n.bottom;t++)this.addBorder(e,n.right+1,t,{left:q});if("top"===o||"all"===o||"external"===o)for(let t=n.left;t<=n.right;t++)this.addBorder(e,t,n.top,{top:q});if("bottom"===o||"all"===o||"external"===o)for(let t=n.left;t<=n.right;t++)this.addBorder(e,t,n.bottom+1,{top:q})}}addBordersToMerge(e,t){const{left:o,right:n,top:i,bottom:r}=t,s=this.getCellBorder(e,o,i),a=this.getCellBorder(e,n,r);this.clearBorders(e,[t]),(null==s?void 0:s.top)&&this.setBorders(e,[{...t,bottom:i}],"top"),(null==s?void 0:s.left)&&this.setBorders(e,[{...t,right:o}],"left"),((null==a?void 0:a.bottom)||(null==s?void 0:s.bottom))&&this.setBorders(e,[{...t,top:r}],"bottom"),((null==a?void 0:a.right)||(null==s?void 0:s.right))&&this.setBorders(e,[{...t,left:n}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[o,n]of Object.entries(t.cells))if(null==n?void 0:n.border){const i=e.borders[n.border],{col:r,row:s}=At(o);this.setBorder(t.id,r,s,i,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,mo(e))}export(e){let t=0;const o={};function n(e){for(let[t,n]of Object.entries(o))if(ye(n)===ye(e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const i=this.getCellBorder(t.id,e,o);if(i){const r=Ot(e,o),s=t.cells[r],a=n(i);s?s.border=a:t.cells[r]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}Mm.getters=["getCellBorder"];const Nm=new RegExp(String.fromCharCode(160),"g");class _m extends Om{constructor(){super(...arguments),this.cells={},this.createCell=function(e){const t=_n.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,n,i,r){const s=t.find((e=>e.match(n,i.format)));if(!s)return new rp(o,n,i);try{return s.createCell(o,n,i,r,e)}catch(e){return new dp(o,n,e instanceof c?e:new h(e.message||oe),i)}}}(this.getters)}adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const n of Object.values(this.cells[o]||{}))if(n.isFormula())for(const i of n.dependencies)if(!t||i.sheetId===t){const t=e(i);"NONE"!==t.changeType&&this.history.update("cells",o,n.id,"dependencies",n.dependencies.indexOf(i),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,o){for(let n of t)for(let t=n.top;t<=n.bottom;t++)for(let i=n.left;i<=n.right;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:null,format:""})}handleAddColumnsRows(e,t){let o,n;"before"===e.position?(o=Fe(e.base,e.base+e.quantity),n=e.base+e.quantity):(o=Fe(e.base+1,e.base+e.quantity+1),n=e.base),t(e.sheetId,n,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const n=t.cells[o],{col:i,row:r}=At(o);if((null==n?void 0:n.content)||(null==n?void 0:n.format)||(null==n?void 0:n.style)){const o=this.importCell(t.id,n,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:i,row:r,sheetId:t.id})}}}export(e){const t={},o={};for(let n of e.sheets){const e={},i=Object.keys(this.cells[n.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const{col:r,row:s}of i){const i=this.getters.getCell(n.id,r,s);e[Ot(r,s)]={style:i.style?Xe(i.style,t):void 0,format:i.format?Xe(i.format,o):void 0,content:i.content||void 0}}n.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,n){const i=t.style&&o[t.style]||void 0,r=t.format&&n[t.format]||void 0,s=this.uuidGenerator.uuidv4(),a={format:r,style:i};return this.createCell(s,(null==t?void 0:t.content)||"",a,e)}exportForExcel(e){this.export(e);for(let t of e.sheets)for(const e in t.cells){const{col:o,row:n}=At(e),i=this.getters.getCell(t.id,o,n),r=t.cells[e];r.value=i.evaluated.value,r.isFormula=i.isFormula()}}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const o=this.cells[t][e];if(o)return o}}buildFormulaContent(e,t,o){const n=o||[...t.dependencies];return Ye(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=n.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return e&&e.style||{}}zoneToXC(e,t,o=[{colFixed:!1,rowFixed:!1}]){const n=Ot((t=this.getters.expandZone(e,t)).left,t.top,o[0]),i=Ot(t.right,t.bottom,o.length>1?o[1]:o[0]),r=this.getters.getMainCellPosition(e,t.left,t.top),s=this.getters.getMainCellPosition(e,t.right,t.bottom),a=r.col===s.col&&r.row===s.row;return n==i||a?n:n+":"+i}setStyle(e,t,o){for(let n of t)for(let t=n.left;t<=n.right;t++)for(let i=n.top;i<=n.bottom;i++){const n=this.getters.getCell(e,t,i);this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:o?{...null==n?void 0:n.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let n=0;n<this.getters.getNumberRows(e);n++){const i=this.getFormat(e,t,n);if(i.style||i.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,...i})}}copyRowStyle(e,t,o){for(let n=0;n<this.getters.getNumberCols(e);n++){const i=this.getFormat(e,n,t);if(i.style||i.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,...i})}}getFormat(e,t,o){const n={},{col:i,row:r}=this.getters.getMainCellPosition(e,t,o),s=this.getters.getCell(e,i,r);return s&&(s.style&&(n.style=s.style),s.format&&(n.format=s.format)),n}updateCell(e,t,o,n){var i;const r=this.getters.getCell(e,t,o),s="content"in n||"formula"in n,a=s?(null===(i=n.content)||void 0===i?void 0:i.replace(Nm,""))||"":(null==r?void 0:r.content)||"";let l;l=void 0!==n.style?n.style||void 0:r?r.style:void 0;let c=("format"in n?n.format:r&&r.format)||undefined;if((s&&!a&&!n.formula||!s&&(!r||r.isEmpty()))&&!l&&!c)return void(r&&(this.history.update("cells",e,r.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:o,sheetId:e})));const h=(null==r?void 0:r.id)||this.uuidGenerator.uuidv4(),d=s,u={format:c,style:l},g=this.createCell(h,a,u,e);r&&!d&&g.isFormula()&&g.assignEvaluation(Ke(r.evaluated)),this.history.update("cells",e,g.id,g),this.dispatch("UPDATE_CELL_POSITION",{cellId:g.id,col:t,row:o,sheetId:e})}checkCellOutOfSheet(e,t,o){if(!this.getters.tryGetSheet(e))return 27;return To(t,o,this.getters.getSheetZone(e))?0:18}}_m.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Fm extends Om{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=Bo.getAll();return function(o,n,i){const r=t.find((e=>e.match(n.type)));if(!r)throw new Error(`No builder for this chart: ${n.type}`);return r.createChart(n,i,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const o=Bo.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,null==o?void 0:o.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const o=this.getters.getFigures(e.sheetId);for(const n of o)if("chart"===n.tag){const o=n.id.split("??").pop(),i=`${e.sheetIdTo}??${o}`,r=null===(t=this.charts[n.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);r&&this.dispatch("CREATE_CHART",{id:i,position:{x:n.x,y:n.y},size:{width:n.width,height:n.height},definition:r.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){var t;return null===(t=this.charts[e])||void 0===t?void 0:t.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){var t;const o=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!o)throw new Error("Chart not defined.");return o}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const o=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!o)throw new Error(`There is no chart with the given figureId: ${e}`);return o}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let o of e.sheets){const e=this.getters.getFigures(o.id),n=[];for(let o of e){const e=o;if(e&&"chart"===e.tag){const o=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();o&&(e.data=o,n.push(e))}else n.push(e)}o.figures=n}}exportForExcel(e){var t;for(let o of e.sheets){const e=this.getters.getFigures(o.id),n=[];for(let o of e)if(o&&"chart"===o.tag){const e=null===(t=this.charts[o.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&n.push({...o,data:e})}o.charts=n}}addFigure(e,t,o={x:0,y:0},n={width:536,height:335}){if(this.getters.getFigure(t,e))return;const i={id:e,x:o.x,y:o.y,width:n.width,height:n.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:i})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?83:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:84}}function Dm(e){return""===e?NaN:Number(e)}Fm.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class km extends Om{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const n of o.ranges){const i=t(n);switch(i.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(n),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(n),i.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let n=t.top;n<=t.bottom;n++)for(let i=t.left;i<=t.right;i++){this.getRulesByCell(e,i,n).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const n=[];for(let i of this.cfRules[e])for(let e of i.ranges)To(t,o,e.zone)&&n.push(i);return new Set(n.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),n=o.findIndex((t=>t.id===e.id)),i=this.mapToConditionalFormatInternal(t,e);n>-1?o.splice(n,1,i):o.push(i),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 27;const n=this.cfRules[o].findIndex((t=>t.id===e));if(-1===n)return 70;const i="up"===t?n-1:n+1;return i<0||i>=this.cfRules[o].length?70:0}checkEmptyRange(e){return e.ranges.length?0:24}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return o=>{if(t.includes(o.operator)){const t=[],n=e=>void 0===e||""===e;return e>=1&&n(o.values[0])&&t.push(50),e>=2&&n(o.values[1])&&t.push(51),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 52;case"max":return 54;case"mid":return 53;case"upperInflectionPoint":return 55;case"lowerInflectionPoint":return 56}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{lg(e.value||"")}catch(e){switch(t){case"min":return 57;case"max":return 59;case"mid":return 58;case"upperInflectionPoint":return 60;case"lowerInflectionPoint":return 61}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?47:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&Dm(t)>=Dm(o)?46:0}checkMidBiggerThanMax(e){var t;const o=null===(t=e.midpoint)||void 0===t?void 0:t.value,n=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&Dm(o)>=Dm(n)?48:0}checkMinBiggerThanMid(e){var t;const o=e.minimum.value,n=null===(t=e.midpoint)||void 0===t?void 0:t.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&Dm(o)>=Dm(n)?49:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const n=this.cfRules[o].findIndex((t=>t.id===e)),i="up"===t?n-1:n+1;if(!(i<0||i>=this.cfRules[o].length)&&-1!==n&&-1!==i){const e=[...this.cfRules[o]],t=e[n];e[n]=e[i],e[i]=t,this.history.update("cfRules",o,e)}}}km.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class $m extends Om{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:o,...n}=e,i=n;this.updateFigure(o,i);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[o,n]of Object.entries(t))switch(o){case"x":case"y":void 0!==n&&this.history.update("figures",e,t.id,o,Math.max(n,0));break;case"width":case"height":void 0!==n&&this.history.update("figures",e,t.id,o,n)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var o;return void 0===(null===(o=this.figures[e])||void 0===o?void 0:o[t])?69:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?81:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(Ze)}getFigure(e,t){var o;return null===(o=this.figures[e])||void 0===o?void 0:o[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var o;return void 0!==(null===(o=this.figures[t])||void 0===o?void 0:o[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}$m.getters=["getFigures","getFigure","getFigureSheetId"];class Lm{constructor(e){this.filters=[],this.zone=e;const t=new po;this.id=t.uuidv4();for(const o of Fe(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new Pm(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){var t;return null===(t=this.filters.find((t=>t.col===e)))||void 0===t?void 0:t.id}clone(){return new Lm(this.zone)}}class Pm{constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}class Um extends Om{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!Vo(...e.target))return 80;const t=yo(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>Io(e.zone,t)))?77:0,n=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(Io(t,e))return 79;return 0};return this.checkValidations(e,o,n);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(Io(o.zone,t))return 79}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":this.history.update("tables",e.sheetIdTo,Ie(this.tables[e.sheetId]));break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=yo(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!xo(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(Ze):[]}getFilter(e,t,o){var n;return null===(n=this.getFilterTable(e,t,o))||void 0===n?void 0:n.filters.find((e=>e.col===t))}getFilterId(e,t,o){var n;return null===(n=this.getFilter(e,t,o))||void 0===n?void 0:n.id}getFilterTable(e,t,o){return this.getFilterTables(e).find((e=>To(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Ao(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if(xo(o,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=So(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),n=[];for(const o of t.filters){const t=So(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);n.push(new Pm(o.id,t))}if(n.length<No(o).width){for(let e=o.left;e<=o.right;e++)n.find((t=>t.col===e))||n.push(new Pm(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));n.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",n)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=wo(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(bo(o)!==bo(t.zone)){const n=[];for(const o of t.filters){const t=wo(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&n.push(new Pm(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",n)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new Lm(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const n=t.filters[o],i={...n.zoneWithHeaders,bottom:n.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",i)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:n},i){var r;if(!e)return;const s=i.zone;if(!(s.bottom+1===n&&o>=s.left&&o<=s.right))return!1;for(const e of Fe(s.left,s.right+1)){if(null===(r=this.getters.getCell(t,e,n))||void 0===r?void 0:r.content)return!1;if(this.getters.getFilter(t,e,n))return!1;if(this.getters.isInMerge(t,e,n))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(mo(e.range));this.history.update("tables",t.id,o.id,o)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:bo(e.zone)})}exportForExcel(e){this.export(e)}}Um.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Vm extends Om{constructor(){super(...arguments),this.sizes={}}handle(e){var t,o,n;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),o={COL:t.COL.map((e=>({manualSize:void 0,computedSize:Ke(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:Ke(e)})))};this.history.update("sizes",e.sheetId,o);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Ie(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const i={...this.sizes};delete i[e.sheetId],this.history.update("sizes",i);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);const o=Math.min(...e.elements);t=t.map(((t,n)=>"ROW"===e.dimension&&n>=o?{manualSize:t.manualSize,computedSize:Ke((()=>this.getRowTallestCellSize(e.sheetId,n)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=Je(e.position,e.base),n=t[e.base];t.splice(o,0,...Array(e.quantity).fill(n)),t=t.map(((t,o)=>"ROW"===e.dimension&&o>e.base+e.quantity?{manualSize:t.manualSize,computedSize:Ke((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const o=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:Ke(o)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:Ke(e.size||N)});break;case"UPDATE_CELL":if(!(null===(n=null===(o=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[e.row])||void 0===n?void 0:n.manualSize)){const{sheetId:t,row:o}=e;this.history.update("sizes",t,"ROW",o,"computedSize",Ke((()=>this.getRowTallestCellSize(t,o))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let o of Fe(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,o);t!==this.getRowSize(e.sheetId,o)&&this.history.update("sizes",e.sheetId,"ROW",o,"computedSize",Ke(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,o){var n,i,r,s;return Math.round((null===(i=null===(n=this.sizes[e])||void 0===n?void 0:n[t][o])||void 0===i?void 0:i.manualSize)||(null===(s=null===(r=this.sizes[e])||void 0===r?void 0:r[t][o])||void 0===s?void 0:s.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,o;const n={COL:[],ROW:[]};for(let t of Fe(0,this.getters.getNumberCols(e)))n.COL.push(this.getHeaderSize(e,"COL",t));for(let i of Fe(0,this.getters.getNumberRows(e))){let r=null===(o=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[i].manualSize;if(!r){r=this.getRowTallestCellSize(e,i)}n.ROW.push(r)}return n}getDefaultHeaderSize(e){return"COL"===e?N:_}getCellHeight(e,t,o){const n=this.getters.getMerge(e,t,o);if(n&&n.bottom!==n.top)return _;const i=this.getters.getCell(e,t,o);return(null==(r=null==i?void 0:i.style)?void 0:r.fontSize)?(s||1)*(_e(r)+L)-L+2*P:_;var r,s}getRowTallestCellSize(e,t){const o=this.getters.getRowCells(e,t);let n=0;for(let t=0;t<o.length;t++){const i=this.getters.getCellById(o[t]);if(!i)continue;const{col:r,row:s}=this.getters.getCellPosition(i.id),a=this.getCellHeight(e,r,s);a>n&&a>_&&(n=a)}return n<=_?_:n}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[o,n]of Object.entries(t.rows))n.size&&(e.ROW[o]=n.size);for(let[o,n]of Object.entries(t.cols))n.size&&(e.COL[o]=n.size);const o=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:o.COL.map(((t,o)=>({manualSize:e.COL[o],computedSize:Ke(t)}))),ROW:o.ROW.map(((t,o)=>({manualSize:e.ROW[o],computedSize:Ke(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var o,n;for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e of Fe(0,this.getters.getNumberRows(i.id)))(t||(null===(o=this.sizes[i.id].ROW[e])||void 0===o?void 0:o.manualSize))&&(i.rows[e]={...i.rows[e],size:this.getRowSize(i.id,e)});void 0===i.cols&&(i.cols={});for(let e of Fe(0,this.getters.getNumberCols(i.id)))(t||(null===(n=this.sizes[i.id].COL[e])||void 0===n?void 0:n.manualSize))&&(i.cols[e]={...i.cols[e],size:this.getColSize(i.id,e)})}}}Vm.getters=["getRowSize","getColSize"];class zm extends Om{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){if("HIDE_COLUMNS_ROWS"===e.type){if(!this.hiddenHeaders[e.sheetId])return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return(t||[]).flat().concat(e.elements).length<o?0:65}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,Ie(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=Je(e.position,e.base);t.splice(o,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}import(e){var t,o;for(let n of e.sheets){this.hiddenHeaders[n.id]={COL:[],ROW:[]};for(let e=0;e<n.rowNumber;e++)this.hiddenHeaders[n.id].ROW[e]=Boolean(null===(t=n.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<n.colNumber;e++)this.hiddenHeaders[n.id].COL[e]=Boolean(null===(o=n.cols[e])||void 0===o?void 0:o.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}zm.getters=["getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class Bm extends Om{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const o of Object.values(t).filter(Ze))this.addMerge(e.sheetIdTo,o.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(Ze)}getMerge(e,t,o){var n;const i=this.mergeCellMap[e],r=i?t in i&&(null===(n=i[t])||void 0===n?void 0:n[o]):void 0;return r?this.getMergeById(e,r):void 0}getMergesInZone(e,t){var o;const n=this.mergeCellMap[e];if(!n)return[];const i=new Set;for(const{col:e,row:r}of Fo(t)){const t=null===(o=n[e])||void 0===o?void 0:o[r];t&&i.add(t)}return Array.from(i).map((t=>this.getMergeById(e,t))).filter(Ze)}doesIntersectMerge(e,t){const{left:o,right:n,top:i,bottom:r}=t;for(let t=i;t<=r;t++)for(let i=o;i<=n;i++)if(this.getMerge(e,i,t))return!0;return!1}doesColumnsHaveCommonMerges(e,t,o){const n=this.getters.getSheet(e);for(let i=0;i<this.getters.getNumberRows(e);i++)if(this.isInSameMerge(n.id,t,i,o,i))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const n=this.getters.getSheet(e);for(let i=0;i<=this.getters.getNumberCols(e);i++)if(this.isInSameMerge(n.id,i,t,i,o))return!0;return!1}expandZone(e,t){let{left:o,right:n,top:i,bottom:r}=t,s={left:o,right:n,top:i,bottom:r};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&Io(o,s)&&(s=yo(o,s))}return Ro(s,t)?s:this.expandZone(e,s)}isInSameMerge(e,t,o,n,i){const r=this.getMerge(e,t,o),s=this.getMerge(e,n,i);return!(!r||!s)&&Ro(r,s)}isInMerge(e,t,o){var n;const i=this.mergeCellMap[e];return!!i&&(t in i&&Boolean(null===(n=i[t])||void 0===n?void 0:n[o]))}getMainCellPosition(e,t,o){if(!this.isInMerge(e,t,o))return{col:t,row:o};const n=this.getMerge(e,t,o).topLeft;return{col:n.col,row:n.row}}getBottomLeftCell(e,t,o){if(!this.isInMerge(e,t,o))return{col:t,row:o};const{bottom:n,left:i}=this.getMerge(e,t,o);return{col:i,row:n}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),n=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of n)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge(e,t.left,t.top);if(o)return Ro(t,o);const{width:n,height:i}=No(t);return 1===n&&1===i}isMergeDestructive(e,t){let{left:o,right:n,top:i,bottom:r}=t;n=Oe(n,0,this.getters.getNumberCols(e)-1),r=Oe(r,0,this.getters.getNumberRows(e)-1);for(let t=i;t<=r;t++)for(let r=o;r<=n;r++)if(r!==o||t!==i){const o=this.getters.getCell(e,r,t);if(o&&!o.isEmpty())return!0}return!1}getMergeById(e,t){var o;const n=null===(o=this.merges[e])||void 0===o?void 0:o[t];return void 0!==n?Wm(t,n):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const o of e)if(t!==o&&Io(t,o))return 64;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:n}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<n&&e.bottom>=n)return 74;return 0}checkMergedContentUpdate(e){const{col:t,row:o,sheetId:n,content:i}=e;if(void 0===i)return 0;const{col:r,row:s}=this.getMainCellPosition(n,t,o);return r===t&&s===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:n}=e,i=this.getMerge(t,o,n);if(void 0===i||!Ro(e,i))return 5}return 0}addMerge(e,t){let{left:o,right:n,top:i,bottom:r}=t;n=Oe(n,0,this.getters.getNumberCols(e)-1),r=Oe(r,0,this.getters.getNumberRows(e)-1);if(Ot(o,i)===Ot(n,r))return;const s=this.getters.getCell(e,o,i);let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,bo({left:o,top:i,right:n,bottom:r})));let l=new Set;for(let t=i;t<=r;t++)for(let r=o;r<=n;r++){r===o&&t===i||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:s?s.style:null,content:""});const n=this.getMerge(e,r,t);n&&l.add(n.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:o,bottom:n,left:i,right:r}=this.getMergeById(e,t);for(let t=o;t<=n;t++)for(let o=i;o<=r;o++){const n=this.getMerge(e,o,t);n&&n.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",{sheetId:e,col:o,row:t}))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:n,bottom:i,right:r}=t,s=this.getMerge(e,o,n);if(void 0!==s&&Ro(t,s)){this.history.update("merges",e,s.id,void 0);for(let t=n;t<=i;t++)for(let n=o;n<=r;n++)this.history.update("mergeCellMap",e,n,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[n,i]of o)if(i){const o=i.zone,r=t(i);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{width:t,height:i}=No(r.range.zone);1===t&&1===i?this.removeMerge(e,o):this.history.update("merges",e,parseInt(n,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:n}of Fo(t))this.history.update("mergeCellMap",e,o,n,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let o of t)this.addMerge(e,mo(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Hm(e))}}exportForExcel(e){this.export(e)}}function Hm(e){return Object.entries(e).map((([e,t])=>t?Wm(parseInt(e,10),t):void 0)).filter(Ze).map((e=>Ot(e.left,e.top)+":"+Ot(e.right,e.bottom)))}function Wm(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Bm.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class Gm extends Om{constructor(){super(...arguments),this.sheetIdsMapName={},this.orderedSheetIds=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":const t=this.orderedSheetIds.indexOf(e.sheetId);if("left"===e.direction){return this.orderedSheetIds.slice(0,t).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0}return this.orderedSheetIds.slice(t+1).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0;case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"REMOVE_COLUMNS_ROWS":return("COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId))>e.elements.length?0:8;case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.direction);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){var t,o;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let n of e.sheets){const e=n.name||i("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:r,rowNumber:s}=this.getImportedSheetSize(n),a={id:n.id,name:e,numberOfCols:r,rows:go(s),areGridLinesVisible:void 0===n.areGridLinesVisible||n.areGridLinesVisible,isVisible:n.isVisible,panes:{xSplit:(null===(t=n.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(o=n.panes)||void 0===o?void 0:o.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(Ze).map((e=>{const t=this.sheets[e],o={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(o.panes=t.panes),o}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}getCellsInZone(e,t){return Fo(t).map((({col:t,row:o})=>this.getCell(e,t,o)))}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=Te(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell(e,t,o){var n;const i=this.tryGetSheet(e),r=null===(n=null==i?void 0:i.rows[o])||void 0===n?void 0:n.cells[t];if(void 0!==r)return this.getters.getCellById(r)}getColCells(e,t){return this.getSheet(e).rows.map((e=>e.cells[t])).filter(Ze).map((e=>this.getters.getCellById(e))).filter(Ze)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){var o;return Object.values(null===(o=this.getSheet(e).rows[t])||void 0===o?void 0:o.cells).filter(Ze)}getRowsZone(e,t,o){return{top:t,bottom:o,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this));let n=`${e}${t}`;for(;o.includes(n);)n=`${e}${t}`,t++;return n}getSheetSize(e){return{height:this.getNumberRows(e),width:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,o){const n={...this.getPaneDivisions(e)};"COL"===o?n.xSplit=t:"ROW"===o&&(n.ySplit=t),this.history.update("sheets",e,"panes",n)}isEmpty(e,t){return this.getCellsInZone(e,t).flat().every((e=>!e||e.isEmpty()))}updateCellPosition(e){const{sheetId:t,cellId:o,col:n,row:i}=e;o?this.setNewPosition(o,t,n,i):this.clearPosition(t,n,i)}setNewPosition(e,t,o,n){const i=this.cellPosition[e];i&&this.clearPosition(t,i.col,i.row),this.history.update("cellPosition",e,{row:n,col:o,sheetId:t}),this.history.update("sheets",t,"rows",n,"cells",o,e)}clearPosition(e,t,o){var n;const i=null===(n=this.sheets[e])||void 0===n?void 0:n.rows[o].cells[t];i&&(this.history.update("cellPosition",i,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){this.sheets[e].rows[n].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:n})}}createSheet(e,t,o,n,i){const r={id:e,name:t,numberOfCols:o,rows:go(n),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},s=this.orderedSheetIds.slice();s.splice(i,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const o=this.orderedSheetIds.slice(),n=o.findIndex((t=>t===e)),i=o.splice(n,1);let r="left"===t?this.findIndexOfPreviousVisibleSheet(n-1,o):this.findIndexOfNextVisibleSheet(n+1,o);void 0===r&&(r=o.length),o.splice(r,0,i[0]),this.history.update("orderedSheetIds",o)}findIndexOfPreviousVisibleSheet(e,t){for(;e>=0&&!this.isSheetVisible(t[e]);)e--;if(-1===e)throw new Error("There is no previous visible sheet");return e}findIndexOfNextVisibleSheet(e,t){for(;e<t.length&&!this.isSheetVisible(t[e]);)e++;if(e!==t.length-1||this.isSheetVisible(t[e-1]))return e}checkSheetName(e){const{orderedSheetIds:t,sheets:o}=this,n=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=o[e])||void 0===t?void 0:t.name.toLowerCase())===n}))?11:ee.test(n)?13:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?15:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:73}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:73}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 64;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 64;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const n=Object.assign({},this.sheetIdsMapName);n[t]=e.id,delete n[o],this.history.update("sheetIdsMapName",n)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),n=this.getDuplicateSheetName(o.name),i=JSON.parse(JSON.stringify(o));i.id=t,i.name=n;for(let e=0;e<=i.numberOfCols;e++)for(let t=0;t<=i.rows.length;t++)i.rows[t]&&(i.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),s=r.indexOf(e);r.splice(s+1,0,i.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[i.id]:i}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:i.id,col:e,row:o,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[i.name]=i.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this)),n=r("Copy of %s",e);let i=n.toString();for(;o.includes(i);)i=`${n} (${t})`,t++;return i}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const n=this.orderedSheetIds.slice(),i=n.indexOf(e.id);n.splice(i,1),this.history.update("orderedSheetIds",n);const r=Object.assign({},this.sheetIdsMapName);delete r[t],this.history.update("sheetIdsMapName",r)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const n=t.filter((t=>t<e.panes.xSplit)).length;n&&this.setPaneDivisions(e.id,e.panes.xSplit-n,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of De(t))this.moveCellOnRowsDeletion(e,o[o.length-1],o[0]),o.map((t=>this.updateRowsStructureOnDeletion(t,e)));const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,n){const i="before"===o?t:t+1;this.moveCellsOnAddition(e,i,n,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+n),i<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+n,"COL")}addRows(e,t,o,n){const i="before"===o?t:t+1;this.addEmptyRows(e,n),this.moveCellsOnAddition(e,i,n,"rows"),this.updateRowsStructureOnAddition(e,t,n),i<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+n,"ROW")}moveCellOnColumnsDeletion(e,t){for(let[o,n]of Object.entries(e.rows)){const i=parseInt(o,10);for(let o in n.cells){const r=parseInt(o,10),s=n.cells[o];s&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:i}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:s,col:r-1,row:i}))}}}moveCellsOnAddition(e,t,o,n){const i=[];for(const[r,s]of Object.entries(e.rows)){const a=parseInt(r,10);if("rows"!==n||a>=t)for(let r in s.cells){const l=parseInt(r,10),c=s.cells[r];c&&("rows"===n||l>=t)&&i.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===n?o:0),row:a+("rows"===n?o:0)})}}for(let e of i.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const n=o-t+1;for(let[i,r]of Object.entries(e.rows)){const s=parseInt(i,10);if(s>=t&&s<=o)for(let t in r.cells){const o=parseInt(t,10);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:s})}if(s>o)for(let t in r.cells){const o=parseInt(t,10),i=r.cells[t];i&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:i,col:o,row:s-n})}}}updateRowsStructureOnDeletion(e,t){const o=[],n=t.rows.map((e=>e.cells));for(let i in t.rows)parseInt(i,10)!==e&&o.push({cells:n.shift()});this.history.update("sheets",t.id,"rows",o)}updateRowsStructureOnAddition(e,t,o){const n=[],i=e.rows.map((e=>e.cells));e.rows.forEach((()=>n.push({cells:i.shift()}))),this.history.update("sheets",e.id,"rows",n)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(At);let o=e.rowNumber,n=e.colNumber;for(let{col:e,row:i}of t)o=Math.max(o,i+1),n=Math.max(n,e+1);return{rowNumber:o,colNumber:n}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?27:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?12:0}checkZones(e){const t=[];if("zone"in e&&t.push(e.zone),"target"in e&&Array.isArray(e.target)&&t.push(...e.target),"ranges"in e&&Array.isArray(e.ranges)&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),!t.every(vo))return 25;if(t.length&&"sheetId"in e){const o=this.getSheetZone(e.sheetId);return t.every((e=>Ao(e,o)))?0:18}return 0}}Gm.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellsInZone","getCellPosition","getColCells","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions"];class qm{constructor(e,t,o){this.index=0,this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:n}=Go.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:n,origin:{col:e.data.col,row:e.data.row}}}}class Zm extends pg{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:Oe(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:Oe(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:44;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),o=this.autofillZone;switch(this.direction){case"down":for(let n=t.left;n<=t.right;n++){const i=[];for(let e=t.top;e<=t.bottom;e++)i.push(Ot(n,e));const r=this.createGenerator(i);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(r,n,t,e)}break;case"up":for(let n=t.left;n<=t.right;n++){const i=[];for(let e=t.bottom;e>=t.top;e--)i.push(Ot(n,e));const r=this.createGenerator(i);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(r,n,t,e)}break;case"left":for(let n=t.top;n<=t.bottom;n++){const i=[];for(let e=t.right;e>=t.left;e--)i.push(Ot(e,n));const r=this.createGenerator(i);for(let t=o.right;t>=o.left;t--)this.computeNewCell(r,t,n,e)}break;case"right":for(let n=t.top;n<=t.bottom;n++){const i=[];for(let e=t.left;e<=t.right;e++)i.push(Ot(e,n));const r=this.createGenerator(i);for(let t=o.left;t<=o.right;t++)this.computeNewCell(r,t,n,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const o=this.getters.getSelectedZone();if(To(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,n=e.bottom;if(o>0){let e=this.getters.getCell(t,o-1,n);for(;e&&!e.isEmpty();)n+=1,e=this.getters.getCell(t,o-1,n)}if(n===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e=this.getters.getCell(t,o+1,n);for(;e&&!e.isEmpty();)n+=1,e=this.getters.getCell(t,o+1,n)}n!==e.bottom&&(this.select(e.left,n-1),this.autofill(!0))}computeNewCell(e,t,o,n){const{cellData:i,tooltip:r,origin:s}=e.next(),{content:a,style:l,border:c,format:h}=i;this.tooltip=r,n&&this.dispatch("AUTOFILL_CELL",{originCol:s.col,originRow:s.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=on.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],n=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:i}=At(t),r=this.getters.getCell(n,e,i);o.push({col:e,row:i,cell:r,sheetId:n})}const i=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,i)||o}const{sheetId:n,col:r,row:s}=e,a=this.getters.getCellBorder(n,r,s)||void 0;t.push({data:{...e,border:a},rule:o})}return new qm(t,this.getters,this.direction)}saveZone(e,t,o,n){this.autofillZone={top:e,bottom:t,left:o,right:n}}getDirection(e,t){const o=this.getters.getSelectedZone(),n={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(n).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(n).find((e=>e.number>0?1:0)).value;const i=n.up.number>0?"up":"down",r=n.left.number>0?"left":"right";return Math.abs(n[i].number)>=Math.abs(n[r].number)?n[i].value:n[r].value}autoFillMerge(e,t,o,n){const i=this.getters.getActiveSheet();if(this.getters.isInMerge(i.id,o,n)&&!this.getters.isInMerge(i.id,e,t)){const e=this.getters.getMerge(i.id,o,n);e&&this.dispatch("REMOVE_MERGE",{sheetId:i.id,target:[e]})}const r=this.getters.getMerge(i.id,e,t);(null==r?void 0:r.topLeft.col)===e&&(null==r?void 0:r.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:i.id,target:[{top:n,bottom:n+r.bottom-r.top,left:o,right:o+r.right-r.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:n,y:i,width:r,height:s}=this.getters.getVisibleRect(this.autofillZone);r>0&&s>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(n,i,r,s),t.setLineDash([]))}}Zm.layers=[6],Zm.getters=["getAutofillTooltip"];class jm extends pg{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const n of t){const t=this.getAutomaticSums(e,n,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),n=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&n.push(this.sumTotal(t)),n}sumAdjacentData(e,t,o){const{col:n,row:i}=To(o.col,o.row,t)?o:{col:t.left,row:t.top},r=this.findAdjacentData(e,n,i);return r?this.getters.isSingleCellOrMerge(e,t)||_o(yo(r,t))?[{position:{col:n,row:i},zone:r}]:this.sumDimensions(e,yo(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const n=this.getters.getSheet(e),i=this.getters.getMainCellPosition(e,t,o),r=this.findSuitableZoneToSum(n,i.col,i.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,o){const n=this.getters.getCell(e.id,t,o-1),i=this.getters.getCell(e.id,t-1,o);if(this.isNumber(i)&&!this.isNumber(n))return this.findHorizontalZone(e,t,o);const r=this.findVerticalZone(e,t,o);if(this.isZoneValid(r))return r;const s=this.findHorizontalZone(e,t,o);return this.isZoneValid(s)?s:void 0}findVerticalZone(e,t,o){const n={top:0,bottom:o-1,left:t,right:t},i=this.reduceZoneStart(e,n,n.bottom);return{...n,top:i}}findHorizontalZone(e,t,o){const n={top:o,bottom:o,left:0,right:t-1},i=this.reduceZoneStart(e,n,n.right);return{...n,left:i}}reduceZoneStart(e,t,o){const n=this.getters.getCellsInZone(e.id,t),i=Fe(o,-1,-1),r=i.filter((e=>{var t;return n[e]&&!(null===(t=n[e])||void 0===t?void 0:t.isAutoSummable)})),s=Math.max(...r),a=De(i.filter((e=>this.isNumber(n[e]))))[0]||[];return Math.max(...a)<s?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return(null==e?void 0:e.evaluated.type)===qo.number&&!(null===(t=e.evaluated.format)||void 0===t?void 0:t.match(j))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const o=new Set;return _o(t)?(o.add(1===No(t).width?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},Fo(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},Fo(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:n}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:n,right:i}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:n,right:i});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:n,bottom:i}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:n,bottom:i});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}jm.getters=["getAutomaticSums"];class Xm extends pg{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{Nn.get(e.popoverType)}catch(e){return 71}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,type:e.popoverType}}}getCellPopover({col:e,row:t}){var o,n;const i=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(i,this.persistentPopover.col,this.persistentPopover.row)){const e=this.getters.getMainCellPosition(i,this.persistentPopover.col,this.persistentPopover.row),t=null===(n=(o=Nn.get(this.persistentPopover.type)).onOpen)||void 0===n?void 0:n.call(o,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,...this.computePopoverProps(this.persistentPopover,t.cellCorner)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport(i,e,t))return{isOpen:!1};const r=this.getters.getMainCellPosition(i,e,t),s=Nn.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,r,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==s?void 0:s.isOpen)?{...s,...this.computePopoverProps(r,s.cellCorner)}:{isOpen:!1}}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverProps({col:e,row:t},o){const{width:n,height:i}=this.getters.getVisibleRect(Lo({col:e,row:t}));return{coordinates:this.computePopoverPosition({col:e,row:t},o),cellWidth:-n,cellHeight:-i}}computePopoverPosition({col:e,row:t},o){const n=this.getters.getActiveSheetId(),i=this.getters.getMerge(n,e,t);i&&(e="TopRight"===o?i.right:i.left,t="TopRight"===o?i.top:i.bottom);const{x:r,y:s,width:a,height:l}=this.getters.getVisibleRect(Lo({col:e,row:t}));switch(o){case"BottomLeft":return{x:r,y:s+l};case"TopRight":return{x:r+a,y:s}}}}Xm.getters=["getCellPopover","getPersistentPopoverTypeAtPosition"],Xm.modes=["normal"];class Ym{constructor(e,t,o,n){this.getters=t,this.dispatch=o,this.selection=n,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,n){const i=this.getters.getActiveSheetId(),r=t+n-this.getters.getNumberRows(i);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(i)-1,sheetId:i,quantity:r,position:"after"});const s=e+o-this.getters.getNumberCols(i);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(i)-1,sheetId:i,quantity:s,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Km extends Ym{constructor(e,t,o,n,i){if(super(t,o,n,i),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),s=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===r.size&&1===s.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let n=0;n<o;n++)if(Io(e[n],t))return e[n]=yo(e[n],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>Fo(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=o.getActiveSheetId();for(let e of u){let t=[];for(let n of d)t.push({cell:o.getCell(p,n,e),border:o.getCellBorder(p,n,e)||void 0,position:{col:n,row:e,sheetId:p}});g.push(t)}const f=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const o of Fe(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues(p,o,e.zone.top));f.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=f}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const n=this.cells.length,i=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||n*i!=1))return 2;const{xSplit:r,ySplit:s}=this.getters.getPaneDivisions(o);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<s&&t.bottom>=s)return 74;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const o=this.cells.length,n=this.cells[0].length,i="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(n,o,i,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,n=this.cells[0].length,i=this.pastedZones(e,n,o);for(const e of i)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let n=o.top;n<=o.bottom;n++)this.pasteZone(e,n,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,o){const n=e[0],i=Math.max(1,Math.floor((n.right+1-n.left)/t)),r=Math.max(1,Math.floor((n.bottom+1-n.top)/o)),s=[];for(let e=0;e<i;e++)for(let i=0;i<r;i++){const r=n.top+i*o,a=n.left+e*t;s.push({left:a,top:r,bottom:r+o-1,right:a+t-1})}return s}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],n=t.length,i=t[0].length,r=e[e.length-1],s=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-s)/i)),c=Math.max(1,Math.floor((r.bottom+1-a)/n));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:s,top:a,right:s-1+e*i,bottom:a-1+t*n});return o}selectPastedZone(e,t,o,n){const i=n[0],r=i.left,s=i.top;if(t>1||e>1||o){const i=this.pastedZones(n,e,t),a=o?i[0]:yo(...i);this.selection.selectZone({cell:{col:r,row:s},zone:a})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,o){const n=this.cells.length,i=this.cells[0].length,r="onlyValue"!==(null==o?void 0:o.pasteOption)&&(null==o?void 0:o.shouldPasteCF),s=this.getters.getActiveSheetId();this.addMissingDimensions(i,n,e,t);for(let a=0;a<n;a++){const n=this.cells[a];for(let l=0;l<i;l++){const i=n[l],c={col:e+l,row:t+a,sheetId:s};"CUT"!==this.operation&&this.pasteMergeIfExist(i.position,c),this.pasteCell(i,c,this.operation,o),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:i.position,target:c,operation:this.operation})}}}pasteCell(e,t,o,n){const{sheetId:i,col:r,row:s}=t,a=this.getters.getCell(i,r,s);if("onlyValue"!==(null==n?void 0:n.pasteOption)){const t=this.getters.getCellBorder(i,r,s),o=e.border,n={top:(null==t?void 0:t.top)||(null==o?void 0:o.top),bottom:(null==t?void 0:t.bottom)||(null==o?void 0:o.bottom),left:(null==t?void 0:t.left)||(null==o?void 0:o.left),right:(null==t?void 0:t.right)||(null==o?void 0:o.right)};this.dispatch("SET_BORDER",{sheetId:i,col:r,row:s,border:n})}if(e.cell){if("onlyFormat"===(null==n?void 0:n.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.evaluated.format||e.cell.format});if("onlyValue"===(null==n?void 0:n.pasteOption)){const o=Ut(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:o})}let a=e.cell.content;if(e.cell.isFormula()&&"COPY"===o){const t=r-e.position.col,n=s-e.position.row;a=this.getUpdatedContent(i,e.cell,t,n,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==n?void 0:n.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==n?void 0:n.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,n,i){const r=this.getters.createAdaptedRanges(t.dependencies,o,n,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:o,col:n,row:i}=e;const{col:r,row:s}=this.getters.getMainCellPosition(o,n,i);if(r===n&&s===i){const e=this.getters.getMerge(o,n,i);if(!e)return;({sheetId:o,col:n,row:i}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:n,top:i,right:n+e.right-e.left,bottom:i+e.bottom-e.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],n=this.zones[0],i=[o.left-n.left,o.top-n.top];for(const e of this.copiedTables){const o=Do(e.zone,"both","MOVE",i);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const n of Fe(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+n,row:o.top,values:e.filtersValues[n]})}}getClipboardContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:n,width:i,height:r}=this.getters.getVisibleRect(e);i>0&&r>0&&t.strokeRect(o,n,i,r)}}}}class Qm{constructor(e,t,o){this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const n=t.getSelectedFigureId();if(!n)throw new Error("No figure selected");const i=t.getFigure(this.sheetId,n);if(!i)throw new Error(`No figure for the given id: ${n}`);this.copiedFigure={...i};const r=t.getChart(n);if(!r)throw new Error(`No chart for the given id: ${n}`);this.copiedChart=r.copyInSheetId(this.sheetId),this.operation=e}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?72:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),o={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},n=this.copiedChart.copyInSheetId(t),i=(new po).uuidv4();this.dispatch("CREATE_CHART",{id:i,sheetId:t,position:o,size:{height:this.copiedFigure.height,width:this.copiedFigure.width},definition:n.getDefinition()}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedChart.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:i})}getClipboardContent(){return"\t"}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Jm extends Ym{constructor(e,t,o,n){super("COPY",t,o,n),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),n=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,n)?2:0}paste(e){const t=this.values,o=this.getPasteZone(e),{left:n,top:i}=o,{width:r,height:s}=No(o),a=this.getters.getActiveSheetId();this.addMissingDimensions(r,s,n,i);for(let e=0;e<t.length;e++)for(let o=0;o<t[e].length;o++)this.dispatch("UPDATE_CELL",{row:i+e,col:n+o,content:t[e][o],sheetId:a});const l={left:n,top:i,right:n+r-1,bottom:i+s-1};this.selection.selectZone({cell:{col:n,row:i},zone:l})}getClipboardContent(){return this.values.map((e=>e.join("\t"))).join("\n")}getPasteZone(e){const t=this.values.length,o=Math.max(...this.values.map((e=>e.length))),{left:n,top:i}=e[0];return{top:i,left:n,bottom:i+t-1,right:n+o-1}}}class ev extends pg{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=e.target||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new Jm(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}}return 0}handle(e){var t,o;switch(e.type){case"COPY":case"CUT":const n="target"in e&&e.target||this.getters.getSelectedZones();this.state=this.getClipboardState(n,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:i,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!vo(t[0])){for(const{col:t,row:o}of Fo(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(o=this.state)||void 0===o?void 0:o.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new Jm(e.text,this.getters,this.dispatch,this.selection).paste(e.target),this.status="invisible";break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}default:Ko(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let n;return n="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[n],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let n,i;return"COL"===t?(n={...e,right:this.getters.getNumberCols(o)-1},i={...e,left:e.right+1,right:e.right+1}):(n={...e,bottom:this.getters.getNumberRows(o)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[n],paste:[i]}}getClipboardStateForCopyCells(e,t){return new Km(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new Qm(t,this.getters,this.dispatch):new Km(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}ev.layers=[2],ev.getters=["getClipboardContent","isCutOperation","isPaintingFormat"];class tv extends pg{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const o=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(o),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:ct(255,0,0),colors:[]},{leadColor:ct(255,128,0),colors:[]},{leadColor:ct(128,128,0),colors:[]},{leadColor:ct(128,255,0),colors:[]},{leadColor:ct(0,255,0),colors:[]},{leadColor:ct(0,255,128),colors:[]},{leadColor:ct(0,255,255),colors:[]},{leadColor:ct(0,127,255),colors:[]},{leadColor:ct(0,0,255),colors:[]},{leadColor:ct(127,0,255),colors:[]},{leadColor:ct(128,0,128),colors:[]},{leadColor:ct(255,0,128),colors:[]}];for(const o of e.map(ut)){let e=500,n=0;t.forEach(((t,i)=>{const r=(s=o,a=t.leadColor,Math.sqrt(Math.pow(s.r-a.r,2)+Math.pow(s.g-a.g,2)+Math.pow(s.b-a.b,2)));var s,a;e>r&&(e=r,n=i)})),t[n].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>pt(e).s-pt(t).s)))).flat().map(dt)}([...new Set([...new Set([...e,...this.customColors])].filter(at).map((e=>st(e).toLowerCase())))]).filter((e=>!A.includes(e)))}getColorsFromCells(e){var t,o;const n=new Set;for(const i of e)(null===(t=i.style)||void 0===t?void 0:t.textColor)&&n.add(i.style.textColor),(null===(o=i.style)||void 0===o?void 0:o.fillColor)&&n.add(i.style.fillColor);return[...n]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(it(t.minimum.color)),o.push(t.midpoint?it(t.midpoint.color):void 0),o.push(it(t.maximum.color)))}return o.filter(Ze)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const n=e;o.add(n.baselineColorDown),o.add(n.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=st(e).toLowerCase();e&&!A.includes(t)&&this.customColors.add(t)}}tv.getters=["getCustomColors"];const ov=Su.mapping;class nv extends pg{constructor(e,t,o,n,i){super(e,t,o,n,i),this.isUpToDate=!1,this.evalContext=n.evalContext}handle(e){switch(Zo.has(e.type)&&(this.isUpToDate=!1),e.type){case"UPDATE_CELL":("content"in e||"format"in e)&&(this.isUpToDate=!1);break;case"EVALUATE_CELLS":this.evaluate()}}finalize(){this.isUpToDate||this.evaluate()}evaluateFormula(e,t=this.getters.getActiveSheetId()){const o=lg(e),n=this.getCompilationParameters((()=>{})),i=[];for(let e of o.dependencies)i.push(this.getters.getRangeFromSheetXC(t,e));return o.execute(i,...n).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>(null==e?void 0:e.formattedValue)||""))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>null==e?void 0:e.evaluated.value))}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){const e=this.getCompilationParameters(o),t={};for(const e of this.getAllCells())o(e);function o(o){if(!o.isFormula())return;const n=o.id,i=Ke((()=>{if(e[2].__originCellXC=()=>{const t=e[2].getters.getCellPosition(n);return Ot(t.col,t.row)},n in t)return null===t[n]?new d:o.evaluated;t[n]=null;try{const i=o.compiledFormula.execute(o.dependencies,...e);if(t[n]=!0,Array.isArray(i.value))throw new Error(r("This formula depends on invalid values"));return{value:i.value,format:o.format||i.format}}catch(o){return t[n]=!0,function(t){t instanceof Error||(t=new Error(t));const o=(null==t?void 0:t.errorType)||a.GenericError,n=e[2].__lastFnCalled||"";return new c(o,t.message.replace("[[FUNCTION_NAME]]",n),void 0!==t.logLevel?t.logLevel:l.error)}(o)}}));o.assignEvaluation(i)}this.isUpToDate=!0}getCompilationParameters(e){const t=Object.assign(Object.create(ov),this.evalContext,{getters:this.getters}),o=this.getters;function n(e){if(e.evaluated.type===qo.error)throw new c(e.evaluated.value,e.evaluated.error.message,e.evaluated.error.logLevel);return e.evaluated}return[function(e,t,i,s){if(t)return{value:bo(e.zone)};if(!vo(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(s?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",i.toString(),s.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",i.toString()));if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!o.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));return t=o.getCell(e.sheetId,e.zone.left,e.zone.top),!t||t.isEmpty()?{value:null}:n(t)}(e)},function(e){const i=e.sheetId;if(!vo(e.zone))throw new u;const r=o.getSheetZone(i),s=[],a=xo(e.zone,r);if(!a)return s.push([]),s;for(let o=a.left;o<=a.right;o++){const i=[];for(let r=a.top;r<=a.bottom;r++){const s=t.getters.getCell(e.sheetId,o,r);i.push(s?n(s):void 0)}s.push(i)}return s},t]}}nv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"];class iv extends pg{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=Bo.getAll();return function(o){const n=t.find((e=>e.match(o.type)));if(!n)throw new Error("No runtime builder for this chart.");return n.getChartRuntime(o,e)}}(this.getters)}handle(e){if(Zo.has(e.type)||jo.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const o=t.zone.left,n=t.zone.top;return this.getters.getCellComputedStyle(t.sheetId,o,n).fillColor||w}}iv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class rv extends pg{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.rulePredicate={CellIsRule:(e,t)=>{if(e&&e.evaluated.type===qo.error)return!1;const o=t.values.map(up);switch(t.operator){case"IsEmpty":return!Ze(e)||""===e.evaluated.value.toString().trim();case"IsNotEmpty":return Ze(e)&&""!==e.evaluated.value.toString().trim();case"BeginsWith":return!(!e&&""===o[0])&&(Ze(e)&&(null==e?void 0:e.evaluated.value.toString().startsWith(o[0].toString())));case"EndsWith":return!(!e&&""===o[0])&&(Ze(e)&&e.evaluated.value.toString().endsWith(o[0].toString()));case"Between":return Ze(e)&&e.evaluated.value>=o[0]&&e.evaluated.value<=o[1];case"NotBetween":return!(Ze(e)&&e.evaluated.value>=o[0]&&e.evaluated.value<=o[1]);case"ContainsText":return Ze(e)&&e.evaluated.value.toString().indexOf(o[0].toString())>-1;case"NotContains":return!Ze(e)||!e.evaluated.value||-1==e.evaluated.value.toString().indexOf(o[0].toString());case"GreaterThan":return Ze(e)&&e.evaluated.value>o[0];case"GreaterThanOrEqual":return Ze(e)&&e.evaluated.value>=o[0];case"LessThan":return Ze(e)&&e.evaluated.value<o[0];case"LessThanOrEqual":return Ze(e)&&e.evaluated.value<=o[0];case"NotEqual":return!(!Ze(e)&&""===o[0])&&(Ze(e)&&e.evaluated.value!==o[0]);case"Equal":return!e&&""===o[0]||Ze(e)&&e.evaluated.value===o[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((jo.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const o=this.getters.getActiveSheetId(),n=this.getters.getRulesByCell(o,e.originCol,e.originRow);for(const t of n)this.adaptRules(o,t,[Ot(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation)}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getCellComputedStyle(e,t,o){var n;const i=this.getters.getCell(e,t,o),r=this.computedStyles[e],s=r&&(null===(n=r[t])||void 0===n?void 0:n[o]),a={...null==i?void 0:i.style,...s};return this.getters.isFilterHeader(e,t,o)&&(a.bold=!0),a}getConditionalIcon(e,t){var o;const n=this.getters.getActiveSheetId(),i=this.computedIcons[n];return i&&(null===(o=i[e])||void 0===o?void 0:o[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const o=this.computedStyles[t];for(let n of this.getters.getConditionalFormats(t).reverse())try{switch(n.rule.type){case"ColorScaleRule":for(let e of n.ranges)this.applyColorScale(e,n.rule);break;case"IconSetRule":for(let e of n.ranges)this.applyIcon(e,n.rule);break;default:for(let i of n.ranges){const r=this.getters.getRangeFromSheetXC(t,i).zone;for(let i=r.top;i<=r.bottom;i++)for(let s=r.left;s<=r.right;s++){const r=this.rulePredicate[n.rule.type];let a=this.getters.getCell(t,s,i);r&&r(a,n.rule)&&(o[s]||(o[s]=[]),o[s][i]=Object.assign((null===(e=o[s])||void 0===e?void 0:e[i])||{},n.rule.style))}}}}catch(e){}}parsePoint(e,t,o){const n=this.getters.getActiveSheetId(),i=this.getters.getRangeValues(this.getters.getRangeFromSheetXC(n,e)).filter(this.isCellValueNumber);switch(t.type){case"value":return"max"===o?Math.max(...i):Math.min(...i);case"number":return Number(t.value);case"percentage":const e=Math.min(...i);return e+(Math.max(...i)-e)*Number(t.value)/100;case"percentile":return lo(i,Number(t.value)/100,!0);case"formula":const n=t.value&&this.getters.evaluateFormula(t.value);return n instanceof Promise?null:n;default:return null}}applyIcon(e,t){const o=this.parsePoint(e,t.lowerInflectionPoint),n=this.parsePoint(e,t.upperInflectionPoint);if(null===o||null===n||o>n)return;const i=this.getters.getActiveSheetId(),r=this.getters.getRangeFromSheetXC(i,e).zone,s=this.computedIcons[i],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=r.top;e<=r.bottom;e++)for(let l=r.left;l<=r.right;l++){const r=this.getters.getCell(i,l,e);if((null==r?void 0:r.evaluated.type)!==qo.number)continue;const c=this.computeIcon(r.evaluated.value,n,t.upperInflectionPoint.operator,o,t.lowerInflectionPoint.operator,a);s[l]||(s[l]=[]),s[l][e]=c}}computeIcon(e,t,o,n,i,r){return"ge"===o&&e>=t||"gt"===o&&e>t?r[0]:"ge"===i&&e>=n||"gt"===i&&e>n?r[1]:r[2]}applyColorScale(e,t){var o;const n=this.parsePoint(e,t.minimum,"min"),i=t.midpoint?this.parsePoint(e,t.midpoint):null,r=this.parsePoint(e,t.maximum,"max");if(null===n||null===r||n>=r||i&&(n>=i||i>=r))return;const s=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(s,e).zone,l=this.computedStyles[s],c=[];t.midpoint&&i?(c.push({minValue:n,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(n,i,t.minimum.color,t.midpoint.color)}),c.push({minValue:i,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(i,r,t.midpoint.color,t.maximum.color)})):c.push({minValue:n,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(n,r,t.minimum.color,t.maximum.color)});for(let e=a.top;e<=a.bottom;e++)for(let t=a.left;t<=a.right;t++){const a=this.getters.getCell(s,t,e);if((null==a?void 0:a.evaluated.type)===qo.number){const s=Oe(a.evaluated.value,n,r);let h;h=2===c.length&&i?s<=i?this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(s,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(o=l[t])||void 0===o?void 0:o[e])||{},l[t][e].fillColor=it(h)}}}computeColorDiffUnits(e,t,o,n){const i=t-e;return[((o>>16)%256-(n>>16)%256)/i,((o>>8)%256-(n>>8)%256)/i,(o%256-n%256)/i]}colorCell(e,t,o,n){const[i,r,s]=n;return Math.round((o>>16)%256-i*(e-t))<<16|Math.round((o>>8)%256-r*(e-t))<<8|Math.round(o%256-s*(e-t))}adaptRules(e,t,o,n){if(0===o.length&&0===n.length)return;const i=this.getters.getConditionalFormats(e),r=i.findIndex((e=>e.id===t.id));let s=[];r>-1&&(s=i[r].ranges),s=s.concat(o);const a=Oo(s,n);this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}pasteCf(e,t,o){const n=Ot(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let r of i.ranges)if(To(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,r).zone)){const r=i,s=[];"CUT"===o&&s.push(Ot(e.col,e.row)),e.sheetId===t.sheetId?this.adaptRules(e.sheetId,r,[n],s):(this.adaptRules(t.sheetId,r,[n],[]),this.adaptRules(e.sheetId,r,[],s))}}isCellValueNumber(e){return"number"==typeof e}}rv.getters=["getConditionalIcon","getCellComputedStyle"];class sv extends pg{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e.sheetId,e.col,e.row))return 78;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const o of this.getters.getFilters(e.sheetIdTo)){const n=o.zoneWithHeaders;t[o.id]=this.getFilterValues(e.sheetId,n.left,n.top)}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e,t,o){let n;for(let i of this.getters.getFilterTables(e)){const r=i.zone;if(To(t,o,r)){const i=this.intersectZoneWithViewport(e,r);n={top:o===i.top?Z:void 0,bottom:o===i.bottom?Z:void 0,left:t===i.left?Z:void 0,right:t===i.right?Z:void 0}}}const i=this.getters.getCellBorder(e,t,o),r={...n,...tt(i||{})};return je(r)?null:r}getFilterHeaders(e){const t=[];for(let o of this.getters.getFilterTables(e)){const n=o.zone;if(!n)continue;const i=n.top;for(let o=n.left;o<=n.right;o++)this.getters.isColHidden(e,o)||this.getters.isRowHidden(e,i)||t.push({col:o,row:i})}return t}getFilterValues(e,t,o){const n=this.getters.getFilterId(e,t,o);return n&&this.filterValues[e]&&this.filterValues[e][n]||[]}isFilterHeader(e,t,o){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}isFilterActive(e,t,o){var n,i;const r=this.getters.getFilterId(e,t,o);return Boolean(r&&(null===(i=null===(n=this.filterValues[e])||void 0===n?void 0:n[r])||void 0===i?void 0:i.length))}intersectZoneWithViewport(e,t){const o=Fe(t.left,t.right+1),n=Fe(t.top,t.bottom+1);return{left:this.getters.findVisibleHeader(e,"COL",o),right:this.getters.findVisibleHeader(e,"COL",o.reverse()),top:this.getters.findVisibleHeader(e,"ROW",n),bottom:this.getters.findVisibleHeader(e,"ROW",n.reverse())}}updateFilter({col:e,row:t,values:o,sheetId:n}){const i=this.getters.getFilterId(n,e,t);i&&(this.filterValues[n]||(this.filterValues[n]={}),this.filterValues[n][i]=o)}updateHiddenRows(){var e,t;const o=this.getters.getActiveSheetId(),n=this.getters.getFilters(o),i=new Set;for(let r of n){const n=null===(t=null===(e=this.filterValues[o])||void 0===e?void 0:e[r.id])||void 0===t?void 0:t.map(ot);if(n&&r.filteredZone)for(let e=r.filteredZone.top;e<=r.filteredZone.bottom;e++){const t=this.getCellValueAsString(o,r.col,e);n.includes(t)&&i.add(e)}}this.hiddenRows=i}getCellValueAsString(e,t,o){var n;const i=null===(n=this.getters.getCell(e,t,o))||void 0===n?void 0:n.formattedValue;return(null==i?void 0:i.toLowerCase())||""}exportForExcel(e){var t;for(const o of e.sheets)for(const e of o.filterTables){const n=mo(e.range),i=[],r=[];for(const e of Fe(0,No(n).width)){const s=this.getFilterValues(o.id,n.left+e,n.top),a=this.getters.getFilter(o.id,n.left+e,n.top);if(!a)continue;const l=a.filteredZone?Fo(a.filteredZone).map((e=>{var t;return null===(t=this.getters.getCell(o.id,e.col,e.row))||void 0===t?void 0:t.formattedValue})).filter(Ze):[],c=l.filter((e=>!s.includes(e)));i.push({colId:e,filteredValues:[...new Set(c)]});const h={col:a.col,row:a.zoneWithHeaders.top},d=null===(t=this.getters.getCell(o.id,h.col,h.row))||void 0===t?void 0:t.formattedValue,u=this.getUniqueColNameForExcel(e,d,r);r.push(u),o.cells[Ot(h.col,h.row)]={...o.cells[Ot(h.col,h.row)],content:u,value:u,isFormula:!1}}e.filters=i}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let n=t,i=2;for(;o.includes(n);)n=t+String(i),i++;return n}}sv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];var av;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(av||(av={}));class lv extends pg{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(av.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(av.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(av.current)}updateRegex(){let e=Re(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),o=[];if(this.toSearch)for(const e of Object.values(t))if(e&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&e.isFormula()?e.content:String(e.evaluated.value))){const t=this.getters.getCellPosition(e.id),n={col:t.col,row:t.row,selected:!1};o.push(n)}return o.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===o||(this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].row));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId(),n=this.getters.getCell(o,t.col,t.row),i=this.toReplace(n,o);if(n&&i){const o=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),n=i.toString().replace(o,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:n}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(av.current)}else this.selectNextCell(av.next)}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replace(e)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.searchOptions.searchFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const n=this.getters.getMerge(o,e.col,e.row),i=n?n.left:e.col,r=n?n.right:e.col,s=n?n.top:e.row,a=n?n.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:s,left:i,right:r,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}lv.layers=[3],lv.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class cv extends pg{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){const n=this.searchNumberFormat(e,t);if(void 0!==n){const i=function(e,t){const o=Pt(e).map((e=>"NUMBER"===e.type?{...e,format:jt(e.format,t)}:e)),n=Qt(o);return Lt[n]=o,n}(n,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:i})}}searchNumberFormat(e,t){var o;for(let n of t)for(let t=n.top;t<=n.bottom;t++)for(let i=n.left;i<=n.right;i++){const n=this.getters.getCell(e,i,t);if((null==n?void 0:n.evaluated.type)===qo.number&&!(null===(o=n.evaluated.format)||void 0===o?void 0:o.match(j)))return n.evaluated.format||qt(n.evaluated.value)}}}cv.modes=["normal"];class hv extends pg{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition(e,t,o){return{col:this.findVisibleHeader(e,"COL",Fe(t,this.getters.getNumberCols(e))),row:this.findVisibleHeader(e,"ROW",Fe(o,this.getters.getNumberRows(e)))}}findVisibleHeader(e,t,o){return o.find((o=>this.getters.doesHeaderExist(e,t,o)&&!this.isHeaderHidden(e,t,o)))}findLastVisibleColRowIndex(e,t,o){let n;for(n=o.last;n>=o.first;n--)if(!this.isHeaderHidden(e,t,n))return n;return n}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let n=0;n<o-1;n++){if("COL"===t&&!this.isColHidden(e,n))return n;if("ROW"===t&&!this.isRowHidden(e,n))return n}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const n=this.isRowHidden(t.id,Number(e));o.isHidden=n}}}hv.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class dv extends pg{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{height:t,width:o}=No(e.zone),n=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:n}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,n=this.getters.getActiveSheetId(),i=3*o;t.lineWidth=i;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>Ro(t.zone,e.zone)&&t.sheetId===n))===t))){const{x:o,y:n,width:r,height:s}=this.getters.getVisibleRect(e.zone);r>0&&s>0&&(t.strokeStyle=e.color,t.strokeRect(o+i/2,n+i/2,r-i,s-i),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+i,n+i,r-2*i,s-2*i))}}}dv.layers=[1],dv.getters=["getHighlights"];class uv extends pg{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleCols()),n=this.getters.getColRowOffsetInViewport("COL",o,t),i=this.getters.getColSize(e,t);return{start:n,size:i,end:n+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleRows()),n=this.getters.getColRowOffsetInViewport("ROW",o,t),i=this.getters.getRowSize(e,t);return{start:n,size:i,end:n+(this.getters.isRowHidden(e,t)?0:i)}}getHeaderOffset(e,t,o){let n=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(n+="ROW"===e?O:M),n}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:o}=e,{width:n,height:i}=this.getters.getSheetViewDimensionWithHeaders(),r=this.getters.getActiveSheetId();t.fillStyle="#ffffff",t.fillRect(0,0,n+f,i+f);const s=this.getters.getSheetViewVisibleCols(),a=s[0],l=s[s.length-1],c=this.getters.getSheetViewVisibleRows(),h=c[0],d=c[c.length-1];if(this.getters.getGridLinesVisibility(r)&&!this.getters.isDashboard()){t.lineWidth=2*o,t.strokeStyle="#E2E3E3",t.beginPath();for(const e of s){const o={top:h,bottom:d,left:e,right:e},{x:n,width:r,height:s}=this.getters.getVisibleRect(o);t.moveTo(n+r,0),t.lineTo(n+r,Math.min(i,s+(this.getters.isDashboard()?0:O)))}for(const e of c){const o={left:a,right:l,top:e,bottom:e},{y:i,width:r,height:s}=this.getters.getVisibleRect(o);t.moveTo(0,i+s),t.lineTo(Math.min(n,r+(this.getters.isDashboard()?0:M)),i+s)}t.stroke()}}drawCellBackground(e){const{ctx:t,thinLineWidth:o}=e,n=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());t.lineWidth=n?.3*o:o;const i=n?.1*o:0;t.strokeStyle="#111";for(let e of this.boxes){let r=e.style;(r.fillColor&&"#ffffff"!==r.fillColor||e.isMerge)&&(t.fillStyle=r.fillColor||"#ffffff",n?(t.fillRect(e.x,e.y,e.width,e.height),t.strokeRect(e.x+i,e.y+i,e.width-2*i,e.height-2*i)):t.fillRect(e.x-o,e.y-o,e.width+2*o,e.height+2*o)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawBorders(e){const{ctx:t,thinLineWidth:o}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:o,y:i,width:r,height:s}=e;t.left&&n(t.left,o,i,o,i+s),t.top&&n(t.top,o,i,o+r,i),t.right&&n(t.right,o+r,i,o+r,i+s),t.bottom&&n(t.bottom,o,i+s,o+r,i+s)}}function n([e,n],i,r,s,a){t.strokeStyle=n,t.lineWidth=("thin"===e?2:3)*o,t.beginPath(),t.moveTo(i,r),t.lineTo(s,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let n;t.textBaseline="top";for(let e of this.boxes)if(e.content){const i=e.style||{},r=e.content.align||"left",s=Ne(i);let a;s!==n&&(n=s,t.font=s),t.fillStyle=i.textColor||"#000";let l=e.y+e.height/2+1;if(a="left"===r?e.x+(e.image?e.image.size+2*$:L):"right"===r?e.x+e.width-L-(e.isFilterHeader?20:0):e.x+e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:o,y:n,width:i,height:r}=e.clipRect;t.rect(o,n,i,r),t.clip()}const c=e.content.multiLineText.length,h=_e(i);let d=l-(c*(h+L)-L)/2;for(let n of e.content.multiLineText){if(t.fillText(n,Math.round(a),Math.round(d)),i.strikethrough||i.underline){const e=Me(t,n,i);let s=a;"right"===r?s-=e:"center"===r&&(s-=e/2),i.strikethrough&&t.fillRect(s,d+h/2,e,2.6*o),i.underline&&t.fillRect(s,d+h+1,e,1.3*o)}d+=L+h}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image,n=e.image.size,i=(e.height-n)/2;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:n,width:i,height:r}=e.image.clipIcon;t.rect(o,n,i,r),t.clip()}t.drawImage(o,e.x+$,e.y+i,n,n),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,n=this.getters.getSheetViewVisibleCols(),i=n[0],r=n[n.length-1],s=this.getters.getSheetViewVisibleRows(),a=s[0],l=s[s.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let o of e)for(let e of Fe(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of Fe(o.top,o.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),f=this.getters.getNumberCols(p),m=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${G}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=i;e<=r;e++){const o={left:e,right:e,top:0,bottom:m-1},{x:n,width:i}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),s=E.has(e),a=u.has(e);t.fillStyle=s?r?R:S:a?r?T:b:r?I:v,t.fillRect(n,0,i,O)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:f-1},{y:n,height:i}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),s=w.has(e),a=g.has(e);t.fillStyle=s?r?R:S:a?r?T:b:r?I:v,t.fillRect(0,n,M,i)}t.beginPath(),t.moveTo(M,0),t.lineTo(M,h),t.moveTo(0,O),t.lineTo(c,O),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of n){const o=this.getters.getColSize(p,e),n=It(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",i,e);t.fillText(n,r+o/2,13),t.moveTo(r+o,0),t.lineTo(r+o,O)}for(const e of s){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let n=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,n+o/2),t.moveTo(0,n+o),t.lineTo(M,n+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:n,y:i}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:M,s=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),n&&(t.moveTo(r+n,0),t.lineTo(r+n,s)),i&&(t.moveTo(0,s+i),t.lineTo(r,s+i)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:n,y:i}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),s=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:s,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:M,u=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),n&&(t.moveTo(d+n,u),t.lineTo(d+n,h.height+u)),i&&(t.moveTo(d,u+i),t.lineTo(h.width+d,u+i)),t.stroke()}hasContent(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.getCell(o,e,t);return n&&!n.isEmpty()||this.getters.isInMerge(o,e,t)}findNextEmptyCol(e,t,o){let n=e;for(;n<t&&!this.hasContent(n+1,o);)n++;return n}findPreviousEmptyCol(e,t,o){let n=e;for(;n>t&&!this.hasContent(n-1,o);)n--;return n}computeCellAlignment(e,t){if(e.isFormula()&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e);return t&&e.evaluated.type===qo.number?"center"!==o?"left":o:o||e.defaultAlign}createZoneBox(e,t,o){const{left:n,right:i}=o,r=t.left,s=t.top,a=this.getters.getCell(e,r,s),c=this.getters.shouldShowFormulas(),{x:h,y:d,width:u,height:g}=this.getters.getVisibleRect(t),p={x:h,y:d,width:u,height:g,border:this.getters.getCellBorderWithFilterBorder(e,r,s)||void 0,style:this.getters.getCellComputedStyle(e,r,s)};if(!a)return p;const f=this.getters.getConditionalIcon(r,s),m=_e(p.style),v=f?2*$+m:0;f&&(p.image={type:"icon",size:m,clipIcon:{x:p.x,y:p.y,width:Math.min(v,u),height:g},image:Zr[f].img}),p.isFilterHeader=this.getters.isFilterHeader(e,r,s);const b=p.isFilterHeader?19:0,S=this.getters.getCellText(a,c),C=this.getters.getTextWidth(a),E=this.getters.getCellStyle(a).wrapping||"overflow",w="wrap"===E?this.getters.getCellMultiLineText(a,u-2*L):[S],y=v+C+b,x=this.computeCellAlignment(a,y>u);p.content={multiLineText:w,width:"overflow"===E?C:u,align:x},a.evaluated.type===qo.error&&a.evaluated.error.logLevel>l.silent&&(p.error=a.evaluated.error.message);const R=y>u||m>g;if(f||p.isFilterHeader)p.clipRect={x:p.x+v,y:p.y,width:Math.max(0,u-v-b),height:g};else if(R&&"overflow"===E){let o,a;switch(this.getters.isInMerge(e,r,s)?(o=this.getters.getMerge(e,r,s).right,a=r):(o=this.findNextEmptyCol(r,i,s),a=this.findPreviousEmptyCol(r,n,s)),x){case"left":{const e=Lo({col:o,row:s}),{x:n,y:i,width:r,height:a}=this.getters.getVisibleRect(yo(t,e));(r<C||m>a)&&(p.clipRect={x:n,y:i,width:r,height:a});break}case"right":{const e=Lo({col:a,row:s}),{x:o,y:n,width:i,height:r}=this.getters.getVisibleRect(yo(t,e));(i<C||m>r)&&(p.clipRect={x:o,y:n,width:i,height:r});break}case"center":{const e={...t,right:o,left:a},{x:n,y:i,width:s,height:l}=this.getters.getVisibleRect(e);(s<C||a===r||o===r||m>l)&&(p.clipRect={x:n,y:i,width:s,height:l});break}}}else"clip"!==E&&"wrap"!==E||(p.clipRect={x:p.x,y:p.y,width:u,height:g});return p}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),o=t[0],n=t[t.length-1],i=this.getters.getSheetViewVisibleRows(),r={left:o,right:n,top:i[0],bottom:i[i.length-1]},s=this.getters.getActiveSheetId();for(const o of i)for(const n of t)this.getters.isInMerge(s,n,o)||e.push(this.createZoneBox(s,Lo({col:n,row:o}),r));for(const t of this.getters.getMerges(s))if(!this.getters.isMergeHidden(s,t)&&Io(t,r)){const o=this.createZoneBox(s,t,r),n=this.getters.getCellBorder(s,t.right,t.bottom);o.border={...o.border,bottom:n?n.bottom:void 0,right:n?n.right:void 0},o.isMerge=!0,e.push(o)}return e}}uv.layers=[0,7],uv.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];const gv=[{name:r("Sum"),types:[qo.number],compute:e=>Va.compute([e])},{name:r("Avg"),types:[qo.number],compute:e=>Ka.compute([e])},{name:r("Min"),types:[qo.number],compute:e=>pl.compute([e])},{name:r("Max"),types:[qo.number],compute:e=>hl.compute([e])},{name:r("Count"),types:[qo.number,qo.text,qo.boolean,qo.error],compute:e=>rl.compute([e])},{name:r("Count Numbers"),types:[qo.number,qo.text,qo.boolean,qo.error],compute:e=>il.compute([e])}];class pv extends pg{constructor(e,t,o,n,i){super(e,t,o,n,i),this.gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]},this.selectedFigureId=null,this.sheetsData={},this.activeSheet=null,this.moveClient=n.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 27}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const n=o.findIndex((t=>Ro(t,e.previousAnchor.zone)));n>=0&&(o[n]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Ie(this.gridSelection.anchor));const{col:n,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:n,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:o,row:n}=this.getters.getNextVisibleCellPosition(t,0,0);this.selectCell(o,n),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:Ie(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Ie(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0);this.selectCell(t,o)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:n})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:n})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const i=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of i)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Ie(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}const r=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(r,e))),this.gridSelection.anchor.zone=this.getters.expandZone(r,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Ie(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),{col:t,row:o}=this.gridSelection.anchor.cell,{col:n,row:i}=this.getters.getMainCellPosition(e,t,o);return this.getters.getCell(e,n,i)}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return Ie(this.gridSelection.zones)}getSelectedZone(){return Ie(this.gridSelection.anchor.zone)}getSelection(){return Ie(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return{col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row}}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?{col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition(e,0,0)}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>void 0!==e)));let t=new Set,o=[];for(let n of e)t.add(n.evaluated.type),o.push(n.evaluated.value);let n={};for(let e of gv){let i;e.types.some((e=>t.has(e)))&&(i=e.compute(o)),n[e.name]=i}return n}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),n=this.gridSelection.zones.map(Fo).flat();for(const{col:i,row:r}of n){const n=this.getters.getCell(o,i,r);(null==n?void 0:n.evaluated.type)===qo.number&&(t++,e+=n.evaluated.value)}return t<2?null:Ut(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Ro(t,e)))}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let o=[];const n="COL"===e?"left":"top",i="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[i]-e[n]+1},((t,o)=>e[n]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:n}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(n)}selectCell(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:n,cell:{col:e,row:t}},[n])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,n=Eo(o,"left",[...e.elements]);let i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Eo(i,"left",[...e.elements]);const r={cell:{col:i.left,row:i.top},zone:n};this.setSelectionMixin(r,[n])}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,n=Eo(o,"top",[...e.elements]);let i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=Eo(i,"top",[...e.elements]);const r={cell:{col:i.left,row:i.top},zone:n};this.setSelectionMixin(r,[n])}onAddElements(e){const t=Co(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(o,[t])}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const o="COL"===e.dimension,n=e.elements[0],i=e.elements[t-1],r=e.base<n,s=r&&o?t:0,a=r&&!o?t:0;this.dispatch("CUT",{target:[{left:o?n+s:0,right:o?i+s:this.getters.getNumberCols(e.sheetId)-1,top:o?0:n+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:i+a}]}),this.dispatch("PASTE",{target:[{left:o?e.base:0,right:o?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:e.base,bottom:o?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=r?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const o="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:o,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],n=e.elements[e.elements.length-1],i=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return r(i,o-1,o)||r(i,n,n+1)||r(i,e.base-1,e.base)?2:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,n=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:Oe(e.left,0,o),right:Oe(e.right,0,o),top:Oe(e.top,0,n),bottom:Oe(e.bottom,0,n)}))),anchor:{cell:{col:Oe(t.anchor.cell.col,0,o),row:Oe(t.anchor.cell.row,0,n)},zone:{left:Oe(t.anchor.zone.left,0,o),right:Oe(t.anchor.zone.right,0,o),top:Oe(t.anchor.zone.top,0,n),bottom:Oe(t.anchor.zone.bottom,0,n)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,n=this.getSelectedZones();t.fillStyle="#f3f7fe";const i=1===n.length&&n[0].left===n[0].right&&n[0].top===n[0].bottom;t.fillStyle=i?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o,t.globalCompositeOperation="multiply";for(const e of n){const{x:o,y:n,width:i,height:r}=this.getters.getVisibleRect(e);t.fillRect(o,n,i,r),t.strokeRect(o,n,i,r)}t.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),{col:s,row:a}=this.getPosition();let l;t.strokeStyle=E,t.lineWidth=3*o,l=this.getters.isInMerge(r,s,a)?this.getters.getMerge(r,s,a):{top:a,bottom:a,left:s,right:s};const{x:c,y:h,width:d,height:u}=this.getters.getVisibleRect(l);d>0&&u>0&&t.strokeRect(c,h,d,u)}}pv.layers=[5],pv.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getPosition","getSheetPosition","isSelected","getElementsFromSelection"];const fv=new po;class mv extends pg{constructor(e,t,o,n,i,r,s){super(e,t,o,n,i),this.inputHasSingleRange=s,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,r),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){if("ADD_EMPTY_RANGE"===e.type)if(this.inputHasSingleRange&&1===this.ranges.length)return 29;return 0}handleEvent(e){const t=bo(e.anchor.zone),o=this.activeSheet,n=this.getters.getActiveSheetId(),i=this.getters.getSheetName(n);this.add([n===o?t:`${Ae(i)}!${t}`])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const o=e.value.split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Lo({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:n})}}}unsubscribe(){this.unfocus()}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],id:fv.uuidv4(),xc:t}}insertNewRange(e,t){this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:(this.ranges.length+t+1).toString(),color:(rt=++rt%nt.length,nt[rt])}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=Rt(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:o}=Rt(t),n=this.getters.getSheetIdByName(o),i=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(n===i||void 0===n&&i===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}mv.layers=[1],mv.getters=[];class vv extends pg{constructor(e,t,o,n,i){super(e,t,o,n,i),this.state=t,this.config=n,this.inputs={},this.focusedInputId=null}get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}allowDispatch(e){var t,o;if("FOCUS_RANGE"===e.type){const n=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(o=this.currentInput)||void 0===o?void 0:o.focusedRangeIndex)===n)return 28}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){var t;switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:Lo({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}unsubscribe(){this.unfocus()}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,o)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=Rt(e);return null!==t.match(Ct)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]=new mv(this.getters,this.state,this.dispatch,this.config,this.selection,t,o),0===t.length){const t=this.inputs[e],o={zone:Lo({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}vv.layers=[1],vv.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class bv{constructor(){this.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,n=o.length;e<n;e++){const n=o[e];n.callback.call(n.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function Sv(e,t){return{...e,definition:gr(e.definition,t)}}function Cv(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}ki.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Sv),ki.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Sv),ki.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)return;return e})),ki.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),ki.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var o;if(e.name===t.name)return{...e,name:(null===(o=e.name)||void 0===o?void 0:o.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),ki.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const n of e.target)for(const e of t.target)Io(n,e)||o.push({...n});if(o.length)return{...e,target:o};return})),ki.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Cv),ki.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Cv),ki.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(Io(e,o))return;return e}));const Ev=[{match:function(e){return"sheetId"in e},fn:xv},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=xv(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const n=[];for(const o of e.target){const e=Bi(o,t);e&&n.push(e)}if(!n.length)return"IGNORE_COMMAND";return{...e,target:n}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=xv(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let n=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(n))return"IGNORE_COMMAND";for(let t of e)n>=t&&n--}"ADD_COLUMNS_ROWS"===t.type&&(n>t.base||n===t.base&&"before"===t.position)&&(n+=t.quantity);return{...e,[o]:n}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&To(e.col,e.row,o))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const o=xv(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,n=o?"base":"elements";let i=o?[e[n]]:e[n];if("REMOVE_COLUMNS_ROWS"===t.type&&(i=i.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(Ze)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;i=i.map((o=>o>e?o+t.quantity:o))}if(i.length){let t=i;return o&&(t=i[0]),{...e,[n]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const o=[],n="DELETE_SHEET"===t.type&&t.sheetId;for(const i of e.ranges)if(i._sheetId!==t.sheetId)o.push({...i,_zone:i._zone});else{const e=Bi(i._zone,t);e&&n!==i._sheetId&&o.push({...i,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function wv(e,t){const o=ki.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:n}of Ev)if(o(e)){const o=n(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function yv(e,t){let o=[...e];for(const e of t)o=o.map((t=>wv(t,e))).filter(Ze);return o}function xv(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class Rv{constructor(e,t,o,n){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...o],this._changes=n?[...n]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Iv extends Error{}class Tv extends bv{constructor(e,t,o=Y){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new po,this.debouncedMove=function(e,t,o){let n;return function(){const i=this,r=arguments,s=o&&!n;clearTimeout(n),n=setTimeout((function(){n=null,o||e.apply(i,r)}),t),s&&e.apply(i,r)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const o=new Rv(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(o.id,o),this.trigger("new-local-state-update",{id:o.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:o.id,clientId:o.clientId,commands:o.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0,this.on("unexpected-revision-id",this,(({revisionId:e})=>{throw new Error(`The spreadsheet could not be loaded. Revision ${e} is corrupted.`)}));for(const t of e)this.onMessageReceived(t);this.off("unexpected-revision-id",this),this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new Iv("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(Ze))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const o=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==o?void 0:o.col)===e.col&&o.row===e.row&&o.sheetId===e.sheetId)return;const n=o?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:n,version:1,client:{...i,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e)){switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":if(e.serverRevisionId!==this.serverRevisionId)return void this.trigger("unexpected-revision-id",{revisionId:e.serverRevisionId});const{clientId:t,commands:o}=e,n=new Rv(e.nextRevisionId,t,o);if(n.clientId!==this.clientId){this.revisions.insert(n.id,n,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:yv(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new Rv(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Av=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Ov extends pg{constructor(){super(...arguments),this.availableColors=new Set(Av),this.colors={}}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Av));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof Iv)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const n=this.colors[o.id];t.push({...o,position:e,color:n})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,n=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:i,col:r}=e.position,s=this.getters.expandZone(n,{top:i,bottom:i,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(s);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*o,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${W+1}px ${G}`}}}Ov.getters=["getClientsToDisplay"],Ov.layers=[5];class Mv{constructor(e,t,o,n,i,r){this.getters=e,this.sheetId=t,this.boundaries=o,this.width=n.width,this.height=n.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const e=this.getters.findLastVisibleColRowIndex(this.sheetId,"COL",{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,"ROW",{first:this.boundaries.top,last:this.boundaries.bottom}),{end:o,size:n}=this.getters.getColDimensions(this.sheetId,e),{end:i,size:r}=this.getters.getRowDimensions(this.sheetId,t),s=this.searchHeaderIndex("COL",o-this.width,0),a=this.getters.getColSize(this.sheetId,s),l=this.searchHeaderIndex("ROW",i-this.height,0),c=this.getters.getRowSize(this.sheetId,l);return{width:o-this.offsetCorrectionX+(this.canScrollHorizontally?Math.max(N,Math.min(a,this.width-n)):0),height:i-this.offsetCorrectionY+(this.canScrollVertically?Math.max(_+5,Math.min(c,this.height-r)):0)}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.width?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.height?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const o=this.getters.getMainCellPosition(t,e.col,e.row),{col:n,row:i}=this.getters.getNextVisibleCellPosition(t,o.col,o.row);To(n,this.boundaries.top,this.boundaries)&&this.adjustPositionX(n),To(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){const t=this.sheetId,{start:o,end:n}=this.getters.getColDimensions(t,e);for(;n>this.offsetX+this.offsetCorrectionX+this.width&&this.offsetX+this.offsetCorrectionX<o;)this.offsetX=this.getters.getColDimensions(t,this.left).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX();for(;e<this.left;){let e;for(e=this.left;e>=0&&this.getters.isColHidden(t,e);e--);this.offsetX=this.getters.getColDimensions(t,e-1).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId;for(;this.getters.getRowDimensions(t,e).end>this.offsetY+this.height+this.offsetCorrectionY&&this.offsetY+this.offsetCorrectionY<this.getters.getRowDimensions(t,e).start;)this.offsetY=this.getters.getRowDimensions(t,this.top).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY();for(;e<this.top;){let e;for(e=this.top;e>=0&&this.getters.isRowHidden(t,e);e--);this.offsetY=this.getters.getRowDimensions(t,e-1).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=xo(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.width),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.height)}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,o=0,n=!1){let i=0;const r=this.sheetId,s=this.getters.getNumberHeaders(r,e);for(let a=o;a<=s-1;a++){const o=n||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!o&&(i+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),i>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.width+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.width))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.width,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.height+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.height))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.width,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.width,this.left)),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.height,this.top)),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}class Nv extends pg{constructor(){super(...arguments),this.viewports={},this.sheetViewWidth=1e3,this.sheetViewHeight=1e3,this.gridOffsetX=0,this.gridOffsetY=0,this.sheetsWithDirtyViewports=new Set}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){switch(e.type){case"HeadersSelected":case"AlterZoneCorner":break;case"ZonesSelected":let{col:t,row:o}=ko(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const n=e.previousAnchor.zone,i=e.anchor.zone,{top:r,bottom:s,left:a,right:l}=this.getters.getActiveMainViewport();n.left===i.left&&n.right===i.right&&(t=a>t||t>l?a:t),n.top===i.top&&n.bottom===i.bottom&&(o=r>o||o>s?r:o)}const n=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(n)-1),o=Math.min(o,this.getters.getNumberRows(n)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:o})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:o}=this.getActiveMainViewport(),n=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(n,o).start+this.sheetViewHeight);this.shiftVertically(i);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),o=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(o);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"START_EDITION":const{col:r,row:s}=this.getters.getPosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:r,row:s})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){var e;const t=this.getters.getSheetIds();for(const o of t)(null===(e=this.viewports[o])||void 0===e?void 0:e.bottomRight)||this.resetViewports(o)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Fe(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Fe(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:o,ySplit:n}=this.getters.getPaneDivisions(e);let{width:i,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,n).start,width:i,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),n=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-n.width+1),maxOffsetY:Math.max(0,o-n.height+1)}}getColRowOffsetInViewport(e,t,o){const n=this.getters.getActiveSheetId(),i=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let s=0;const a="COL"===e?i:r;for(let i=t;i<o;i++)a.includes(i)&&(s+="COL"===e?this.getters.getColSize(n,i):this.getters.getRowSize(n,i));return s}isVisibleInViewport(e,t,o){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let n=!1,i=0,r=0;const{xSplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(n=!0,r=Ft(e-a),i=1):e<l&&o>=l&&c>0?(n=!0,r=Ft(l-e),i=-1):s&&t<l&&e>l&&(n=!0,r=Ft(e),i="reset"),{canEdgeScroll:n,direction:i,delay:r}}getEdgeScrollRow(e,t,o){let n=!1,i=0,r=0;const{ySplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(n=!0,r=Ft(e-a),i=1):e<l&&o>=l&&c>0?(n=!0,r=Ft(l-e),i=-1):s&&t<l&&e>l&&(n=!0,r=Ft(e),i="reset"),{canEdgeScroll:n,direction:i,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(Ze);if(0===o.length)return{x:0,y:0,width:0,height:0};const n=Math.min(...o.map((e=>e.x))),i=Math.min(...o.map((e=>e.y))),r=Math.max(...o.map((e=>e.x+e.width)))-n,s=Math.max(...o.map((e=>e.y+e.height)))-i;return{x:n+this.gridOffsetX,y:i+this.gridOffsetY,width:r,height:s}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(Ze)}checkPositiveDimension(e){return e.width<0||e.height<0?67:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?75:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.canScrollVertically&&t>0?68:0}getMainViewport(e){const t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,n=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=n,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:n,maxOffsetY:i}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(Oe(e,0,n),Oe(t,0,i))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),o=t-this.sheetViewHeight;return e=Math.min(e,o),e=Math.max(e,0)}getViewportOffset(e){var t,o;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(o=this.viewports[e])||void 0===o?void 0:o.bottomRight.offsetScrollbarY)||0}}resetViewports(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),n=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),s=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new Mv(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:r,height:s},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new Mv(this.getters,e,{left:t,right:n-1,top:0,bottom:o-1},{width:this.sheetViewWidth-r,height:s},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Mv(this.getters,e,{left:0,right:t-1,top:o,bottom:i-1},{width:r,height:this.sheetViewHeight-s},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Mv(this.getters,e,{left:t,right:n-1,top:o,bottom:i-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-s},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:o}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(o,e);const{anchor:n}=this.getters.getSelection(),i=this.getActiveMainViewport().top-t;this.selection.selectCell(n.cell.col,n.cell.row+i)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:n,scrollY:i}=this.getActiveSheetScrollInfo(),{x:r,y:s}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=r&&(e.x+e.width<=r+n||e.x>=a+n+r)||e.y>=s&&(e.y+e.height<=s+i||e.y>=l+i+s)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),n=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,o).start;return{xRatio:n/(this.sheetViewWidth+this.gridOffsetX),yRatio:i/(this.sheetViewHeight+this.gridOffsetY)}}}Nv.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class _v extends pg{allowDispatch(e){if("SORT_CELLS"===e.type){if(!To(e.col,e.row,e.zone))throw new Error(r("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++)if(!this.getters.isInMerge(e,n,o))return 62;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>Io(e,t))),n=No(o[0]);let[i,r]=[n.width,n.height];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===i&&o===r}))?0:62}expand(e,t){const{left:o,right:n,top:i,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,n),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const o=this.expand(e,t);let n;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:i,top:r,bottom:s}=o;for(let o=t;o<=i;o++)for(let t=r;t<=s;t++){const{col:i,row:r}=this.getters.getMainCellPosition(e,o,t);if(n=this.getters.getCell(e,i,r),null==n?void 0:n.formattedValue)return!0}}else for(let t of this.getters.getCellsInZone(e,o))if(null==t?void 0:t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:n,bottom:i,left:r,right:s}=t,a=!1;for(;!a;)a=!0,n>0&&(o=this.checkExpandedValues(e,{left:r-1,right:s+1,top:n-1,bottom:n-1}),o&&(a=!1,n--)),r>0&&(o=this.checkExpandedValues(e,{left:r-1,right:r-1,top:n-1,bottom:i+1}),o&&(a=!1,r--)),s<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:s+1,right:s+1,top:n-1,bottom:i+1}),o&&(a=!1,s++)),i<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:r-1,right:s+1,top:i+1,bottom:i+1}),o&&(a=!1,i++));return{left:r,right:s,top:n,bottom:i}}hasHeader(e){if(1===e[0].length)return!1;let t=e.map((e=>e.map((e=>(null==e?void 0:e.evaluated.type)||qo.empty))));return t[0][0]===qo.empty&&(t=t.slice(1)),!t.some((e=>e[0]===qo.empty))&&!!t.some((e=>e[1]!==qo.empty&&e[0]!==e[1]))}sortZone(e,t,o,n,i){const[r,s]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition(e,t.col,t.row).col,l=Object.assign({},o),c=this.mainCells(e,o);!i.sortHeaders&&this.hasHeader(c)&&(l.top+=s),c=this.mainCells(e,l);const h=function(e,t,o){const n=e.map(Pn);let i=n.filter((e=>e.type===qo.empty)),r=n.filter((e=>e.type!==qo.empty));o&&(r.push(...i.map((e=>({...e,type:qo.number,value:0})))),i=[]);const s="descending"===t?-1:1;return r.sort(((e,t)=>{let o=Ln.indexOf(e.type)-Ln.indexOf(t.type);return 0===o&&(o=e.type===qo.text||e.type===qo.error?e.value.localeCompare(t.value):e.value-t.value),s*o})).concat(i)}(c[a-l.left],n,Boolean(i.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length];for(let t=0;t<u;t++)for(let o=0;o<g;o++){let n=c[t][d[o]],i=l.left+t*r,a=l.top+o*s,h={sheetId:e,col:i,row:a,content:"",value:""};if(n){let t=n.content;if(n.isFormula()){const o=a-this.getters.getCellPosition(n.id).row,i=this.getters.createAdaptedRanges(n.dependencies,0,o,e);t=this.getters.buildFormulaContent(e,n,i)}h.style=n.style,h.content=t,h.format=n.format,h.value=n.evaluated.value}this.dispatch("UPDATE_CELL",h)}}mainCellsSteps(e,t){const o=this.getters.getMerge(e,t.left,t.top);return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,n]=this.mainCellsSteps(e,t),i=[],r=Fe(t.left,t.right+1,o),s=Fe(t.top,t.bottom+1,n);for(const t of r){const o=[];i.push(o);for(const n of s)o.push(this.getters.getCell(e,t,n))}return i}}_v.getters=["getContiguousZone"];class Fv extends pg{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Fv.getters=["shouldShowFormulas"];class Dv extends pg{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e,{col:t,row:o}){const n=this.getters.getCell(e,t,o);let i=0;n&&(i+=this.getTextWidth(n));this.getters.getConditionalIcon(t,o)&&(i+=_e(this.getters.getCellStyle(n))+2*$);if(this.getters.isFilterHeader(e,t,o)&&(i+=20),i>0&&(i+=2*U,"wrap"===this.getters.getCellStyle(n).wrapping)){const e=Lo({col:t,row:o}),n=this.getters.getColSize(this.getters.getActiveSheetId(),e.left);return Math.min(n,i)}return i}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas()),{sheetId:o,col:n,row:i}=this.getters.getCellPosition(e.id);return Me(this.ctx,t,this.getters.getCellComputedStyle(o,n,i))}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===qo.error)?e.content:e.formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),n=this.getters.getCellText(e).split(" "),i=[];let r="",s=t;for(let e of n){const n=this.splitWordToSpecificWidth(this.ctx,e,t,o),a=n.pop(),l=Me(this.ctx,a,o);if(n.length)""!==r&&(i.push(r),r="",s=t),n.forEach((e=>{i.push(e)})),r=a,s=t-l;else{const e=""===r?a:" "+a,n=Me(this.ctx,e,o);n<=s?(r+=e,s-=n):(i.push(r),r=a,s=t-l)}}return""!==r&&i.push(r),i}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getColRowOffset(e,t,o,n=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let i=0;for(let r=t;r<o;r++)this.getters.isHeaderHidden(n,e,r)||(i+="COL"===e?this.getters.getColSize(n,r):this.getters.getRowSize(n,r));return i}getColMaxWidth(e,t){const o=Fo(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth(e,t)));return Math.max(0,...o)}splitWordToSpecificWidth(e,t,o,n){if(Me(e,t,n)<=o)return[t];const i=[];let r="";for(let s of t){Me(e,r+s,n)>o?(i.push(r),r=s):r+=s}return i.push(r),i}}Dv.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];const kv=(new zo).add("sheet",Gm).add("header visibility",zm).add("filters",Um).add("cell",_m).add("merge",Bm).add("headerSize",Vm).add("borders",Mm).add("conditional formatting",km).add("figures",$m).add("chart",Fm),$v=(new zo).add("selection",pv).add("ui_sheet",Dv).add("header_visibility_ui",hv).add("ui_options",Fv).add("evaluation",nv).add("evaluation_filter",sv).add("evaluation_cf",rv).add("evaluation_chart",iv).add("clipboard",ev).add("edition",mg).add("selectionInputManager",vv).add("highlight",dv).add("viewport",Nv).add("grid renderer",uv).add("autofill",Zm).add("find_and_replace",lv).add("sort",_v).add("automatic_sum",jm).add("format",cv).add("cell_popovers",Xm).add("selection_multiuser",Ov).add("custom_colors",tv),Lv=new zo;Lv.add("link",{condition:e=>e.isLink(),action:(e,t)=>{e.action(t)},sequence:5}),sn`
1366
+ `}function om(e){return new pp(e.join("\n"))}function nm(e,...t){let o=[e[0]];for(let n=0;n<t.length;n++){const i=t[n]instanceof pp?t[n]:Qf(t[n]);o.push(i+e[n+1])}return new pp(Ke(o))}function im(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function rm(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class sm{constructor(e){this.value=e}asString(){return nf(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class am{constructor(e,t,o){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(Ze)}mapOnElements(e,t){var o;const n=[],i=this.currentFile;let r;if(e.children){const t=null===(o=this.querySelector(e.parent,e.query))||void 0===o?void 0:o.children;r=t||[]}else r=this.querySelectorAll(e.parent,e.query);if(r)for(let e of r)try{n.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=i,n}catchErrorOnElement(e,t){const o=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([o,e.message].join("\n"))}extractAttr(e,t,o){const n=e.attributes[t];n||this.handleMissingValue(e,`attribute "${t}"`,o);const i=(null==n?void 0:n.value)?n.value:null==o?void 0:o.default;return void 0===i?void 0:new sm(i)}extractTextContent(e,t){var o;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const n="preserve"===(null===(o=null==e?void 0:e.attributes["xml:space"])||void 0===o?void 0:o.value);let i=null==e?void 0:e.textContent;return e&&null!==i||this.handleMissingValue(e,"text content",t),i&&(i=n?i:i.trim()),i?nf(i):null==t?void 0:t.default}extractChildAttr(e,t,o,n){var i;let r;r="number"==typeof t?e.children[t]:this.querySelector(e,t),r||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,n);const s=r?null===(i=this.extractAttr(r,o,n))||void 0===i?void 0:i.asString():null==n?void 0:n.default;return void 0!==s?new sm(s):void 0}extractChildTextContent(e,t,o){if(void 0!==(null==o?void 0:o.default)&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let n=this.querySelector(e,t);return n||this.handleMissingValue(e,`child <${t}>`,o),n?this.extractTextContent(n,o):null==o?void 0:o.default}handleMissingValue(e,t,o){if(null==o?void 0:o.required){if(!(null==o?void 0:o.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${o.default}`)}}extractColor(e,t,o){var n,i,r,s,a;if(!e)return o?{rgb:o}:void 0;const l=null===(n=this.extractAttr(e,"theme"))||void 0===n?void 0:n.asString();let c;if(void 0!==l){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");c=this.getThemeColor(l,t.clrScheme)}else c=null===(i=this.extractAttr(e,"rgb"))||void 0===i?void 0:i.asString();return{rgb:c,auto:null===(r=this.extractAttr(e,"auto"))||void 0===r?void 0:r.asBool(),indexed:null===(s=this.extractAttr(e,"indexed"))||void 0===s?void 0:s.asNum(),tint:null===(a=this.extractAttr(e,"tint"))||void 0===a?void 0:a.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const o=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}querySelector(e,t){return t=this.areNamespaceIgnored?im(t):rm(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?im(t):rm(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class lm extends am{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:mp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:mp}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class cm extends am{constructor(e,t,o,n){super(e,t,o),this.theme=n}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var o,n,i,r,s,a,l,c,h,d,u;const g=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===g)throw new Error("Databars conditional formats are not supported.");return{type:g,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:null===(o=this.extractAttr(e,"dxfId"))||void 0===o?void 0:o.asNum(),stopIfTrue:null===(n=this.extractAttr(e,"stopIfTrue"))||void 0===n?void 0:n.asBool(),aboveAverage:null===(i=this.extractAttr(e,"aboveAverage"))||void 0===i?void 0:i.asBool(),percent:null===(r=this.extractAttr(e,"percent"))||void 0===r?void 0:r.asBool(),bottom:null===(s=this.extractAttr(e,"bottom"))||void 0===s?void 0:s.asBool(),operator:null===(a=this.extractAttr(e,"operator"))||void 0===a?void 0:a.asString(),text:null===(l=this.extractAttr(e,"text"))||void 0===l?void 0:l.asString(),timePeriod:null===(c=this.extractAttr(e,"timePeriod"))||void 0===c?void 0:c.asString(),rank:null===(h=this.extractAttr(e,"rank"))||void 0===h?void 0:h.asNum(),stdDev:null===(d=this.extractAttr(e,"stdDev"))||void 0===d?void 0:d.asNum(),equalAverage:null===(u=this.extractAttr(e,"equalAverage"))||void 0===u?void 0:u.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){var t,o;const n=this.querySelector(e,"iconSet, x14:iconSet");if(n)return{iconSet:this.extractAttr(n,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(n,"showValue",{default:!0}).asBool(),percent:this.extractAttr(n,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(n,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(o=this.extractAttr(n,"custom"))||void 0===o?void 0:o.asBool(),cfvos:this.extractCFVos(n),cfIcons:this.extractCfIcons(n)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,o;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(o=this.extractAttr(e,"val"))||void 0===o?void 0:o.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class hm extends am{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!jp[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),n=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:jp[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:Zp[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===n,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:cat c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=im(e.tagName);if(fp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class dm extends am{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==im(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),n=new hm(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!n)throw new Error("Unable to extract chart definition");return n}}class um extends am{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class gm extends am{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,o,n,i,r;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(o=this.extractAttr(e,"showFirstColumn"))||void 0===o?void 0:o.asBool(),showLastColumn:null===(n=this.extractAttr(e,"showLastColumn"))||void 0===n?void 0:n.asBool(),showRowStripes:null===(i=this.extractAttr(e,"showRowStripes"))||void 0===i?void 0:i.asBool(),showColumnStripes:null===(r=this.extractAttr(e,"showColumnStripes"))||void 0===r?void 0:r.asBool()}}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class pm extends am{constructor(e,t,o,n){super(e,t,o),this.theme=n}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=ef(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=ef(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new cm(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),n=this.getTargetXmlFile(this.relationships[o]);return new dm(n,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),n=this.getTargetXmlFile(this.relationships[o]);return new gm(n,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new um(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:Ip.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:Tp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,o,n,i,r,s,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(o=this.extractAttr(e,"customWidth"))||void 0===o?void 0:o.asBool(),bestFit:null===(n=this.extractAttr(e,"bestFit"))||void 0===n?void 0:n.asBool(),hidden:null===(i=this.extractAttr(e,"hidden"))||void 0===i?void 0:i.asBool(),min:null===(r=this.extractAttr(e,"min",{required:!0}))||void 0===r?void 0:r.asNum(),max:null===(s=this.extractAttr(e,"max",{required:!0}))||void 0===s?void 0:s.asNum(),styleIndex:null===(a=this.extractAttr(e,"style"))||void 0===a?void 0:a.asNum()}}))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>{var t,o,n,i,r;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(o=this.extractAttr(e,"ht"))||void 0===o?void 0:o.asNum(),customHeight:null===(n=this.extractAttr(e,"customHeight"))||void 0===n?void 0:n.asBool(),hidden:null===(i=this.extractAttr(e,"hidden"))||void 0===i?void 0:i.asBool(),styleIndex:null===(r=this.extractAttr(e,"s"))||void 0===r?void 0:r.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,o,n;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(o=this.extractAttr(e,"s"))||void 0===o?void 0:o.asNum(),type:zp[null===(n=this.extractAttr(e,"t",{default:"n"}))||void 0===n?void 0:n.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,o;const n=this.querySelector(e,"f");if(n)return{content:this.extractTextContent(n),sharedIndex:null===(t=this.extractAttr(n,"si"))||void 0===t?void 0:t.asNum(),ref:null===(o=this.extractAttr(n,"ref"))||void 0===o?void 0:o.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,o,n,i;const r=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(o=this.extractAttr(e,"ref",{required:!0}))||void 0===o?void 0:o.asString(),location:null===(n=this.extractAttr(e,"location"))||void 0===n?void 0:n.asString(),display:null===(i=this.extractAttr(e,"display"))||void 0===i?void 0:i.asString(),relTarget:r?this.relationships[r].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),n=this.extractTextContent(e,{required:!0});o[t]=n}const n=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?n.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),n.push(""));return n}}class fm extends am{constructor(e,t,o){super(e.styles,e,t),this.theme=o}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,o,n,i;const r=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),s=this.extractChildAttr(e,"sz","val",{default:W.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(o=h.attributes.val)||void 0===o?void 0:o.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(n=u.attributes.val)||void 0===n?void 0:n.value),p=this.querySelector(e,"u")||void 0;return{name:r,size:s,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(i=p.attributes.val)||void 0===i?void 0:i.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const o=e.children[0];return"patternFill"===o.tagName?{patternType:null===(t=o.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(o,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(o,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(o,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,o;const n={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return n.diagonal&&(n.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),n.diagonalDown=null===(o=this.extractAttr(e,"diagonalDown"))||void 0===o?void 0:o.asBool()),n}extractSingleBorder(e,t,o){const n=this.querySelector(e,t);if(n&&n.attributes.style)return{style:this.extractAttr(n,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(n.children[0],o,"000000")}}extractAlignment(e){var t,o,n,i,r,s,a;return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"center"}).asString(),textRotation:null===(t=this.extractAttr(e,"textRotation"))||void 0===t?void 0:t.asNum(),wrapText:null===(o=this.extractAttr(e,"wrapText"))||void 0===o?void 0:o.asBool(),indent:null===(n=this.extractAttr(e,"indent"))||void 0===n?void 0:n.asNum(),relativeIndent:null===(i=this.extractAttr(e,"relativeIndent"))||void 0===i?void 0:i.asNum(),justifyLastLine:null===(r=this.extractAttr(e,"justifyLastLine"))||void 0===r?void 0:r.asBool(),shrinkToFit:null===(s=this.extractAttr(e,"shrinkToFit"))||void 0===s?void 0:s.asBool(),readingOrder:null===(a=this.extractAttr(e,"readingOrder"))||void 0===a?void 0:a.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),o=this.querySelector(e,"fill"),n=this.querySelector(e,"border"),i=this.querySelector(e,"numFmt"),r=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:i?this.extractNumFormats(i):void 0,alignment:r?this.extractAlignment(r):void 0,border:n?this.extractBorder(n):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class mm extends am{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function vm(e,t){const o=function(e,t){const o=t[Fp],n=o.querySelectorAll(`Override[ContentType="${e}"]`),i=[];for(let e of n){const t=null==e?void 0:e.attributes.PartName.value;i.push(t.substring(1))}return i}(e,t);return function(e,t){const o=[];for(let n of e){const e=bm(n,t);o.push({file:{fileName:n,xml:t[n]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function bm(e,t){if(e===Fp)return"_rels/.rels";let o="";const n=e.split("/");for(let e=0;e<n.length-1;e++)o+=n[e]+"/";return o+="_rels/",o+=n[n.length-1]+".rels",t[o]||(o=void 0),o}class Sm{constructor(e){this.warningManager=new kp,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=em(new pp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new lm(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new lm(e.sharedStrings,e,this.warningManager).getSharedStrings():[],n=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new pm(o,e,this.warningManager,t).getSheet())),i=e.externalLinks.map((t=>new mm(t,e,this.warningManager).getExternalBook())),r=new fm(e,this.warningManager,t);return{fonts:r.getFonts(),fills:r.getFills(),borders:r.getBorders(),dxfs:r.getDxfs(),numFmts:r.getNumFormats(),styles:r.getStyles(),sheets:n,sharedStrings:o,externalBooks:i}}buildXlsxFileStructure(){const e={sheets:vm(Ep.sheet,this.xmls),workbook:vm(Ep.workbook,this.xmls)[0],styles:vm(Ep.styles,this.xmls)[0],sharedStrings:vm(Ep.sharedStrings,this.xmls)[0],theme:vm(Ep.themes,this.xmls)[0],charts:vm(Ep.chart,this.xmls),figures:vm(Ep.drawing,this.xmls),tables:vm(Ep.table,this.xmls),pivots:vm(Ep.pivot,this.xmls),externalLinks:vm(Ep.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(r("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Vf(e,this.warningManager),styles:af(e,this.warningManager),formats:cf(e,this.warningManager),borders:rf(e,this.warningManager),entities:{},revisionId:Y};return jf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=ot(e.styles[t])})),t}}function Cm(e){const t=ng(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&mt.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${te}${o.indexOf(t)}${te}`}return e.value}))),dependencies:o}}const Em=12,wm="Sheet1";function ym(e,t){if(!e)return Am();if(e["[Content_Types].xml"]){const o=new Sm(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<Em&&(e=function(e){for(let t=xm.findIndex((t=>t.from===e.version));t<xm.length;t++)e=xm[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new fo;for(const n of e.sheets||[])for(const e of n.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Am(),e,{version:Em}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(Tm(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(Tm(wm,"Sheet1"));return e}(e),e}(e),e}const xm=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=Cm(o.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:o,...n}=t.figures[e].data,i=[];for(let e of o)if(e.labelCell){const t=vo(e.dataRange),o=e.labelCell+":"+Mt(t.right,t.bottom);i.push(o)}else i.push(e.dataRange);n.dataSetsHaveTitle=Boolean(o[0].labelCell),n.dataSets=i,t.figures[e].data=n}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const o=[],n=new RegExp(ee,"g");for(let i of e.sheets||[]){if(!i.name)continue;const e=i.name,r=e.replace(n,"_");let s=1,a=r;for(;o.includes(a);)a=`${r}${s}`,s++;i.name=a,o.push(a);const l=t=>{if(void 0===t)return t;let o=t.replace(e,a),n=t;for(;n!==o;)n=o,o=n.replace(e,a);return n};for(let e in i.cells){const t=i.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of i.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),o=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of i.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const o of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[o])||void 0===t?void 0:t.type)&&(e.rule[o].value=l(e.rule[o].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,n]of Object.entries(t)){const t=`\\${te}${o}\\${te}`;e=e.replace(new RegExp(t,"g"),n)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const n=o.cells[e];n.format&&(n.format=Ye(n.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}];function Rm(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],n=[],i=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:wm};return e};for(const e of t)"REMOTE_REVISION"===e.type?n.push({...e,commands:e.commands.map(i)}):n.push(e);return n}(e,t),t=Im(t,"SORT_CELLS"),t=function(e,t){var o;const n=[],i={};for(const t of e.sheets||[])null===(o=t.figures)||void 0===o||o.forEach((e=>{"chart"===e.tag&&(i[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":i[o.id]=o.definition;break;case"UPDATE_CHART":if(!i[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...i[o.id],...o.definition};e={...o,definition:t},i[o.id]=t}t.push(e)}n.push({...e,commands:t})}else n.push(e);return n}(e,t=Im(t,"SET_DECIMAL")),t}function Im(e,t){const o=[];for(const n of e)"REMOTE_REVISION"===n.type?o.push({...n,commands:n.commands.filter((e=>e.type!==t))}):o.push(n);return o}function Tm(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Am(e="Sheet1"){return{version:Em,sheets:[Tm(wm,e)],entities:{},styles:{},formats:{},borders:{},revisionId:Y,uniqueFigureIds:!0}}function Om(e,t){return{...Tm(e,t),charts:[]}}class Mm extends pg{constructor(e,t,o,n,i,r){super(t,n,i),this.dispatch=n,this.range=o,o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=r}import(e){}export(e){}adaptRanges(e,t){}}class Nm extends Mm{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const o=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder(e,t,o){var n,i,r,s,a,l,c,h,d,u,g,p;const f={top:null===(r=null===(i=null===(n=this.borders[e])||void 0===n?void 0:n[t])||void 0===i?void 0:i[o])||void 0===r?void 0:r.horizontal,bottom:null===(l=null===(a=null===(s=this.borders[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[o+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[o])||void 0===p?void 0:p.vertical};return f.bottom||f.left||f.right||f.top?f:null}ensureColumnBorderContinuity(e,t,o){const n=Fe(t+1,o);for(let i=0;i<this.getters.getNumberRows(e);i++){const r=this.getCellBorder(e,t,i),s=this.getCellBorder(e,o,i);if(r&&s){const t=this.getCommonSides(r,s);for(let o of n)this.addBorder(e,o,i,t)}}}ensureRowBorderContinuity(e,t,o){const n=Fe(t+1,o);for(let i=0;i<this.getters.getNumberCols(e);i++){const r=this.getCellBorder(e,i,t),s=this.getCellBorder(e,i,o);if(r&&s){const t=this.getCommonSides(r,s);for(let o of n)this.addBorder(e,i,o,t)}}}getCommonSides(e,t){const o={};for(let n of["top","bottom","left","right"])e[n]&&e[n]===t[n]&&(o[n]=e[n]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?Fe(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:n}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((i=>{(i===t&&n||i!==t)&&this.moveBordersOfColumn(e,i,o,"vertical"),this.moveBordersOfColumn(e,i,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:n}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((i=>{(i===t&&n||i!==t)&&this.moveBordersOfRow(e,i,o,"horizontal"),this.moveBordersOfRow(e,i,o,"vertical")})))}moveBordersOfRow(e,t,o,n,{destructive:i}={destructive:!0}){const r=this.borders[e];r&&this.getColumnsWithBorders(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[s])||void 0===a?void 0:a[t+o])||void 0===l?void 0:l[n],u=null===(h=null===(c=r[s])||void 0===c?void 0:c[t])||void 0===h?void 0:h[n];this.history.update("borders",e,s,t+o,n,i?u:u||d),this.history.update("borders",e,s,t,n,void 0)}))}moveBordersOfColumn(e,t,o,n,{destructive:i}={destructive:!0}){const r=this.borders[e];r&&this.getRowsRange(e).forEach((s=>{var a,l,c,h;const d=null===(l=null===(a=r[t+o])||void 0===a?void 0:a[s])||void 0===l?void 0:l[n],u=null===(h=null===(c=r[t])||void 0===c?void 0:c[s])||void 0===h?void 0:h[n];this.history.update("borders",e,t+o,s,n,i?u:u||d),this.history.update("borders",e,t,s,n,void 0)}))}setBorder(e,t,o,n,i=!0){var r,s,a,l,c,h,d,u,g,p,f,m,v,b,S,C;!i&&(null===(l=null===(a=null===(s=null===(r=this.borders)||void 0===r?void 0:r[e])||void 0===s?void 0:s[t])||void 0===a?void 0:a[o])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,o,"vertical",null==n?void 0:n.left),!i&&(null===(u=null===(d=null===(h=null===(c=this.borders)||void 0===c?void 0:c[e])||void 0===h?void 0:h[t])||void 0===d?void 0:d[o])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,o,"horizontal",null==n?void 0:n.top),!i&&(null===(m=null===(f=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===f?void 0:f[o])||void 0===m?void 0:m.vertical)||this.history.update("borders",e,t+1,o,"vertical",null==n?void 0:n.right),!i&&(null===(C=null===(S=null===(b=null===(v=this.borders)||void 0===v?void 0:v[e])||void 0===b?void 0:b[t])||void 0===S?void 0:S[o+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,o+1,"horizontal",null==n?void 0:n.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let n=o.left;n<=o.right;n++)this.history.update("borders",e,n,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,n){this.setBorder(e,t,o,{...this.getCellBorder(e,t,o),...n})}setBorders(e,t,o){if("clear"===o)return this.clearBorders(e,t);for(let n of t){if("h"===o||"hv"===o||"all"===o)for(let t=n.top+1;t<=n.bottom;t++)for(let o=n.left;o<=n.right;o++)this.addBorder(e,o,t,{top:q});if("v"===o||"hv"===o||"all"===o)for(let t=n.top;t<=n.bottom;t++)for(let o=n.left+1;o<=n.right;o++)this.addBorder(e,o,t,{left:q});if("left"===o||"all"===o||"external"===o)for(let t=n.top;t<=n.bottom;t++)this.addBorder(e,n.left,t,{left:q});if("right"===o||"all"===o||"external"===o)for(let t=n.top;t<=n.bottom;t++)this.addBorder(e,n.right+1,t,{left:q});if("top"===o||"all"===o||"external"===o)for(let t=n.left;t<=n.right;t++)this.addBorder(e,t,n.top,{top:q});if("bottom"===o||"all"===o||"external"===o)for(let t=n.left;t<=n.right;t++)this.addBorder(e,t,n.bottom+1,{top:q})}}addBordersToMerge(e,t){const{left:o,right:n,top:i,bottom:r}=t,s=this.getCellBorder(e,o,i),a=this.getCellBorder(e,n,r);this.clearBorders(e,[t]),(null==s?void 0:s.top)&&this.setBorders(e,[{...t,bottom:i}],"top"),(null==s?void 0:s.left)&&this.setBorders(e,[{...t,right:o}],"left"),((null==a?void 0:a.bottom)||(null==s?void 0:s.bottom))&&this.setBorders(e,[{...t,top:r}],"bottom"),((null==a?void 0:a.right)||(null==s?void 0:s.right))&&this.setBorders(e,[{...t,left:n}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[o,n]of Object.entries(t.cells))if(null==n?void 0:n.border){const i=e.borders[n.border],{col:r,row:s}=Ot(o);this.setBorder(t.id,r,s,i,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,vo(e))}export(e){let t=0;const o={};function n(e){for(let[t,n]of Object.entries(o))if(ye(n)===ye(e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const i=this.getCellBorder(t.id,e,o);if(i){const r=Mt(e,o),s=t.cells[r],a=n(i);s?s.border=a:t.cells[r]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}Nm.getters=["getCellBorder"];const _m=new RegExp(String.fromCharCode(160),"g");class Fm extends Mm{constructor(){super(...arguments),this.cells={},this.createCell=function(e){const t=Fn.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,n,i,r){const s=t.find((e=>e.match(n,i.format)));if(!s)return new sp(o,n,i);try{return s.createCell(o,n,i,r,e)}catch(e){return new up(o,n,e instanceof c?e:new h(e.message||oe),i)}}}(this.getters)}adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const n of Object.values(this.cells[o]||{}))if(n.isFormula())for(const i of n.dependencies)if(!t||i.sheetId===t){const t=e(i);"NONE"!==t.changeType&&this.history.update("cells",o,n.id,"dependencies",n.dependencies.indexOf(i),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":case"CLEAR_CELL":return this.checkCellOutOfSheet(e.sheetId,e.col,e.row);default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,o){for(let n of t)for(let t=n.top;t<=n.bottom;t++)for(let i=n.left;i<=n.right;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:null,format:""})}handleAddColumnsRows(e,t){let o,n;"before"===e.position?(o=Fe(e.base,e.base+e.quantity),n=e.base+e.quantity):(o=Fe(e.base+1,e.base+e.quantity+1),n=e.base),t(e.sheetId,n,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const n=t.cells[o],{col:i,row:r}=Ot(o);if((null==n?void 0:n.content)||(null==n?void 0:n.format)||(null==n?void 0:n.style)){const o=this.importCell(t.id,n,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:i,row:r,sheetId:t.id})}}}export(e){const t={},o={};for(let n of e.sheets){const e={},i=Object.keys(this.cells[n.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const{col:r,row:s}of i){const i=this.getters.getCell(n.id,r,s);e[Mt(r,s)]={style:i.style?Ye(i.style,t):void 0,format:i.format?Ye(i.format,o):void 0,content:i.content||void 0}}n.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,n){const i=t.style&&o[t.style]||void 0,r=t.format&&n[t.format]||void 0,s=this.uuidGenerator.uuidv4(),a={format:r,style:i};return this.createCell(s,(null==t?void 0:t.content)||"",a,e)}exportForExcel(e){this.export(e);for(let t of e.sheets)for(const e in t.cells){const{col:o,row:n}=Ot(e),i=this.getters.getCell(t.id,o,n),r=t.cells[e];r.value=i.evaluated.value,r.isFormula=i.isFormula()}}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const o=this.cells[t][e];if(o)return o}}buildFormulaContent(e,t,o){const n=o||[...t.dependencies];return Ke(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=n.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){return e&&e.style||{}}zoneToXC(e,t,o=[{colFixed:!1,rowFixed:!1}]){const n=Mt((t=this.getters.expandZone(e,t)).left,t.top,o[0]),i=Mt(t.right,t.bottom,o.length>1?o[1]:o[0]),r=this.getters.getMainCellPosition(e,t.left,t.top),s=this.getters.getMainCellPosition(e,t.right,t.bottom),a=r.col===s.col&&r.row===s.row;return n==i||a?n:n+":"+i}setStyle(e,t,o){for(let n of t)for(let t=n.left;t<=n.right;t++)for(let i=n.top;i<=n.bottom;i++){const n=this.getters.getCell(e,t,i);this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:o?{...null==n?void 0:n.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let n=0;n<this.getters.getNumberRows(e);n++){const i=this.getFormat(e,t,n);if(i.style||i.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,...i})}}copyRowStyle(e,t,o){for(let n=0;n<this.getters.getNumberCols(e);n++){const i=this.getFormat(e,n,t);if(i.style||i.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,...i})}}getFormat(e,t,o){const n={},{col:i,row:r}=this.getters.getMainCellPosition(e,t,o),s=this.getters.getCell(e,i,r);return s&&(s.style&&(n.style=s.style),s.format&&(n.format=s.format)),n}updateCell(e,t,o,n){var i;const r=this.getters.getCell(e,t,o),s="content"in n||"formula"in n,a=s?(null===(i=n.content)||void 0===i?void 0:i.replace(_m,""))||"":(null==r?void 0:r.content)||"";let l;l=void 0!==n.style?n.style||void 0:r?r.style:void 0;let c=("format"in n?n.format:r&&r.format)||undefined;if((s&&!a&&!n.formula||!s&&(!r||r.isEmpty()))&&!l&&!c)return void(r&&(this.history.update("cells",e,r.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:o,sheetId:e})));const h=(null==r?void 0:r.id)||this.uuidGenerator.uuidv4(),d=s,u={format:c,style:l},g=this.createCell(h,a,u,e);r&&!d&&g.isFormula()&&g.assignEvaluation(Qe(r.evaluated)),this.history.update("cells",e,g.id,g),this.dispatch("UPDATE_CELL_POSITION",{cellId:g.id,col:t,row:o,sheetId:e})}checkCellOutOfSheet(e,t,o){if(!this.getters.tryGetSheet(e))return 27;return Ao(t,o,this.getters.getSheetZone(e))?0:18}}Fm.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Dm extends Mm{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=Ho.getAll();return function(o,n,i){const r=t.find((e=>e.match(n.type)));if(!r)throw new Error(`No builder for this chart: ${n.type}`);return r.createChart(n,i,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const o=Ho.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,null==o?void 0:o.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const o=this.getters.getFigures(e.sheetId);for(const n of o)if("chart"===n.tag){const o=n.id.split("??").pop(),i=`${e.sheetIdTo}??${o}`,r=null===(t=this.charts[n.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);r&&this.dispatch("CREATE_CHART",{id:i,position:{x:n.x,y:n.y},size:{width:n.width,height:n.height},definition:r.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){var t;return null===(t=this.charts[e])||void 0===t?void 0:t.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){var t;const o=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!o)throw new Error("Chart not defined.");return o}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const o=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!o)throw new Error(`There is no chart with the given figureId: ${e}`);return o}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let o of e.sheets){const e=this.getters.getFigures(o.id),n=[];for(let o of e){const e=o;if(e&&"chart"===e.tag){const o=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();o&&(e.data=o,n.push(e))}else n.push(e)}o.figures=n}}exportForExcel(e){var t;for(let o of e.sheets){const e=this.getters.getFigures(o.id),n=[];for(let o of e)if(o&&"chart"===o.tag){const e=null===(t=this.charts[o.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&n.push({...o,data:e})}o.charts=n}}addFigure(e,t,o={x:0,y:0},n={width:536,height:335}){if(this.getters.getFigure(t,e))return;const i={id:e,x:o.x,y:o.y,width:n.width,height:n.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:i})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?83:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:84}}function km(e){return""===e?NaN:Number(e)}Dm.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class $m extends Mm{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const n of o.ranges){const i=t(n);switch(i.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(n),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(n),i.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let n=t.top;n<=t.bottom;n++)for(let i=t.left;i<=t.right;i++){this.getRulesByCell(e,i,n).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const n=[];for(let i of this.cfRules[e])for(let e of i.ranges)Ao(t,o,e.zone)&&n.push(i);return new Set(n.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),n=o.findIndex((t=>t.id===e.id)),i=this.mapToConditionalFormatInternal(t,e);n>-1?o.splice(n,1,i):o.push(i),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 27;const n=this.cfRules[o].findIndex((t=>t.id===e));if(-1===n)return 70;const i="up"===t?n-1:n+1;return i<0||i>=this.cfRules[o].length?70:0}checkEmptyRange(e){return e.ranges.length?0:24}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return o=>{if(t.includes(o.operator)){const t=[],n=e=>void 0===e||""===e;return e>=1&&n(o.values[0])&&t.push(50),e>=2&&n(o.values[1])&&t.push(51),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 52;case"max":return 54;case"mid":return 53;case"upperInflectionPoint":return 55;case"lowerInflectionPoint":return 56}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{cg(e.value||"")}catch(e){switch(t){case"min":return 57;case"max":return 59;case"mid":return 58;case"upperInflectionPoint":return 60;case"lowerInflectionPoint":return 61}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?47:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&km(t)>=km(o)?46:0}checkMidBiggerThanMax(e){var t;const o=null===(t=e.midpoint)||void 0===t?void 0:t.value,n=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&km(o)>=km(n)?48:0}checkMinBiggerThanMid(e){var t;const o=e.minimum.value,n=null===(t=e.midpoint)||void 0===t?void 0:t.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&km(o)>=km(n)?49:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const n=this.cfRules[o].findIndex((t=>t.id===e)),i="up"===t?n-1:n+1;if(!(i<0||i>=this.cfRules[o].length)&&-1!==n&&-1!==i){const e=[...this.cfRules[o]],t=e[n];e[n]=e[i],e[i]=t,this.history.update("cfRules",o,e)}}}$m.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Lm extends Mm{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:o,...n}=e,i=n;this.updateFigure(o,i);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[o,n]of Object.entries(t))switch(o){case"x":case"y":void 0!==n&&this.history.update("figures",e,t.id,o,Math.max(n,0));break;case"width":case"height":void 0!==n&&this.history.update("figures",e,t.id,o,n)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var o;return void 0===(null===(o=this.figures[e])||void 0===o?void 0:o[t])?69:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?81:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(Ze)}getFigure(e,t){var o;return null===(o=this.figures[e])||void 0===o?void 0:o[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var o;return void 0!==(null===(o=this.figures[t])||void 0===o?void 0:o[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}Lm.getters=["getFigures","getFigure","getFigureSheetId"];class Pm{constructor(e){this.filters=[],this.zone=e;const t=new fo;this.id=t.uuidv4();for(const o of Fe(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new Um(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){var t;return null===(t=this.filters.find((t=>t.col===e)))||void 0===t?void 0:t.id}clone(){return new Pm(this.zone)}}class Um{constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}class Vm extends Mm{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!zo(...e.target))return 80;const t=xo(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>To(e.zone,t)))?77:0,n=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(To(t,e))return 79;return 0};return this.checkValidations(e,o,n);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(To(o.zone,t))return 79}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":this.history.update("tables",e.sheetIdTo,Ie(this.tables[e.sheetId]));break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=xo(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!Ro(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(Ze):[]}getFilter(e,t,o){var n;return null===(n=this.getFilterTable(e,t,o))||void 0===n?void 0:n.filters.find((e=>e.col===t))}getFilterId(e,t,o){var n;return null===(n=this.getFilter(e,t,o))||void 0===n?void 0:n.id}getFilterTable(e,t,o){return this.getFilterTables(e).find((e=>Ao(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Oo(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if(Ro(o,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=Co(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),n=[];for(const o of t.filters){const t=Co(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);n.push(new Um(o.id,t))}if(n.length<_o(o).width){for(let e=o.left;e<=o.right;e++)n.find((t=>t.col===e))||n.push(new Um(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));n.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",n)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=yo(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(So(o)!==So(t.zone)){const n=[];for(const o of t.filters){const t=yo(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&n.push(new Um(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",n)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new Pm(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const n=t.filters[o],i={...n.zoneWithHeaders,bottom:n.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",i)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:n},i){var r;if(!e)return;const s=i.zone;if(!(s.bottom+1===n&&o>=s.left&&o<=s.right))return!1;for(const e of Fe(s.left,s.right+1)){if(null===(r=this.getters.getCell(t,e,n))||void 0===r?void 0:r.content)return!1;if(this.getters.getFilter(t,e,n))return!1;if(this.getters.isInMerge(t,e,n))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(vo(e.range));this.history.update("tables",t.id,o.id,o)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:So(e.zone)})}exportForExcel(e){this.export(e)}}Vm.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class zm extends Mm{constructor(){super(...arguments),this.sizes={}}handle(e){var t,o,n;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),o={COL:t.COL.map((e=>({manualSize:void 0,computedSize:Qe(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:Qe(e)})))};this.history.update("sizes",e.sheetId,o);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Ie(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const i={...this.sizes};delete i[e.sheetId],this.history.update("sizes",i);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);const o=Math.min(...e.elements);t=t.map(((t,n)=>"ROW"===e.dimension&&n>=o?{manualSize:t.manualSize,computedSize:Qe((()=>this.getRowTallestCellSize(e.sheetId,n)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=et(e.position,e.base),n=t[e.base];t.splice(o,0,...Array(e.quantity).fill(n)),t=t.map(((t,o)=>"ROW"===e.dimension&&o>e.base+e.quantity?{manualSize:t.manualSize,computedSize:Qe((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const o=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:Qe(o)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:Qe(e.size||N)});break;case"UPDATE_CELL":if(!(null===(n=null===(o=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[e.row])||void 0===n?void 0:n.manualSize)){const{sheetId:t,row:o}=e;this.history.update("sizes",t,"ROW",o,"computedSize",Qe((()=>this.getRowTallestCellSize(t,o))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let o of Fe(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,o);t!==this.getRowSize(e.sheetId,o)&&this.history.update("sizes",e.sheetId,"ROW",o,"computedSize",Qe(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,o){var n,i,r,s;return Math.round((null===(i=null===(n=this.sizes[e])||void 0===n?void 0:n[t][o])||void 0===i?void 0:i.manualSize)||(null===(s=null===(r=this.sizes[e])||void 0===r?void 0:r[t][o])||void 0===s?void 0:s.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,o;const n={COL:[],ROW:[]};for(let t of Fe(0,this.getters.getNumberCols(e)))n.COL.push(this.getHeaderSize(e,"COL",t));for(let i of Fe(0,this.getters.getNumberRows(e))){let r=null===(o=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[i].manualSize;if(!r){r=this.getRowTallestCellSize(e,i)}n.ROW.push(r)}return n}getDefaultHeaderSize(e){return"COL"===e?N:_}getCellHeight(e,t,o){const n=this.getters.getMerge(e,t,o);if(n&&n.bottom!==n.top)return _;const i=this.getters.getCell(e,t,o);return(null==(r=null==i?void 0:i.style)?void 0:r.fontSize)?(s||1)*(_e(r)+L)-L+2*P:_;var r,s}getRowTallestCellSize(e,t){const o=this.getters.getRowCells(e,t);let n=0;for(let t=0;t<o.length;t++){const i=this.getters.getCellById(o[t]);if(!i)continue;const{col:r,row:s}=this.getters.getCellPosition(i.id),a=this.getCellHeight(e,r,s);a>n&&a>_&&(n=a)}return n<=_?_:n}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[o,n]of Object.entries(t.rows))n.size&&(e.ROW[o]=n.size);for(let[o,n]of Object.entries(t.cols))n.size&&(e.COL[o]=n.size);const o=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:o.COL.map(((t,o)=>({manualSize:e.COL[o],computedSize:Qe(t)}))),ROW:o.ROW.map(((t,o)=>({manualSize:e.ROW[o],computedSize:Qe(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var o,n;for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e of Fe(0,this.getters.getNumberRows(i.id)))(t||(null===(o=this.sizes[i.id].ROW[e])||void 0===o?void 0:o.manualSize))&&(i.rows[e]={...i.rows[e],size:this.getRowSize(i.id,e)});void 0===i.cols&&(i.cols={});for(let e of Fe(0,this.getters.getNumberCols(i.id)))(t||(null===(n=this.sizes[i.id].COL[e])||void 0===n?void 0:n.manualSize))&&(i.cols[e]={...i.cols[e],size:this.getColSize(i.id,e)})}}}zm.getters=["getRowSize","getColSize"];class Bm extends Mm{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){if("HIDE_COLUMNS_ROWS"===e.type){if(!this.hiddenHeaders[e.sheetId])return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return(t||[]).flat().concat(e.elements).length<o?0:65}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,Ie(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=et(e.position,e.base);t.splice(o,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}import(e){var t,o;for(let n of e.sheets){this.hiddenHeaders[n.id]={COL:[],ROW:[]};for(let e=0;e<n.rowNumber;e++)this.hiddenHeaders[n.id].ROW[e]=Boolean(null===(t=n.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<n.colNumber;e++)this.hiddenHeaders[n.id].COL[e]=Boolean(null===(o=n.cols[e])||void 0===o?void 0:o.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}Bm.getters=["getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class Hm extends Mm{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const o of Object.values(t).filter(Ze))this.addMerge(e.sheetIdTo,o.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(Ze)}getMerge(e,t,o){var n;const i=this.mergeCellMap[e],r=i?t in i&&(null===(n=i[t])||void 0===n?void 0:n[o]):void 0;return r?this.getMergeById(e,r):void 0}getMergesInZone(e,t){var o;const n=this.mergeCellMap[e];if(!n)return[];const i=new Set;for(const{col:e,row:r}of Do(t)){const t=null===(o=n[e])||void 0===o?void 0:o[r];t&&i.add(t)}return Array.from(i).map((t=>this.getMergeById(e,t))).filter(Ze)}doesIntersectMerge(e,t){const{left:o,right:n,top:i,bottom:r}=t;for(let t=i;t<=r;t++)for(let i=o;i<=n;i++)if(this.getMerge(e,i,t))return!0;return!1}doesColumnsHaveCommonMerges(e,t,o){const n=this.getters.getSheet(e);for(let i=0;i<this.getters.getNumberRows(e);i++)if(this.isInSameMerge(n.id,t,i,o,i))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const n=this.getters.getSheet(e);for(let i=0;i<=this.getters.getNumberCols(e);i++)if(this.isInSameMerge(n.id,i,t,i,o))return!0;return!1}expandZone(e,t){let{left:o,right:n,top:i,bottom:r}=t,s={left:o,right:n,top:i,bottom:r};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&To(o,s)&&(s=xo(o,s))}return Io(s,t)?s:this.expandZone(e,s)}isInSameMerge(e,t,o,n,i){const r=this.getMerge(e,t,o),s=this.getMerge(e,n,i);return!(!r||!s)&&Io(r,s)}isInMerge(e,t,o){var n;const i=this.mergeCellMap[e];return!!i&&(t in i&&Boolean(null===(n=i[t])||void 0===n?void 0:n[o]))}getMainCellPosition(e,t,o){if(!this.isInMerge(e,t,o))return{col:t,row:o};const n=this.getMerge(e,t,o).topLeft;return{col:n.col,row:n.row}}getBottomLeftCell(e,t,o){if(!this.isInMerge(e,t,o))return{col:t,row:o};const{bottom:n,left:i}=this.getMerge(e,t,o);return{col:i,row:n}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),n=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of n)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge(e,t.left,t.top);if(o)return Io(t,o);const{width:n,height:i}=_o(t);return 1===n&&1===i}isMergeDestructive(e,t){let{left:o,right:n,top:i,bottom:r}=t;n=Oe(n,0,this.getters.getNumberCols(e)-1),r=Oe(r,0,this.getters.getNumberRows(e)-1);for(let t=i;t<=r;t++)for(let r=o;r<=n;r++)if(r!==o||t!==i){const o=this.getters.getCell(e,r,t);if(o&&!o.isEmpty())return!0}return!1}getMergeById(e,t){var o;const n=null===(o=this.merges[e])||void 0===o?void 0:o[t];return void 0!==n?Gm(t,n):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const o of e)if(t!==o&&To(t,o))return 64;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:n}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<n&&e.bottom>=n)return 74;return 0}checkMergedContentUpdate(e){const{col:t,row:o,sheetId:n,content:i}=e;if(void 0===i)return 0;const{col:r,row:s}=this.getMainCellPosition(n,t,o);return r===t&&s===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:n}=e,i=this.getMerge(t,o,n);if(void 0===i||!Io(e,i))return 5}return 0}addMerge(e,t){let{left:o,right:n,top:i,bottom:r}=t;n=Oe(n,0,this.getters.getNumberCols(e)-1),r=Oe(r,0,this.getters.getNumberRows(e)-1);if(Mt(o,i)===Mt(n,r))return;const s=this.getters.getCell(e,o,i);let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,So({left:o,top:i,right:n,bottom:r})));let l=new Set;for(let t=i;t<=r;t++)for(let r=o;r<=n;r++){r===o&&t===i||this.dispatch("UPDATE_CELL",{sheetId:e,col:r,row:t,style:s?s.style:null,content:""});const n=this.getMerge(e,r,t);n&&l.add(n.id),this.history.update("mergeCellMap",e,r,t,a)}for(let t of l){const{top:o,bottom:n,left:i,right:r}=this.getMergeById(e,t);for(let t=o;t<=n;t++)for(let o=i;o<=r;o++){const n=this.getMerge(e,o,t);n&&n.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",{sheetId:e,col:o,row:t}))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:n,bottom:i,right:r}=t,s=this.getMerge(e,o,n);if(void 0!==s&&Io(t,s)){this.history.update("merges",e,s.id,void 0);for(let t=n;t<=i;t++)for(let n=o;n<=r;n++)this.history.update("mergeCellMap",e,n,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[n,i]of o)if(i){const o=i.zone,r=t(i);switch(r.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{width:t,height:i}=_o(r.range.zone);1===t&&1===i?this.removeMerge(e,o):this.history.update("merges",e,parseInt(n,10),r.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:n}of Do(t))this.history.update("mergeCellMap",e,o,n,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let o of t)this.addMerge(e,vo(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Wm(e))}}exportForExcel(e){this.export(e)}}function Wm(e){return Object.entries(e).map((([e,t])=>t?Gm(parseInt(e,10),t):void 0)).filter(Ze).map((e=>Mt(e.left,e.top)+":"+Mt(e.right,e.bottom)))}function Gm(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Hm.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class qm extends Mm{constructor(){super(...arguments),this.sheetIdsMapName={},this.orderedSheetIds=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":const t=this.orderedSheetIds.indexOf(e.sheetId);if("left"===e.direction){return this.orderedSheetIds.slice(0,t).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0}return this.orderedSheetIds.slice(t+1).map((e=>!this.isSheetVisible(e))).every((e=>e))?14:0;case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"REMOVE_COLUMNS_ROWS":return("COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId))>e.elements.length?0:8;case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.direction);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){var t,o;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let n of e.sheets){const e=n.name||i("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:r,rowNumber:s}=this.getImportedSheetSize(n),a={id:n.id,name:e,numberOfCols:r,rows:po(s),areGridLinesVisible:void 0===n.areGridLinesVisible||n.areGridLinesVisible,isVisible:n.isVisible,panes:{xSplit:(null===(t=n.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(o=n.panes)||void 0===o?void 0:o.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(Ze).map((e=>{const t=this.sheets[e],o={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(o.panes=t.panes),o}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}getCellsInZone(e,t){return Do(t).map((({col:t,row:o})=>this.getCell(e,t,o)))}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=Te(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell(e,t,o){var n;const i=this.tryGetSheet(e),r=null===(n=null==i?void 0:i.rows[o])||void 0===n?void 0:n.cells[t];if(void 0!==r)return this.getters.getCellById(r)}getColCells(e,t){return this.getSheet(e).rows.map((e=>e.cells[t])).filter(Ze).map((e=>this.getters.getCellById(e))).filter(Ze)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){var o;return Object.values(null===(o=this.getSheet(e).rows[t])||void 0===o?void 0:o.cells).filter(Ze)}getRowsZone(e,t,o){return{top:t,bottom:o,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this));let n=`${e}${t}`;for(;o.includes(n);)n=`${e}${t}`,t++;return n}getSheetSize(e){return{height:this.getNumberRows(e),width:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,o){const n={...this.getPaneDivisions(e)};"COL"===o?n.xSplit=t:"ROW"===o&&(n.ySplit=t),this.history.update("sheets",e,"panes",n)}isEmpty(e,t){return this.getCellsInZone(e,t).flat().every((e=>!e||e.isEmpty()))}updateCellPosition(e){const{sheetId:t,cellId:o,col:n,row:i}=e;o?this.setNewPosition(o,t,n,i):this.clearPosition(t,n,i)}setNewPosition(e,t,o,n){const i=this.cellPosition[e];i&&this.clearPosition(t,i.col,i.row),this.history.update("cellPosition",e,{row:n,col:o,sheetId:t}),this.history.update("sheets",t,"rows",n,"cells",o,e)}clearPosition(e,t,o){var n;const i=null===(n=this.sheets[e])||void 0===n?void 0:n.rows[o].cells[t];i&&(this.history.update("cellPosition",i,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){this.sheets[e].rows[n].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:n})}}createSheet(e,t,o,n,i){const r={id:e,name:t,numberOfCols:o,rows:po(n),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},s=this.orderedSheetIds.slice();s.splice(i,0,r.id);const a=this.sheets;return this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},a,{[r.id]:r})),r}moveSheet(e,t){const o=this.orderedSheetIds.slice(),n=o.findIndex((t=>t===e)),i=o.splice(n,1);let r="left"===t?this.findIndexOfPreviousVisibleSheet(n-1,o):this.findIndexOfNextVisibleSheet(n+1,o);void 0===r&&(r=o.length),o.splice(r,0,i[0]),this.history.update("orderedSheetIds",o)}findIndexOfPreviousVisibleSheet(e,t){for(;e>=0&&!this.isSheetVisible(t[e]);)e--;if(-1===e)throw new Error("There is no previous visible sheet");return e}findIndexOfNextVisibleSheet(e,t){for(;e<t.length&&!this.isSheetVisible(t[e]);)e++;if(e!==t.length-1||this.isSheetVisible(t[e-1]))return e}checkSheetName(e){const{orderedSheetIds:t,sheets:o}=this,n=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=o[e])||void 0===t?void 0:t.name.toLowerCase())===n}))?11:ee.test(n)?13:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?15:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:73}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:73}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 64;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 64;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const n=Object.assign({},this.sheetIdsMapName);n[t]=e.id,delete n[o],this.history.update("sheetIdsMapName",n)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),n=this.getDuplicateSheetName(o.name),i=JSON.parse(JSON.stringify(o));i.id=t,i.name=n;for(let e=0;e<=i.numberOfCols;e++)for(let t=0;t<=i.rows.length;t++)i.rows[t]&&(i.rows[t].cells[e]=void 0);const r=this.orderedSheetIds.slice(),s=r.indexOf(e);r.splice(s+1,0,i.id),this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},this.sheets,{[i.id]:i}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:i.id,col:e,row:o,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[i.name]=i.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this)),n=r("Copy of %s",e);let i=n.toString();for(;o.includes(i);)i=`${n} (${t})`,t++;return i}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const n=this.orderedSheetIds.slice(),i=n.indexOf(e.id);n.splice(i,1),this.history.update("orderedSheetIds",n);const r=Object.assign({},this.sheetIdsMapName);delete r[t],this.history.update("sheetIdsMapName",r)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const n=t.filter((t=>t<e.panes.xSplit)).length;n&&this.setPaneDivisions(e.id,e.panes.xSplit-n,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of De(t))this.moveCellOnRowsDeletion(e,o[o.length-1],o[0]),o.map((t=>this.updateRowsStructureOnDeletion(t,e)));const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,n){const i="before"===o?t:t+1;this.moveCellsOnAddition(e,i,n,"columns");const r=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",r+n),i<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+n,"COL")}addRows(e,t,o,n){const i="before"===o?t:t+1;this.addEmptyRows(e,n),this.moveCellsOnAddition(e,i,n,"rows"),this.updateRowsStructureOnAddition(e,t,n),i<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+n,"ROW")}moveCellOnColumnsDeletion(e,t){for(let[o,n]of Object.entries(e.rows)){const i=parseInt(o,10);for(let o in n.cells){const r=parseInt(o,10),s=n.cells[o];s&&(r===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:r,row:i}),r>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:s,col:r-1,row:i}))}}}moveCellsOnAddition(e,t,o,n){const i=[];for(const[r,s]of Object.entries(e.rows)){const a=parseInt(r,10);if("rows"!==n||a>=t)for(let r in s.cells){const l=parseInt(r,10),c=s.cells[r];c&&("rows"===n||l>=t)&&i.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===n?o:0),row:a+("rows"===n?o:0)})}}for(let e of i.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const n=o-t+1;for(let[i,r]of Object.entries(e.rows)){const s=parseInt(i,10);if(s>=t&&s<=o)for(let t in r.cells){const o=parseInt(t,10);r.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:s})}if(s>o)for(let t in r.cells){const o=parseInt(t,10),i=r.cells[t];i&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:i,col:o,row:s-n})}}}updateRowsStructureOnDeletion(e,t){const o=[],n=t.rows.map((e=>e.cells));for(let i in t.rows)parseInt(i,10)!==e&&o.push({cells:n.shift()});this.history.update("sheets",t.id,"rows",o)}updateRowsStructureOnAddition(e,t,o){const n=[],i=e.rows.map((e=>e.cells));e.rows.forEach((()=>n.push({cells:i.shift()}))),this.history.update("sheets",e.id,"rows",n)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Ot);let o=e.rowNumber,n=e.colNumber;for(let{col:e,row:i}of t)o=Math.max(o,i+1),n=Math.max(n,e+1);return{rowNumber:o,colNumber:n}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?27:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?12:0}checkZones(e){const t=[];if("zone"in e&&t.push(e.zone),"target"in e&&Array.isArray(e.target)&&t.push(...e.target),"ranges"in e&&Array.isArray(e.ranges)&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),!t.every(bo))return 25;if(t.length&&"sheetId"in e){const o=this.getSheetZone(e.sheetId);return t.every((e=>Oo(e,o)))?0:18}return 0}}qm.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellsInZone","getCellPosition","getColCells","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions"];class Zm{constructor(e,t,o){this.index=0,this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:n}=qo.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:n,origin:{col:e.data.col,row:e.data.row}}}}class jm extends fg{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:Oe(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:Oe(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:44;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),o=this.autofillZone;switch(this.direction){case"down":for(let n=t.left;n<=t.right;n++){const i=[];for(let e=t.top;e<=t.bottom;e++)i.push(Mt(n,e));const r=this.createGenerator(i);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(r,n,t,e)}break;case"up":for(let n=t.left;n<=t.right;n++){const i=[];for(let e=t.bottom;e>=t.top;e--)i.push(Mt(n,e));const r=this.createGenerator(i);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(r,n,t,e)}break;case"left":for(let n=t.top;n<=t.bottom;n++){const i=[];for(let e=t.right;e>=t.left;e--)i.push(Mt(e,n));const r=this.createGenerator(i);for(let t=o.right;t>=o.left;t--)this.computeNewCell(r,t,n,e)}break;case"right":for(let n=t.top;n<=t.bottom;n++){const i=[];for(let e=t.left;e<=t.right;e++)i.push(Mt(e,n));const r=this.createGenerator(i);for(let t=o.left;t<=o.right;t++)this.computeNewCell(r,t,n,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const o=this.getters.getSelectedZone();if(Ao(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,n=e.bottom;if(o>0){let e=this.getters.getCell(t,o-1,n);for(;e&&!e.isEmpty();)n+=1,e=this.getters.getCell(t,o-1,n)}if(n===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e=this.getters.getCell(t,o+1,n);for(;e&&!e.isEmpty();)n+=1,e=this.getters.getCell(t,o+1,n)}n!==e.bottom&&(this.select(e.left,n-1),this.autofill(!0))}computeNewCell(e,t,o,n){const{cellData:i,tooltip:r,origin:s}=e.next(),{content:a,style:l,border:c,format:h}=i;this.tooltip=r,n&&this.dispatch("AUTOFILL_CELL",{originCol:s.col,originRow:s.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=nn.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],n=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:i}=Ot(t),r=this.getters.getCell(n,e,i);o.push({col:e,row:i,cell:r,sheetId:n})}const i=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,i)||o}const{sheetId:n,col:r,row:s}=e,a=this.getters.getCellBorder(n,r,s)||void 0;t.push({data:{...e,border:a},rule:o})}return new Zm(t,this.getters,this.direction)}saveZone(e,t,o,n){this.autofillZone={top:e,bottom:t,left:o,right:n}}getDirection(e,t){const o=this.getters.getSelectedZone(),n={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(n).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(n).find((e=>e.number>0?1:0)).value;const i=n.up.number>0?"up":"down",r=n.left.number>0?"left":"right";return Math.abs(n[i].number)>=Math.abs(n[r].number)?n[i].value:n[r].value}autoFillMerge(e,t,o,n){const i=this.getters.getActiveSheet();if(this.getters.isInMerge(i.id,o,n)&&!this.getters.isInMerge(i.id,e,t)){const e=this.getters.getMerge(i.id,o,n);e&&this.dispatch("REMOVE_MERGE",{sheetId:i.id,target:[e]})}const r=this.getters.getMerge(i.id,e,t);(null==r?void 0:r.topLeft.col)===e&&(null==r?void 0:r.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:i.id,target:[{top:n,bottom:n+r.bottom-r.top,left:o,right:o+r.right-r.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:n,y:i,width:r,height:s}=this.getters.getVisibleRect(this.autofillZone);r>0&&s>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(n,i,r,s),t.setLineDash([]))}}jm.layers=[6],jm.getters=["getAutofillTooltip"];class Xm extends fg{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const n of t){const t=this.getAutomaticSums(e,n,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),n=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&n.push(this.sumTotal(t)),n}sumAdjacentData(e,t,o){const{col:n,row:i}=Ao(o.col,o.row,t)?o:{col:t.left,row:t.top},r=this.findAdjacentData(e,n,i);return r?this.getters.isSingleCellOrMerge(e,t)||Fo(xo(r,t))?[{position:{col:n,row:i},zone:r}]:this.sumDimensions(e,xo(r,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const n=this.getters.getSheet(e),i=this.getters.getMainCellPosition(e,t,o),r=this.findSuitableZoneToSum(n,i.col,i.row);if(r)return this.getters.expandZone(e,r)}findSuitableZoneToSum(e,t,o){const n=this.getters.getCell(e.id,t,o-1),i=this.getters.getCell(e.id,t-1,o);if(this.isNumber(i)&&!this.isNumber(n))return this.findHorizontalZone(e,t,o);const r=this.findVerticalZone(e,t,o);if(this.isZoneValid(r))return r;const s=this.findHorizontalZone(e,t,o);return this.isZoneValid(s)?s:void 0}findVerticalZone(e,t,o){const n={top:0,bottom:o-1,left:t,right:t},i=this.reduceZoneStart(e,n,n.bottom);return{...n,top:i}}findHorizontalZone(e,t,o){const n={top:o,bottom:o,left:0,right:t-1},i=this.reduceZoneStart(e,n,n.right);return{...n,left:i}}reduceZoneStart(e,t,o){const n=this.getters.getCellsInZone(e.id,t),i=Fe(o,-1,-1),r=i.filter((e=>{var t;return n[e]&&!(null===(t=n[e])||void 0===t?void 0:t.isAutoSummable)})),s=Math.max(...r),a=De(i.filter((e=>this.isNumber(n[e]))))[0]||[];return Math.max(...a)<s?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return(null==e?void 0:e.evaluated.type)===Zo.number&&!(null===(t=e.evaluated.format)||void 0===t?void 0:t.match(j))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const o=new Set;return Fo(t)?(o.add(1===_o(t).width?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},Do(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},Do(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:n}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:n,right:i}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:n,right:i});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:n,bottom:i}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:n,bottom:i});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}Xm.getters=["getAutomaticSums"];class Ym extends fg{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{_n.get(e.popoverType)}catch(e){return 71}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,type:e.popoverType}}}getCellPopover({col:e,row:t}){var o,n;const i=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(i,this.persistentPopover.col,this.persistentPopover.row)){const e=this.getters.getMainCellPosition(i,this.persistentPopover.col,this.persistentPopover.row),t=null===(n=(o=_n.get(this.persistentPopover.type)).onOpen)||void 0===n?void 0:n.call(o,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,...this.computePopoverProps(this.persistentPopover,t.cellCorner)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport(i,e,t))return{isOpen:!1};const r=this.getters.getMainCellPosition(i,e,t),s=_n.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,r,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==s?void 0:s.isOpen)?{...s,...this.computePopoverProps(r,s.cellCorner)}:{isOpen:!1}}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverProps({col:e,row:t},o){const{width:n,height:i}=this.getters.getVisibleRect(Po({col:e,row:t}));return{coordinates:this.computePopoverPosition({col:e,row:t},o),cellWidth:-n,cellHeight:-i}}computePopoverPosition({col:e,row:t},o){const n=this.getters.getActiveSheetId(),i=this.getters.getMerge(n,e,t);i&&(e="TopRight"===o?i.right:i.left,t="TopRight"===o?i.top:i.bottom);const{x:r,y:s,width:a,height:l}=this.getters.getVisibleRect(Po({col:e,row:t}));switch(o){case"BottomLeft":return{x:r,y:s+l};case"TopRight":return{x:r+a,y:s}}}}Ym.getters=["getCellPopover","getPersistentPopoverTypeAtPosition"],Ym.modes=["normal"];class Km{constructor(e,t,o,n){this.getters=t,this.dispatch=o,this.selection=n,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,n){const i=this.getters.getActiveSheetId(),r=t+n-this.getters.getNumberRows(i);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(i)-1,sheetId:i,quantity:r,position:"after"});const s=e+o-this.getters.getNumberCols(i);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(i)-1,sheetId:i,quantity:s,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Qm extends Km{constructor(e,t,o,n,i){if(super(t,o,n,i),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const r=new Set(e.map((e=>e.left))),s=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===r.size&&1===s.size?function(e){return e.reduce(((e,t)=>{const o=e.length;for(let n=0;n<o;n++)if(To(e[n],t))return e[n]=xo(e[n],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>Do(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=o.getActiveSheetId();for(let e of u){let t=[];for(let n of d)t.push({cell:o.getCell(p,n,e),border:o.getCellBorder(p,n,e)||void 0,position:{col:n,row:e,sheetId:p}});g.push(t)}const f=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const o of Fe(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues(p,o,e.zone.top));f.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=f}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const n=this.cells.length,i=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||n*i!=1))return 2;const{xSplit:r,ySplit:s}=this.getters.getPaneDivisions(o);for(const t of this.getPasteZones(e))if(t.left<r&&t.right>=r||t.top<s&&t.bottom>=s)return 74;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const o=this.cells.length,n=this.cells[0].length,i="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(n,o,i,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,n=this.cells[0].length,i=this.pastedZones(e,n,o);for(const e of i)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let n=o.top;n<=o.bottom;n++)this.pasteZone(e,n,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,o){const n=e[0],i=Math.max(1,Math.floor((n.right+1-n.left)/t)),r=Math.max(1,Math.floor((n.bottom+1-n.top)/o)),s=[];for(let e=0;e<i;e++)for(let i=0;i<r;i++){const r=n.top+i*o,a=n.left+e*t;s.push({left:a,top:r,bottom:r+o-1,right:a+t-1})}return s}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],n=t.length,i=t[0].length,r=e[e.length-1],s=r.left,a=r.top,l=Math.max(1,Math.floor((r.right+1-s)/i)),c=Math.max(1,Math.floor((r.bottom+1-a)/n));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:s,top:a,right:s-1+e*i,bottom:a-1+t*n});return o}selectPastedZone(e,t,o,n){const i=n[0],r=i.left,s=i.top;if(t>1||e>1||o){const i=this.pastedZones(n,e,t),a=o?i[0]:xo(...i);this.selection.selectZone({cell:{col:r,row:s},zone:a})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,o){const n=this.cells.length,i=this.cells[0].length,r="onlyValue"!==(null==o?void 0:o.pasteOption)&&(null==o?void 0:o.shouldPasteCF),s=this.getters.getActiveSheetId();this.addMissingDimensions(i,n,e,t);for(let a=0;a<n;a++){const n=this.cells[a];for(let l=0;l<i;l++){const i=n[l],c={col:e+l,row:t+a,sheetId:s};"CUT"!==this.operation&&this.pasteMergeIfExist(i.position,c),this.pasteCell(i,c,this.operation,o),r&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:i.position,target:c,operation:this.operation})}}}pasteCell(e,t,o,n){const{sheetId:i,col:r,row:s}=t,a=this.getters.getCell(i,r,s);if("onlyValue"!==(null==n?void 0:n.pasteOption)){const t=this.getters.getCellBorder(i,r,s),o=e.border,n={top:(null==t?void 0:t.top)||(null==o?void 0:o.top),bottom:(null==t?void 0:t.bottom)||(null==o?void 0:o.bottom),left:(null==t?void 0:t.left)||(null==o?void 0:o.left),right:(null==t?void 0:t.right)||(null==o?void 0:o.right)};this.dispatch("SET_BORDER",{sheetId:i,col:r,row:s,border:n})}if(e.cell){if("onlyFormat"===(null==n?void 0:n.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.cell.evaluated.format||e.cell.format});if("onlyValue"===(null==n?void 0:n.pasteOption)){const o=Vt(e.cell.evaluated.value);return void this.dispatch("UPDATE_CELL",{...t,content:o})}let a=e.cell.content;if(e.cell.isFormula()&&"COPY"===o){const t=r-e.position.col,n=s-e.position.row;a=this.getUpdatedContent(i,e.cell,t,n,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==n?void 0:n.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==n?void 0:n.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,n,i){const r=this.getters.createAdaptedRanges(t.dependencies,o,n,e);return this.getters.buildFormulaContent(e,t,r)}pasteMergeIfExist(e,t){let{sheetId:o,col:n,row:i}=e;const{col:r,row:s}=this.getters.getMainCellPosition(o,n,i);if(r===n&&s===i){const e=this.getters.getMerge(o,n,i);if(!e)return;({sheetId:o,col:n,row:i}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:n,top:i,right:n+e.right-e.left,bottom:i+e.bottom-e.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],n=this.zones[0],i=[o.left-n.left,o.top-n.top];for(const e of this.copiedTables){const o=ko(e.zone,"both","MOVE",i);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const n of Fe(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+n,row:o.top,values:e.filtersValues[n]})}}getClipboardContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.cell,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:n,width:i,height:r}=this.getters.getVisibleRect(e);i>0&&r>0&&t.strokeRect(o,n,i,r)}}}}class Jm{constructor(e,t,o){this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const n=t.getSelectedFigureId();if(!n)throw new Error("No figure selected");const i=t.getFigure(this.sheetId,n);if(!i)throw new Error(`No figure for the given id: ${n}`);this.copiedFigure={...i};const r=t.getChart(n);if(!r)throw new Error(`No chart for the given id: ${n}`);this.copiedChart=r.copyInSheetId(this.sheetId),this.operation=e}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?72:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),o={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},n=this.copiedChart.copyInSheetId(t),i=(new fo).uuidv4();this.dispatch("CREATE_CHART",{id:i,sheetId:t,position:o,size:{height:this.copiedFigure.height,width:this.copiedFigure.width},definition:n.getDefinition()}),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedChart.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:i})}getClipboardContent(){return"\t"}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class ev extends Km{constructor(e,t,o,n){super("COPY",t,o,n),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),n=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,n)?2:0}paste(e){const t=this.values,o=this.getPasteZone(e),{left:n,top:i}=o,{width:r,height:s}=_o(o),a=this.getters.getActiveSheetId();this.addMissingDimensions(r,s,n,i);for(let e=0;e<t.length;e++)for(let o=0;o<t[e].length;o++)this.dispatch("UPDATE_CELL",{row:i+e,col:n+o,content:t[e][o],sheetId:a});const l={left:n,top:i,right:n+r-1,bottom:i+s-1};this.selection.selectZone({cell:{col:n,row:i},zone:l})}getClipboardContent(){return this.values.map((e=>e.join("\t"))).join("\n")}getPasteZone(e){const t=this.values.length,o=Math.max(...this.values.map((e=>e.length))),{left:n,top:i}=e[0];return{top:i,left:n,bottom:i+t-1,right:n+o-1}}}class tv extends fg{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=e.target||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new ev(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}}return 0}handle(e){var t,o;switch(e.type){case"COPY":case"CUT":const n="target"in e&&e.target||this.getters.getSelectedZones();this.state=this.getClipboardState(n,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:i,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!bo(t[0])){for(const{col:t,row:o}of Do(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(o=this.state)||void 0===o?void 0:o.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new ev(e.text,this.getters,this.dispatch,this.selection).paste(e.target),this.status="invisible";break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}default:Qo(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let n;return n="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[n],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let n,i;return"COL"===t?(n={...e,right:this.getters.getNumberCols(o)-1},i={...e,left:e.right+1,right:e.right+1}):(n={...e,bottom:this.getters.getNumberRows(o)-1},i={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[n],paste:[i]}}getClipboardStateForCopyCells(e,t){return new Qm(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new Jm(t,this.getters,this.dispatch):new Qm(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}tv.layers=[2],tv.getters=["getClipboardContent","isCutOperation","isPaintingFormat"];class ov extends fg{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const o=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(o),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:ht(255,0,0),colors:[]},{leadColor:ht(255,128,0),colors:[]},{leadColor:ht(128,128,0),colors:[]},{leadColor:ht(128,255,0),colors:[]},{leadColor:ht(0,255,0),colors:[]},{leadColor:ht(0,255,128),colors:[]},{leadColor:ht(0,255,255),colors:[]},{leadColor:ht(0,127,255),colors:[]},{leadColor:ht(0,0,255),colors:[]},{leadColor:ht(127,0,255),colors:[]},{leadColor:ht(128,0,128),colors:[]},{leadColor:ht(255,0,128),colors:[]}];for(const o of e.map(gt)){let e=500,n=0;t.forEach(((t,i)=>{const r=(s=o,a=t.leadColor,Math.sqrt(Math.pow(s.r-a.r,2)+Math.pow(s.g-a.g,2)+Math.pow(s.b-a.b,2)));var s,a;e>r&&(e=r,n=i)})),t[n].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>ft(e).s-ft(t).s)))).flat().map(ut)}([...new Set([...new Set([...e,...this.customColors])].filter(lt).map((e=>at(e).toLowerCase())))]).filter((e=>!A.includes(e)))}getColorsFromCells(e){var t,o;const n=new Set;for(const i of e)(null===(t=i.style)||void 0===t?void 0:t.textColor)&&n.add(i.style.textColor),(null===(o=i.style)||void 0===o?void 0:o.fillColor)&&n.add(i.style.fillColor);return[...n]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(rt(t.minimum.color)),o.push(t.midpoint?rt(t.midpoint.color):void 0),o.push(rt(t.maximum.color)))}return o.filter(Ze)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const n=e;o.add(n.baselineColorDown),o.add(n.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=at(e).toLowerCase();e&&!A.includes(t)&&this.customColors.add(t)}}ov.getters=["getCustomColors"];const nv=Cu.mapping;class iv extends fg{constructor(e,t,o,n,i){super(e,t,o,n,i),this.isUpToDate=!1,this.evalContext=n.evalContext}handle(e){switch(jo.has(e.type)&&(this.isUpToDate=!1),e.type){case"UPDATE_CELL":("content"in e||"format"in e)&&(this.isUpToDate=!1);break;case"EVALUATE_CELLS":this.evaluate()}}finalize(){this.isUpToDate||this.evaluate()}evaluateFormula(e,t=this.getters.getActiveSheetId()){const o=cg(e),n=this.getCompilationParameters((()=>{})),i=[];for(let e of o.dependencies)i.push(this.getters.getRangeFromSheetXC(t,e));return o.execute(i,...n).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>(null==e?void 0:e.formattedValue)||""))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getCellsInZone(t.id,e.zone).map((e=>null==e?void 0:e.evaluated.value))}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){const e=this.getCompilationParameters(o),t={};for(const e of this.getAllCells())o(e);function o(o){if(!o.isFormula())return;const n=o.id,i=Qe((()=>{if(e[2].__originCellXC=()=>{const t=e[2].getters.getCellPosition(n);return Mt(t.col,t.row)},n in t)return null===t[n]?new d:o.evaluated;t[n]=null;try{const i=o.compiledFormula.execute(o.dependencies,...e);if(t[n]=!0,Array.isArray(i.value))throw new Error(r("This formula depends on invalid values"));return{value:i.value,format:o.format||i.format}}catch(o){return t[n]=!0,function(t){t instanceof Error||(t=new Error(t));const o=(null==t?void 0:t.errorType)||a.GenericError,n=e[2].__lastFnCalled||"";return new c(o,t.message.replace("[[FUNCTION_NAME]]",n),void 0!==t.logLevel?t.logLevel:l.error)}(o)}}));o.assignEvaluation(i)}this.isUpToDate=!0}getCompilationParameters(e){const t=Object.assign(Object.create(nv),this.evalContext,{getters:this.getters}),o=this.getters;function n(e){if(e.evaluated.type===Zo.error)throw new c(e.evaluated.value,e.evaluated.error.message,e.evaluated.error.logLevel);return e.evaluated}return[function(e,t,i,s){if(t)return{value:So(e.zone)};if(!bo(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(s?r("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",i.toString(),s.toString()):r("Function %s expects its parameters to be single values or single cell references, not ranges.",i.toString()));if(e.invalidSheetName)throw new Error(r("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!o.tryGetSheet(e.sheetId))throw new Error(r("Invalid sheet name"));return t=o.getCell(e.sheetId,e.zone.left,e.zone.top),!t||t.isEmpty()?{value:null}:n(t)}(e)},function(e){const i=e.sheetId;if(!bo(e.zone))throw new u;const r=o.getSheetZone(i),s=[],a=Ro(e.zone,r);if(!a)return s.push([]),s;for(let o=a.left;o<=a.right;o++){const i=[];for(let r=a.top;r<=a.bottom;r++){const s=t.getters.getCell(e.sheetId,o,r);i.push(s?n(s):void 0)}s.push(i)}return s},t]}}iv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues"];class rv extends fg{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=Ho.getAll();return function(o){const n=t.find((e=>e.match(o.type)));if(!n)throw new Error("No runtime builder for this chart.");return n.getChartRuntime(o,e)}}(this.getters)}handle(e){if(jo.has(e.type)||Xo.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const o=t.zone.left,n=t.zone.top;return this.getters.getCellComputedStyle(t.sheetId,o,n).fillColor||w}}rv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class sv extends fg{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.rulePredicate={CellIsRule:(e,t)=>{if(e&&e.evaluated.type===Zo.error)return!1;const o=t.values.map(gp);switch(t.operator){case"IsEmpty":return!Ze(e)||""===e.evaluated.value.toString().trim();case"IsNotEmpty":return Ze(e)&&""!==e.evaluated.value.toString().trim();case"BeginsWith":return!(!e&&""===o[0])&&(Ze(e)&&(null==e?void 0:e.evaluated.value.toString().startsWith(o[0].toString())));case"EndsWith":return!(!e&&""===o[0])&&(Ze(e)&&e.evaluated.value.toString().endsWith(o[0].toString()));case"Between":return Ze(e)&&e.evaluated.value>=o[0]&&e.evaluated.value<=o[1];case"NotBetween":return!(Ze(e)&&e.evaluated.value>=o[0]&&e.evaluated.value<=o[1]);case"ContainsText":return Ze(e)&&e.evaluated.value.toString().indexOf(o[0].toString())>-1;case"NotContains":return!Ze(e)||!e.evaluated.value||-1==e.evaluated.value.toString().indexOf(o[0].toString());case"GreaterThan":return Ze(e)&&e.evaluated.value>o[0];case"GreaterThanOrEqual":return Ze(e)&&e.evaluated.value>=o[0];case"LessThan":return Ze(e)&&e.evaluated.value<o[0];case"LessThanOrEqual":return Ze(e)&&e.evaluated.value<=o[0];case"NotEqual":return!(!Ze(e)&&""===o[0])&&(Ze(e)&&e.evaluated.value!==o[0]);case"Equal":return!e&&""===o[0]||Ze(e)&&e.evaluated.value===o[0];default:console.warn(r("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((Xo.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const o=this.getters.getActiveSheetId(),n=this.getters.getRulesByCell(o,e.originCol,e.originRow);for(const t of n)this.adaptRules(o,t,[Mt(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation)}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getCellComputedStyle(e,t,o){var n;const i=this.getters.getCell(e,t,o),r=this.computedStyles[e],s=r&&(null===(n=r[t])||void 0===n?void 0:n[o]),a={...null==i?void 0:i.style,...s};return this.getters.isFilterHeader(e,t,o)&&(a.bold=!0),a}getConditionalIcon(e,t){var o;const n=this.getters.getActiveSheetId(),i=this.computedIcons[n];return i&&(null===(o=i[e])||void 0===o?void 0:o[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const o=this.computedStyles[t];for(let n of this.getters.getConditionalFormats(t).reverse())try{switch(n.rule.type){case"ColorScaleRule":for(let e of n.ranges)this.applyColorScale(e,n.rule);break;case"IconSetRule":for(let e of n.ranges)this.applyIcon(e,n.rule);break;default:for(let i of n.ranges){const r=this.getters.getRangeFromSheetXC(t,i).zone;for(let i=r.top;i<=r.bottom;i++)for(let s=r.left;s<=r.right;s++){const r=this.rulePredicate[n.rule.type];let a=this.getters.getCell(t,s,i);r&&r(a,n.rule)&&(o[s]||(o[s]=[]),o[s][i]=Object.assign((null===(e=o[s])||void 0===e?void 0:e[i])||{},n.rule.style))}}}}catch(e){}}parsePoint(e,t,o){const n=this.getters.getActiveSheetId(),i=this.getters.getRangeValues(this.getters.getRangeFromSheetXC(n,e)).filter(this.isCellValueNumber);switch(t.type){case"value":return"max"===o?Math.max(...i):Math.min(...i);case"number":return Number(t.value);case"percentage":const e=Math.min(...i);return e+(Math.max(...i)-e)*Number(t.value)/100;case"percentile":return co(i,Number(t.value)/100,!0);case"formula":const n=t.value&&this.getters.evaluateFormula(t.value);return n instanceof Promise?null:n;default:return null}}applyIcon(e,t){const o=this.parsePoint(e,t.lowerInflectionPoint),n=this.parsePoint(e,t.upperInflectionPoint);if(null===o||null===n||o>n)return;const i=this.getters.getActiveSheetId(),r=this.getters.getRangeFromSheetXC(i,e).zone,s=this.computedIcons[i],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=r.top;e<=r.bottom;e++)for(let l=r.left;l<=r.right;l++){const r=this.getters.getCell(i,l,e);if((null==r?void 0:r.evaluated.type)!==Zo.number)continue;const c=this.computeIcon(r.evaluated.value,n,t.upperInflectionPoint.operator,o,t.lowerInflectionPoint.operator,a);s[l]||(s[l]=[]),s[l][e]=c}}computeIcon(e,t,o,n,i,r){return"ge"===o&&e>=t||"gt"===o&&e>t?r[0]:"ge"===i&&e>=n||"gt"===i&&e>n?r[1]:r[2]}applyColorScale(e,t){var o;const n=this.parsePoint(e,t.minimum,"min"),i=t.midpoint?this.parsePoint(e,t.midpoint):null,r=this.parsePoint(e,t.maximum,"max");if(null===n||null===r||n>=r||i&&(n>=i||i>=r))return;const s=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(s,e).zone,l=this.computedStyles[s],c=[];t.midpoint&&i?(c.push({minValue:n,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(n,i,t.minimum.color,t.midpoint.color)}),c.push({minValue:i,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(i,r,t.midpoint.color,t.maximum.color)})):c.push({minValue:n,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(n,r,t.minimum.color,t.maximum.color)});for(let e=a.top;e<=a.bottom;e++)for(let t=a.left;t<=a.right;t++){const a=this.getters.getCell(s,t,e);if((null==a?void 0:a.evaluated.type)===Zo.number){const s=Oe(a.evaluated.value,n,r);let h;h=2===c.length&&i?s<=i?this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(s,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(s,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(o=l[t])||void 0===o?void 0:o[e])||{},l[t][e].fillColor=rt(h)}}}computeColorDiffUnits(e,t,o,n){const i=t-e;return[((o>>16)%256-(n>>16)%256)/i,((o>>8)%256-(n>>8)%256)/i,(o%256-n%256)/i]}colorCell(e,t,o,n){const[i,r,s]=n;return Math.round((o>>16)%256-i*(e-t))<<16|Math.round((o>>8)%256-r*(e-t))<<8|Math.round(o%256-s*(e-t))}adaptRules(e,t,o,n){if(0===o.length&&0===n.length)return;const i=this.getters.getConditionalFormats(e),r=i.findIndex((e=>e.id===t.id));let s=[];r>-1&&(s=i[r].ranges),s=s.concat(o);const a=Mo(s,n);this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}pasteCf(e,t,o){const n=Mt(t.col,t.row);for(let i of this.getters.getConditionalFormats(e.sheetId))for(let r of i.ranges)if(Ao(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,r).zone)){const r=i,s=[];"CUT"===o&&s.push(Mt(e.col,e.row)),e.sheetId===t.sheetId?this.adaptRules(e.sheetId,r,[n],s):(this.adaptRules(t.sheetId,r,[n],[]),this.adaptRules(e.sheetId,r,[],s))}}isCellValueNumber(e){return"number"==typeof e}}sv.getters=["getConditionalIcon","getCellComputedStyle"];class av extends fg{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e.sheetId,e.col,e.row))return 78;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"HIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const o of this.getters.getFilters(e.sheetIdTo)){const n=o.zoneWithHeaders;t[o.id]=this.getFilterValues(e.sheetId,n.left,n.top)}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e,t,o){let n;for(let i of this.getters.getFilterTables(e)){const r=i.zone;if(Ao(t,o,r)){const i=this.intersectZoneWithViewport(e,r);n={top:o===i.top?Z:void 0,bottom:o===i.bottom?Z:void 0,left:t===i.left?Z:void 0,right:t===i.right?Z:void 0}}}const i=this.getters.getCellBorder(e,t,o),r={...n,...ot(i||{})};return Xe(r)?null:r}getFilterHeaders(e){const t=[];for(let o of this.getters.getFilterTables(e)){const n=o.zone;if(!n)continue;const i=n.top;for(let o=n.left;o<=n.right;o++)this.getters.isColHidden(e,o)||this.getters.isRowHidden(e,i)||t.push({col:o,row:i})}return t}getFilterValues(e,t,o){const n=this.getters.getFilterId(e,t,o);return n&&this.filterValues[e]&&this.filterValues[e][n]||[]}isFilterHeader(e,t,o){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}isFilterActive(e,t,o){var n,i;const r=this.getters.getFilterId(e,t,o);return Boolean(r&&(null===(i=null===(n=this.filterValues[e])||void 0===n?void 0:n[r])||void 0===i?void 0:i.length))}intersectZoneWithViewport(e,t){const o=Fe(t.left,t.right+1),n=Fe(t.top,t.bottom+1);return{left:this.getters.findVisibleHeader(e,"COL",o),right:this.getters.findVisibleHeader(e,"COL",o.reverse()),top:this.getters.findVisibleHeader(e,"ROW",n),bottom:this.getters.findVisibleHeader(e,"ROW",n.reverse())}}updateFilter({col:e,row:t,values:o,sheetId:n}){const i=this.getters.getFilterId(n,e,t);i&&(this.filterValues[n]||(this.filterValues[n]={}),this.filterValues[n][i]=o)}updateHiddenRows(){var e,t;const o=this.getters.getActiveSheetId(),n=this.getters.getFilters(o).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),i=new Set;for(let r of n){if(this.getters.isRowHiddenByUser(o,r.zoneWithHeaders.top))continue;if(i.has(r.zoneWithHeaders.top))continue;const n=null===(t=null===(e=this.filterValues[o])||void 0===e?void 0:e[r.id])||void 0===t?void 0:t.map(nt);if(n&&r.filteredZone)for(let e=r.filteredZone.top;e<=r.filteredZone.bottom;e++){const t=this.getCellValueAsString(o,r.col,e);n.includes(t)&&i.add(e)}}this.hiddenRows=i}getCellValueAsString(e,t,o){var n;const i=null===(n=this.getters.getCell(e,t,o))||void 0===n?void 0:n.formattedValue;return(null==i?void 0:i.toLowerCase())||""}exportForExcel(e){var t;for(const o of e.sheets)for(const e of o.filterTables){const n=vo(e.range),i=[],r=[];for(const e of Fe(0,_o(n).width)){const s=this.getFilterValues(o.id,n.left+e,n.top),a=this.getters.getFilter(o.id,n.left+e,n.top);if(!a)continue;const l=a.filteredZone?Do(a.filteredZone).map((e=>{var t;return null===(t=this.getters.getCell(o.id,e.col,e.row))||void 0===t?void 0:t.formattedValue})).filter(je):[],c=l.filter((e=>!s.includes(e)));i.push({colId:e,filteredValues:[...new Set(c)]});const h={col:a.col,row:a.zoneWithHeaders.top},d=null===(t=this.getters.getCell(o.id,h.col,h.row))||void 0===t?void 0:t.formattedValue,u=this.getUniqueColNameForExcel(e,d,r);r.push(u),o.cells[Mt(h.col,h.row)]={...o.cells[Mt(h.col,h.row)],content:u,value:u,isFormula:!1}}e.filters=i}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let n=t,i=2;for(;o.includes(n);)n=t+String(i),i++;return n}}av.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];var lv;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(lv||(lv={}));class cv extends fg{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(lv.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(lv.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(lv.current)}updateRegex(){let e=Re(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),o=[];if(this.toSearch)for(const e of Object.values(t))if(e&&this.currentSearchRegex&&this.currentSearchRegex.test(this.searchOptions.searchFormulas&&e.isFormula()?e.content:String(e.evaluated.value))){const t=this.getters.getCellPosition(e.id),n={col:t.col,row:t.row,selected:!1};o.push(n)}return o.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,null!==this.selectedMatchIndex&&this.selectedMatchIndex===o||(this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].row));for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId(),n=this.getters.getCell(o,t.col,t.row),i=this.toReplace(n,o);if(n&&i){const o=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),n=i.toString().replace(o,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:n}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(lv.current)}else this.selectNextCell(lv.next)}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replace(e)}toReplace(e,t){if(e){if(this.searchOptions.searchFormulas&&e.isFormula())return e.content;if(this.searchOptions.searchFormulas||!e.isFormula())return e.evaluated.value.toString()}return null}drawGrid(e){const{ctx:t}=e,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const n=this.getters.getMerge(o,e.col,e.row),i=n?n.left:e.col,r=n?n.right:e.col,s=n?n.top:e.row,a=n?n.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:s,left:i,right:r,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}cv.layers=[3],cv.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class hv extends fg{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){const n=this.searchNumberFormat(e,t);if(void 0!==n){const i=function(e,t){const o=Ut(e).map((e=>"NUMBER"===e.type?{...e,format:Xt(e.format,t)}:e)),n=Jt(o);return Pt[n]=o,n}(n,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:t,format:i})}}searchNumberFormat(e,t){var o;for(let n of t)for(let t=n.top;t<=n.bottom;t++)for(let i=n.left;i<=n.right;i++){const n=this.getters.getCell(e,i,t);if((null==n?void 0:n.evaluated.type)===Zo.number&&!(null===(o=n.evaluated.format)||void 0===o?void 0:o.match(j)))return n.evaluated.format||Zt(n.evaluated.value)}}}hv.modes=["normal"];class dv extends fg{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition(e,t,o){return{col:this.findVisibleHeader(e,"COL",Fe(t,this.getters.getNumberCols(e))),row:this.findVisibleHeader(e,"ROW",Fe(o,this.getters.getNumberRows(e)))}}findVisibleHeader(e,t,o){return o.find((o=>this.getters.doesHeaderExist(e,t,o)&&!this.isHeaderHidden(e,t,o)))}findLastVisibleColRowIndex(e,t,o){let n;for(n=o.last;n>=o.first;n--)if(!this.isHeaderHidden(e,t,n))return n;return n}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let n=0;n<o-1;n++){if("COL"===t&&!this.isColHidden(e,n))return n;if("ROW"===t&&!this.isRowHidden(e,n))return n}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const n=this.isRowHidden(t.id,Number(e));o.isHidden=n}}}dv.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class uv extends fg{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{height:t,width:o}=_o(e.zone),n=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:n}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,n=this.getters.getActiveSheetId(),i=3*o;t.lineWidth=i;const r=this.getHighlights();for(let e of r.filter(((e,t)=>r.findIndex((t=>Io(t.zone,e.zone)&&t.sheetId===n))===t))){const{x:o,y:n,width:r,height:s}=this.getters.getVisibleRect(e.zone);r>0&&s>0&&(t.strokeStyle=e.color,t.strokeRect(o+i/2,n+i/2,r-i,s-i),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+i,n+i,r-2*i,s-2*i))}}}uv.layers=[1],uv.getters=["getHighlights"];class gv extends fg{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleCols()),n=this.getters.getColRowOffsetInViewport("COL",o,t),i=this.getters.getColSize(e,t);return{start:n,size:i,end:n+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleRows()),n=this.getters.getColRowOffsetInViewport("ROW",o,t),i=this.getters.getRowSize(e,t);return{start:n,size:i,end:n+(this.getters.isRowHidden(e,t)?0:i)}}getHeaderOffset(e,t,o){let n=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(n+="ROW"===e?O:M),n}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:o}=e,{width:n,height:i}=this.getters.getSheetViewDimensionWithHeaders(),r=this.getters.getActiveSheetId();t.fillStyle="#ffffff",t.fillRect(0,0,n+f,i+f);const s=this.getters.getSheetViewVisibleCols(),a=s[0],l=s[s.length-1],c=this.getters.getSheetViewVisibleRows(),h=c[0],d=c[c.length-1];if(this.getters.getGridLinesVisibility(r)&&!this.getters.isDashboard()){t.lineWidth=2*o,t.strokeStyle="#E2E3E3",t.beginPath();for(const e of s){const o={top:h,bottom:d,left:e,right:e},{x:n,width:r,height:s}=this.getters.getVisibleRect(o);t.moveTo(n+r,0),t.lineTo(n+r,Math.min(i,s+(this.getters.isDashboard()?0:O)))}for(const e of c){const o={left:a,right:l,top:e,bottom:e},{y:i,width:r,height:s}=this.getters.getVisibleRect(o);t.moveTo(0,i+s),t.lineTo(Math.min(n,r+(this.getters.isDashboard()?0:M)),i+s)}t.stroke()}}drawCellBackground(e){const{ctx:t,thinLineWidth:o}=e,n=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());t.lineWidth=n?.3*o:o;const i=n?.1*o:0;t.strokeStyle="#111";for(let e of this.boxes){let r=e.style;(r.fillColor&&"#ffffff"!==r.fillColor||e.isMerge)&&(t.fillStyle=r.fillColor||"#ffffff",n?(t.fillRect(e.x,e.y,e.width,e.height),t.strokeRect(e.x+i,e.y+i,e.width-2*i,e.height-2*i)):t.fillRect(e.x-o,e.y-o,e.width+2*o,e.height+2*o)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawBorders(e){const{ctx:t,thinLineWidth:o}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:o,y:i,width:r,height:s}=e;t.left&&n(t.left,o,i,o,i+s),t.top&&n(t.top,o,i,o+r,i),t.right&&n(t.right,o+r,i,o+r,i+s),t.bottom&&n(t.bottom,o,i+s,o+r,i+s)}}function n([e,n],i,r,s,a){t.strokeStyle=n,t.lineWidth=("thin"===e?2:3)*o,t.beginPath(),t.moveTo(i,r),t.lineTo(s,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let n;t.textBaseline="top";for(let e of this.boxes)if(e.content){const i=e.style||{},r=e.content.align||"left",s=Ne(i);let a;s!==n&&(n=s,t.font=s),t.fillStyle=i.textColor||"#000";let l=e.y+e.height/2+1;if(a="left"===r?e.x+(e.image?e.image.size+2*$:L):"right"===r?e.x+e.width-L-(e.isFilterHeader?20:0):e.x+e.width/2,t.textAlign=r,e.clipRect){t.save(),t.beginPath();const{x:o,y:n,width:i,height:r}=e.clipRect;t.rect(o,n,i,r),t.clip()}const c=e.content.multiLineText.length,h=_e(i);let d=l-(c*(h+L)-L)/2;for(let n of e.content.multiLineText){if(t.fillText(n,Math.round(a),Math.round(d)),i.strikethrough||i.underline){const e=Me(t,n,i);let s=a;"right"===r?s-=e:"center"===r&&(s-=e/2),i.strikethrough&&t.fillRect(s,d+h/2,e,2.6*o),i.underline&&t.fillRect(s,d+h+1,e,1.3*o)}d+=L+h}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image,n=e.image.size,i=(e.height-n)/2;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:n,width:i,height:r}=e.image.clipIcon;t.rect(o,n,i,r),t.clip()}t.drawImage(o,e.x+$,e.y+i,n,n),e.image.clipIcon&&t.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,n=this.getters.getSheetViewVisibleCols(),i=n[0],r=n[n.length-1],s=this.getters.getSheetViewVisibleRows(),a=s[0],l=s[s.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let o of e)for(let e of Fe(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of Fe(o.top,o.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),f=this.getters.getNumberCols(p),m=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${G}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=i;e<=r;e++){const o={left:e,right:e,top:0,bottom:m-1},{x:n,width:i}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),s=E.has(e),a=u.has(e);t.fillStyle=s?r?R:S:a?r?T:b:r?I:v,t.fillRect(n,0,i,O)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:f-1},{y:n,height:i}=this.getters.getVisibleRect(o),r=this.getters.doesZonesContainFilter(p,[o]),s=w.has(e),a=g.has(e);t.fillStyle=s?r?R:S:a?r?T:b:r?I:v,t.fillRect(0,n,M,i)}t.beginPath(),t.moveTo(M,0),t.lineTo(M,h),t.moveTo(0,O),t.lineTo(c,O),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of n){const o=this.getters.getColSize(p,e),n=Tt(e);t.fillStyle=E.has(e)?"#fff":C;let r=this.getHeaderOffset("COL",i,e);t.fillText(n,r+o/2,13),t.moveTo(r+o,0),t.lineTo(r+o,O)}for(const e of s){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let n=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,n+o/2),t.moveTo(0,n+o),t.lineTo(M,n+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:n,y:i}=this.getters.getMainViewportCoordinates(),r=this.getters.isDashboard()?0:M,s=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),n&&(t.moveTo(r+n,0),t.lineTo(r+n,s)),i&&(t.moveTo(0,s+i),t.lineTo(r,s+i)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:n,y:i}=this.getters.getMainViewportCoordinates(),r=this.getters.getSheetViewVisibleCols(),s=r[0],a=r[r.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:s,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:M,u=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),n&&(t.moveTo(d+n,u),t.lineTo(d+n,h.height+u)),i&&(t.moveTo(d,u+i),t.lineTo(h.width+d,u+i)),t.stroke()}hasContent(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.getCell(o,e,t);return n&&!n.isEmpty()||this.getters.isInMerge(o,e,t)}findNextEmptyCol(e,t,o){let n=e;for(;n<t&&!this.hasContent(n+1,o);)n++;return n}findPreviousEmptyCol(e,t,o){let n=e;for(;n>t&&!this.hasContent(n-1,o);)n--;return n}computeCellAlignment(e,t){if(e.isFormula()&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e);return t&&e.evaluated.type===Zo.number?"center"!==o?"left":o:o||e.defaultAlign}createZoneBox(e,t,o){const{left:n,right:i}=o,r=t.left,s=t.top,a=this.getters.getCell(e,r,s),c=this.getters.shouldShowFormulas(),{x:h,y:d,width:u,height:g}=this.getters.getVisibleRect(t),p={x:h,y:d,width:u,height:g,border:this.getters.getCellBorderWithFilterBorder(e,r,s)||void 0,style:this.getters.getCellComputedStyle(e,r,s)};if(!a)return p;const f=this.getters.getConditionalIcon(r,s),m=_e(p.style),v=f?2*$+m:0;f&&(p.image={type:"icon",size:m,clipIcon:{x:p.x,y:p.y,width:Math.min(v,u),height:g},image:jr[f].img}),p.isFilterHeader=this.getters.isFilterHeader(e,r,s);const b=p.isFilterHeader?19:0,S=this.getters.getCellText(a,c),C=this.getters.getTextWidth(a),E=this.getters.getCellStyle(a).wrapping||"overflow",w="wrap"===E?this.getters.getCellMultiLineText(a,u-2*L):[S],y=v+C+b,x=this.computeCellAlignment(a,y>u);p.content={multiLineText:w,width:"overflow"===E?C:u,align:x},a.evaluated.type===Zo.error&&a.evaluated.error.logLevel>l.silent&&(p.error=a.evaluated.error.message);const R=y>u||m>g;if(f||p.isFilterHeader)p.clipRect={x:p.x+v,y:p.y,width:Math.max(0,u-v-b),height:g};else if(R&&"overflow"===E){let o,a;switch(this.getters.isInMerge(e,r,s)?(o=this.getters.getMerge(e,r,s).right,a=r):(o=this.findNextEmptyCol(r,i,s),a=this.findPreviousEmptyCol(r,n,s)),x){case"left":{const e=Po({col:o,row:s}),{x:n,y:i,width:r,height:a}=this.getters.getVisibleRect(xo(t,e));(r<C||m>a)&&(p.clipRect={x:n,y:i,width:r,height:a});break}case"right":{const e=Po({col:a,row:s}),{x:o,y:n,width:i,height:r}=this.getters.getVisibleRect(xo(t,e));(i<C||m>r)&&(p.clipRect={x:o,y:n,width:i,height:r});break}case"center":{const e={...t,right:o,left:a},{x:n,y:i,width:s,height:l}=this.getters.getVisibleRect(e);(s<C||a===r||o===r||m>l)&&(p.clipRect={x:n,y:i,width:s,height:l});break}}}else"clip"!==E&&"wrap"!==E||(p.clipRect={x:p.x,y:p.y,width:u,height:g});return p}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),o=t[0],n=t[t.length-1],i=this.getters.getSheetViewVisibleRows(),r={left:o,right:n,top:i[0],bottom:i[i.length-1]},s=this.getters.getActiveSheetId();for(const o of i)for(const n of t)this.getters.isInMerge(s,n,o)||e.push(this.createZoneBox(s,Po({col:n,row:o}),r));for(const t of this.getters.getMerges(s))if(!this.getters.isMergeHidden(s,t)&&To(t,r)){const o=this.createZoneBox(s,t,r),n=this.getters.getCellBorder(s,t.right,t.bottom);o.border={...o.border,bottom:n?n.bottom:void 0,right:n?n.right:void 0},o.isMerge=!0,e.push(o)}return e}}gv.layers=[0,7],gv.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];const pv=[{name:r("Sum"),types:[Zo.number],compute:e=>za.compute([e])},{name:r("Avg"),types:[Zo.number],compute:e=>Qa.compute([e])},{name:r("Min"),types:[Zo.number],compute:e=>fl.compute([e])},{name:r("Max"),types:[Zo.number],compute:e=>dl.compute([e])},{name:r("Count"),types:[Zo.number,Zo.text,Zo.boolean,Zo.error],compute:e=>sl.compute([e])},{name:r("Count Numbers"),types:[Zo.number,Zo.text,Zo.boolean,Zo.error],compute:e=>rl.compute([e])}];class fv extends fg{constructor(e,t,o,n,i){super(e,t,o,n,i),this.gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]},this.selectedFigureId=null,this.sheetsData={},this.activeSheet=null,this.moveClient=n.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 27}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const n=o.findIndex((t=>Io(t,e.previousAnchor.zone)));n>=0&&(o[n]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Ie(this.gridSelection.anchor));const{col:n,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:n,row:i}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:o,row:n}=this.getters.getNextVisibleCellPosition(t,0,0);this.selectCell(o,n),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:Ie(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Ie(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0);this.selectCell(t,o)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:n})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:n})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const i=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of i)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Ie(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}const r=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(r,e))),this.gridSelection.anchor.zone=this.getters.expandZone(r,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Ie(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){const e=this.getters.getActiveSheetId(),{col:t,row:o}=this.gridSelection.anchor.cell,{col:n,row:i}=this.getters.getMainCellPosition(e,t,o);return this.getters.getCell(e,n,i)}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getActiveCell();return e?this.getters.getCellStyle(e):{}}getSelectedZones(){return Ie(this.gridSelection.zones)}getSelectedZone(){return Ie(this.gridSelection.anchor.zone)}getSelection(){return Ie(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getPosition(){return{col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row}}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getPosition();{const t=this.sheetsData[e];return t?{col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition(e,0,0)}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>void 0!==e)));let t=new Set,o=[];for(let n of e)t.add(n.evaluated.type),o.push(n.evaluated.value);let n={};for(let e of pv){let i;e.types.some((e=>t.has(e)))&&(i=e.compute(o)),n[e.name]=i}return n}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),n=this.gridSelection.zones.map(Do).flat();for(const{col:i,row:r}of n){const n=this.getters.getCell(o,i,r);(null==n?void 0:n.evaluated.type)===Zo.number&&(t++,e+=n.evaluated.value)}return t<2?null:Vt(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Io(t,e)))}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let o=[];const n="COL"===e?"left":"top",i="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[i]-e[n]+1},((t,o)=>e[n]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:n}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(n)}selectCell(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:n,cell:{col:e,row:t}},[n])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,n=wo(o,"left",[...e.elements]);let i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=wo(i,"left",[...e.elements]);const r={cell:{col:i.left,row:i.top},zone:n};this.setSelectionMixin(r,[n])}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,n=wo(o,"top",[...e.elements]);let i={left:t.col,right:t.col,top:t.row,bottom:t.row};i=wo(i,"top",[...e.elements]);const r={cell:{col:i.left,row:i.top},zone:n};this.setSelectionMixin(r,[n])}onAddElements(e){const t=Eo(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(o,[t])}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const o="COL"===e.dimension,n=e.elements[0],i=e.elements[t-1],r=e.base<n,s=r&&o?t:0,a=r&&!o?t:0;this.dispatch("CUT",{target:[{left:o?n+s:0,right:o?i+s:this.getters.getNumberCols(e.sheetId)-1,top:o?0:n+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:i+a}]}),this.dispatch("PASTE",{target:[{left:o?e.base:0,right:o?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:e.base,bottom:o?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=r?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const o="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:o,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],n=e.elements[e.elements.length-1],i=e.sheetId,r=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return r(i,o-1,o)||r(i,n,n+1)||r(i,e.base-1,e.base)?2:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,n=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:Oe(e.left,0,o),right:Oe(e.right,0,o),top:Oe(e.top,0,n),bottom:Oe(e.bottom,0,n)}))),anchor:{cell:{col:Oe(t.anchor.cell.col,0,o),row:Oe(t.anchor.cell.row,0,n)},zone:{left:Oe(t.anchor.zone.left,0,o),right:Oe(t.anchor.zone.right,0,o),top:Oe(t.anchor.zone.top,0,n),bottom:Oe(t.anchor.zone.bottom,0,n)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,n=this.getSelectedZones();t.fillStyle="#f3f7fe";const i=1===n.length&&n[0].left===n[0].right&&n[0].top===n[0].bottom;t.fillStyle=i?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o,t.globalCompositeOperation="multiply";for(const e of n){const{x:o,y:n,width:i,height:r}=this.getters.getVisibleRect(e);t.fillRect(o,n,i,r),t.strokeRect(o,n,i,r)}t.globalCompositeOperation="source-over";const r=this.getters.getActiveSheetId(),{col:s,row:a}=this.getPosition();let l;t.strokeStyle=E,t.lineWidth=3*o,l=this.getters.isInMerge(r,s,a)?this.getters.getMerge(r,s,a):{top:a,bottom:a,left:s,right:s};const{x:c,y:h,width:d,height:u}=this.getters.getVisibleRect(l);d>0&&u>0&&t.strokeRect(c,h,d,u)}}fv.layers=[5],fv.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getPosition","getSheetPosition","isSelected","getElementsFromSelection"];const mv=new fo;class vv extends fg{constructor(e,t,o,n,i,r,s){super(e,t,o,n,i),this.inputHasSingleRange=s,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,r),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){if("ADD_EMPTY_RANGE"===e.type)if(this.inputHasSingleRange&&1===this.ranges.length)return 29;return 0}handleEvent(e){const t=So(e.anchor.zone),o=this.activeSheet,n=this.getters.getActiveSheetId(),i=this.getters.getSheetName(n);this.add([n===o?t:`${Ae(i)}!${t}`])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const o=e.value.split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition(e.sheetIdTo,0,0),n=this.getters.expandZone(e.sheetIdTo,Po({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:n})}}}unsubscribe(){this.unfocus()}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],id:mv.uuidv4(),xc:t}}insertNewRange(e,t){this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:(this.ranges.length+t+1).toString(),color:(st=++st%it.length,it[st])}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=It(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:o}=It(t),n=this.getters.getSheetIdByName(o),i=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(n===i||void 0===n&&i===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}vv.layers=[1],vv.getters=[];class bv extends fg{constructor(e,t,o,n,i){super(e,t,o,n,i),this.state=t,this.config=n,this.inputs={},this.focusedInputId=null}get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}allowDispatch(e){var t,o;if("FOCUS_RANGE"===e.type){const n=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(o=this.currentInput)||void 0===o?void 0:o.focusedRangeIndex)===n)return 28}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){var t;switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:Po({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}unsubscribe(){this.unfocus()}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,o)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=It(e);return null!==t.match(Et)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]=new vv(this.getters,this.state,this.dispatch,this.config,this.selection,t,o),0===t.length){const t=this.inputs[e],o={zone:Po({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}bv.layers=[1],bv.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class Sv{constructor(){this.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,n=o.length;e<n;e++){const n=o[e];n.callback.call(n.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function Cv(e,t){return{...e,definition:pr(e.definition,t)}}function Ev(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}$i.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Cv),$i.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Cv),$i.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)return;return e})),$i.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),$i.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var o;if(e.name===t.name)return{...e,name:(null===(o=e.name)||void 0===o?void 0:o.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),$i.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const n of e.target)for(const e of t.target)To(n,e)||o.push({...n});if(o.length)return{...e,target:o};return})),$i.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Ev),$i.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Ev),$i.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(To(e,o))return;return e}));const wv=[{match:function(e){return"sheetId"in e},fn:Rv},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=Rv(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const n=[];for(const o of e.target){const e=Hi(o,t);e&&n.push(e)}if(!n.length)return"IGNORE_COMMAND";return{...e,target:n}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=Rv(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let n=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(n))return"IGNORE_COMMAND";for(let t of e)n>=t&&n--}"ADD_COLUMNS_ROWS"===t.type&&(n>t.base||n===t.base&&"before"===t.position)&&(n+=t.quantity);return{...e,[o]:n}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&Ao(e.col,e.row,o))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const o=Rv(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,n=o?"base":"elements";let i=o?[e[n]]:e[n];if("REMOVE_COLUMNS_ROWS"===t.type&&(i=i.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(Ze)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;i=i.map((o=>o>e?o+t.quantity:o))}if(i.length){let t=i;return o&&(t=i[0]),{...e,[n]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const o=[],n="DELETE_SHEET"===t.type&&t.sheetId;for(const i of e.ranges)if(i._sheetId!==t.sheetId)o.push({...i,_zone:i._zone});else{const e=Hi(i._zone,t);e&&n!==i._sheetId&&o.push({...i,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function yv(e,t){const o=$i.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:n}of wv)if(o(e)){const o=n(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function xv(e,t){let o=[...e];for(const e of t)o=o.map((t=>yv(t,e))).filter(Ze);return o}function Rv(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class Iv{constructor(e,t,o,n){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...o],this._changes=n?[...n]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Tv extends Error{}class Av extends Sv{constructor(e,t,o=Y){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new fo,this.debouncedMove=function(e,t,o){let n;return function(){const i=this,r=arguments,s=o&&!n;clearTimeout(n),n=setTimeout((function(){n=null,o||e.apply(i,r)}),t),s&&e.apply(i,r)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const o=new Iv(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(o.id,o),this.trigger("new-local-state-update",{id:o.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:o.id,clientId:o.clientId,commands:o.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0,this.on("unexpected-revision-id",this,(({revisionId:e})=>{throw new Error(`The spreadsheet could not be loaded. Revision ${e} is corrupted.`)}));for(const t of e)this.onMessageReceived(t);this.off("unexpected-revision-id",this),this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new Tv("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(Ze))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const o=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==o?void 0:o.col)===e.col&&o.row===e.row&&o.sheetId===e.sheetId)return;const n=o?"CLIENT_MOVED":"CLIENT_JOINED",i=this.getClient();this.clients[this.clientId]={...i,position:e},this.transportService.sendMessage({type:n,version:1,client:{...i,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e)){switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":if(e.serverRevisionId!==this.serverRevisionId)return void this.trigger("unexpected-revision-id",{revisionId:e.serverRevisionId});const{clientId:t,commands:o}=e,n=new Iv(e.nextRevisionId,t,o);if(n.clientId!==this.clientId){this.revisions.insert(n.id,n,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:xv(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new Iv(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Ov=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Mv extends fg{constructor(){super(...arguments),this.availableColors=new Set(Ov),this.colors={}}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Ov));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof Tv)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const n=this.colors[o.id];t.push({...o,position:e,color:n})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,n=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:i,col:r}=e.position,s=this.getters.expandZone(n,{top:i,bottom:i,left:r,right:r}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(s);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*o,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${W+1}px ${G}`}}}Mv.getters=["getClientsToDisplay"],Mv.layers=[5];class Nv{constructor(e,t,o,n,i,r){this.getters=e,this.sheetId=t,this.boundaries=o,this.width=n.width,this.height=n.height,this.offsetScrollbarX=r.x,this.offsetScrollbarY=r.y,this.canScrollVertically=i.canScrollVertically,this.canScrollHorizontally=i.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const e=this.getters.findLastVisibleColRowIndex(this.sheetId,"COL",{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,"ROW",{first:this.boundaries.top,last:this.boundaries.bottom}),{end:o,size:n}=this.getters.getColDimensions(this.sheetId,e),{end:i,size:r}=this.getters.getRowDimensions(this.sheetId,t),s=this.searchHeaderIndex("COL",o-this.width,0),a=this.getters.getColSize(this.sheetId,s),l=this.searchHeaderIndex("ROW",i-this.height,0),c=this.getters.getRowSize(this.sheetId,l);return{width:o-this.offsetCorrectionX+(this.canScrollHorizontally?Math.max(N,Math.min(a,this.width-n)):0),height:i-this.offsetCorrectionY+(this.canScrollVertically?Math.max(_+5,Math.min(c,this.height-r)):0)}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.width?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.height?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const o=this.getters.getMainCellPosition(t,e.col,e.row),{col:n,row:i}=this.getters.getNextVisibleCellPosition(t,o.col,o.row);Ao(n,this.boundaries.top,this.boundaries)&&this.adjustPositionX(n),Ao(this.boundaries.left,i,this.boundaries)&&this.adjustPositionY(i)}adjustPositionX(e){const t=this.sheetId,{start:o,end:n}=this.getters.getColDimensions(t,e);for(;n>this.offsetX+this.offsetCorrectionX+this.width&&this.offsetX+this.offsetCorrectionX<o;)this.offsetX=this.getters.getColDimensions(t,this.left).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX();for(;e<this.left;){let e;for(e=this.left;e>=0&&this.getters.isColHidden(t,e);e--);this.offsetX=this.getters.getColDimensions(t,e-1).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId;for(;this.getters.getRowDimensions(t,e).end>this.offsetY+this.height+this.offsetCorrectionY&&this.offsetY+this.offsetCorrectionY<this.getters.getRowDimensions(t,e).start;)this.offsetY=this.getters.getRowDimensions(t,this.top).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY();for(;e<this.top;){let e;for(e=this.top;e>=0&&this.getters.isRowHidden(t,e);e--);this.offsetY=this.getters.getRowDimensions(t,e-1).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=Ro(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.width),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.height)}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,o=0,n=!1){let i=0;const r=this.sheetId,s=this.getters.getNumberHeaders(r,e);for(let a=o;a<=s-1;a++){const o=n||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(r,e,a)&&!o&&(i+="COL"===e?this.getters.getColSize(r,a):this.getters.getRowSize(r,a),i>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.width+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.width))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.width,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.height+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.height))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.width,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.width,this.left)),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.height,this.top)),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}class _v extends fg{constructor(){super(...arguments),this.viewports={},this.sheetViewWidth=1e3,this.sheetViewHeight=1e3,this.gridOffsetX=0,this.gridOffsetY=0,this.sheetsWithDirtyViewports=new Set}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){switch(e.type){case"HeadersSelected":case"AlterZoneCorner":break;case"ZonesSelected":let{col:t,row:o}=$o(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const n=e.previousAnchor.zone,i=e.anchor.zone,{top:r,bottom:s,left:a,right:l}=this.getters.getActiveMainViewport();n.left===i.left&&n.right===i.right&&(t=a>t||t>l?a:t),n.top===i.top&&n.bottom===i.bottom&&(o=r>o||o>s?r:o)}const n=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(n)-1),o=Math.min(o,this.getters.getNumberRows(n)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:o})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:o}=this.getActiveMainViewport(),n=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(n,o).start+this.sheetViewHeight);this.shiftVertically(i);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),o=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(o);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"START_EDITION":const{col:r,row:s}=this.getters.getPosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:r,row:s})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){var e;const t=this.getters.getSheetIds();for(const o of t)(null===(e=this.viewports[o])||void 0===e?void 0:e.bottomRight)||this.resetViewports(o)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Fe(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>Fe(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:o,ySplit:n}=this.getters.getPaneDivisions(e);let{width:i,height:r}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,n).start,width:i,height:r}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),n=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-n.width+1),maxOffsetY:Math.max(0,o-n.height+1)}}getColRowOffsetInViewport(e,t,o){const n=this.getters.getActiveSheetId(),i=this.getters.getSheetViewVisibleCols(),r=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let s=0;const a="COL"===e?i:r;for(let i=t;i<o;i++)a.includes(i)&&(s+="COL"===e?this.getters.getColSize(n,i):this.getters.getRowSize(n,i));return s}isVisibleInViewport(e,t,o){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let n=!1,i=0,r=0;const{xSplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(n=!0,r=Dt(e-a),i=1):e<l&&o>=l&&c>0?(n=!0,r=Dt(l-e),i=-1):s&&t<l&&e>l&&(n=!0,r=Dt(e),i="reset"),{canEdgeScroll:n,direction:i,delay:r}}getEdgeScrollRow(e,t,o){let n=!1,i=0,r=0;const{ySplit:s}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(n=!0,r=Dt(e-a),i=1):e<l&&o>=l&&c>0?(n=!0,r=Dt(l-e),i=-1):s&&t<l&&e>l&&(n=!0,r=Dt(e),i="reset"),{canEdgeScroll:n,direction:i,delay:r}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(Ze);if(0===o.length)return{x:0,y:0,width:0,height:0};const n=Math.min(...o.map((e=>e.x))),i=Math.min(...o.map((e=>e.y))),r=Math.max(...o.map((e=>e.x+e.width)))-n,s=Math.max(...o.map((e=>e.y+e.height)))-i;return{x:n+this.gridOffsetX,y:i+this.gridOffsetY,width:r,height:s}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(Ze)}checkPositiveDimension(e){return e.width<0||e.height<0?67:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?75:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.canScrollVertically&&t>0?68:0}getMainViewport(e){const t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,n=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=n,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:n,maxOffsetY:i}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(Oe(e,0,n),Oe(t,0,i))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),o=t-this.sheetViewHeight;return e=Math.min(e,o),e=Math.max(e,0)}getViewportOffset(e){var t,o;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(o=this.viewports[e])||void 0===o?void 0:o.bottomRight.offsetScrollbarY)||0}}resetViewports(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),n=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),r=this.getters.getColRowOffset("COL",0,t,e),s=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new Nv(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:r,height:s},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new Nv(this.getters,e,{left:t,right:n-1,top:0,bottom:o-1},{width:this.sheetViewWidth-r,height:s},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Nv(this.getters,e,{left:0,right:t-1,top:o,bottom:i-1},{width:r,height:this.sheetViewHeight-s},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Nv(this.getters,e,{left:t,right:n-1,top:o,bottom:i-1},{width:this.sheetViewWidth-r,height:this.sheetViewHeight-s},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:o}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(o,e);const{anchor:n}=this.getters.getSelection(),i=this.getActiveMainViewport().top-t;this.selection.selectCell(n.cell.col,n.cell.row+i)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:n,scrollY:i}=this.getActiveSheetScrollInfo(),{x:r,y:s}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=r&&(e.x+e.width<=r+n||e.x>=a+n+r)||e.y>=s&&(e.y+e.height<=s+i||e.y>=l+i+s)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),n=this.getters.getColDimensions(e,t).start,i=this.getters.getRowDimensions(e,o).start;return{xRatio:n/(this.sheetViewWidth+this.gridOffsetX),yRatio:i/(this.sheetViewHeight+this.gridOffsetY)}}}_v.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class Fv extends fg{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Ao(e.col,e.row,e.zone))throw new Error(r("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++)if(!this.getters.isInMerge(e,n,o))return 62;return 0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>To(e,t))),n=_o(o[0]);let[i,r]=[n.width,n.height];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===i&&o===r}))?0:62}expand(e,t){const{left:o,right:n,top:i,bottom:r}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,n),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(e)-1,r)}}checkExpandedValues(e,t){const o=this.expand(e,t);let n;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:i,top:r,bottom:s}=o;for(let o=t;o<=i;o++)for(let t=r;t<=s;t++){const{col:i,row:r}=this.getters.getMainCellPosition(e,o,t);if(n=this.getters.getCell(e,i,r),null==n?void 0:n.formattedValue)return!0}}else for(let t of this.getters.getCellsInZone(e,o))if(null==t?void 0:t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:n,bottom:i,left:r,right:s}=t,a=!1;for(;!a;)a=!0,n>0&&(o=this.checkExpandedValues(e,{left:r-1,right:s+1,top:n-1,bottom:n-1}),o&&(a=!1,n--)),r>0&&(o=this.checkExpandedValues(e,{left:r-1,right:r-1,top:n-1,bottom:i+1}),o&&(a=!1,r--)),s<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:s+1,right:s+1,top:n-1,bottom:i+1}),o&&(a=!1,s++)),i<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:r-1,right:s+1,top:i+1,bottom:i+1}),o&&(a=!1,i++));return{left:r,right:s,top:n,bottom:i}}hasHeader(e){if(1===e[0].length)return!1;let t=e.map((e=>e.map((e=>(null==e?void 0:e.evaluated.type)||Zo.empty))));return t[0][0]===Zo.empty&&(t=t.slice(1)),!t.some((e=>e[0]===Zo.empty))&&!!t.some((e=>e[1]!==Zo.empty&&e[0]!==e[1]))}sortZone(e,t,o,n,i){const[r,s]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition(e,t.col,t.row).col,l=Object.assign({},o),c=this.mainCells(e,o);!i.sortHeaders&&this.hasHeader(c)&&(l.top+=s),c=this.mainCells(e,l);const h=function(e,t,o){const n=e.map(Un);let i=n.filter((e=>e.type===Zo.empty)),r=n.filter((e=>e.type!==Zo.empty));o&&(r.push(...i.map((e=>({...e,type:Zo.number,value:0})))),i=[]);const s="descending"===t?-1:1;return r.sort(((e,t)=>{let o=Pn.indexOf(e.type)-Pn.indexOf(t.type);return 0===o&&(o=e.type===Zo.text||e.type===Zo.error?e.value.localeCompare(t.value):e.value-t.value),s*o})).concat(i)}(c[a-l.left],n,Boolean(i.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length];for(let t=0;t<u;t++)for(let o=0;o<g;o++){let n=c[t][d[o]],i=l.left+t*r,a=l.top+o*s,h={sheetId:e,col:i,row:a,content:"",value:""};if(n){let t=n.content;if(n.isFormula()){const o=a-this.getters.getCellPosition(n.id).row,i=this.getters.createAdaptedRanges(n.dependencies,0,o,e);t=this.getters.buildFormulaContent(e,n,i)}h.style=n.style,h.content=t,h.format=n.format,h.value=n.evaluated.value}this.dispatch("UPDATE_CELL",h)}}mainCellsSteps(e,t){const o=this.getters.getMerge(e,t.left,t.top);return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,n]=this.mainCellsSteps(e,t),i=[],r=Fe(t.left,t.right+1,o),s=Fe(t.top,t.bottom+1,n);for(const t of r){const o=[];i.push(o);for(const n of s)o.push(this.getters.getCell(e,t,n))}return i}}Fv.getters=["getContiguousZone"];class Dv extends fg{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Dv.getters=["shouldShowFormulas"];class kv extends fg{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e,{col:t,row:o}){const n=this.getters.getCell(e,t,o);let i=0;n&&(i+=this.getTextWidth(n));this.getters.getConditionalIcon(t,o)&&(i+=_e(this.getters.getCellStyle(n))+2*$);if(this.getters.isFilterHeader(e,t,o)&&(i+=20),i>0&&(i+=2*U,"wrap"===this.getters.getCellStyle(n).wrapping)){const e=Po({col:t,row:o}),n=this.getters.getColSize(this.getters.getActiveSheetId(),e.left);return Math.min(n,i)}return i}getTextWidth(e){const t=this.getters.getCellText(e,this.getters.shouldShowFormulas()),{sheetId:o,col:n,row:i}=this.getters.getCellPosition(e.id);return Me(this.ctx,t,this.getters.getCellComputedStyle(o,n,i))}getCellText(e,t=!1){return t&&(e.isFormula()||e.evaluated.type===Zo.error)?e.content:e.formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),n=this.getters.getCellText(e).split(" "),i=[];let r="",s=t;for(let e of n){const n=this.splitWordToSpecificWidth(this.ctx,e,t,o),a=n.pop(),l=Me(this.ctx,a,o);if(n.length)""!==r&&(i.push(r),r="",s=t),n.forEach((e=>{i.push(e)})),r=a,s=t-l;else{const e=""===r?a:" "+a,n=Me(this.ctx,e,o);n<=s?(r+=e,s-=n):(i.push(r),r=a,s=t-l)}}return""!==r&&i.push(r),i}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getColRowOffset(e,t,o,n=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let i=0;for(let r=t;r<o;r++)this.getters.isHeaderHidden(n,e,r)||(i+="COL"===e?this.getters.getColSize(n,r):this.getters.getRowSize(n,r));return i}getColMaxWidth(e,t){const o=Do(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth(e,t)));return Math.max(0,...o)}splitWordToSpecificWidth(e,t,o,n){if(Me(e,t,n)<=o)return[t];const i=[];let r="";for(let s of t){Me(e,r+s,n)>o?(i.push(r),r=s):r+=s}return i.push(r),i}}kv.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];const $v=(new Bo).add("sheet",qm).add("header visibility",Bm).add("filters",Vm).add("cell",Fm).add("merge",Hm).add("headerSize",zm).add("borders",Nm).add("conditional formatting",$m).add("figures",Lm).add("chart",Dm),Lv=(new Bo).add("selection",fv).add("ui_sheet",kv).add("header_visibility_ui",dv).add("ui_options",Dv).add("evaluation",iv).add("evaluation_filter",av).add("evaluation_cf",sv).add("evaluation_chart",rv).add("clipboard",tv).add("edition",vg).add("selectionInputManager",bv).add("highlight",uv).add("viewport",_v).add("grid renderer",gv).add("autofill",jm).add("find_and_replace",cv).add("sort",Fv).add("automatic_sum",Xm).add("format",hv).add("cell_popovers",Ym).add("selection_multiuser",Mv).add("custom_colors",ov),Pv=new Bo;Pv.add("link",{condition:e=>e.isLink(),action:(e,t)=>{e.action(t)},sequence:5}),an`
1367
1367
  .o-spreadsheet-bottom-bar {
1368
1368
  background-color: ${m};
1369
1369
  padding-left: ${M}px;
@@ -1452,12 +1452,12 @@
1452
1452
  opacity: 0;
1453
1453
  }
1454
1454
  }
1455
- `;class Pv extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.selectedStatisticFn=""}setup(){t.onMounted((()=>this.focusSheet())),t.onPatched((()=>this.focusSheet()))}focusSheet(){const e=this.bottomBarRef.el.querySelector(`[data-id="${this.env.model.getters.getActiveSheetId()}"]`);e&&e.scrollIntoView&&e.scrollIntoView()}addSheet(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSheetIds().findIndex((t=>t===e))+1,o=this.env.model.uuidGenerator.uuidv4(),n=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:o,position:t,name:n}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:o})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>this.env.model.getters.getSheet(e)))}listSheets(e){const t=new Tn,o=this.env.model.getters.getActiveSheetId();let n=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:n,isReadonlyAllowed:!0,textColor:i.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})}}),n++}const i=e.currentTarget,{top:r,left:s}=i.getBoundingClientRect();this.openContextMenu(s,r,t)}activateSheet(e){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:e})}onDblClick(e){Ri(this.env,e)}openContextMenu(e,t,o,n){this.menuState.isOpen=!0,this.menuState.menuItems=o.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position={x:e,y:t},this.menuState.menuId=n}onIconClick(e,t){if(this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e),t.closedMenuId===e)this.menuState.isOpen=!1,this.menuState.menuId=void 0;else{const o=t.currentTarget.parentElement,{top:n,left:i}=o.getBoundingClientRect();this.openContextMenu(i,n,Ii,e)}}onContextMenu(e,t){this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e);const o=t.currentTarget,{top:n,left:i}=o.getBoundingClientRect();this.openContextMenu(i,n,Ii,e)}getSelectedStatistic(){const e=this.env.model.getters.getStatisticFnResults();if(!Object.values(e).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(e)[0]),this.getComposedFnName(this.selectedStatisticFn,e[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new Tn;let o=0;for(let[e,n]of Object.entries(this.env.model.getters.getStatisticFnResults()))t.add(e,{name:this.getComposedFnName(e,n),sequence:o,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),o++;const n=e.currentTarget,{top:i,left:r,width:s}=n.getBoundingClientRect();this.openContextMenu(r+s,i,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?Ut(t):"__")}}Pv.template="o-spreadsheet-BottomBar",Pv.components={Menu:En},sn`
1455
+ `;class Uv extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.selectedStatisticFn=""}setup(){t.onMounted((()=>this.focusSheet())),t.onPatched((()=>this.focusSheet()))}focusSheet(){const e=this.bottomBarRef.el.querySelector(`[data-id="${this.env.model.getters.getActiveSheetId()}"]`);e&&e.scrollIntoView&&e.scrollIntoView()}addSheet(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSheetIds().findIndex((t=>t===e))+1,o=this.env.model.uuidGenerator.uuidv4(),n=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:o,position:t,name:n}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:o})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>this.env.model.getters.getSheet(e)))}listSheets(e){const t=new An,o=this.env.model.getters.getActiveSheetId();let n=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:n,isReadonlyAllowed:!0,textColor:i.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})}}),n++}const i=e.currentTarget,{top:r,left:s}=i.getBoundingClientRect();this.openContextMenu(s,r,t)}activateSheet(e){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:e})}onDblClick(e){Ii(this.env,e)}openContextMenu(e,t,o,n){this.menuState.isOpen=!0,this.menuState.menuItems=o.getAll().filter((e=>e.isVisible(this.env))),this.menuState.position={x:e,y:t},this.menuState.menuId=n}onIconClick(e,t){if(this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e),t.closedMenuId===e)this.menuState.isOpen=!1,this.menuState.menuId=void 0;else{const o=t.currentTarget.parentElement,{top:n,left:i}=o.getBoundingClientRect();this.openContextMenu(i,n,Ti,e)}}onContextMenu(e,t){this.env.model.getters.getActiveSheetId()!==e&&this.activateSheet(e);const o=t.currentTarget,{top:n,left:i}=o.getBoundingClientRect();this.openContextMenu(i,n,Ti,e)}getSelectedStatistic(){const e=this.env.model.getters.getStatisticFnResults();if(!Object.values(e).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(e)[0]),this.getComposedFnName(this.selectedStatisticFn,e[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new An;let o=0;for(let[e,n]of Object.entries(this.env.model.getters.getStatisticFnResults()))t.add(e,{name:this.getComposedFnName(e,n),sequence:o,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),o++;const n=e.currentTarget,{top:i,left:r,width:s}=n.getBoundingClientRect();this.openContextMenu(r+s,i,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?Vt(t):"__")}}Uv.template="o-spreadsheet-BottomBar",Uv.components={Menu:wn},an`
1456
1456
  .o-dashboard-clickable-cell {
1457
1457
  position: absolute;
1458
1458
  cursor: pointer;
1459
1459
  }
1460
- `;class Uv extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=Sn(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),Wg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=Gg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:o}=this.env.model.getters.getColDimensions(e,t);return`\n max-width: ${o}px;\n `}get gridOverlayDimensions(){return"\n height: 100%;\n width: 100%\n "}getCellClickableStyle(e){return`\n top: ${e.y}px;\n left: ${e.x}px;\n width: ${e.width}px;\n height: ${e.height}px;\n `}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const o of this.env.model.getters.getSheetViewVisibleCols())for(const n of this.env.model.getters.getSheetViewVisibleRows()){const i=this.env.model.getters.getCell(t,o,n);if(i){const r=this.getClickableAction(i);if(!r)continue;let s;s=this.env.model.getters.isInMerge(t,o,n)?this.env.model.getters.getMerge(t,o,n):Lo({col:o,row:n});const a=this.env.model.getters.getVisibleRect(s);e.push({coordinates:a,cell:i,action:r})}}return e}getClickableAction(e){for(const t of Lv.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{cell:t,action:o}=e;o(t,this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:o,scrollY:n}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:n+t})}}Uv.template="o-spreadsheet-SpreadsheetDashboard",Uv.components={GridOverlay:Pg,GridPopover:Ug,Popover:Cn,VerticalScrollBar:Qg,HorizontalScrollBar:Kg,FilterIconsOverlay:Dg},sn`
1460
+ `;class Vv extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=Cn(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),Gg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=qg(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:o}=this.env.model.getters.getColDimensions(e,t);return`\n max-width: ${o}px;\n `}get gridOverlayDimensions(){return"\n height: 100%;\n width: 100%\n "}getCellClickableStyle(e){return`\n top: ${e.y}px;\n left: ${e.x}px;\n width: ${e.width}px;\n height: ${e.height}px;\n `}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const o of this.env.model.getters.getSheetViewVisibleCols())for(const n of this.env.model.getters.getSheetViewVisibleRows()){const i=this.env.model.getters.getCell(t,o,n);if(i){const r=this.getClickableAction(i);if(!r)continue;let s;s=this.env.model.getters.isInMerge(t,o,n)?this.env.model.getters.getMerge(t,o,n):Po({col:o,row:n});const a=this.env.model.getters.getVisibleRect(s);e.push({coordinates:a,cell:i,action:r})}}return e}getClickableAction(e){for(const t of Pv.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{cell:t,action:o}=e;o(t,this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:o,scrollY:n}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:n+t})}}Vv.template="o-spreadsheet-SpreadsheetDashboard",Vv.components={GridOverlay:Ug,GridPopover:Vg,Popover:En,VerticalScrollBar:Jg,HorizontalScrollBar:Qg,FilterIconsOverlay:kg},an`
1461
1461
  .o-sidePanel {
1462
1462
  display: flex;
1463
1463
  flex-direction: column;
@@ -1696,7 +1696,7 @@
1696
1696
  }
1697
1697
  }
1698
1698
  }
1699
- `;class Vv extends t.Component{setup(){this.state=t.useState({panel:Jr.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=Jr.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}Vv.template="o-spreadsheet-SidePanel";const zv={MergeIsDestructive:r("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:r("You can't merge cells inside of an existing filter.")};const Bv=[{name:"automatic",text:Mi.Automatic},{name:"number",text:Mi.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:Mi.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:Mi.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:Mi.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:Mi.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:Mi.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:Mi.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:Mi.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],Hv=[{name:"custom_currency",text:Mi.CustomCurrency,sidePanel:"CustomCurrency"}];sn`
1699
+ `;class zv extends t.Component{setup(){this.state=t.useState({panel:es.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=es.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}zv.template="o-spreadsheet-SidePanel";const Bv={MergeIsDestructive:r("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:r("You can't merge cells inside of an existing filter.")};const Hv=[{name:"automatic",text:Ni.Automatic},{name:"number",text:Ni.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:Ni.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:Ni.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:Ni.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:Ni.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:Ni.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:Ni.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:Ni.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],Wv=[{name:"custom_currency",text:Ni.CustomCurrency,sidePanel:"CustomCurrency"}];an`
1700
1700
  .o-spreadsheet-topbar {
1701
1701
  background-color: white;
1702
1702
  line-height: 1.2;
@@ -1890,7 +1890,7 @@
1890
1890
  }
1891
1891
  }
1892
1892
  }
1893
- `;class Wv extends t.Component{constructor(){super(...arguments),this.DEFAULT_FONT_SIZE=W,this.commonFormats=Bv,this.customFormats=Hv,this.currentFormatName="automatic",this.fontSizes=ie,this.style={},this.state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:""}),this.isSelectingMenu=!1,this.openedEl=null,this.inMerge=!1,this.cannotMerge=!1,this.undoTool=!1,this.redoTool=!1,this.paintFormatTool=!1,this.fillColor="#ffffff",this.textColor="#000000",this.menus=[],this.composerStyle="\n line-height: 34px;\n padding-left: 8px;\n height: 34px;\n background-color: white;\n "}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return es.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onClick(e){this.openedEl&&vn(this.openedEl,e)||this.closeMenus()}toogleStyle(e){Yn(this.env,{[e]:!this.style[e]})}toogleFormat(e){const t=Bv.find((t=>t.name===e)),o=t&&t.value||"";Xn(this.env,o)}toggleAlign(e){Yn(this.env,{align:e})}onMenuMouseOver(e,t){this.isSelectingMenu&&this.toggleContextMenu(e,t)}toggleDropdownTool(e,t){const o=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=o?"":e,this.openedEl=o?null:t.target}toggleContextMenu(e,t){this.closeMenus();const{left:o,top:n,height:i}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:o,y:n+i},this.state.menuState.menuItems=fn(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId();this.inMerge=!1;const{top:o,left:n,right:i,bottom:r}=this.env.model.getters.getSelectedZone(),{xSplit:s,ySplit:a}=this.env.model.getters.getPaneDivisions(t);if(this.cannotMerge=e.length>1||o===r&&n===i||n<s&&s<=i||o<a&&a<=r,!this.cannotMerge){const{col:o,row:n}=this.env.model.getters.getPosition(),i=this.env.model.getters.expandZone(t,{left:o,right:o,top:n,bottom:n});this.inMerge=Ro(e[0],i)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const l=this.env.model.getters.getActiveCell();if(l&&l.format){const e=this.commonFormats.find((e=>e.value===l.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||(null==l?void 0:l.defaultAlign),this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=Di.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}getMenuName(e){return mn(e,this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],o=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:o,target:t}):function(e,t,o){const n=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});n.isCancelledBecause(79)?e.raiseError(zv.MergeInFilter):n.isCancelledBecause(3)&&e.askConfirmation(zv.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(this.env,o,t)}setColor(e,t){Yn(this.env,{[e]:t})}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e})}setFormat(e){const t=e.target.dataset.format;if(t)return void this.toogleFormat(t);const o=e.target.dataset.custom;o&&this.openCustomFormatSidePanel(o)}openCustomFormatSidePanel(e){const t=Hv.find((t=>t.name===e)),o=t&&t.sidePanel||"";this.env.openSidePanel(o)}setDecimal(e){this.env.model.dispatch("SET_DECIMAL",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),step:e})}paintFormat(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.env.model.getters.getSelectedZones()})}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setSize(e){const t=parseFloat(e.target.dataset.size);Yn(this.env,{fontSize:t})}doAction(e){e(this.env),this.closeMenus()}undo(){this.env.model.dispatch("REQUEST_UNDO")}redo(){this.env.model.dispatch("REQUEST_REDO")}get selectionContainsFilter(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();return this.env.model.getters.doesZonesContainFilter(e,t)}get cannotCreateFilter(){return!Vo(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();Bn(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}Wv.template="o-spreadsheet-TopBar",Wv.components={ColorPicker:kr,Menu:En,Composer:Ag},sn`
1893
+ `;class Gv extends t.Component{constructor(){super(...arguments),this.DEFAULT_FONT_SIZE=W,this.commonFormats=Hv,this.customFormats=Wv,this.currentFormatName="automatic",this.fontSizes=ie,this.style={},this.state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:""}),this.isSelectingMenu=!1,this.openedEl=null,this.inMerge=!1,this.cannotMerge=!1,this.undoTool=!1,this.redoTool=!1,this.paintFormatTool=!1,this.fillColor="#ffffff",this.textColor="#000000",this.menus=[],this.composerStyle="\n line-height: 34px;\n padding-left: 8px;\n height: 34px;\n background-color: white;\n "}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return ts.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onClick(e){this.openedEl&&bn(this.openedEl,e)||this.closeMenus()}toogleStyle(e){Kn(this.env,{[e]:!this.style[e]})}toogleFormat(e){const t=Hv.find((t=>t.name===e)),o=t&&t.value||"";Yn(this.env,o)}toggleAlign(e){Kn(this.env,{align:e})}onMenuMouseOver(e,t){this.isSelectingMenu&&this.toggleContextMenu(e,t)}toggleDropdownTool(e,t){const o=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=o?"":e,this.openedEl=o?null:t.target}toggleContextMenu(e,t){this.closeMenus();const{left:o,top:n,height:i}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:o,y:n+i},this.state.menuState.menuItems=mn(e,this.env).filter((e=>!e.isVisible||e.isVisible(this.env))),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.env.model.dispatch("STOP_EDITION")}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId();this.inMerge=!1;const{top:o,left:n,right:i,bottom:r}=this.env.model.getters.getSelectedZone(),{xSplit:s,ySplit:a}=this.env.model.getters.getPaneDivisions(t);if(this.cannotMerge=e.length>1||o===r&&n===i||n<s&&s<=i||o<a&&a<=r,!this.cannotMerge){const{col:o,row:n}=this.env.model.getters.getPosition(),i=this.env.model.getters.expandZone(t,{left:o,right:o,top:n,bottom:n});this.inMerge=Io(e[0],i)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const l=this.env.model.getters.getActiveCell();if(l&&l.format){const e=this.commonFormats.find((e=>e.value===l.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||(null==l?void 0:l.defaultAlign),this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=ki.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}getMenuName(e){return vn(e,this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],o=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:o,target:t}):function(e,t,o){const n=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});n.isCancelledBecause(79)?e.raiseError(Bv.MergeInFilter):n.isCancelledBecause(3)&&e.askConfirmation(Bv.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(this.env,o,t)}setColor(e,t){Kn(this.env,{[e]:t})}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e})}setFormat(e){const t=e.target.dataset.format;if(t)return void this.toogleFormat(t);const o=e.target.dataset.custom;o&&this.openCustomFormatSidePanel(o)}openCustomFormatSidePanel(e){const t=Wv.find((t=>t.name===e)),o=t&&t.sidePanel||"";this.env.openSidePanel(o)}setDecimal(e){this.env.model.dispatch("SET_DECIMAL",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),step:e})}paintFormat(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.env.model.getters.getSelectedZones()})}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setSize(e){const t=parseFloat(e.target.dataset.size);Kn(this.env,{fontSize:t})}doAction(e){e(this.env),this.closeMenus()}undo(){this.env.model.dispatch("REQUEST_UNDO")}redo(){this.env.model.dispatch("REQUEST_REDO")}get selectionContainsFilter(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();return this.env.model.getters.doesZonesContainFilter(e,t)}get cannotCreateFilter(){return!zo(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();Hn(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}Gv.template="o-spreadsheet-TopBar",Gv.components={ColorPicker:$r,Menu:wn,Composer:Og},an`
1894
1894
  .o-spreadsheet {
1895
1895
  position: relative;
1896
1896
  display: grid;
@@ -1938,7 +1938,7 @@
1938
1938
  height: ${15}px;
1939
1939
  vertical-align: sub;
1940
1940
  }
1941
- `,sn`
1941
+ `,an`
1942
1942
  .o-grid {
1943
1943
  position: relative;
1944
1944
  overflow: hidden;
@@ -1967,23 +1967,23 @@
1967
1967
  outline: none;
1968
1968
  }
1969
1969
  }
1970
- `;class Gv extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){var e,o;null===(o=(e=this.props).exposeSpreadsheet)||void 0===o||o.call(e,this),this.model=this.props.model,this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},t.useSubEnv({model:this.model,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:Gv._t,clipboard:navigator.clipboard}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:r("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){var e,t;null===(t=(e=this.props).onContentSaved)||void 0===t||t.call(e,this.model.exportData())}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}Gv.template="o-spreadsheet-Spreadsheet",Gv.components={TopBar:Wv,Grid:ep,BottomBar:Pv,SidePanel:Vv,SpreadsheetDashboard:Uv},Gv._t=e=>e;class qv{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function Zv(e){return kn.get(e.type)(e)}function jv(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class Xv{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:n,operation:i,after:r}=this.locateOperation(t);this.operations=[...n,i,e,...r.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new Xv(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class Yv{constructor(e,t){this.id=e,this.data=t}transformed(e){return new Kv(this.id,Ke((()=>e(this.data))))}}class Kv{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new Kv(this.id,this.lazyData.map(e))}}class Qv{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new Qv(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new Qv(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new Qv(function*(e,t){let o=!0;for(const n of e)o||(yield n),n.operation.id===t&&(o=!1)}(this.operations,e))}}class Jv{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new Qv(ke(this._execution(e),this._execution(e)))}revertedExecution(e){return new Qv(ke(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var o;const n=e.getLastOperationId()||(null===(o=this.previousBranch(e))||void 0===o?void 0:o.getLastOperationId());e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),n=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);n&&this.branchingOperationIds.set(i,n),this.insertBranchAfter(e,i),this.transform(i,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const n=this.branchingOperationIds.get(t);n?this.branchingOperationIds.set(e,n):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const n=this.buildTransformation.without(o.data),i=t.fork(o.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(n);const r=this.nextBranch(i);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const n=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(n&&i)if(e.getFirstOperationAmong(o,n)===n){const r=this.addToNextBranch(e,i,n,t,o);this.updateNextWith(i,r,o)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,o,n,i){let r=n;return i===o?(r=this.getTransformedOperation(e,o,n),t.prepend(r)):t.contains(i)?(r=this.getTransformedOperation(e,o,n),t.insert(r,i)):t.append(n),r}getTransformedOperation(e,t,o){const n=e.getOperation(t),i=this.buildTransformation.without(n.data);return o.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:n,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!n||!i)return;const r=this.buildTransformation.with(i.data),s=e.fork(o);s.transform(r),n.cutAfter(o),n.appendBranch(s);const a=t.transformed(r);this.insertPrevious(n,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const n=e.getOperations();for(let i=n.length-1;i>=0;i--){const r=n[i];r.id===t&&(o=!1),o||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class eb{constructor(e,t,o,n,i){this.applyOperation=t,this.revertOperation=o,this.buildEmpty=n,this.buildTransformation=i,this.HEAD_BRANCH=new Xv(this.buildTransformation),this.tree=new Jv(i,this.HEAD_BRANCH);const r=new Yv(e,n(e));this.tree.insertOperationLast(this.HEAD_BRANCH,r),this.HEAD_OPERATION=r}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new Yv(e,t),n=this.tree.getLastBranch();this.tree.insertOperationLast(n,o),this.HEAD_BRANCH=n,this.HEAD_OPERATION=o}insert(e,t,o){const n=new Yv(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,n,o),this.fastForward()}undo(e,t,o){const{branch:n,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(n,i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(n),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:n}of e)n||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:n}of e)n||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function tb(e,t,o){return new eb(e,(e=>{const n=e.commands.slice(),{changes:i}=t((()=>{for(const e of n)o(e)}));e.setChanges(i)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){ob(t.changes[e],"before")}}([e])),(e=>new Rv(e,"empty",[],[])),{with:e=>t=>new Rv(t.id,t.clientId,yv(t.commands,e.commands)),without:e=>t=>new Rv(t.id,t.clientId,yv(t.commands,e.commands.map(Zv).flat()))})}function ob(e,t){let o=e.root,n=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const n=e.path[t];if(void 0===o[n]){const i=e.path[t+1];o[n]=jv(i)}o=o[n]}void 0===e[t]?delete o[n]:o[n]=e[t]}class nb extends t.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class ib{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";const i=[...e.elements];i.sort(((e,t)=>t-e));const r=De(i);this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId)return{changeType:"NONE"};let s=i,a="NONE";for(let e of r){const r=Math.min(...e),l=Math.max(...e);if(i.zone[t]<=r&&r<=i.zone[o]){const e=Math.min(i.zone[o],l)-r+1;a="RESIZE",s=this.createAdaptedRange(s,n,a,-e)}else if(i.zone[t]>=r&&i.zone[o]<=l)a="REMOVE";else if(i.zone[t]<=l&&i.zone[o]>=l){const e=l-i.zone[t]+1;a="RESIZE",s=this.createAdaptedRange(s,n,a,-e),s=this.createAdaptedRange(s,n,"MOVE",-(i.zone[t]-r))}else r<i.zone[t]&&(a="MOVE",s=this.createAdaptedRange(s,n,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:s}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(i.zone[t]<=e.base&&e.base<i.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(i,n,"RESIZE",e.quantity)};if(e.base<i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,n,"MOVE",e.quantity)}}else{if(i.zone[t]<e.base&&e.base<=i.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(i,n,"RESIZE",e.quantity)};if(e.base<=i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,n,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({sheetId:"",invalidSheetName:o})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const o=void 0,n=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:n,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!Ao(o.zone,t))return{changeType:"NONE"};const n=e.targetSheetId,i=e.col-t.left,r=e.row-t.top,s=this.createAdaptedRange(o,"both","MOVE",[i,r]),a=e.sheetId!==n||s.prefixSheet;return{changeType:"MOVE",range:s.clone({sheetId:n,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||vo(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,n){const i=Do(e.unboundedZone,t,o,n);return e.clone({zone:i})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,n){const i=e.map((e=>co.fromRange(e,this.getters)));return i.map((e=>{if(!vo(e.zone))return e;const i=e.prefixSheet?e.sheetId:n,r={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return(e=e.clone({sheetId:i,zone:r})).orderZone(),e}))}getRangeFromSheetXC(e,t){if(!Ct.test(t))return new co({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,n=t,i=!1;t.includes("!")&&(({xc:n,sheetName:o}=Rt(t)),o&&(i=!0));const r=fo(n),s=co.getRangeParts(n,r),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e,c=new co({prefixSheet:i,zone:r,sheetId:l,invalidSheetName:a,parts:s},this.getters.getSheetSize);return c.orderZone(),c}getSelectionRangeString(e,t){const o=co.fromRange(e,this.getters),n=this.getters.expandZone(o.sheetId,o.zone),i=o.clone({zone:{...n,bottom:o.isFullCol?void 0:n.bottom,right:o.isFullRow?void 0:n.right}});return this.getRangeString(i,t)}getRangeString(e,t){if(!e)return X;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return X;if(e.zone.left<0||e.zone.top<0)return X;const o=co.fromRange(e,this.getters);let n=o.sheetId!==t||o.invalidSheetName||o.prefixSheet,i="";if(n&&(i=o.invalidSheetName?o.invalidSheetName:Ae(this.getters.getSheetName(o.sheetId))),n&&!i)return X;let r=this.getRangePartString(o,0);return o.parts&&2===o.parts.length&&(o.zone.top!==o.zone.bottom||o.zone.left!==o.zone.right||o.parts[0].rowFixed||o.parts[0].colFixed||o.parts[1].rowFixed||o.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(o,1)),`${n?i+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new co(t,this.getters.getSheetSize)}getRangePartString(e,t){const o=e.parts&&e.parts[t].colFixed?"$":"",n=It(0===t?e.zone.left:e.zone.right),i=e.parts&&e.parts[t].rowFixed?"$":"",r=String(0===t?e.zone.top+1:e.zone.bottom+1);let s="";return s=e.isFullCol?0===t&&e.unboundedZone.hasHeader?o+n+i+r:o+n:e.isFullRow?0===t&&e.unboundedZone.hasHeader?o+n+i+r:i+r:o+n+i+r,s}}ib.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class rb{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var o,n,i;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(o=this.mainSubscription)||void 0===o?void 0:o.owner)&&(null===(i=(n=this.mainSubscription.callbacks).release)||void 0===i||i.call(n)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t,o,n,i;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(null===(i=null===(o=this.mainSubscription)||void 0===o?void 0:(n=o.callbacks).release)||void 0===i||i.call(n),this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,o;this.mainSubscription!==this.defaultSubscription&&(null===(o=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===o||o.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class sb{constructor(e){this.getters=e,this.stream=new rb,this.anchor={cell:{col:0,row:0},zone:Lo({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){const t=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(t,e.zone)},this.processEvent({type:"ZonesSelected",anchor:e,mode:"overrideSelection"})}selectCell(e,t){const o=Lo({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new Qo(82);const{col:o,row:n}=this.getNextAvailablePosition(e,t);return this.selectCell(o,n)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:n,row:i}=this.anchor.cell,r={left:Math.min(n,e),top:Math.min(i,t),right:Math.max(n,e),bottom:Math.max(i,t)},s={zone:this.getters.expandZone(o,r),cell:{col:n,row:i}};return this.processEvent({type:"AlterZoneCorner",mode:"updateAnchor",anchor:s})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition(o,e,t));const n=this.getters.expandZone(o,Lo({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:n,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new Qo(82);const o=this.getters.getActiveSheetId(),n=this.anchor,{col:i,row:r}=n.cell,{left:s,right:a,top:l,bottom:c}=n.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return Qo.Success;let g=n.zone;const p=e=>{e=$o(e);const{left:t,right:n,top:i,bottom:r}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,n),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(o)-1,r)}},{col:f,row:m}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),m);g=f<=a-v?p({top:l,left:s,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,s+(v-1),m);g=s+v<=f?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,f,c-(v-1));g=m<=c-v?p({top:l,left:s,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,f,l+(v-1));g=l+v<=m?p({top:e,left:s,bottom:c,right:a}):null}if(g=g?$o(g):g,g&&!Ro(g,n.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:i,row:r}}})}g=p(yo({top:r,bottom:r,left:i,right:i},$o({top:this.getNextAvailableRow(u,f,l),left:this.getNextAvailableCol(d,s,m),bottom:this.getNextAvailableRow(u,f,c),right:this.getNextAvailableCol(d,a,m)})));const b={zone:g,cell:{col:i,row:r}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.getNumberRows(o)-1;let i={left:e,right:e,top:0,bottom:n};const r=this.getters.findFirstVisibleColRowIndex(o,"ROW");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=e,a=r;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),i=yo(i,{left:s,right:s,top:r,bottom:n})}return this.processEvent({type:"HeadersSelected",anchor:{zone:i,cell:{col:s,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.getNumberCols(o)-1;let i={top:e,bottom:e,left:0,right:n};const r=this.getters.findFirstVisibleColRowIndex(o,"COL");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=r,a=e;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),i=yo(i,{left:r,right:n,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:i,cell:{col:s,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor,o=e=>{for(const t of Fe(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of Fe(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};if(Ro(this.anchor.zone,this.getters.getSheetZone(e)))return this.selectZone({...t,zone:Lo(t.cell)});let n=!1,i=!1,r=t.zone;do{i=i||n,n=!1;const e=o(r);Ro(r,e)||(n=!0,r=e)}while(n);return i?this.selectZone({...t,zone:r}):this.selectAll()}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}processEvent(e){const t={...e,previousAnchor:Ie(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new Qo(o):(this.anchor=t.anchor,this.stream.send(t),Qo.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!To(t.col,t.row,o))return 16;const{left:n,right:i,top:r,bottom:s}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",Fe(n,i+1));return void 0===this.getters.findVisibleHeader(a,"ROW",Fe(r,s+1))||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(i("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:n}=this.anchor.cell,i=this.deltaToTarget({col:o,row:n},e,t);return{col:this.getNextAvailableCol(i[0],o,n),row:this.getNextAvailableRow(i[1],o,n)}}getNextAvailableCol(e,t,o){const n=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,i,(e=>this.getters.isInSameMerge(n,t,o,e,o)))}getNextAvailableRow(e,t,o){const n=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,i,(e=>this.getters.isInSameMerge(n,t,o,t,e)))}getNextAvailableHeader(e,t,o,n,i){const r=this.getters.getActiveSheetId();if(0===e)return o;const s=Math.sign(e);let a=o+e;for(;i(a);)a+=s;for(;this.getters.isHeaderHidden(r,t,a);)a+=s;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,o)?this.getNextAvailableHeader(-s,t,o,n,i):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:n,top:i,bottom:r}=t.zone,{col:s,row:a}=t.cell;return{col:this.getters.isColHidden(e,s)&&this.getters.findVisibleHeader(e,"COL",Fe(o,n+1))||s,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",Fe(i,r+1))||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const n=this.anchor.zone;switch(e){case"down":case"up":o=o===n.top?n.bottom:n.top;break;case"left":case"right":t=t===n.right?n.left:n.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const n=this.getters.getActiveSheet();let i=e;const r=this.getNextCellPosition(e,t,o);let s=this.isCellEmpty(i,n.id)||this.isCellEmpty(r,n.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const r=this.isCellEmpty(e,n.id);if("endOfCluster"===s&&r)break;if("nextCluster"===s&&!r){i=e;break}i=e}return"cols"===t?i.col:i.row}isCellEmpty({col:e,row:t},o=this.getters.getActiveSheetId()){const n=this.getters.getMainCellPosition(o,e,t),i=this.getters.getCell(o,n.col,n.row);return!i||i.isEmpty()}getNextCellPosition(e,t,o){const n="cols"===t?"col":"row",i={...e},r="cols"===t?this.getNextAvailableCol(o,i.col,i.row):this.getNextAvailableRow(o,i.col,i.row);return i[n]=r,{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}}class ab{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop(),[o,...n]=e;let i=o,r=n[n.length-1];for(let e=0;e<=n.length-2;e++){const t=n[e];if(void 0===i[t]){const o=n[e+1];i[t]=jv(o)}i=i[t]}i[r]!==t&&(this.changes.push({root:o,path:n,before:i[r],after:t}),void 0===t?delete i[r]:i[r]=t)}}const lb=17781237,cb=88853993;function hb(e,t,o){const n=[["xmlns:r",wp],["xmlns:a",bp],["xmlns:c",Sp]],i=db({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=om``;e.data.title&&(r=om`
1970
+ `;class qv extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){var e,o;null===(o=(e=this.props).exposeSpreadsheet)||void 0===o||o.call(e,this),this.model=this.props.model,this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})},t.useSubEnv({model:this.model,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:qv._t,clipboard:navigator.clipboard}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:r("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}save(){var e,t;null===(t=(e=this.props).onContentSaved)||void 0===t||t.call(e,this.model.exportData())}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}qv.template="o-spreadsheet-Spreadsheet",qv.components={TopBar:Gv,Grid:tp,BottomBar:Uv,SidePanel:zv,SpreadsheetDashboard:Vv},qv._t=e=>e;class Zv{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function jv(e){return $n.get(e.type)(e)}function Xv(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class Yv{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:n,operation:i,after:r}=this.locateOperation(t);this.operations=[...n,i,e,...r.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new Yv(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class Kv{constructor(e,t){this.id=e,this.data=t}transformed(e){return new Qv(this.id,Qe((()=>e(this.data))))}}class Qv{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new Qv(this.id,this.lazyData.map(e))}}class Jv{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new Jv(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new Jv(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new Jv(function*(e,t){let o=!0;for(const n of e)o||(yield n),n.operation.id===t&&(o=!1)}(this.operations,e))}}class eb{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new Jv(ke(this._execution(e),this._execution(e)))}revertedExecution(e){return new Jv(ke(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var o;const n=e.getLastOperationId()||(null===(o=this.previousBranch(e))||void 0===o?void 0:o.getLastOperationId());e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),n=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);n&&this.branchingOperationIds.set(i,n),this.insertBranchAfter(e,i),this.transform(i,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const n=this.branchingOperationIds.get(t);n?this.branchingOperationIds.set(e,n):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const n=this.buildTransformation.without(o.data),i=t.fork(o.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(n);const r=this.nextBranch(i);r&&this.rebaseUp(r)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const n=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(n&&i)if(e.getFirstOperationAmong(o,n)===n){const r=this.addToNextBranch(e,i,n,t,o);this.updateNextWith(i,r,o)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,o,n,i){let r=n;return i===o?(r=this.getTransformedOperation(e,o,n),t.prepend(r)):t.contains(i)?(r=this.getTransformedOperation(e,o,n),t.insert(r,i)):t.append(n),r}getTransformedOperation(e,t,o){const n=e.getOperation(t),i=this.buildTransformation.without(n.data);return o.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:n,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!n||!i)return;const r=this.buildTransformation.with(i.data),s=e.fork(o);s.transform(r),n.cutAfter(o),n.appendBranch(s);const a=t.transformed(r);this.insertPrevious(n,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const n=e.getOperations();for(let i=n.length-1;i>=0;i--){const r=n[i];r.id===t&&(o=!1),o||(yield{operation:r,branch:e,isCancelled:!this.shouldExecute(e,r)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class tb{constructor(e,t,o,n,i){this.applyOperation=t,this.revertOperation=o,this.buildEmpty=n,this.buildTransformation=i,this.HEAD_BRANCH=new Yv(this.buildTransformation),this.tree=new eb(i,this.HEAD_BRANCH);const r=new Kv(e,n(e));this.tree.insertOperationLast(this.HEAD_BRANCH,r),this.HEAD_OPERATION=r}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new Kv(e,t),n=this.tree.getLastBranch();this.tree.insertOperationLast(n,o),this.HEAD_BRANCH=n,this.HEAD_OPERATION=o}insert(e,t,o){const n=new Kv(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,n,o),this.fastForward()}undo(e,t,o){const{branch:n,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(n,i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(n),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:n}of e)n||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:n}of e)n||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function ob(e,t,o){return new tb(e,(e=>{const n=e.commands.slice(),{changes:i}=t((()=>{for(const e of n)o(e)}));e.setChanges(i)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){nb(t.changes[e],"before")}}([e])),(e=>new Iv(e,"empty",[],[])),{with:e=>t=>new Iv(t.id,t.clientId,xv(t.commands,e.commands)),without:e=>t=>new Iv(t.id,t.clientId,xv(t.commands,e.commands.map(jv).flat()))})}function nb(e,t){let o=e.root,n=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const n=e.path[t];if(void 0===o[n]){const i=e.path[t+1];o[n]=Xv(i)}o=o[n]}void 0===e[t]?delete o[n]:o[n]=e[t]}class ib extends t.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class rb{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";const i=[...e.elements];i.sort(((e,t)=>t-e));const r=De(i);this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId)return{changeType:"NONE"};let s=i,a="NONE";for(let e of r){const r=Math.min(...e),l=Math.max(...e);if(i.zone[t]<=r&&r<=i.zone[o]){const e=Math.min(i.zone[o],l)-r+1;a="RESIZE",s=this.createAdaptedRange(s,n,a,-e)}else if(i.zone[t]>=r&&i.zone[o]<=l)a="REMOVE";else if(i.zone[t]<=l&&i.zone[o]>=l){const e=l-i.zone[t]+1;a="RESIZE",s=this.createAdaptedRange(s,n,a,-e),s=this.createAdaptedRange(s,n,"MOVE",-(i.zone[t]-r))}else r<i.zone[t]&&(a="MOVE",s=this.createAdaptedRange(s,n,a,-(l-r+1)))}return"NONE"!==a?{changeType:a,range:s}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",n="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(i.zone[t]<=e.base&&e.base<i.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(i,n,"RESIZE",e.quantity)};if(e.base<i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,n,"MOVE",e.quantity)}}else{if(i.zone[t]<e.base&&e.base<=i.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(i,n,"RESIZE",e.quantity)};if(e.base<=i.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(i,n,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({sheetId:"",invalidSheetName:o})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const o=void 0,n=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:n,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!Oo(o.zone,t))return{changeType:"NONE"};const n=e.targetSheetId,i=e.col-t.left,r=e.row-t.top,s=this.createAdaptedRange(o,"both","MOVE",[i,r]),a=e.sheetId!==n||s.prefixSheet;return{changeType:"MOVE",range:s.clone({sheetId:n,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||bo(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,n){const i=ko(e.unboundedZone,t,o,n);return e.clone({zone:i})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,n){const i=e.map((e=>ho.fromRange(e,this.getters)));return i.map((e=>{if(!bo(e.zone))return e;const i=e.prefixSheet?e.sheetId:n,r={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return(e=e.clone({sheetId:i,zone:r})).orderZone(),e}))}getRangeFromSheetXC(e,t){if(!Et.test(t))return new ho({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,n=t,i=!1;t.includes("!")&&(({xc:n,sheetName:o}=It(t)),o&&(i=!0));const r=mo(n),s=ho.getRangeParts(n,r),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e,c=new ho({prefixSheet:i,zone:r,sheetId:l,invalidSheetName:a,parts:s},this.getters.getSheetSize);return c.orderZone(),c}getSelectionRangeString(e,t){const o=ho.fromRange(e,this.getters),n=this.getters.expandZone(o.sheetId,o.zone),i=o.clone({zone:{...n,bottom:o.isFullCol?void 0:n.bottom,right:o.isFullRow?void 0:n.right}});return this.getRangeString(i,t)}getRangeString(e,t){if(!e)return X;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return X;if(e.zone.left<0||e.zone.top<0)return X;const o=ho.fromRange(e,this.getters);let n=o.sheetId!==t||o.invalidSheetName||o.prefixSheet,i="";if(n&&(i=o.invalidSheetName?o.invalidSheetName:Ae(this.getters.getSheetName(o.sheetId))),n&&!i)return X;let r=this.getRangePartString(o,0);return o.parts&&2===o.parts.length&&(o.zone.top!==o.zone.bottom||o.zone.left!==o.zone.right||o.parts[0].rowFixed||o.parts[0].colFixed||o.parts[1].rowFixed||o.parts[1].colFixed)&&(r+=":",r+=this.getRangePartString(o,1)),`${n?i+"!":""}${r}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new ho(t,this.getters.getSheetSize)}getRangePartString(e,t){const o=e.parts&&e.parts[t].colFixed?"$":"",n=Tt(0===t?e.zone.left:e.zone.right),i=e.parts&&e.parts[t].rowFixed?"$":"",r=String(0===t?e.zone.top+1:e.zone.bottom+1);let s="";return s=e.isFullCol?0===t&&e.unboundedZone.hasHeader?o+n+i+r:o+n:e.isFullRow?0===t&&e.unboundedZone.hasHeader?o+n+i+r:i+r:o+n+i+r,s}}rb.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class sb{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var o,n,i;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(o=this.mainSubscription)||void 0===o?void 0:o.owner)&&(null===(i=(n=this.mainSubscription.callbacks).release)||void 0===i||i.call(n)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t,o,n,i;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(null===(i=null===(o=this.mainSubscription)||void 0===o?void 0:(n=o.callbacks).release)||void 0===i||i.call(n),this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,o;this.mainSubscription!==this.defaultSubscription&&(null===(o=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===o||o.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class ab{constructor(e){this.getters=e,this.stream=new sb,this.anchor={cell:{col:0,row:0},zone:Po({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){const t=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(t,e.zone)},this.processEvent({type:"ZonesSelected",anchor:e,mode:"overrideSelection"})}selectCell(e,t){const o=Po({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new Jo(82);const{col:o,row:n}=this.getNextAvailablePosition(e,t);return this.selectCell(o,n)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:n,row:i}=this.anchor.cell,r={left:Math.min(n,e),top:Math.min(i,t),right:Math.max(n,e),bottom:Math.max(i,t)},s={zone:this.getters.expandZone(o,r),cell:{col:n,row:i}};return this.processEvent({type:"AlterZoneCorner",mode:"updateAnchor",anchor:s})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition(o,e,t));const n=this.getters.expandZone(o,Po({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:n,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new Jo(82);const o=this.getters.getActiveSheetId(),n=this.anchor,{col:i,row:r}=n.cell,{left:s,right:a,top:l,bottom:c}=n.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return Jo.Success;let g=n.zone;const p=e=>{e=Lo(e);const{left:t,right:n,top:i,bottom:r}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,n),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(o)-1,r)}},{col:f,row:m}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),m);g=f<=a-v?p({top:l,left:s,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,s+(v-1),m);g=s+v<=f?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,f,c-(v-1));g=m<=c-v?p({top:l,left:s,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,f,l+(v-1));g=l+v<=m?p({top:e,left:s,bottom:c,right:a}):null}if(g=g?Lo(g):g,g&&!Io(g,n.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:i,row:r}}})}g=p(xo({top:r,bottom:r,left:i,right:i},Lo({top:this.getNextAvailableRow(u,f,l),left:this.getNextAvailableCol(d,s,m),bottom:this.getNextAvailableRow(u,f,c),right:this.getNextAvailableCol(d,a,m)})));const b={zone:g,cell:{col:i,row:r}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.getNumberRows(o)-1;let i={left:e,right:e,top:0,bottom:n};const r=this.getters.findFirstVisibleColRowIndex(o,"ROW");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=e,a=r;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),i=xo(i,{left:s,right:s,top:r,bottom:n})}return this.processEvent({type:"HeadersSelected",anchor:{zone:i,cell:{col:s,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),n=this.getters.getNumberCols(o)-1;let i={top:e,bottom:e,left:0,right:n};const r=this.getters.findFirstVisibleColRowIndex(o,"COL");let s,a;switch(t){case"overrideSelection":case"newAnchor":s=r,a=e;break;case"updateAnchor":({col:s,row:a}=this.anchor.cell),i=xo(i,{left:r,right:n,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:i,cell:{col:s,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor,o=e=>{for(const t of Fe(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of Fe(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};if(Io(this.anchor.zone,this.getters.getSheetZone(e)))return this.selectZone({...t,zone:Po(t.cell)});let n=!1,i=!1,r=t.zone;do{i=i||n,n=!1;const e=o(r);Io(r,e)||(n=!0,r=e)}while(n);return i?this.selectZone({...t,zone:r}):this.selectAll()}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}processEvent(e){const t={...e,previousAnchor:Ie(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new Jo(o):(this.anchor=t.anchor,this.stream.send(t),Jo.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!Ao(t.col,t.row,o))return 16;const{left:n,right:i,top:r,bottom:s}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",Fe(n,i+1));return void 0===this.getters.findVisibleHeader(a,"ROW",Fe(r,s+1))||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(i("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:o,row:n}=this.anchor.cell,i=this.deltaToTarget({col:o,row:n},e,t);return{col:this.getNextAvailableCol(i[0],o,n),row:this.getNextAvailableRow(i[1],o,n)}}getNextAvailableCol(e,t,o){const n=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,i,(e=>this.getters.isInSameMerge(n,t,o,e,o)))}getNextAvailableRow(e,t,o){const n=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,i,(e=>this.getters.isInSameMerge(n,t,o,t,e)))}getNextAvailableHeader(e,t,o,n,i){const r=this.getters.getActiveSheetId();if(0===e)return o;const s=Math.sign(e);let a=o+e;for(;i(a);)a+=s;for(;this.getters.isHeaderHidden(r,t,a);)a+=s;return a<0||a>this.getters.getNumberHeaders(r,t)-1?this.getters.isHeaderHidden(r,t,o)?this.getNextAvailableHeader(-s,t,o,n,i):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:n,top:i,bottom:r}=t.zone,{col:s,row:a}=t.cell;return{col:this.getters.isColHidden(e,s)&&this.getters.findVisibleHeader(e,"COL",Fe(o,n+1))||s,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",Fe(i,r+1))||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const n=this.anchor.zone;switch(e){case"down":case"up":o=o===n.top?n.bottom:n.top;break;case"left":case"right":t=t===n.right?n.left:n.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const n=this.getters.getActiveSheet();let i=e;const r=this.getNextCellPosition(e,t,o);let s=this.isCellEmpty(i,n.id)||this.isCellEmpty(r,n.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const r=this.isCellEmpty(e,n.id);if("endOfCluster"===s&&r)break;if("nextCluster"===s&&!r){i=e;break}i=e}return"cols"===t?i.col:i.row}isCellEmpty({col:e,row:t},o=this.getters.getActiveSheetId()){const n=this.getters.getMainCellPosition(o,e,t),i=this.getters.getCell(o,n.col,n.row);return!i||i.isEmpty()}getNextCellPosition(e,t,o){const n="cols"===t?"col":"row",i={...e},r="cols"===t?this.getNextAvailableCol(o,i.col,i.row):this.getNextAvailableRow(o,i.col,i.row);return i[n]=r,{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}}class lb{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop(),[o,...n]=e;let i=o,r=n[n.length-1];for(let e=0;e<=n.length-2;e++){const t=n[e];if(void 0===i[t]){const o=n[e+1];i[t]=Xv(o)}i=i[t]}i[r]!==t&&(this.changes.push({root:o,path:n,before:i[r],after:t}),void 0===t?delete i[r]:i[r]=t)}}const cb=17781237,hb=88853993;function db(e,t,o){const n=[["xmlns:r",yp],["xmlns:a",Sp],["xmlns:c",Cp]],i=ub({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let r=nm``;e.data.title&&(r=nm`
1971
1971
  <c:title>
1972
- ${gb(e.data.title,e.data.fontColor)}
1972
+ ${pb(e.data.title,e.data.fontColor)}
1973
1973
  <c:overlay val="0" />
1974
1974
  </c:title>
1975
- `);let s=om``;switch(e.data.type){case"bar":s=function(e){const t=new Qi,o=[];for(const[n,i]of Object.entries(e.dataSets)){const r=zi(t.next()),s=db({backgroundColor:r,line:{color:r}});o.push(om`
1975
+ `);let s=nm``;switch(e.data.type){case"bar":s=function(e){const t=new Ji,o=[];for(const[n,i]of Object.entries(e.dataSets)){const r=Bi(t.next()),s=ub({backgroundColor:r,line:{color:r}});o.push(nm`
1976
1976
  <c:ser>
1977
1977
  <c:idx val="${n}"/>
1978
1978
  <c:order val="${n}"/>
1979
- ${i.label?om`<c:tx>${vb(i.label)}</c:tx>`:""}
1979
+ ${i.label?nm`<c:tx>${bb(i.label)}</c:tx>`:""}
1980
1980
  ${s}
1981
- ${e.labelRange?om`<c:cat>${vb(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1981
+ ${e.labelRange?nm`<c:cat>${bb(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1982
1982
  <c:val> <!-- x-coordinate values -->
1983
- ${bb(i.range)}
1983
+ ${Sb(i.range)}
1984
1984
  </c:val>
1985
1985
  </c:ser>
1986
- `)}const n="left"===e.verticalAxisPosition?"l":"r",i=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return om`
1986
+ `)}const n="left"===e.verticalAxisPosition?"l":"r",i=e.stacked?"stacked":"clustered",r=e.stacked?100:-20;return nm`
1987
1987
  <c:barChart>
1988
1988
  <c:barDir val="col"/>
1989
1989
  <c:grouping val="${i}"/>
@@ -1991,13 +1991,13 @@
1991
1991
  <c:gapWidth val="70"/>
1992
1992
  <!-- each data marker in the series does not have a different color -->
1993
1993
  <c:varyColors val="0"/>
1994
- ${tm(o)}
1995
- <c:axId val="${lb}" />
1994
+ ${om(o)}
1996
1995
  <c:axId val="${cb}" />
1996
+ <c:axId val="${hb}" />
1997
1997
  </c:barChart>
1998
- ${mb("b","c:catAx",lb,cb,{fontColor:e.fontColor})}
1999
- ${mb(n,"c:valAx",cb,lb,{fontColor:e.fontColor})}
2000
- `}(e.data);break;case"line":s=function(e){const t=new Qi,o=[];for(const[n,i]of Object.entries(e.dataSets)){const r=db({line:{width:2.5,style:"solid",color:zi(t.next())}});o.push(om`
1998
+ ${vb("b","c:catAx",cb,hb,{fontColor:e.fontColor})}
1999
+ ${vb(n,"c:valAx",hb,cb,{fontColor:e.fontColor})}
2000
+ `}(e.data);break;case"line":s=function(e){const t=new Ji,o=[];for(const[n,i]of Object.entries(e.dataSets)){const r=ub({line:{width:2.5,style:"solid",color:Bi(t.next())}});o.push(nm`
2001
2001
  <c:ser>
2002
2002
  <c:idx val="${n}"/>
2003
2003
  <c:order val="${n}"/>
@@ -2006,50 +2006,50 @@
2006
2006
  <c:symbol val="circle" />
2007
2007
  <c:size val="5"/>
2008
2008
  </c:marker>
2009
- ${i.label?om`<c:tx>${vb(i.label)}</c:tx>`:""}
2009
+ ${i.label?nm`<c:tx>${bb(i.label)}</c:tx>`:""}
2010
2010
  ${r}
2011
- ${e.labelRange?om`<c:cat>${vb(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2011
+ ${e.labelRange?nm`<c:cat>${bb(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2012
2012
  <c:val> <!-- x-coordinate values -->
2013
- ${bb(i.range)}
2013
+ ${Sb(i.range)}
2014
2014
  </c:val>
2015
2015
  </c:ser>
2016
- `)}const n="left"===e.verticalAxisPosition?"l":"r",i=e.stacked?"stacked":"standard";return om`
2016
+ `)}const n="left"===e.verticalAxisPosition?"l":"r",i=e.stacked?"stacked":"standard";return nm`
2017
2017
  <c:lineChart>
2018
2018
  <c:grouping val="${i}"/>
2019
2019
  <!-- each data marker in the series does not have a different color -->
2020
2020
  <c:varyColors val="0"/>
2021
- ${tm(o)}
2022
- <c:axId val="${lb}" />
2021
+ ${om(o)}
2023
2022
  <c:axId val="${cb}" />
2023
+ <c:axId val="${hb}" />
2024
2024
  </c:lineChart>
2025
- ${mb("b","c:catAx",lb,cb,{fontColor:e.fontColor})}
2026
- ${mb(n,"c:valAx",cb,lb,{fontColor:e.fontColor})}
2027
- `}(e.data);break;case"pie":s=function(e,t,o,{holeSize:n}={holeSize:50}){const i=new Qi,r=Math.max(...e.dataSets.map((e=>Tf(e.range,t,o)))),s=Fe(0,r).map((()=>zi(i.next()))),a=[];for(const[n,i]of Object.entries(e.dataSets).reverse()){const r=Tf(i.range,t,o),l=[];for(const e of Fe(0,r)){const t=db({backgroundColor:s[e],line:{color:"FFFFFF",width:1.5}});l.push(om`
2025
+ ${vb("b","c:catAx",cb,hb,{fontColor:e.fontColor})}
2026
+ ${vb(n,"c:valAx",hb,cb,{fontColor:e.fontColor})}
2027
+ `}(e.data);break;case"pie":s=function(e,t,o,{holeSize:n}={holeSize:50}){const i=new Ji,r=Math.max(...e.dataSets.map((e=>Af(e.range,t,o)))),s=Fe(0,r).map((()=>Bi(i.next()))),a=[];for(const[n,i]of Object.entries(e.dataSets).reverse()){const r=Af(i.range,t,o),l=[];for(const e of Fe(0,r)){const t=ub({backgroundColor:s[e],line:{color:"FFFFFF",width:1.5}});l.push(nm`
2028
2028
  <c:dPt>
2029
2029
  <c:idx val="${e}"/>
2030
2030
  ${t}
2031
2031
  </c:dPt>
2032
- `)}a.push(om`
2032
+ `)}a.push(nm`
2033
2033
  <c:ser>
2034
2034
  <c:idx val="${n}"/>
2035
2035
  <c:order val="${n}"/>
2036
- ${i.label?om`<c:tx>${vb(i.label)}</c:tx>`:""}
2037
- ${tm(l)}
2038
- ${fb({showLeaderLines:!0})}
2039
- ${e.labelRange?om`<c:cat>${vb(e.labelRange)}</c:cat>`:""}
2036
+ ${i.label?nm`<c:tx>${bb(i.label)}</c:tx>`:""}
2037
+ ${om(l)}
2038
+ ${mb({showLeaderLines:!0})}
2039
+ ${e.labelRange?nm`<c:cat>${bb(e.labelRange)}</c:cat>`:""}
2040
2040
  <c:val>
2041
- ${bb(i.range)}
2041
+ ${Sb(i.range)}
2042
2042
  </c:val>
2043
2043
  </c:ser>
2044
- `)}return om`
2044
+ `)}return nm`
2045
2045
  <c:doughnutChart>
2046
2046
  <c:varyColors val="1" />
2047
2047
  <c:holeSize val="${n}" />
2048
- ${fb()}
2049
- ${tm(a)}
2048
+ ${mb()}
2049
+ ${om(a)}
2050
2050
  </c:doughnutChart>
2051
- `}(e.data,t,o,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=om`
2052
- <c:chartSpace ${Qf(n)}>
2051
+ `}(e.data,t,o,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=nm`
2052
+ <c:chartSpace ${Jf(n)}>
2053
2053
  <c:roundedCorners val="0" />
2054
2054
  <!-- <manualLayout/> to manually position the chart in the figure container -->
2055
2055
  ${i}
@@ -2060,32 +2060,32 @@
2060
2060
  <!-- how the chart element is placed on the chart -->
2061
2061
  <c:layout />
2062
2062
  ${s}
2063
- ${db({backgroundColor:e.data.backgroundColor})}
2063
+ ${ub({backgroundColor:e.data.backgroundColor})}
2064
2064
  </c:plotArea>
2065
- ${function(e,t){return om`
2065
+ ${function(e,t){return nm`
2066
2066
  <c:legend>
2067
2067
  <c:legendPos val="${e}"/>
2068
2068
  <c:overlay val="0"/>
2069
- ${pb(10,t)}
2069
+ ${fb(10,t)}
2070
2070
  </c:legend>
2071
2071
  `}(a,l)}
2072
2072
  </c:chart>
2073
2073
  </c:chartSpace>
2074
- `;return Jf(c)}function db(e){return om`
2074
+ `;return em(c)}function ub(e){return nm`
2075
2075
  <c:spPr>
2076
- ${e.backgroundColor?ub(e.backgroundColor):""}
2077
- ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",If(e.width)]);const o=e.style?om`<a:prstDash val="${e.style}"/>`:"";return om`
2078
- <a:ln ${Qf(t)}>
2079
- ${ub(e.color)}
2076
+ ${e.backgroundColor?gb(e.backgroundColor):""}
2077
+ ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",Tf(e.width)]);const o=e.style?nm`<a:prstDash val="${e.style}"/>`:"";return nm`
2078
+ <a:ln ${Jf(t)}>
2079
+ ${gb(e.color)}
2080
2080
  ${o}
2081
2081
  </a:ln>
2082
2082
  `}(e.line):""}
2083
2083
  </c:spPr>
2084
- `}function ub(e){return om`
2084
+ `}function gb(e){return nm`
2085
2085
  <a:solidFill>
2086
2086
  <a:srgbClr val="${e}"/>
2087
2087
  </a:solidFill>
2088
- `}function gb(e,t="000000",o=22){return om`
2088
+ `}function pb(e,t="000000",o=22){return nm`
2089
2089
  <c:tx>
2090
2090
  <c:rich>
2091
2091
  <a:bodyPr />
@@ -2093,7 +2093,7 @@
2093
2093
  <a:p>
2094
2094
  <a:pPr lvl="0">
2095
2095
  <a:defRPr b="0">
2096
- ${ub(t)}
2096
+ ${gb(t)}
2097
2097
  <a:latin typeface="+mn-lt"/>
2098
2098
  </a:defRPr>
2099
2099
  </a:pPr>
@@ -2104,20 +2104,20 @@
2104
2104
  </a:p>
2105
2105
  </c:rich>
2106
2106
  </c:tx>
2107
- `}function pb(e=12,t="000000",o=!1,n=!1){return om`
2107
+ `}function fb(e=12,t="000000",o=!1,n=!1){return nm`
2108
2108
  <c:txPr>
2109
2109
  <a:bodyPr/>
2110
2110
  <a:lstStyle/>
2111
2111
  <a:p>
2112
2112
  <a:pPr lvl="0">
2113
- <a:defRPr ${Qf([["b",o?"1":"0"],["i",n?"1":"0"],["sz",100*e]])}>
2114
- ${ub(t)}
2113
+ <a:defRPr ${Jf([["b",o?"1":"0"],["i",n?"1":"0"],["sz",100*e]])}>
2114
+ ${gb(t)}
2115
2115
  <a:latin typeface="+mn-lt"/>
2116
2116
  </a:defRPr>
2117
2117
  </a:pPr>
2118
2118
  </a:p>
2119
2119
  </c:txPr>
2120
- `}function fb({showLeaderLines:e}={showLeaderLines:!1}){return om`
2120
+ `}function mb({showLeaderLines:e}={showLeaderLines:!1}){return nm`
2121
2121
  <dLbls>
2122
2122
  <c:showLegendKey val="0"/>
2123
2123
  <c:showVal val="0"/>
@@ -2127,7 +2127,7 @@
2127
2127
  <c:showBubbleSize val="0"/>
2128
2128
  <c:showLeaderLines val="${e?"1":"0"}"/>
2129
2129
  </dLbls>
2130
- `}function mb(e,t,o,n,{fontColor:i}){return om`
2130
+ `}function vb(e,t,o,n,{fontColor:i}){return nm`
2131
2131
  <${t}>
2132
2132
  <c:axId val="${o}"/>
2133
2133
  <c:crossAx val="${n}"/> <!-- reference to the other axe of the chart -->
@@ -2136,58 +2136,58 @@
2136
2136
  <c:orientation val="minMax" />
2137
2137
  </c:scaling>
2138
2138
  <c:axPos val="${e}" />
2139
- ${function(e="B7B7B7"){return om`
2139
+ ${function(e="B7B7B7"){return nm`
2140
2140
  <c:majorGridlines>
2141
- ${db({line:{color:e}})}
2141
+ ${ub({line:{color:e}})}
2142
2142
  </c:majorGridlines>
2143
2143
  `}()}
2144
2144
  <c:majorTickMark val="out" />
2145
2145
  <c:minorTickMark val="none" />
2146
2146
  <c:numFmt formatCode="General" sourceLinked="1" />
2147
2147
  <c:title>
2148
- ${gb("")}
2148
+ ${pb("")}
2149
2149
  </c:title>
2150
- ${pb(10,i)}
2150
+ ${fb(10,i)}
2151
2151
  </${t}>
2152
2152
  <!-- <tickLblPos/> omitted -->
2153
- `}function vb(e){return om`
2153
+ `}function bb(e){return nm`
2154
2154
  <c:strRef>
2155
2155
  <c:f>${e}</c:f>
2156
2156
  </c:strRef>
2157
- `}function bb(e){return om`
2157
+ `}function Sb(e){return nm`
2158
2158
  <c:numRef>
2159
2159
  <c:f>${e}</c:f>
2160
2160
  <c:numCache />
2161
2161
  </c:numRef>
2162
- `}function Sb(e){const t=e.content,o=Su.content,n=[];let i=om``;if(yu(t).filter((e=>"FUNCTION"===e.type)).every((e=>o[e.value.toUpperCase()].isExported))){let o=om``;const r=Eb(t);return e.value===a.CircularDependency&&(n.push(["t","str"]),o=om`<v>${e.value}</v>`),i=om`
2162
+ `}function Cb(e){const t=e.content,o=Cu.content,n=[];let i=nm``;if(xu(t).filter((e=>"FUNCTION"===e.type)).every((e=>o[e.value.toUpperCase()].isExported))){let o=nm``;const r=wb(t);return e.value===a.CircularDependency&&(n.push(["t","str"]),o=nm`<v>${e.value}</v>`),i=nm`
2163
2163
  <f>
2164
2164
  ${r}
2165
2165
  </f>
2166
2166
  ${o}
2167
- `,{attrs:n,node:i}}{const t=e.value;if(t){const e=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);n.push(["t",e]),i=om`<v>${t}</v>`}return{attrs:n,node:i}}}function Cb(e,t,o=!1){let n=e;const i=[];if(!o&&["TRUE","FALSE"].includes(n.trim()))n="TRUE"===n?"1":"0",i.push(["t","b"]);else if(o||!ro(n)){const{id:o}=yf(e,t);n=o.toString(),i.push(["t","s"])}return{attrs:i,node:om`<v>${n}</v>`}}function Eb(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Gu(e)}catch(t){return e}return t=Zu(t,"STRING",wb),t=Zu(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),o=e.args,n=Mp[t];if(n){const i=Su.content[t].args.filter((e=>!e.optional)),r=i.length-e.args.length;if(r)for(let t=e.args.length;t<i.length;t++){const e=n[t-r];o.push({type:e.type,value:e.value})}}return{...e,args:o}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:Np.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?ju(t):e}function wb(e){const t=e.value.replace(new RegExp('"',"g"),""),o=pe(t);if(o){let n=[];return(t.match(de)||t.match(ue))&&n.push("yyyy-mm-dd"),t.match(ge)&&n.push("hh:mm:ss"),{...e,value:Ut(o.value,n.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function yb(e,t){const o=[];for(const n of t)switch(n.rule.type){case"CellIsRule":o.push(xb(n,n.rule,e));break;case"ColorScaleRule":o.push(Rb(n,n.rule));break;case"IconSetRule":o.push(Ib(n,n.rule));break;default:console.warn(`Conditional formatting ${n.rule.type} not implemented`)}return o}function xb(e,t,o){const n=Tb(e),i=mf(t.operator);n.push(...function(e){const t=mf(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",i]);const r=function(e,t){const o=e[0].split(":")[0],n=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${n[0]}",${o})))`];case"NotContains":return[`ISERROR(SEARCH("${n[0]}",${o}))`];case"BeginsWith":return[`LEFT(${o},LEN("${n[0]}"))="${n[0]}"`];case"EndsWith":return[`RIGHT(${o},LEN("${n[0]}"))="${n[0]}"`];case"IsEmpty":return[`LEN(TRIM(${o}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${o}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[n[0]];case"Between":case"NotBetween":return[n[0],n[1]]}}(e.ranges,t).map((e=>om`<formula>${e}</formula>`)),s={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(s.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=yf(s,o);return n.push(["dxfId",a]),om`
2167
+ `,{attrs:n,node:i}}{const t=e.value;if(t){const e=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);n.push(["t",e]),i=nm`<v>${t}</v>`}return{attrs:n,node:i}}}function Eb(e,t,o=!1){let n=e;const i=[];if(!o&&["TRUE","FALSE"].includes(n.trim()))n="TRUE"===n?"1":"0",i.push(["t","b"]);else if(o||!so(n)){const{id:o}=xf(e,t);n=o.toString(),i.push(["t","s"])}return{attrs:i,node:nm`<v>${n}</v>`}}function wb(e){let t;"="===e[0]&&(e=e.slice(1));try{t=qu(e)}catch(t){return e}return t=ju(t,"STRING",yb),t=ju(t,"FUNCALL",(e=>(e=function(e){const t=e.value.toUpperCase(),o=e.args,n=Np[t];if(n){const i=Cu.content[t].args.filter((e=>!e.optional)),r=i.length-e.args.length;if(r)for(let t=e.args.length;t<i.length;t++){const e=n[t-r];o.push({type:e.type,value:e.value})}}return{...e,args:o}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:_p.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})),e))),t?Xu(t):e}function yb(e){const t=e.value.replace(new RegExp('"',"g"),""),o=pe(t);if(o){let n=[];return(t.match(de)||t.match(ue))&&n.push("yyyy-mm-dd"),t.match(ge)&&n.push("hh:mm:ss"),{...e,value:Vt(o.value,n.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function xb(e,t){const o=[];for(const n of t)switch(n.rule.type){case"CellIsRule":o.push(Rb(n,n.rule,e));break;case"ColorScaleRule":o.push(Ib(n,n.rule));break;case"IconSetRule":o.push(Tb(n,n.rule));break;default:console.warn(`Conditional formatting ${n.rule.type} not implemented`)}return o}function Rb(e,t,o){const n=Ab(e),i=vf(t.operator);n.push(...function(e){const t=vf(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",i]);const r=function(e,t){const o=e[0].split(":")[0],n=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${n[0]}",${o})))`];case"NotContains":return[`ISERROR(SEARCH("${n[0]}",${o}))`];case"BeginsWith":return[`LEFT(${o},LEN("${n[0]}"))="${n[0]}"`];case"EndsWith":return[`RIGHT(${o},LEN("${n[0]}"))="${n[0]}"`];case"IsEmpty":return[`LEN(TRIM(${o}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${o}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[n[0]];case"Between":case"NotBetween":return[n[0],n[1]]}}(e.ranges,t).map((e=>nm`<formula>${e}</formula>`)),s={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(s.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=xf(s,o);return n.push(["dxfId",a]),nm`
2168
2168
  <conditionalFormatting sqref="${e.ranges.join(" ")}">
2169
- <cfRule ${Qf(n)}>
2170
- ${tm(r)}
2169
+ <cfRule ${Jf(n)}>
2170
+ ${om(r)}
2171
2171
  </cfRule>
2172
2172
  </conditionalFormatting>
2173
- `}function Rb(e,t){const o=Tb(e);o.push(["type","colorScale"]);const n=[];for(const i of e.ranges){const e=[],r=[];let s=!0;for(let o of["minimum","midpoint","maximum"]){const n=t[o];n&&("formula"!==n.type?(e.push(Ob(n,o)),r.push([["rgb",zi(it(n.color))]])):s=!1)}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>om`<cfvo ${Qf(e)}/>`)),l=r.map((e=>om`<color ${Qf(e)}/>`));n.push(om`
2173
+ `}function Ib(e,t){const o=Ab(e);o.push(["type","colorScale"]);const n=[];for(const i of e.ranges){const e=[],r=[];let s=!0;for(let o of["minimum","midpoint","maximum"]){const n=t[o];n&&("formula"!==n.type?(e.push(Mb(n,o)),r.push([["rgb",Bi(rt(n.color))]])):s=!1)}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>nm`<cfvo ${Jf(e)}/>`)),l=r.map((e=>nm`<color ${Jf(e)}/>`));n.push(nm`
2174
2174
  <conditionalFormatting sqref="${i}">
2175
- <cfRule ${Qf(o)}>
2175
+ <cfRule ${Jf(o)}>
2176
2176
  <colorScale>
2177
- ${tm(a)}
2178
- ${tm(l)}
2177
+ ${om(a)}
2178
+ ${om(l)}
2179
2179
  </colorScale>
2180
2180
  </cfRule>
2181
2181
  </conditionalFormatting>
2182
- `)}return tm(n)}function Ib(e,t){const o=Tb(e);o.push(["type","iconSet"]);const n=[];for(const i of e.ranges){const e=[[["type","percent"],["val",0]]];let r=!0;for(let o of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[o].type){r=!1;continue}const n=t[o];e.push([...Ob(n,o),["gte","ge"===n.operator?"1":"0"]])}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const s=e.map((e=>om`<cfvo ${Qf(e)} />`));n.push(om`
2182
+ `)}return om(n)}function Tb(e,t){const o=Ab(e);o.push(["type","iconSet"]);const n=[];for(const i of e.ranges){const e=[[["type","percent"],["val",0]]];let r=!0;for(let o of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[o].type){r=!1;continue}const n=t[o];e.push([...Mb(n,o),["gte","ge"===n.operator?"1":"0"]])}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const s=e.map((e=>nm`<cfvo ${Jf(e)} />`));n.push(nm`
2183
2183
  <conditionalFormatting sqref="${i}">
2184
- <cfRule ${Qf(o)}>
2185
- <iconSet iconSet="${Ab(t.icons)}">
2186
- ${tm(s)}
2184
+ <cfRule ${Jf(o)}>
2185
+ <iconSet iconSet="${Ob(t.icons)}">
2186
+ ${om(s)}
2187
2187
  </iconSet>
2188
2188
  </cfRule>
2189
2189
  </conditionalFormatting>
2190
- `)}return tm(n)}function Tb(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function Ab(e){return mp[Object.keys(mp).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function Ob(e,t){const o=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),n=[["type",o]];if("min"!==o&&"max"!==o){let t=e.value;if("formula"===o)try{t=Eb(e.value)}catch(o){t=e.value}n.push(["val",t])}return n}function Mb(e,t,o){const n=[["xmlns:xdr",vp.drawing],["xmlns:r",wp],["xmlns:a",bp],["xmlns:c",Sp]],i=[];for(const[n,r]of Object.entries(o)){const{from:o,to:s}=Nb(r,t),a=Rf(r.id),l=[["id",a],["name",`Chart ${a}`],["title","Chart"]];i.push(om`
2190
+ `)}return om(n)}function Ab(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function Ob(e){return vp[Object.keys(vp).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function Mb(e,t){const o=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),n=[["type",o]];if("min"!==o&&"max"!==o){let t=e.value;if("formula"===o)try{t=wb(e.value)}catch(o){t=e.value}n.push(["val",t])}return n}function Nb(e,t,o){const n=[["xmlns:xdr",bp.drawing],["xmlns:r",yp],["xmlns:a",Sp],["xmlns:c",Cp]],i=[];for(const[n,r]of Object.entries(o)){const{from:o,to:s}=_b(r,t),a=If(r.id),l=[["id",a],["name",`Chart ${a}`],["title","Chart"]];i.push(nm`
2191
2191
  <xdr:twoCellAnchor>
2192
2192
  <xdr:from>
2193
2193
  <xdr:col>${o.col}</xdr:col>
@@ -2203,7 +2203,7 @@
2203
2203
  </xdr:to>
2204
2204
  <xdr:graphicFrame>
2205
2205
  <xdr:nvGraphicFramePr>
2206
- <xdr:cNvPr ${Qf(l)} />
2206
+ <xdr:cNvPr ${Jf(l)} />
2207
2207
  <xdr:cNvGraphicFramePr />
2208
2208
  </xdr:nvGraphicFramePr>
2209
2209
  <xdr:xfrm>
@@ -2211,80 +2211,80 @@
2211
2211
  <a:ext cx="0" cy="0"/>
2212
2212
  </xdr:xfrm>
2213
2213
  <a:graphic>
2214
- <a:graphicData uri="${Sp}">
2214
+ <a:graphicData uri="${Cp}">
2215
2215
  <c:chart r:id="${e[n]}" />
2216
2216
  </a:graphicData>
2217
2217
  </a:graphic>
2218
2218
  </xdr:graphicFrame>
2219
2219
  <xdr:clientData fLocksWithSheet="0"/>
2220
2220
  </xdr:twoCellAnchor>
2221
- `)}return Jf(om`
2222
- <xdr:wsDr ${Qf(n)}>
2223
- ${tm(i)}
2221
+ `)}return em(nm`
2222
+ <xdr:wsDr ${Jf(n)}>
2223
+ ${om(i)}
2224
2224
  </xdr:wsDr>
2225
- `)}function Nb(e,t){const{x:o,y:n,height:i,width:r}=e,s=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=_b(s,o),{index:h,offset:d}=_b(s,o+r),{index:u,offset:g}=_b(a,n),{index:p,offset:f}=_b(a,n+i);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:f}}}function _b(e,t){let o=0;for(const[n,i]of Object.entries(e)){if(o<=t&&t<o+i.size)return{index:parseInt(n),offset:If(t-o+B)};o+=i.size}return{index:e.length-1,offset:If(t-o+B)}}function Fb(e){return je(e)?om``:om`
2225
+ `)}function _b(e,t){const{x:o,y:n,height:i,width:r}=e,s=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=Fb(s,o),{index:h,offset:d}=Fb(s,o+r),{index:u,offset:g}=Fb(a,n),{index:p,offset:f}=Fb(a,n+i);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:f}}}function Fb(e,t){let o=0;for(const[n,i]of Object.entries(e)){if(o<=t&&t<o+i.size)return{index:parseInt(n),offset:Tf(t-o+B)};o+=i.size}return{index:e.length-1,offset:Tf(t-o+B)}}function Db(e){return Xe(e)?nm``:nm`
2226
2226
  <font>
2227
- ${e.bold?om`<b />`:""}
2228
- ${e.italic?om`<i />`:""}
2229
- ${e.underline?om`<u />`:""}
2230
- ${e.strike?om`<strike />`:""}
2231
- ${e.size?om`<sz val="${e.size}" />`:""}
2232
- ${e.color&&e.color.rgb?om`<color rgb="${zi(e.color.rgb)}" />`:""}
2233
- ${e.name?om`<name val="${e.name}" />`:""}
2227
+ ${e.bold?nm`<b />`:""}
2228
+ ${e.italic?nm`<i />`:""}
2229
+ ${e.underline?nm`<u />`:""}
2230
+ ${e.strike?nm`<strike />`:""}
2231
+ ${e.size?nm`<sz val="${e.size}" />`:""}
2232
+ ${e.color&&e.color.rgb?nm`<color rgb="${Bi(e.color.rgb)}" />`:""}
2233
+ ${e.name?nm`<name val="${e.name}" />`:""}
2234
2234
  </font>
2235
- `}function Db(e){return e?Qf([["style",e.style],["color",zi(e.color.rgb)]]):om``}const kb=om`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function $b(e,t,o){const n=om`
2236
- <table ${Qf([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",vp.table],["xmlns:xr",vp.revision],["xmlns:xr3",vp.revision3],["xmlns:mc",vp.markupCompatibility]])}>
2237
- ${function(e){const t=[["ref",e.range]];return om`
2238
- <autoFilter ${Qf(t)}>
2239
- ${tm(function(e){const t=mo(e.range),o=[];for(const n of Fe(0,No(t).width)){const t=e.filters[n];if(!t||!t.filteredValues.length)continue;const i=om`
2240
- <filterColumn ${Qf([["colId",n]])}>
2241
- ${Lb(t)}
2235
+ `}function kb(e){return e?Jf([["style",e.style],["color",Bi(e.color.rgb)]]):nm``}const $b=nm`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function Lb(e,t,o){const n=nm`
2236
+ <table ${Jf([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",bp.table],["xmlns:xr",bp.revision],["xmlns:xr3",bp.revision3],["xmlns:mc",bp.markupCompatibility]])}>
2237
+ ${function(e){const t=[["ref",e.range]];return nm`
2238
+ <autoFilter ${Jf(t)}>
2239
+ ${om(function(e){const t=vo(e.range),o=[];for(const n of Fe(0,_o(t).width)){const t=e.filters[n];if(!t||!t.filteredValues.length)continue;const i=nm`
2240
+ <filterColumn ${Jf([["colId",n]])}>
2241
+ ${Pb(t)}
2242
2242
  </filterColumn>
2243
2243
  `;o.push(i)}return o}(e))}
2244
2244
  </autoFilter>
2245
2245
  `}(e)}
2246
- ${function(e,t){var o;const n=mo(e.range),i=[];for(const e of Fe(0,No(n).width)){const r=Ot(n.left+e,n.top),s=[["id",e+1],["name",(null===(o=t.cells[r])||void 0===o?void 0:o.content)||`col${e}`]];i.push(om`<tableColumn ${Qf(s)}/>`)}return om`
2247
- <tableColumns ${Qf([["count",i.length]])}>
2248
- ${tm(i)}
2246
+ ${function(e,t){var o;const n=vo(e.range),i=[];for(const e of Fe(0,_o(n).width)){const r=Mt(n.left+e,n.top),s=[["id",e+1],["name",(null===(o=t.cells[r])||void 0===o?void 0:o.content)||`col${e}`]];i.push(nm`<tableColumn ${Jf(s)}/>`)}return nm`
2247
+ <tableColumns ${Jf([["count",i.length]])}>
2248
+ ${om(i)}
2249
2249
  </tableColumns>
2250
2250
  `}(e,o)}
2251
- ${kb}
2251
+ ${$b}
2252
2252
  </table>
2253
- `;return Jf(n)}function Lb(e){return om`
2253
+ `;return em(n)}function Pb(e){return nm`
2254
2254
  <filters>
2255
- ${tm(e.filteredValues.map((e=>om`<filter ${Qf([["val",e]])}/>`)))}
2255
+ ${om(e.filteredValues.map((e=>nm`<filter ${Jf([["val",e]])}/>`)))}
2256
2256
  </filters>
2257
- `}function Pb(e){if(!Object.values(e).length)return om``;const t=[];for(let[o,n]of Object.entries(e)){const e=[["min",parseInt(o)+1],["max",parseInt(o)+1],["width",bf(n.size||N)],["customWidth",1],["hidden",n.isHidden?1:0]];t.push(om`
2258
- <col ${Qf(e)}/>
2259
- `)}return om`
2257
+ `}function Ub(e){if(!Object.values(e).length)return nm``;const t=[];for(let[o,n]of Object.entries(e)){const e=[["min",parseInt(o)+1],["max",parseInt(o)+1],["width",Sf(n.size||N)],["customWidth",1],["hidden",n.isHidden?1:0]];t.push(nm`
2258
+ <col ${Jf(e)}/>
2259
+ `)}return nm`
2260
2260
  <cols>
2261
- ${tm(t)}
2261
+ ${om(t)}
2262
2262
  </cols>
2263
- `}function Ub(e,t,o){const n=[];for(let i=0;i<o.rowNumber;i++){const r=[["r",i+1]],s=o.rows[i]||{};r.push(["ht",vf(s.size||_)],["customHeight",1],["hidden",s.isHidden?1:0]);const a=[];for(let n=0;n<o.colNumber;n++){const r=Ot(n,i),s=o.cells[r];if(s){const l=[["r",r]],c=Ef(e,Cf(s,t));l.push(["s",c]);let h=[],d=om``;if(s.isFormula)({attrs:h,node:d}=Sb(s));else if(s.content&&Ve(s.content)){const{label:t}=Be(s.content);({attrs:h,node:d}=Cb(t,e.sharedStrings))}else if(s.content&&""!==s.content){const t=Vb(n,i,o);({attrs:h,node:d}=Cb(s.content,e.sharedStrings,t))}l.push(...h),a.push(om`
2264
- <c ${Qf(l)}>
2263
+ `}function Vb(e,t,o){const n=[];for(let i=0;i<o.rowNumber;i++){const r=[["r",i+1]],s=o.rows[i]||{};r.push(["ht",bf(s.size||_)],["customHeight",1],["hidden",s.isHidden?1:0]);const a=[];for(let n=0;n<o.colNumber;n++){const r=Mt(n,i),s=o.cells[r];if(s){const l=[["r",r]],c=wf(e,Ef(s,t));l.push(["s",c]);let h=[],d=nm``;if(s.isFormula)({attrs:h,node:d}=Cb(s));else if(s.content&&Ve(s.content)){const{label:t}=Be(s.content);({attrs:h,node:d}=Eb(t,e.sharedStrings))}else if(s.content&&""!==s.content){const t=zb(n,i,o);({attrs:h,node:d}=Eb(s.content,e.sharedStrings,t))}l.push(...h),a.push(nm`
2264
+ <c ${Jf(l)}>
2265
2265
  ${d}
2266
2266
  </c>
2267
- `)}}(a.length||s.size!==_||s.isHidden)&&n.push(om`
2268
- <row ${Qf(r)}>
2269
- ${tm(a)}
2267
+ `)}}(a.length||s.size!==_||s.isHidden)&&n.push(nm`
2268
+ <row ${Jf(r)}>
2269
+ ${om(a)}
2270
2270
  </row>
2271
- `)}return om`
2271
+ `)}return nm`
2272
2272
  <sheetData>
2273
- ${tm(n)}
2273
+ ${om(n)}
2274
2274
  </sheetData>
2275
- `}function Vb(e,t,o){return o.filterTables.some((o=>{const n=mo(o.range),i={...n,bottom:n.top};return To(e,t,i)}))}function zb(e,t,o){var n;const i=t.sheets[o].cells,r=[];for(const s in i){const a=null===(n=i[s])||void 0===n?void 0:n.content;if(a&&Ve(a)){const{label:n,url:i}=Be(a);if(We(a)){const e=qe(i),o=t.sheets.find((t=>t.id===e)),a=o?`${o.name}!A1`:X;r.push(om`
2275
+ `}function zb(e,t,o){return o.filterTables.some((o=>{const n=vo(o.range),i={...n,bottom:n.top};return Ao(e,t,i)}))}function Bb(e,t,o){var n;const i=t.sheets[o].cells,r=[];for(const s in i){const a=null===(n=i[s])||void 0===n?void 0:n.content;if(a&&Ve(a)){const{label:n,url:i}=Be(a);if(We(a)){const e=qe(i),o=t.sheets.find((t=>t.id===e)),a=o?`${o.name}!A1`:X;r.push(nm`
2276
2276
  <hyperlink display="${n}" location="${a}" ref="${s}"/>
2277
- `)}else{const t=wf(e.relsFiles,`xl/worksheets/_rels/sheet${o}.xml.rels`,{target:i,type:Ep.hyperlink,targetMode:"External"});r.push(om`
2277
+ `)}else{const t=yf(e.relsFiles,`xl/worksheets/_rels/sheet${o}.xml.rels`,{target:i,type:wp.hyperlink,targetMode:"External"});r.push(nm`
2278
2278
  <hyperlink r:id="${t}" ref="${s}"/>
2279
- `)}}}return r.length?om`
2279
+ `)}}}return r.length?nm`
2280
2280
  <hyperlinks>
2281
- ${tm(r)}
2281
+ ${om(r)}
2282
2282
  </hyperlinks>
2283
- `:om``}function Bb(e){if(e.length){const t=e.map((e=>om`<mergeCell ref="${e}" />`));return om`
2283
+ `:nm``}function Hb(e){if(e.length){const t=e.map((e=>nm`<mergeCell ref="${e}" />`));return nm`
2284
2284
  <mergeCells count="${e.length}">
2285
- ${tm(t)}
2285
+ ${om(t)}
2286
2286
  </mergeCells>
2287
- `}return om``}function Hb(e){const t=e.panes;let o=om``;if(t&&(t.xSplit||t.ySplit)){const e=Ot(t.xSplit,t.ySplit),n=t.xSplit?om`xSplit="${t.xSplit}"`:"",i=t.ySplit?om`ySplit="${t.ySplit}"`:"",r=t.xSplit?om`<selection pane="topRight"/>`:"",s=t.ySplit?om`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?om`<selection pane="bottomRight"/>`:"";o=om`
2287
+ `}return nm``}function Wb(e){const t=e.panes;let o=nm``;if(t&&(t.xSplit||t.ySplit)){const e=Mt(t.xSplit,t.ySplit),n=t.xSplit?nm`xSplit="${t.xSplit}"`:"",i=t.ySplit?nm`ySplit="${t.ySplit}"`:"",r=t.xSplit?nm`<selection pane="topRight"/>`:"",s=t.ySplit?nm`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?nm`<selection pane="bottomRight"/>`:"";o=nm`
2288
2288
  <pane
2289
2289
  ${n}
2290
2290
  ${i}
@@ -2294,123 +2294,123 @@
2294
2294
  ${r}
2295
2295
  ${s}
2296
2296
  ${a}
2297
- `}return om`
2297
+ `}return nm`
2298
2298
  <sheetViews>
2299
2299
  <sheetView showGridLines="${e.areGridLinesVisible?1:0}" workbookViewId="0">
2300
2300
  ${o}
2301
2301
  </sheetView>
2302
2302
  </sheetViews>
2303
- `}function Wb(e){const t=[],o={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:W,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const o=[["xmlns",vp.workbook],["xmlns:r",wp]],n=[];for(const[o,i]of Object.entries(e.sheets)){const e=[["state",i.isVisible?"visible":"hidden"],["name",i.name],["sheetId",parseInt(o)+1],["r:id",`rId${parseInt(o)+1}`]];n.push(om`
2304
- <sheet ${Qf(e)} />
2305
- `),wf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Ep.sheet,target:`worksheets/sheet${o}.xml`})}return Yf(Jf(om`
2306
- <workbook ${Qf(o)}>
2303
+ `}function Gb(e){const t=[],o={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:W,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const o=[["xmlns",bp.workbook],["xmlns:r",yp]],n=[];for(const[o,i]of Object.entries(e.sheets)){const e=[["state",i.isVisible?"visible":"hidden"],["name",i.name],["sheetId",parseInt(o)+1],["r:id",`rId${parseInt(o)+1}`]];n.push(nm`
2304
+ <sheet ${Jf(e)} />
2305
+ `),yf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:wp.sheet,target:`worksheets/sheet${o}.xml`})}return Kf(em(nm`
2306
+ <workbook ${Jf(o)}>
2307
2307
  <sheets>
2308
- ${tm(n)}
2308
+ ${om(n)}
2309
2309
  </sheets>
2310
2310
  </workbook>
2311
- `),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let n=1;for(const[i,r]of Object.entries(e.sheets)){const s=[["xmlns",vp.worksheet],["xmlns:r",wp]],a=[["defaultRowHeight",vf(_)],["defaultColWidth",bf(N)]],l=Gb(r,i,n,t,o);n+=r.filterTables.length;let c=om``;const h=r.charts;if(h.length){const n=[];for(const r of h){const s=Rf(r.id),a=wf(t.relsFiles,`xl/drawings/_rels/drawing${i}.xml.rels`,{target:`../charts/chart${s}.xml`,type:Ep.chart});n.push(a),o.push(Yf(hb(r,i,e),`xl/charts/chart${s}.xml`,"chart"))}const s=wf(t.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:`../drawings/drawing${i}.xml`,type:Ep.drawing});o.push(Yf(Mb(n,r,h),`xl/drawings/drawing${i}.xml`,"drawing")),c=om`<drawing r:id="${s}" />`}const d=om`
2312
- <worksheet ${Qf(s)}>
2313
- ${Hb(r)}
2314
- <sheetFormatPr ${Qf(a)} />
2315
- ${Pb(r.cols)}
2316
- ${Ub(t,e,r)}
2317
- ${Bb(r.merges)}
2318
- ${tm(yb(t.dxfs,r.conditionalFormats))}
2319
- ${zb(t,e,i)}
2311
+ `),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let n=1;for(const[i,r]of Object.entries(e.sheets)){const s=[["xmlns",bp.worksheet],["xmlns:r",yp]],a=[["defaultRowHeight",bf(_)],["defaultColWidth",Sf(N)]],l=qb(r,i,n,t,o);n+=r.filterTables.length;let c=nm``;const h=r.charts;if(h.length){const n=[];for(const r of h){const s=If(r.id),a=yf(t.relsFiles,`xl/drawings/_rels/drawing${i}.xml.rels`,{target:`../charts/chart${s}.xml`,type:wp.chart});n.push(a),o.push(Kf(db(r,i,e),`xl/charts/chart${s}.xml`,"chart"))}const s=yf(t.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:`../drawings/drawing${i}.xml`,type:wp.drawing});o.push(Kf(Nb(n,r,h),`xl/drawings/drawing${i}.xml`,"drawing")),c=nm`<drawing r:id="${s}" />`}const d=nm`
2312
+ <worksheet ${Jf(s)}>
2313
+ ${Wb(r)}
2314
+ <sheetFormatPr ${Jf(a)} />
2315
+ ${Ub(r.cols)}
2316
+ ${Vb(t,e,r)}
2317
+ ${Hb(r.merges)}
2318
+ ${om(xb(t.dxfs,r.conditionalFormats))}
2319
+ ${Bb(t,e,i)}
2320
2320
  ${c}
2321
2321
  ${l}
2322
2322
  </worksheet>
2323
- `;o.push(Yf(Jf(d),`xl/worksheets/sheet${i}.xml`,"sheet"))}return wf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Ep.sharedStrings,target:"sharedStrings.xml"}),wf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Ep.styles,target:"styles.xml"}),o}(e,o)),t.push(function(e){const t=om`
2324
- <styleSheet ${Qf([["xmlns",vp.styleSheet],["xmlns:r",wp]])}>
2325
- ${function(e){const t=[];for(let[o,n]of Object.entries(e)){const e=[["numFmtId",parseInt(o)+Op],["formatCode",n.format]];t.push(om`
2326
- <numFmt ${Qf(e)}/>
2327
- `)}return om`
2323
+ `;o.push(Kf(em(d),`xl/worksheets/sheet${i}.xml`,"sheet"))}return yf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:wp.sharedStrings,target:"sharedStrings.xml"}),yf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:wp.styles,target:"styles.xml"}),o}(e,o)),t.push(function(e){const t=nm`
2324
+ <styleSheet ${Jf([["xmlns",bp.styleSheet],["xmlns:r",yp]])}>
2325
+ ${function(e){const t=[];for(let[o,n]of Object.entries(e)){const e=[["numFmtId",parseInt(o)+Mp],["formatCode",n.format]];t.push(nm`
2326
+ <numFmt ${Jf(e)}/>
2327
+ `)}return nm`
2328
2328
  <numFmts count="${e.length}">
2329
- ${tm(t)}
2329
+ ${om(t)}
2330
2330
  </numFmts>
2331
2331
  `}(e.numFmts)}
2332
- ${o=e.fonts,om`
2332
+ ${o=e.fonts,nm`
2333
2333
  <fonts count="${o.length}">
2334
- ${tm(Object.values(o).map(Fb))}
2334
+ ${om(Object.values(o).map(Db))}
2335
2335
  </fonts>
2336
2336
  `}
2337
- ${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(om`
2337
+ ${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(nm`
2338
2338
  <fill>
2339
2339
  <patternFill patternType="${o.reservedAttribute}" />
2340
2340
  </fill>
2341
- `):t.push(om`
2341
+ `):t.push(nm`
2342
2342
  <fill>
2343
2343
  <patternFill patternType="solid">
2344
- <fgColor rgb="${zi(o.fgColor.rgb)}" />
2344
+ <fgColor rgb="${Bi(o.fgColor.rgb)}" />
2345
2345
  <bgColor indexed="64" />
2346
2346
  </patternFill>
2347
2347
  </fill>
2348
- `);return om`
2348
+ `);return nm`
2349
2349
  <fills count="${e.length}">
2350
- ${tm(t)}
2350
+ ${om(t)}
2351
2351
  </fills>
2352
2352
  `}(e.fills)}
2353
- ${function(e){const t=[];for(let o of Object.values(e))t.push(om`
2353
+ ${function(e){const t=[];for(let o of Object.values(e))t.push(nm`
2354
2354
  <border>
2355
- <left ${Db(o.left)} />
2356
- <right ${Db(o.right)} />
2357
- <top ${Db(o.top)} />
2358
- <bottom ${Db(o.bottom)} />
2359
- <diagonal ${Db(o.diagonal)} />
2355
+ <left ${kb(o.left)} />
2356
+ <right ${kb(o.right)} />
2357
+ <top ${kb(o.top)} />
2358
+ <bottom ${kb(o.bottom)} />
2359
+ <diagonal ${kb(o.diagonal)} />
2360
2360
  </border>
2361
- `);return om`
2361
+ `);return nm`
2362
2362
  <borders count="${e.length}">
2363
- ${tm(t)}
2363
+ ${om(t)}
2364
2364
  </borders>
2365
2365
  `}(e.borders)}
2366
- ${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],n=[];o.alignment&&o.alignment.vertical&&n.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&n.push(["horizontal",o.alignment.horizontal]),t.push(om`
2367
- <xf ${Qf(e)}>
2368
- ${n?om`<alignment ${Qf(n)} />`:""}
2366
+ ${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],n=[];o.alignment&&o.alignment.vertical&&n.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&n.push(["horizontal",o.alignment.horizontal]),t.push(nm`
2367
+ <xf ${Jf(e)}>
2368
+ ${n?nm`<alignment ${Jf(n)} />`:""}
2369
2369
  </xf>
2370
- `)}return om`
2370
+ `)}return nm`
2371
2371
  <cellXfs count="${e.length}">
2372
- ${tm(t)}
2372
+ ${om(t)}
2373
2373
  </cellXfs>
2374
2374
  `}(e.styles)}
2375
- ${function(e){const t=[];for(const o of e){let e=om``;o.font&&(e=Fb(o.font));let n=om``;o.fill&&(n=om`
2375
+ ${function(e){const t=[];for(const o of e){let e=nm``;o.font&&(e=Db(o.font));let n=nm``;o.fill&&(n=nm`
2376
2376
  <fill>
2377
2377
  <patternFill>
2378
- <bgColor rgb="${zi(o.fill.fgColor.rgb)}" />
2378
+ <bgColor rgb="${Bi(o.fill.fgColor.rgb)}" />
2379
2379
  </patternFill>
2380
2380
  </fill>
2381
- `),t.push(om`
2381
+ `),t.push(nm`
2382
2382
  <dxf>
2383
2383
  ${e}
2384
2384
  ${n}
2385
2385
  </dxf>
2386
- `)}return om`
2386
+ `)}return nm`
2387
2387
  <dxfs count="${e.length}">
2388
- ${tm(t)}
2388
+ ${om(t)}
2389
2389
  </dxfs>
2390
2390
  `}(e.dxfs)}
2391
2391
  </styleSheet>
2392
- `;var o;return Yf(Jf(t),"xl/styles.xml","styles")}(o)),t.push(function(e){const t=[["xmlns",vp.sst],["count",e.length],["uniqueCount",e.length]],o=e.map((e=>om`<si><t>${e}</t></si>`));return Yf(Jf(om`
2393
- <sst ${Qf(t)}>
2394
- ${tm(o)}
2392
+ `;var o;return Kf(em(t),"xl/styles.xml","styles")}(o)),t.push(function(e){const t=[["xmlns",bp.sst],["count",e.length],["uniqueCount",e.length]],o=e.map((e=>nm`<si><t>${e}</t></si>`));return Kf(em(nm`
2393
+ <sst ${Jf(t)}>
2394
+ ${om(o)}
2395
2395
  </sst>
2396
- `),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(om`
2397
- <Relationship ${Qf(o)} />
2398
- `)}const n=om`
2399
- <Relationships xmlns="${vp.Relationships}">
2400
- ${tm(e)}
2396
+ `),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(nm`
2397
+ <Relationship ${Jf(o)} />
2398
+ `)}const n=nm`
2399
+ <Relationships xmlns="${bp.Relationships}">
2400
+ ${om(e)}
2401
2401
  </Relationships>
2402
- `;t.push(Yf(Jf(n),o.path))}return t}(o.relsFiles)),t.push(function(e){const t=[];for(const o of e)o.contentType&&t.push(em("/"+o.path,Cp[o.contentType]));return Yf(Jf(om`
2403
- <Types xmlns="${vp.Types}">
2402
+ `;t.push(Kf(em(n),o.path))}return t}(o.relsFiles)),t.push(function(e){const t=[];for(const o of e)o.contentType&&t.push(tm("/"+o.path,Ep[o.contentType]));return Kf(em(nm`
2403
+ <Types xmlns="${bp.Types}">
2404
2404
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
2405
2405
  <Default Extension="xml" ContentType="application/xml" />
2406
- ${tm(t)}
2406
+ ${om(t)}
2407
2407
  </Types>
2408
- `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",Ep.document],["Target","xl/workbook.xml"]];return Yf(Jf(om`
2409
- <Relationships xmlns="${vp.Relationships}">
2410
- <Relationship ${Qf(e)} />
2408
+ `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",wp.document],["Target","xl/workbook.xml"]];return Kf(em(nm`
2409
+ <Relationships xmlns="${bp.Relationships}">
2410
+ <Relationship ${Jf(e)} />
2411
2411
  </Relationships>
2412
- `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function Gb(e,t,o,n,i){let r=o;if(!e.filterTables.length)return new gp("");const s=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const o=wf(n.relsFiles,s,{target:`../tables/table${r}.xml`,type:Ep.table});i.push(Yf($b(t,r,e),`xl/tables/table${r}.xml`,"table")),a.push(om`<tablePart r:id="${o}" />`),r++}return om`
2412
+ `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function qb(e,t,o,n,i){let r=o;if(!e.filterTables.length)return new pp("");const s=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const o=yf(n.relsFiles,s,{target:`../tables/table${r}.xml`,type:wp.table});i.push(Kf(Lb(t,r,e),`xl/tables/table${r}.xml`,"table")),a.push(nm`<tablePart r:id="${o}" />`),r++}return nm`
2413
2413
  <tableParts count="${e.filterTables.length}">
2414
- ${tm(a)}
2414
+ ${om(a)}
2415
2415
  </tableParts>
2416
- `}var qb;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(qb||(qb={}));const Zb={},jb={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:N,DEFAULT_CELL_HEIGHT:_,SCROLLBAR_WIDTH:F},Xb={autofillModifiersRegistry:Go,autofillRulesRegistry:on,cellMenuRegistry:wi,colMenuRegistry:yi,linkMenuRegistry:An,functionRegistry:Su,uiPluginRegistry:$v,corePluginRegistry:kv,rowMenuRegistry:xi,sidePanelRegistry:Jr,figureRegistry:Dn,sheetMenuRegistry:Ii,chartSidePanelComponentRegistry:Wr,chartComponentRegistry:Ho,chartRegistry:Bo,topbarMenuRegistry:Di,topbarComponentRegistry:es,clickableCellRegistry:Lv,otRegistry:ki,inverseCommandRegistry:kn,cellRegistry:_n,cellPopoverRegistry:Nn},Yb={LinkCell:ap},Kb={args:gs,toBoolean:xs,toJsDate:Rs,toNumber:Ss,toString:Es,toXC:Ot,toZone:mo,toCartesian:At,numberToLetters:It,createFullMenuItem:Rn,UuidGenerator:po,formatValue:Ut,computeTextWidth:Me,isMarkdownLink:Ve,parseMarkdownLink:Be,markdownLink:ze,createEmptyWorkbookData:Tm,createEmptySheet:Im,createEmptyExcelSheet:Am,getDefaultChartJsRuntime:lr,chartFontColor:Ji,getMenuChildren:fn,ChartColors:Qi,EvaluationError:c,CellErrorLevel:l,getFillingMode:dr,rgbaToHex:dt,colorToRGBA:ut,positionToZone:Lo},Qb={ChartPanel:Gr,ChartFigure:rs,ChartJsComponent:Wo,Grid:ep,GridOverlay:Pg,ScorecardChart:os,LineConfigPanel:Vr,LineBarPieDesignPanel:$r,BarConfigPanel:Ui,LineBarPieConfigPanel:Pi,GaugeChartConfigPanel:Pr,GaugeChartDesignPanel:Ur,ScorecardChartConfigPanel:Br,ScorecardChartDesignPanel:Hr};e.AbstractChart=Vi,e.CorePlugin=Om,e.DATETIME_FORMAT=j,e.DispatchResult=Qo,e.EvaluationError=c,e.Model=class extends bv{constructor(e={},o={},n=[],i=new po,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const o={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(i=o,!Xo.has(i.type)))return new Qo(66);var i;if(!this.session.canApplyOptimisticUpdate())return new Qo(63);switch(n){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:i}=this.state.recordChanges((()=>{Ko(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(i,n),this.status=0,this.trigger("update");break;case 1:if(Ko(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o)}else this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(Ko(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Qo.Success},this.dispatchFromCorePlugin=(e,t)=>{const o={type:e,...t},n=this.status;this.status=2;const i=this.isReplayingCommand?[this.range,...this.corePlugins]:this.handlers;return this.dispatchToHandlers(i,o),this.status=n,Qo.Success},n=xm(e,n);const s=wm(e,r);this.state=new ab,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new nb(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new ib(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new sb(this.getters);for(let e of kv.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of $v.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),o.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}get handlers(){return[this.range,...this.corePlugins,...this.uiPlugins,this.history]}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let 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)}this.uiPlugins.push(t);const o=e.layers.map((e=>[t,e]));this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const o=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);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)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Tv(tb(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new qv;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new Qo(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ie(t);for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=Tm();for(let t of this.handlers)t instanceof Om&&t.export(e);return e.revisionId=this.session.getRevisionId()||Y,e=JSON.parse(JSON.stringify(e)),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Tm(),sheets:[Am(Em,"Sheet1")]};for(let t of this.handlers)t instanceof gg&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),Wb(e)}},e.Registry=zo,e.Revision=Rv,e.SPREADSHEET_DIMENSIONS=jb,e.Spreadsheet=Gv,e.UIPlugin=pg,e.__info__=Zb,e.addFunction=function(e,t){Su.add(e,t)},e.astToFormula=ju,e.cellTypes=Yb,e.compile=lg,e.components=Qb,e.convertAstNodes=Zu,e.coreTypes=Yo,e.findCellInNewZone=ko,e.functionCache=ag,e.helpers=Kb,e.invalidateEvaluationCommands=Zo,e.load=wm,e.parse=Gu,e.readonlyAllowedCommands=Xo,e.registries=Xb,e.setTranslationMethod=function(e){o=e},e.tokenize=yu,Object.defineProperty(e,"__esModule",{value:!0}),Zb.version="16.0.2",Zb.date="2023-03-06T07:17:51.313Z",Zb.hash="6b4d816"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2416
+ `}var Zb;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(Zb||(Zb={}));const jb={},Xb={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:M,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:N,DEFAULT_CELL_HEIGHT:_,SCROLLBAR_WIDTH:F},Yb={autofillModifiersRegistry:qo,autofillRulesRegistry:nn,cellMenuRegistry:yi,colMenuRegistry:xi,linkMenuRegistry:On,functionRegistry:Cu,uiPluginRegistry:Lv,corePluginRegistry:$v,rowMenuRegistry:Ri,sidePanelRegistry:es,figureRegistry:kn,sheetMenuRegistry:Ti,chartSidePanelComponentRegistry:Gr,chartComponentRegistry:Wo,chartRegistry:Ho,topbarMenuRegistry:ki,topbarComponentRegistry:ts,clickableCellRegistry:Pv,otRegistry:$i,inverseCommandRegistry:$n,cellRegistry:Fn,cellPopoverRegistry:_n},Kb={LinkCell:lp},Qb={args:ps,toBoolean:Rs,toJsDate:Is,toNumber:Cs,toString:ws,toXC:Mt,toZone:vo,toCartesian:Ot,numberToLetters:Tt,createFullMenuItem:In,UuidGenerator:fo,formatValue:Vt,computeTextWidth:Me,isMarkdownLink:Ve,parseMarkdownLink:Be,markdownLink:ze,createEmptyWorkbookData:Am,createEmptySheet:Tm,createEmptyExcelSheet:Om,getDefaultChartJsRuntime:cr,chartFontColor:er,getMenuChildren:mn,ChartColors:Ji,EvaluationError:c,CellErrorLevel:l,getFillingMode:ur,rgbaToHex:ut,colorToRGBA:gt,positionToZone:Po},Jb={ChartPanel:qr,ChartFigure:ss,ChartJsComponent:Go,Grid:tp,GridOverlay:Ug,ScorecardChart:ns,LineConfigPanel:zr,LineBarPieDesignPanel:Lr,BarConfigPanel:Vi,LineBarPieConfigPanel:Ui,GaugeChartConfigPanel:Ur,GaugeChartDesignPanel:Vr,ScorecardChartConfigPanel:Hr,ScorecardChartDesignPanel:Wr};e.AbstractChart=zi,e.CorePlugin=Mm,e.DATETIME_FORMAT=j,e.DispatchResult=Jo,e.EvaluationError=c,e.Model=class extends Sv{constructor(e={},o={},n=[],i=new fo,r=!0){super(),this.corePlugins=[],this.uiPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.dispatch=(e,t)=>{const o={type:e,...t};let n=this.status;if(this.getters.isReadonly()&&(i=o,!Yo.has(i.type)))return new Jo(66);var i;if(!this.session.canApplyOptimisticUpdate())return new Jo(63);switch(n){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:n,commands:i}=this.state.recordChanges((()=>{Qo(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(i,n),this.status=0,this.trigger("update");break;case 1:if(Qo(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o)}else this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(Qo(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Jo.Success},this.dispatchFromCorePlugin=(e,t)=>{const o={type:e,...t},n=this.status;this.status=2;const i=this.isReplayingCommand?[this.range,...this.corePlugins]:this.handlers;return this.dispatchToHandlers(i,o),this.status=n,Jo.Success},n=Rm(e,n);const s=ym(e,r);this.state=new lb,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(s.revisionId),this.config.moveClient=this.session.move.bind(this.session),this.history=new ib(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new rb(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new ab(this.getters);for(let e of $v.getAll())this.setupCorePlugin(e,s);Object.assign(this.getters,this.coreGetters);for(let e of Lv.getAll())this.setupUiPlugin(e);this.uuidGenerator.setIsFastStrategy(!1),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(n),this.joinSession(),o.snapshotRequested&&this.session.snapshot(this.exportData()),t.markRaw(this)}get handlers(){return[this.range,...this.corePlugins,...this.uiPlugins,this.history]}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.getters,this.state,this.dispatch,this.config,this.selection);for(let 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)}this.uiPlugins.push(t);const o=e.layers.map((e=>[t,e]));this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1]))}setupCorePlugin(e,t){const o=new e(this.coreGetters,this.state,this.range,this.dispatchFromCorePlugin,this.config,this.uuidGenerator);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)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.uiPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Av(ob(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:r("Anonymous").toString()},o=e.transportService||new Zv;return{...e,mode:e.mode||"normal",evalContext:e.evalContext||{},transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e)}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new Jo(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ie(t);for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=Am();for(let t of this.handlers)t instanceof Mm&&t.export(e);return e.revisionId=this.session.getRevisionId()||Y,e=JSON.parse(JSON.stringify(e)),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Am(),sheets:[Om(wm,"Sheet1")]};for(let t of this.handlers)t instanceof pg&&t.exportForExcel(e);return e=JSON.parse(JSON.stringify(e)),Gb(e)}},e.Registry=Bo,e.Revision=Iv,e.SPREADSHEET_DIMENSIONS=Xb,e.Spreadsheet=qv,e.UIPlugin=fg,e.__info__=jb,e.addFunction=function(e,t){Cu.add(e,t)},e.astToFormula=Xu,e.cellTypes=Kb,e.compile=cg,e.components=Jb,e.convertAstNodes=ju,e.coreTypes=Ko,e.findCellInNewZone=$o,e.functionCache=lg,e.helpers=Qb,e.invalidateEvaluationCommands=jo,e.load=ym,e.parse=qu,e.readonlyAllowedCommands=Yo,e.registries=Yb,e.setTranslationMethod=function(e){o=e},e.tokenize=xu,Object.defineProperty(e,"__esModule",{value:!0}),jb.version="16.0.4",jb.date="2023-03-16T12:11:01.007Z",jb.hash="ebbb1f0"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);