@odoo/o-spreadsheet 16.2.17 → 16.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- !function(e,t){"use strict";let i=e=>e;function o(e,...t){if(1===t.length&&"object"==typeof t[0]){const i=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>i[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const n=function(e,...t){return o(i(e),...t)},s=function(e,...t){return new r(e,t)};class r extends String{constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return o(i(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,i=l.error){super(t),this.errorType=e,this.logLevel=i}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,s("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,s("Invalid reference"))}}class g extends c{constructor(e){super(a.NotAvailable,e||s("Data not available"),e?l.error:l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,s('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",v="#F8F9FA",b="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y="#CACACA",x=11982760,I="#01666b",R="#188038",T="#E6F4EA",A="#CEEAD6",M="#E0E2E4",O=["#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"],N=26,_=48,F=96,D=23,k=15,L=18,P=14,U=4,V=4,z=3,B=V,H=17,$=250,W=1,G="400",q=10,Z="'Roboto', arial",j=["thin","#000"],X=["thin",R],Y=/[ymdhs:]/,K=a.InvalidReference,Q="START_REVISION",J=20,ee="??",te="difference",ie="#00A04A",oe="#DC6965",ne=.4,se=["'","*","?","/","\\","[","]"],re=/'|\*|\?|\/|\\|\[|\]/,ae="|",le=s("Invalid expression");var ce;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.ChartAnchor=1e3]="ChartAnchor"}(ce||(ce={}));const he="\n",de=[6,7,8,9,10,11,12,14,18,24,36],ue=new Date(1899,11,30),ge=864e5,pe=2e3,me=(new Date).getFullYear(),fe=new Date(0)-ue,ve=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,be=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Se=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Ce(e){let t;const i=(e=e.trim()).match(Se);if(i){if(t=function(e){if(e=e.trim(),Se.test(e)){const t=/AM/i.test(e),i=/PM/i.test(e),o=(t||i?e.substring(0,e.length-2).trim():e).split(/:/),n=o.length>=2,s=3===o.length;let r=Number(o[0]),a=n?Number(o[1]):0,l=s?Number(o[2]):0,c=s?"hh:mm:ss":"hh:mm";if(t||i)c+=" a";else if(!n)return null;r>=12&&t?r-=12:r<12&&i&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,r,a,l)}}return null}(i[0]),null===t)return null;e=e.replace(i[0],"").trim()}let o;const n=e.match(ve),s=e.match(be);if(n||s){let t;if(n?(t=n[0],o=Ee(t,"mdy")):(t=s[0],o=Ee(t,"ymd")),null===o)return null;e=e.replace(t,"").trim()}return""!==e||!o&&!t?null:o&&t?{value:o.value+t.value,format:o.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(o.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,o.jsDate.getMonth()+t.jsDate.getMonth()-11,o.jsDate.getDate()+t.jsDate.getDate()-30,o.jsDate.getHours()+t.jsDate.getHours(),o.jsDate.getMinutes()+t.jsDate.getMinutes(),o.jsDate.getSeconds()+t.jsDate.getSeconds())}:o||t}function Ee(e,t){const i="mdy"===t;if(i||"ymd"===t){const t=e.split(/\/|-|\s/),o=i?0:1,n=i?1:2,s=i?2:0,r=Number(t[o]),a=Number(t[n]),l=2===t[o].length&&r<10||2===t[n].length&&a<10,c=t[s]?function(e){const t=Number(e);switch(e.length){case 1:return pe+t;case 2:return pe+(pe+t>me+10?-100:0)+t;case 3:case 4:return t}return 0}(t[s]):me,h=new Date(c,r-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==r-1||h.getDate()!==a)return null;const u=h-ue;let g=l?`mm${d}dd`:`m${d}d`;return t[s]&&(g=i?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/ge),format:g,jsDate:h}}return null}function we(e){const t=Math.trunc(e);let i=new Date(t*ge-fe),o=e-t;o=o<0?1+o:o;const n=Math.round(24*o),s=Math.round(24*(o-n/24)*60),r=Math.round(24*(o-n/24-s/24/60)*60*60);return i.setHours(n),i.setMinutes(s),i.setSeconds(r),i}function ye(e){const t=e.getTime()-ue.getTime();return Math.round(t/ge)}function xe(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ie(e){return xe(e)===e.getDate()}function Re(e,t,i){const o=e.getFullYear(),n=e.getMonth(),s=e.getDate(),r=new Date(o,n+t);return i&&s===xe(e)||s>xe(r)?r.setDate(xe(r)):r.setDate(s),r}function Te(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Ae(e,t,i){if(e===t)return 0;if(e>t){const i=t;t=e,e=i}const o=we(e),n=we(t);let s=o.getDate(),r=n.getDate();const a=o.getMonth(),l=n.getMonth(),c=o.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(i){case 0:31===s&&(s=30),30===s&&31===r&&(r=30),1===a&&s===(Te(c)?29:28)&&(s=30,1===l&&r===(Te(h)?29:28)&&(r=30)),d=c+(30*a+s)/360,u=h+(30*l+r)/360;break;case 1:let i=365;const o=c===h;if(!o&&!(c+1===h)||!o&&a<l||!o&&a===l&&s<r){let e=0,t=0;for(let i=c;i<=h;i++)e++,t+=Te(i)?366:365;i=t/e}else o?Te(c)&&(i=366):(Te(c)&&a<2&&(i=366),Te(h)&&(l>1||1===l&&29===r)&&(i=366));d=e/i,u=t/i;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===s&&(s=30),31===r&&(r=30),d=c+(30*a+s)/360,u=h+(30*l+r)/360}return u-d}function Me(e){return JSON.stringify(e,Object.keys(e).sort())}function Oe(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function _e(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 i in e)t[i]=_e(e[i]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function Fe(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function De(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function ke(e,t,i){return e<t?t:e>i?i:e}function Le(e,t=1){return t*(e+V)-V}function Pe(e,t,i){const o=ze(i);if(Ue[o]||(Ue[o]={}),void 0===Ue[o][t]){e.save(),e.font=o;const i=e.measureText(t).width;e.restore(),Ue[o][t]=i}return Ue[o][t]}const Ue={};function Ve(e){return Math.round(96*e/72)}function ze(e){return`${e.italic?"italic ":""}${e.bold?"bold":G} ${Be(e)}px ${Z}`}function Be(e){return Ve((null==e?void 0:e.fontSize)||q)}function He(e,t,i=1){if(t<=e&&i>0)return[];if(0===i)throw new Error("range() step must not be zero");const o=Math.ceil(Math.abs((t-e)/i)),n=Array(o);for(let t=0;t<o;t++)n[t]=e+t*i;return n}function $e(e){return e.reduce(((e,t,i,o)=>{if(1===Math.abs(t-o[i-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*We(e,t){t.next();for(const i of e){const e=t.next();yield{...i,next:e.done?void 0:e.value}}}function Ge(e){return null!==Ce(e)}const qe=/^\[([^\[]+)\]\((.+)\)$/,Ze=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function je(e){return qe.test(e)}function Xe(e){return Ze.test(e)}function Ye(e,t){return`[${e}](${t})`}function Ke(e){const t=e.match(qe)||[],i=t[1],o=t[2];if(!i||!o)throw new Error(`Could not parse markdown link ${e}.`);return{label:i,url:o}}const Qe="o-spreadsheet://";function Je(e){return e.startsWith(Qe)}function et(e){return`${Qe}${e}`}function tt(e){if(e.startsWith(Qe))return e.substr(Qe.length);throw new Error(`${e} is not a valid sheet link`)}function it(e){return void 0!==e}function ot(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?ot(e):!e))}function nt(e,t){for(let[i,o]of Object.entries(t))if(Me(o)===Me(e))return parseInt(i,10);const i=Object.keys(t),o=0===i.length?0:Math.max(...i.map((e=>parseInt(e,10))));return t[o+1]=e,o+1}function st(e){let t="";for(let i=0,o=e.length;i<o;i++)t+=e[i];return t}function rt(e){let t,i=!1;const o=()=>(i||(t=e instanceof Function?e():e,i=!0),t);return o.map=e=>rt((()=>e(o()))),o}function at(e,t){let i=e.slice(t).find((e=>e));return i||(i=e.slice(0,t).reverse().find((e=>e))),i||""}function lt(e,t){return"after"===e?t+1:t}function ct(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return e===t;const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e)));for(let o of i){if(typeof e[o]!=typeof e[o])return!1;if("object"==typeof e[o]){if(!ct(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function ht(e,t){return t.every((t=>e.includes(t)))}function dt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function ut(e){return e?e.toLowerCase():""}const gt=[" ","\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],pt=new RegExp(gt.join("|"),"g"),mt=/\r\n|\r|\n/g;function ft(e){return e?e=(e=e.replace(pt," ")).replace(mt,he):""}const vt=/rgba?\(|\s+|\)/gi,bt=/^#([A-F\d]{2}){3,4}$/g,St=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function Ct(e){return Et(e.toString(16).padStart(6,"0"))}function Et(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(vt,"").split(",");let i=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");i=Math.round(255*(e||1))}const o=t.map((e=>parseInt(e,10)));255!==i&&o.push(i);return"#"+st(o.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!t.match(bt))throw new Error(`invalid color input: ${e}`);return t}function wt(e){try{return Et(e),!0}catch(e){return!1}}const yt=e=>e>=0&&e<=255;function xt(e,t,i,o=1){if(!yt(e)||!yt(t)||!yt(i)||o<0||o>1)throw new Error(`Invalid RGBA values ${[e,t,i,o]}`);return{a:o,b:i,g:t,r:e}}function It(e){let{r:t,g:i,b:o}=Tt(e);t/=255,i/=255,o/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(i)+.0722*n(o)}function Rt(e){let t=e.r.toString(16),i=e.g.toString(16),o=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1==t.length&&(t="0"+t),1==i.length&&(i="0"+i),1==o.length&&(o="0"+o),1==n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+i+o+n).toUpperCase()}function Tt(e){let t,i,o,n;if(7===(e=Et(e)).length)t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:i,b:o}}function At(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,i=t*(1-Math.abs(e.h/60%2-1)),o=e.l-t/2,n=0,s=0,r=0;return 0<=e.h&&e.h<60?(n=t,s=i,r=0):60<=e.h&&e.h<120?(n=i,s=t,r=0):120<=e.h&&e.h<180?(n=0,s=t,r=i):180<=e.h&&e.h<240?(n=0,s=i,r=t):240<=e.h&&e.h<300?(n=i,s=0,r=t):300<=e.h&&e.h<360&&(n=t,s=0,r=i),n=Math.round(255*(n+o)),s=Math.round(255*(s+o)),r=Math.round(255*(r+o)),{a:e.a,r:n,g:s,b:r}}function Mt(e){const t=e.r/255,i=e.g/255,o=e.b/255;let n=Math.min(t,i,o),s=Math.max(t,i,o),r=s-n,a=0,l=0,c=0;return a=0==r?0:s==t?(i-o)/r%6:s==i?(o-t)/r+2:(t-i)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(s+n)/2,l=0==r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}const Ot=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),Nt=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),_t=new RegExp(/^([A-Z]{1,3})+$/,"i"),Ft=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Dt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),kt=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[Ot.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 Lt(e){return Ft.test(e)}function Pt(e){return Dt.test(e)}function Ut(e){return _t.test(e)}function Vt(e){return Nt.test(e)}function zt(e){const t=e.split("!"),i=t.pop();return{sheetName:Fe(t.join("!"))||void 0,xc:i}}function Bt(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Bt(Math.floor(e/26)-1)+Bt(e%26)}function Ht(e){let t=0;const i=e.length;for(let o=0;o<i;o++){t+=(e.charCodeAt(o)-65+(o<i-1?1:0))*26**(i-o-1)}return t}function $t(e){const t=(e=e.toUpperCase().trim()).match(Ot);if(null!==t){const[i,o,n]=t;if(i===e){return{col:Ht(o),row:parseInt(n,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function Wt(e,t,i={colFixed:!1,rowFixed:!1}){return(i.colFixed?"$":"")+Bt(e)+(i.rowFixed?"$":"")+String(t+1)}const Gt=140,qt=20,Zt=.035;function jt(e){return qt+(Gt-qt)*Math.exp(-Zt*(e-1))}const Xt=/(^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+)(?!\w|!)/,Yt="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",Kt="(\\s*-)?",Qt="(\\s*[\\$€])?",Jt="^(("+[Kt+Qt+Yt,Kt+Yt+Qt,Qt+Kt+Yt].join(")|(")+"))$",ei=new RegExp(Jt,"i");function ti(e){return!!e&&ei.test(e.trim())}const ii=/[,\$€]+/g;function oi(e){e=e.replace(ii,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function ni(e,t,i){const o=[...e].sort(((e,t)=>e-t));let n=(o.length+(i?-1:1))*t;if(i||n--,Number.isInteger(n))return o[n];const s=Math.ceil(n),r=Math.floor(n);return o[s]*(n-r)+o[r]*(s-n)}const si=20,ri=11,ai=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,li=/0/g,ci={0:s("January"),1:s("February"),2:s("March"),3:s("April"),4:s("May"),5:s("June"),6:s("July"),7:s("August"),8:s("September"),9:s("October"),10:s("November"),11:s("December")},hi={0:s("Sunday"),1:s("Monday"),2:s("Tuesday"),3:s("Wednesday"),4:s("Thursday"),5:s("Friday"),6:s("Saturday")},di={};function ui(e){let t=di[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,i=[];for(;t<e.length;){let o;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(o=e.substring(t+1).indexOf("]")+t+2,0===o)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,o-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);i.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");o=n>-1?n+t:e.length;const s=e.substring(t,o);s.match(Y)?i.push({type:"DATE",format:s}):i.push({type:"NUMBER",format:Mi(s)})}t=o}return i}(e),di[e]=t),t}function gi(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=yi(e));return function(e,t){if("DATE"===t[0].type)return Ci(e,t[0].format);let i=e<0?"-":"";for(let o of t)switch(o.type){case"NUMBER":i+=pi(Math.abs(e),o.format);break;case"STRING":i+=o.format}return i}(e,ui(t));case"object":return"0"}}function pi(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:o,decimalDigits:n}=fi(e,i);let s=function(e,t,i){var o;const n="0"===e?"":e;let s=n;const r=t.length-n.length;if(r>0){const e=(t.substring(0,r).match(li)||[]).length;s="0".repeat(e)+s}i&&(s=(null===(o=s.match(ai))||void 0===o?void 0:o.join(","))||s);return s}(o,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(s+="."+function(e,t){let i=e;if(t.length-e.length>0){const o=(t.substring(e.length,t.length+1).match(li)||[]).length;i+="0".repeat(o)}return i}(n||"",t.decimalPart)),t.isPercent&&(s+="%"),s}const mi=[];function fi(e,t=si){const i=e.toString();if(i.includes("e"))return function(e,t=si){let i=mi[t];i||(i=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),mi[t]=i);const[o,n]=i.format(e).split(".");return{integerDigits:o,decimalDigits:n}}(e,t);if(Number.isInteger(e))return{integerDigits:i,decimalDigits:void 0};const o=i.indexOf(".");let n=i.substring(0,o),s=i.substring(o+1);if(0===t)return Number(s[0])>=5&&(n=(Number(n)+1).toString()),{integerDigits:n,decimalDigits:void 0};if(s.length>t){const{integerDigits:e,decimalDigits:i}=function(e,t){var i;let o="0",n=e,s=e.slice(0,t);const r=t;if(Number(e[r])<5)return{integerDigits:o,decimalDigits:s};const a=(null===(i=s.match(bi))||void 0===i?void 0:i[0])||"",l=(Number(s)+1).toString(),c=s.slice(a.length),h=l.length>c.length;h&&!a?(o="1",n=void 0):n=h?a.slice(0,-1)+l:a+l;return{integerDigits:o,decimalDigits:n}}(s,t);s=i,"0"!==e&&(n=(Number(n)+Number(e)).toString())}return{integerDigits:n,decimalDigits:vi(s||"")}}function vi(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const bi=/^0+/;function Si(e){try{return Ci(1,e),!0}catch(e){return!1}}function Ci(e,t){const i=we(e),o=t.indexOf("h");let n="",s="";return o>0?(n=Ei(i,t.substring(0,o-1)),s=wi(i,t.substring(o))):0===o?s=wi(i,t):o<0&&(n=Ei(i,t)),n+(n&&s?" ":"")+s}function Ei(e,t){var i;const o=null===(i=t.match(/\/|-|\s/))||void 0===i?void 0:i[0];return(o?t.split(o):[t]).map((i=>{switch(i){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return hi[e.getDay()].slice(0,3);case"dddd":return hi[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ci[e.getMonth()].slice(0,3);case"mmmm":return ci[e.getMonth()];case"mmmmm":return ci[e.getMonth()].slice(0,1);case"yy":const i=String(e.getFullYear()).replace("-","").padStart(2,"0");return i.slice(i.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function wi(e,t){let i=t.split(/:|\s/);const o=e.getHours(),n="a"===i[i.length-1];let s=o,r="";return n&&(s=0===s?12:s>12?s-12:s,r=o>=12?" PM":" AM",i.pop()),i.map((i=>{switch(i){case"hhhh":return Math.floor((e.getTime()-ue)/36e5).toString();case"hh":return s.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}function yi(e){let{integerDigits:t,decimalDigits:i}=fi(e);if(!i)return"0";const o=t.replace("-","").length;if(o+2>ri)return"0";const n=ri-o-1;return({decimalDigits:i}=fi(e,Math.min(n,i.length))),i?"0."+"0".repeat(i.length):"0"}function xi(e){if(Ge(e)){return Ce(e).format}if(!ti(e))return;const t=e.includes(".")?"0.00":"0",i=e.match(/[\$€]/);if(i){const o=e.match(/[\d]/),n="[$"+i.values().next().value+"]";return o.index<i.index?"#,##"+t+n:n+"#,##"+t}return e.includes("%")?t+"%":void 0}function Ii(e,t,i){return Ni(ui(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:i}]:e)).flat())}function Ri(e,t){const i=ui(e).map((e=>"NUMBER"===e.type?{...e,format:Ti(e.format,t)}:e)),o=Ni(i);return di[o]=i,o}function Ti(e,t){var i;const o={...e},n=Math.sign(t),s=(null===(i=o.decimalPart)||void 0===i?void 0:i.length)||0,r=Math.min(Math.max(0,s+n),si);return o.decimalPart="0".repeat(r),""===o.decimalPart&&delete o.decimalPart,o}const Ai=/,*?$/;function Mi(e){var t;if(function(e){return Boolean(e.replace(Oi,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const i=e.includes("%"),o=(null===(t=e.match(Ai))||void 0===t?void 0:t[0])||"",n=o?1e3**o.length:1;let s=e.slice(0,e.length-(o.length||0));const r=s.includes(",");if(s.match(/\..*,/))throw new Error("A format can't contain ',' symbol in the decimal part");s=s.replace("%","").replace(",","");const a=s.match(/[\%|,]/);if(a)throw new Error(`A format can only contain a single '${a[0]}' symbol`);const[l,c]=s.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:i,thousandsSeparator:r,decimalPart:c,magnitude:n}:{integerPart:l,isPercent:i,thousandsSeparator:r,magnitude:n}}const Oi=/[,#0.%]/g;function Ni(e){let t="";for(let i of e){let e;switch(i.type){case"NUMBER":const t=i.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=`[$${i.format}]`;break;case"DATE":e=i.format}t+=e}return t}class _i{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 _i?e:new _i(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:i,right:o}=this._zone;if(void 0!==o&&void 0!==i)return{left:e,top:t,right:o,bottom:i};if(void 0===i&&void 0!==o)return{right:o,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===o&&void 0!==i)return{bottom:i,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(s("Bad zone format"))}static getRangeParts(e,t){const i=e.split(":").map((e=>{const t=Pt(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),o=void 0===t.bottom,n=void 0===t.right;return o&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed,t.left===t.right&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed)),n&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed,t.top===t.bottom&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed)),i}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(){var e,t,i,o,n,s,r,a;const l={...this._zone};let c=this.parts;if(void 0!==l.right&&l.right<l.left){let n=l.right;l.right=l.left,l.left=n,c=[{colFixed:(null===(e=c[1])||void 0===e?void 0:e.colFixed)||!1,rowFixed:(null===(t=c[0])||void 0===t?void 0:t.rowFixed)||!1},{colFixed:(null===(i=c[0])||void 0===i?void 0:i.colFixed)||!1,rowFixed:(null===(o=c[1])||void 0===o?void 0:o.rowFixed)||!1}]}if(void 0!==l.bottom&&l.bottom<l.top){let e=l.bottom;l.bottom=l.top,l.top=e,c=[{colFixed:(null===(n=c[0])||void 0===n?void 0:n.colFixed)||!1,rowFixed:(null===(s=c[1])||void 0===s?void 0:s.rowFixed)||!1},{colFixed:(null===(r=c[1])||void 0===r?void 0:r.colFixed)||!1,rowFixed:(null===(a=c[0])||void 0===a?void 0:a.rowFixed)||!1}]}return this.clone({zone:l,parts:c})}clone(e){return new _i({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 Fi(e,t,i){const o=i.sheetId===e?t:i.sheetId;return i.clone({sheetId:o})}function Di(e,t,i){return i?e.getRangeFromSheetXC(t,i):void 0}function ki(e,t,i){const o=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let i=0,o=0,n=(t=t.toLocaleLowerCase()).length,s=0;for(let r=0;r<n;r++)t[r]===e[s]?(s++,o+=100+o-r/200):o=0,i+=o;return s===e.length?i:0}(e,i(t));n>0&&o.push({score:n,elem:t})})),o.sort(((e,t)=>t.score-e.score)),o.map((e=>e.elem))}function Li(e){const t=[];for(let i=0;i<e;i++){const e={cells:{}};t.push(e)}return t}class Pi{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 Ui(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let i,o,n,s,r=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Lt(c))n=s=Ht(c),i=o=0,r=!0;else if(Pt(c))i=o=parseInt(c,10)-1,n=s=0,a=!0;else{const e=$t(c);n=s=e.col,i=o=e.row,l=!0}if(2===t.length)if(Lt(h))s=Ht(h),r=!0;else if(Pt(h))o=parseInt(h,10)-1,a=!0;else{const e=$t(h);s=e.col,o=e.row,i=r?o:i,n=a?s:n,l=!0}if(r&&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:i,left:n,bottom:r?void 0:o,right:a?void 0:s};return l=l&&(a||r),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 Vi(e){const t=Ui(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function zi(e){const{bottom:t,top:i,left:o,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(i)||isNaN(o)||void 0!==n&&isNaN(n))&&((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 Bi(e){const{top:t,bottom:i,left:o,right:n}=e,r="hasHeader"in e&&e.hasHeader,a=t===i&&o===n;if(void 0===i&&void 0!==n)return 0!==t||r?`${Wt(o,t)}:${Bt(n)}`:`${Bt(o)}:${Bt(n)}`;if(void 0===n&&void 0!==i)return 0!==o||r?`${Wt(o,t)}:${i+1}`:`${t+1}:${i+1}`;if(void 0!==i&&void 0!==n)return a?Wt(o,t):`${Wt(o,t)}:${Wt(n,i)}`;throw new Error(s("Bad zone format"))}function Hi(e,t,i,o,n){const s="left"===t?"columns":"rows",r="before"===o?i-1:i,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?oo(e,s,"RESIZE",n):r<e[t]?oo(e,s,"MOVE",n):{...e}}function $i(e,t,i,o,n){const s="left"===t?"columns":"rows",r="before"===o?i-1:i,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?oo(e,s,"RESIZE",n):r<e[t]?oo(e,s,"MOVE",n):{...e}}function Wi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],s=e[o];for(let r of i.sort(((e,t)=>t-e)))e[t]>r&&(n--,s--),e[t]<r&&e[o]>=r&&s--;return{...e,[t]:n,[o]:s}}function Gi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],s=e[o];const r=e[o];for(let o of i.sort(((e,t)=>t-e)))e[t]>o&&(n--,void 0!==s&&s--),void 0!==r&&void 0!==s&&e[t]<=o&&r>=o&&s--;if(!(void 0!==s&&n>s))return{...e,[t]:n,[o]:s}}function qi(...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 Zi(e,t){if(Xi(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 ji(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Xi(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Yi(e,t,i){const{left:o,right:n,top:s,bottom:r}=i;return e>=o&&e<=n&&t>=s&&t<=r}function Ki(e,t){return ji(qi(t,e),t)}function Qi(e,t){const i=e.map(Ui),o=t.map(Vi),n=Math.max(...i.concat(o).map((e=>e.bottom||0))),s=Math.max(...i.concat(o).map((e=>e.right||0))),r=i.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),a=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),l=function(e,t){const i=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!i.has(`${e}-${t}`)))}(r.map(io).flat(),a.map(io).flat()),c=function(e){if(0===e.length)return[];const[t,...i]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),o=[];let n=ro(t);for(const{col:e,row:t}of i)if(!Yi(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else o.push(n),n=ro({col:e,row:t});return[...o,n]}(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=[],i=Ji(e),o=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;i.length;){const e=i.reduce(((e,t)=>o(e,t)?qi(e,t):e),i.shift());t.push(e)}return Ji(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===s+1?void 0:e.right}))).map(Bi)}function Ji(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(),i=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Ki(e,t)))||i.push(e)}return i.reverse()}function eo(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function to(e){const{numberOfCols:t,numberOfRows:i}=eo(e);return 1===t||1===i}function io(e){const t=[],[i,o]=[e.right,e.left].sort(((e,t)=>e-t)),[n,s]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of He(i,o+1))for(const i of He(n,s+1))t.push({col:e,row:i});return t}function oo(e,t,i,o){const n="both"===t?o[0]:"columns"===t?o:0,s="both"===t?o[1]:"rows"===t?o:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(ao(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===i&&(l.left+=n,l.top+=s),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=s),l}function no(e,t){let i,o;const{left:n,right:s,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return i=l!=n?l:c!=s?c:l,o=h!=r?h:d!=a?d:h,{col:i,row:o}}function so(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 ro(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function ao(e){return void 0===e.right}function lo(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function co(...e){return e.length<2||1===Qi(e.map(Bi),[]).length}class ho 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;ct(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,i,o,n,s;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===(i=r.options)||void 0===i?void 0:i.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=null===(o=r.options)||void 0===o?void 0:o.tooltips,this.chart.config.options.legend=null===(n=r.options)||void 0===n?void 0:n.legend,this.chart.config.options.scales=null===(s=r.options)||void 0===s?void 0:s.scales,this.chart.update({duration:0})}}ho.template="o-spreadsheet-ChartJsComponent",ho.props={figure:Object};const uo={};let go=0;function po(e,...t){const i="__sheet__"+go++;return function(e,t){const i=document.createElement("style");i.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),i=[],o=[];let n=[];function s(e,t){const o=[];for(const n of i[e]){let r=t&&t+" "+n||n;r.includes("&")&&(r=n.replace(/&/g,t||"")),e<i.length-1&&(r=s(e+1,r)),o.push(r)}return o.join(", ")}function r(){n.length&&(o.push(s(0)+" {"),o.push(...n),o.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),i.pop()):("{"===t[0]&&(r(),i.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return o.join("\n")}(t),uo[e]=i}(i,String.raw(e,...t)),function(e){const t=uo[e];t.setAttribute("component",e),document.head.appendChild(t)}(i),i}function mo({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function fo(e){const t=vo(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function vo(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 i=e.strikethrough?"line-through":"";i=e.underline?i+" underline":i,t["text-decoration"]=i}return e.textColor&&(t.color=e.textColor),t}function bo(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const So=1.2;po`
1
+ !function(e,t){"use strict";let i=e=>e;function o(e,...t){if(1===t.length&&"object"==typeof t[0]){const i=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>i[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const n=function(e,...t){return o(i(e),...t)},s=function(e,...t){return new r(e,t)};class r extends String{constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return o(i(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,i=l.error){super(t),this.errorType=e,this.logLevel=i}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,s("Circular reference"))}}class u extends c{constructor(){super(a.InvalidReference,s("Invalid reference"))}}class g extends c{constructor(e){super(a.NotAvailable,e||s("Data not available"),e?l.error:l.silent)}}class p extends c{constructor(e){super(a.UnknownFunction,s('Unknown function: "%s"',e))}}const m=.5,f="#f5f5f5",v="#F8F9FA",b="#E8EAED",S="#595959",C="#666666",E="#3266ca",w="#FFFFFF",y="#CACACA",x=11982760,I="#01666b",R="#188038",T="#E6F4EA",A="#CEEAD6",M="#E0E2E4",O=["#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"],N=26,_=48,F=96,D=23,k=15,L=18,P=14,U=4,V=4,z=3,B=V,H=17,$=250,W=1,G="400",q=10,Z="'Roboto', arial",j=["thin","#000"],X=["thin",R],Y=/[ymdhs:]/,K=a.InvalidReference,Q="START_REVISION",J=20,ee="??",te="difference",ie="#00A04A",oe="#DC6965",ne=.4,se=["'","*","?","/","\\","[","]"],re=/'|\*|\?|\/|\\|\[|\]/,ae="|",le=s("Invalid expression");var ce;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.ChartAnchor=1e3]="ChartAnchor"}(ce||(ce={}));const he="\n",de=[6,7,8,9,10,11,12,14,18,24,36],ue=new Date(1899,11,30),ge=864e5,pe=2e3,me=(new Date).getFullYear(),fe=new Date(0)-ue,ve=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,be=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Se=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/,Ce={};function Ee(e){if(e in Ce)return Ce[e];const t=function(e){let t;e=e.trim();const i=e.match(Se);if(i){if(t=function(e){if(e=e.trim(),Se.test(e)){const t=/AM/i.test(e),i=/PM/i.test(e),o=(t||i?e.substring(0,e.length-2).trim():e).split(/:/),n=o.length>=2,s=3===o.length;let r=Number(o[0]),a=n?Number(o[1]):0,l=s?Number(o[2]):0,c=s?"hh:mm:ss":"hh:mm";if(t||i)c+=" a";else if(!n)return null;r>=12&&t?r-=12:r<12&&i&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,r,a,l)}}return null}(i[0]),null===t)return null;e=e.replace(i[0],"").trim()}let o;const n=e.match(ve),s=e.match(be);if(n||s){let t;if(n?(t=n[0],o=we(t,"mdy")):(t=s[0],o=we(t,"ymd")),null===o)return null;e=e.replace(t,"").trim()}if(""!==e||!o&&!t)return null;if(o&&t)return{value:o.value+t.value,format:o.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(o.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,o.jsDate.getMonth()+t.jsDate.getMonth()-11,o.jsDate.getDate()+t.jsDate.getDate()-30,o.jsDate.getHours()+t.jsDate.getHours(),o.jsDate.getMinutes()+t.jsDate.getMinutes(),o.jsDate.getSeconds()+t.jsDate.getSeconds())};return o||t}(e);return Ce[e]=t,t}function we(e,t){const i="mdy"===t;if(i||"ymd"===t){const t=e.split(/\/|-|\s/),o=i?0:1,n=i?1:2,s=i?2:0,r=Number(t[o]),a=Number(t[n]),l=2===t[o].length&&r<10||2===t[n].length&&a<10,c=t[s]?function(e){const t=Number(e);switch(e.length){case 1:return pe+t;case 2:return pe+(pe+t>me+10?-100:0)+t;case 3:case 4:return t}return 0}(t[s]):me,h=new Date(c,r-1,a),d=e.match(/\/|-|\s/)[0];if(h.getMonth()!==r-1||h.getDate()!==a)return null;const u=h-ue;let g=l?`mm${d}dd`:`m${d}d`;return t[s]&&(g=i?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/ge),format:g,jsDate:h}}return null}function ye(e){const t=Math.trunc(e);let i=new Date(t*ge-fe),o=e-t;o=o<0?1+o:o;const n=Math.round(24*o),s=Math.round(24*(o-n/24)*60),r=Math.round(24*(o-n/24-s/24/60)*60*60);return i.setHours(n),i.setMinutes(s),i.setSeconds(r),i}function xe(e){const t=e.getTime()-ue.getTime();return Math.round(t/ge)}function Ie(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function Re(e){return Ie(e)===e.getDate()}function Te(e,t,i){const o=e.getFullYear(),n=e.getMonth(),s=e.getDate(),r=new Date(o,n+t);return i&&s===Ie(e)||s>Ie(r)?r.setDate(Ie(r)):r.setDate(s),r}function Ae(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Me(e,t,i){if(e===t)return 0;if(e>t){const i=t;t=e,e=i}const o=ye(e),n=ye(t);let s=o.getDate(),r=n.getDate();const a=o.getMonth(),l=n.getMonth(),c=o.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(i){case 0:31===s&&(s=30),30===s&&31===r&&(r=30),1===a&&s===(Ae(c)?29:28)&&(s=30,1===l&&r===(Ae(h)?29:28)&&(r=30)),d=c+(30*a+s)/360,u=h+(30*l+r)/360;break;case 1:let i=365;const o=c===h;if(!o&&!(c+1===h)||!o&&a<l||!o&&a===l&&s<r){let e=0,t=0;for(let i=c;i<=h;i++)e++,t+=Ae(i)?366:365;i=t/e}else o?Ae(c)&&(i=366):(Ae(c)&&a<2&&(i=366),Ae(h)&&(l>1||1===l&&29===r)&&(i=366));d=e/i,u=t/i;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===s&&(s=30),31===r&&(r=30),d=c+(30*a+s)/360,u=h+(30*l+r)/360}return u-d}function Oe(e){return JSON.stringify(e,Object.keys(e).sort())}function Ne(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fe(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 i in e)t[i]=Fe(e[i]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function De(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function ke(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function Le(e,t,i){return e<t?t:e>i?i:e}function Pe(e,t=1){return t*(e+V)-V}function Ue(e,t,i){const o=Be(i);if(Ve[o]||(Ve[o]={}),void 0===Ve[o][t]){e.save(),e.font=o;const i=e.measureText(t).width;e.restore(),Ve[o][t]=i}return Ve[o][t]}const Ve={};function ze(e){return Math.round(96*e/72)}function Be(e){return`${e.italic?"italic ":""}${e.bold?"bold":G} ${He(e)}px ${Z}`}function He(e){return ze((null==e?void 0:e.fontSize)||q)}function $e(e,t,i=1){if(t<=e&&i>0)return[];if(0===i)throw new Error("range() step must not be zero");const o=Math.ceil(Math.abs((t-e)/i)),n=Array(o);for(let t=0;t<o;t++)n[t]=e+t*i;return n}function We(e){return e.reduce(((e,t,i,o)=>{if(1===Math.abs(t-o[i-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Ge(e,t){t.next();for(const i of e){const e=t.next();yield{...i,next:e.done?void 0:e.value}}}function qe(e){return null!==Ee(e)}const Ze=/^\[([^\[]+)\]\((.+)\)$/,je=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function Xe(e){return Ze.test(e)}function Ye(e){return je.test(e)}function Ke(e,t){return`[${e}](${t})`}function Qe(e){const t=e.match(Ze)||[],i=t[1],o=t[2];if(!i||!o)throw new Error(`Could not parse markdown link ${e}.`);return{label:i,url:o}}const Je="o-spreadsheet://";function et(e){return e.startsWith(Je)}function tt(e){return`${Je}${e}`}function it(e){if(e.startsWith(Je))return e.substr(Je.length);throw new Error(`${e} is not a valid sheet link`)}function ot(e){return void 0!==e}function nt(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?nt(e):!e))}function st(e,t){for(let[i,o]of Object.entries(t))if(Oe(o)===Oe(e))return parseInt(i,10);const i=Object.keys(t),o=0===i.length?0:Math.max(...i.map((e=>parseInt(e,10))));return t[o+1]=e,o+1}function rt(e){let t="";for(let i=0,o=e.length;i<o;i++)t+=e[i];return t}function at(e){let t,i=!1;const o=()=>(i||(t=e instanceof Function?e():e,i=!0),t);return o.map=e=>at((()=>e(o()))),o}function lt(e,t){let i=e.slice(t).find((e=>e));return i||(i=e.slice(0,t).reverse().find((e=>e))),i||""}function ct(e,t){return"after"===e?t+1:t}function ht(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return e===t;const i=new Set;Object.keys(e).forEach((e=>i.add(e))),Object.keys(t).forEach((e=>i.add(e)));for(let o of i){if(typeof e[o]!=typeof e[o])return!1;if("object"==typeof e[o]){if(!ht(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function dt(e,t){return t.every((t=>e.includes(t)))}function ut(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function gt(e){return e?e.toLowerCase():""}const pt=[" ","\t","\f","\v",String.fromCharCode(parseInt("00a0",16)),String.fromCharCode(parseInt("1680",16)),String.fromCharCode(parseInt("2000",16)),String.fromCharCode(parseInt("200a",16)),String.fromCharCode(parseInt("2028",16)),String.fromCharCode(parseInt("2029",16)),String.fromCharCode(parseInt("202f",16)),String.fromCharCode(parseInt("205f",16)),String.fromCharCode(parseInt("3000",16)),String.fromCharCode(parseInt("feff",16))],mt=new RegExp(pt.join("|"),"g"),ft=/\r\n|\r|\n/g;function vt(e){return e?e=(e=e.replace(mt," ")).replace(ft,he):""}const bt=/rgba?\(|\s+|\)/gi,St=/^#([A-F\d]{2}){3,4}$/g,Ct=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function Et(e){return wt(e.toString(16).padStart(6,"0"))}function wt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(bt,"").split(",");let i=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");i=Math.round(255*(e||1))}const o=t.map((e=>parseInt(e,10)));255!==i&&o.push(i);return"#"+rt(o.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!t.match(St))throw new Error(`invalid color input: ${e}`);return t}function yt(e){try{return wt(e),!0}catch(e){return!1}}const xt=e=>e>=0&&e<=255;function It(e,t,i,o=1){if(!xt(e)||!xt(t)||!xt(i)||o<0||o>1)throw new Error(`Invalid RGBA values ${[e,t,i,o]}`);return{a:o,b:i,g:t,r:e}}function Rt(e){let{r:t,g:i,b:o}=At(e);t/=255,i/=255,o/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(i)+.0722*n(o)}function Tt(e){let t=e.r.toString(16),i=e.g.toString(16),o=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1==t.length&&(t="0"+t),1==i.length&&(i="0"+i),1==o.length&&(o="0"+o),1==n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+i+o+n).toUpperCase()}function At(e){let t,i,o,n;if(7===(e=wt(e)).length)t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),i=parseInt(e[3]+e[4],16),o=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:i,b:o}}function Mt(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,i=t*(1-Math.abs(e.h/60%2-1)),o=e.l-t/2,n=0,s=0,r=0;return 0<=e.h&&e.h<60?(n=t,s=i,r=0):60<=e.h&&e.h<120?(n=i,s=t,r=0):120<=e.h&&e.h<180?(n=0,s=t,r=i):180<=e.h&&e.h<240?(n=0,s=i,r=t):240<=e.h&&e.h<300?(n=i,s=0,r=t):300<=e.h&&e.h<360&&(n=t,s=0,r=i),n=Math.round(255*(n+o)),s=Math.round(255*(s+o)),r=Math.round(255*(r+o)),{a:e.a,r:n,g:s,b:r}}function Ot(e){const t=e.r/255,i=e.g/255,o=e.b/255;let n=Math.min(t,i,o),s=Math.max(t,i,o),r=s-n,a=0,l=0,c=0;return a=0==r?0:s==t?(i-o)/r%6:s==i?(o-t)/r+2:(t-i)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(s+n)/2,l=0==r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}const Nt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),_t=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Ft=new RegExp(/^([A-Z]{1,3})+$/,"i"),Dt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),kt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Lt=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[Nt.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 Pt(e){return Dt.test(e)}function Ut(e){return kt.test(e)}function Vt(e){return Ft.test(e)}function zt(e){return _t.test(e)}function Bt(e){const t=e.split("!"),i=t.pop();return{sheetName:De(t.join("!"))||void 0,xc:i}}function Ht(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Ht(Math.floor(e/26)-1)+Ht(e%26)}function $t(e){let t=0;const i=e.length;for(let o=0;o<i;o++){t+=(e.charCodeAt(o)-65+(o<i-1?1:0))*26**(i-o-1)}return t}function Wt(e){const t=(e=e.toUpperCase().trim()).match(Nt);if(null!==t){const[i,o,n]=t;if(i===e){return{col:$t(o),row:parseInt(n,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function Gt(e,t,i={colFixed:!1,rowFixed:!1}){return(i.colFixed?"$":"")+Ht(e)+(i.rowFixed?"$":"")+String(t+1)}const qt=140,Zt=20,jt=.035;function Xt(e){return Zt+(qt-Zt)*Math.exp(-jt*(e-1))}const Yt=/(^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+)(?!\w|!)/,Kt="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",Qt="(\\s*-)?",Jt="(\\s*[\\$€])?",ei="^(("+[Qt+Jt+Kt,Qt+Kt+Jt,Jt+Qt+Kt].join(")|(")+"))$",ti=new RegExp(ei,"i");function ii(e){return!!e&&ti.test(e.trim())}const oi=/[,\$€]+/g;function ni(e){e=e.replace(oi,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function si(e,t,i){const o=[...e].sort(((e,t)=>e-t));let n=(o.length+(i?-1:1))*t;if(i||n--,Number.isInteger(n))return o[n];const s=Math.ceil(n),r=Math.floor(n);return o[s]*(n-r)+o[r]*(s-n)}const ri=20,ai=11,li=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,ci=/0/g,hi={0:s("January"),1:s("February"),2:s("March"),3:s("April"),4:s("May"),5:s("June"),6:s("July"),7:s("August"),8:s("September"),9:s("October"),10:s("November"),11:s("December")},di={0:s("Sunday"),1:s("Monday"),2:s("Tuesday"),3:s("Wednesday"),4:s("Thursday"),5:s("Friday"),6:s("Saturday")},ui={};function gi(e){let t=ui[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,i=[];for(;t<e.length;){let o;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(o=e.substring(t+1).indexOf("]")+t+2,0===o)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,o-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);i.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");o=n>-1?n+t:e.length;const s=e.substring(t,o);s.match(Y)?i.push({type:"DATE",format:s}):i.push({type:"NUMBER",format:Oi(s)})}t=o}return i}(e),ui[e]=t),t}function pi(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=xi(e));return function(e,t){if("DATE"===t[0].type)return Ei(e,t[0].format);let i=e<0?"-":"";for(let o of t)switch(o.type){case"NUMBER":i+=mi(Math.abs(e),o.format);break;case"STRING":i+=o.format}return i}(e,gi(t));case"object":return"0"}}function mi(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let i=0;void 0!==t.decimalPart&&(i=t.decimalPart.length);const{integerDigits:o,decimalDigits:n}=vi(e,i);let s=function(e,t,i){var o;const n="0"===e?"":e;let s=n;const r=t.length-n.length;if(r>0){const e=(t.substring(0,r).match(ci)||[]).length;s="0".repeat(e)+s}i&&(s=(null===(o=s.match(li))||void 0===o?void 0:o.join(","))||s);return s}(o,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(s+="."+function(e,t){let i=e;if(t.length-e.length>0){const o=(t.substring(e.length,t.length+1).match(ci)||[]).length;i+="0".repeat(o)}return i}(n||"",t.decimalPart)),t.isPercent&&(s+="%"),s}const fi=[];function vi(e,t=ri){const i=e.toString();if(i.includes("e"))return function(e,t=ri){let i=fi[t];i||(i=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),fi[t]=i);const[o,n]=i.format(e).split(".");return{integerDigits:o,decimalDigits:n}}(e,t);if(Number.isInteger(e))return{integerDigits:i,decimalDigits:void 0};const o=i.indexOf(".");let n=i.substring(0,o),s=i.substring(o+1);if(0===t)return Number(s[0])>=5&&(n=(Number(n)+1).toString()),{integerDigits:n,decimalDigits:void 0};if(s.length>t){const{integerDigits:e,decimalDigits:i}=function(e,t){var i;let o="0",n=e,s=e.slice(0,t);const r=t;if(Number(e[r])<5)return{integerDigits:o,decimalDigits:s};const a=(null===(i=s.match(Si))||void 0===i?void 0:i[0])||"",l=(Number(s)+1).toString(),c=s.slice(a.length),h=l.length>c.length;h&&!a?(o="1",n=void 0):n=h?a.slice(0,-1)+l:a+l;return{integerDigits:o,decimalDigits:n}}(s,t);s=i,"0"!==e&&(n=(Number(n)+Number(e)).toString())}return{integerDigits:n,decimalDigits:bi(s||"")}}function bi(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}const Si=/^0+/;function Ci(e){try{return Ei(1,e),!0}catch(e){return!1}}function Ei(e,t){const i=ye(e),o=t.indexOf("h");let n="",s="";return o>0?(n=wi(i,t.substring(0,o-1)),s=yi(i,t.substring(o))):0===o?s=yi(i,t):o<0&&(n=wi(i,t)),n+(n&&s?" ":"")+s}function wi(e,t){var i;const o=null===(i=t.match(/\/|-|\s/))||void 0===i?void 0:i[0];return(o?t.split(o):[t]).map((i=>{switch(i){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return di[e.getDay()].slice(0,3);case"dddd":return di[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return hi[e.getMonth()].slice(0,3);case"mmmm":return hi[e.getMonth()];case"mmmmm":return hi[e.getMonth()].slice(0,1);case"yy":const i=String(e.getFullYear()).replace("-","").padStart(2,"0");return i.slice(i.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(o)}function yi(e,t){let i=t.split(/:|\s/);const o=e.getHours(),n="a"===i[i.length-1];let s=o,r="";return n&&(s=0===s?12:s>12?s-12:s,r=o>=12?" PM":" AM",i.pop()),i.map((i=>{switch(i){case"hhhh":return Math.floor((e.getTime()-ue)/36e5).toString();case"hh":return s.toString().padStart(2,"0");case"mm":return e.getMinutes().toString().padStart(2,"0");case"ss":return e.getSeconds().toString().padStart(2,"0");default:throw new Error(`invalid format: ${t}`)}})).join(":")+r}function xi(e){let{integerDigits:t,decimalDigits:i}=vi(e);if(!i)return"0";const o=t.replace("-","").length;if(o+2>ai)return"0";const n=ai-o-1;return({decimalDigits:i}=vi(e,Math.min(n,i.length))),i?"0."+"0".repeat(i.length):"0"}function Ii(e){if(qe(e)){return Ee(e).format}if(!ii(e))return;const t=e.includes(".")?"0.00":"0",i=e.match(/[\$€]/);if(i){const o=e.match(/[\d]/),n="[$"+i.values().next().value+"]";return o.index<i.index?"#,##"+t+n:n+"#,##"+t}return e.includes("%")?t+"%":void 0}function Ri(e,t,i){return _i(gi(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:i}]:e)).flat())}function Ti(e,t){const i=gi(e).map((e=>"NUMBER"===e.type?{...e,format:Ai(e.format,t)}:e)),o=_i(i);return ui[o]=i,o}function Ai(e,t){var i;const o={...e},n=Math.sign(t),s=(null===(i=o.decimalPart)||void 0===i?void 0:i.length)||0,r=Math.min(Math.max(0,s+n),ri);return o.decimalPart="0".repeat(r),""===o.decimalPart&&delete o.decimalPart,o}const Mi=/,*?$/;function Oi(e){var t;if(function(e){return Boolean(e.replace(Ni,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const i=e.includes("%"),o=(null===(t=e.match(Mi))||void 0===t?void 0:t[0])||"",n=o?1e3**o.length:1;let s=e.slice(0,e.length-(o.length||0));const r=s.includes(",");if(s.match(/\..*,/))throw new Error("A format can't contain ',' symbol in the decimal part");s=s.replace("%","").replace(",","");const a=s.match(/[\%|,]/);if(a)throw new Error(`A format can only contain a single '${a[0]}' symbol`);const[l,c]=s.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:i,thousandsSeparator:r,decimalPart:c,magnitude:n}:{integerPart:l,isPercent:i,thousandsSeparator:r,magnitude:n}}const Ni=/[,#0.%]/g;function _i(e){let t="";for(let i of e){let e;switch(i.type){case"NUMBER":const t=i.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=`[$${i.format}]`;break;case"DATE":e=i.format}t+=e}return t}class Fi{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 Fi?e:new Fi(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:i,right:o}=this._zone;if(void 0!==o&&void 0!==i)return this._zone;if(void 0===i&&void 0!==o)return{right:o,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===o&&void 0!==i)return{bottom:i,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(s("Bad zone format"))}static getRangeParts(e,t){const i=e.split(":").map((e=>{const t=Ut(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),o=void 0===t.bottom,n=void 0===t.right;return o&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed,t.left===t.right&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed)),n&&(i[0].colFixed=i[0].colFixed||i[1].colFixed,i[1].colFixed=i[0].colFixed||i[1].colFixed,t.top===t.bottom&&(i[0].rowFixed=i[0].rowFixed||i[1].rowFixed,i[1].rowFixed=i[0].rowFixed||i[1].rowFixed)),i}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(){var e,t,i,o,n,s,r,a;const l={...this._zone};let c=this.parts;if(void 0!==l.right&&l.right<l.left){let n=l.right;l.right=l.left,l.left=n,c=[{colFixed:(null===(e=c[1])||void 0===e?void 0:e.colFixed)||!1,rowFixed:(null===(t=c[0])||void 0===t?void 0:t.rowFixed)||!1},{colFixed:(null===(i=c[0])||void 0===i?void 0:i.colFixed)||!1,rowFixed:(null===(o=c[1])||void 0===o?void 0:o.rowFixed)||!1}]}if(void 0!==l.bottom&&l.bottom<l.top){let e=l.bottom;l.bottom=l.top,l.top=e,c=[{colFixed:(null===(n=c[0])||void 0===n?void 0:n.colFixed)||!1,rowFixed:(null===(s=c[1])||void 0===s?void 0:s.rowFixed)||!1},{colFixed:(null===(r=c[1])||void 0===r?void 0:r.colFixed)||!1,rowFixed:(null===(a=c[0])||void 0===a?void 0:a.rowFixed)||!1}]}return this.clone({zone:l,parts:c})}clone(e){return new Fi({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 Di(e,t,i){const o=i.sheetId===e?t:i.sheetId;return i.clone({sheetId:o})}function ki(e,t,i){return i?e.getRangeFromSheetXC(t,i):void 0}function Li(e,t,i){const o=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let i=0,o=0,n=(t=t.toLocaleLowerCase()).length,s=0;for(let r=0;r<n;r++)t[r]===e[s]?(s++,o+=100+o-r/200):o=0,i+=o;return s===e.length?i:0}(e,i(t));n>0&&o.push({score:n,elem:t})})),o.sort(((e,t)=>t.score-e.score)),o.map((e=>e.elem))}function Pi(e){const t=[];for(let i=0;i<e;i++){const e={cells:{}};t.push(e)}return t}class Ui{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 Vi(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let i,o,n,s,r=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Pt(c))n=s=$t(c),i=o=0,r=!0;else if(Ut(c))i=o=parseInt(c,10)-1,n=s=0,a=!0;else{const e=Wt(c);n=s=e.col,i=o=e.row,l=!0}if(2===t.length)if(Pt(h))s=$t(h),r=!0;else if(Ut(h))o=parseInt(h,10)-1,a=!0;else{const e=Wt(h);s=e.col,o=e.row,i=r?o:i,n=a?s:n,l=!0}if(r&&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:i,left:n,bottom:r?void 0:o,right:a?void 0:s};return l=l&&(a||r),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 zi(e){const t=Vi(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Bi(e){const{bottom:t,top:i,left:o,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(i)||isNaN(o)||void 0!==n&&isNaN(n))&&((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 Hi(e){const{top:t,bottom:i,left:o,right:n}=e,r="hasHeader"in e&&e.hasHeader,a=t===i&&o===n;if(void 0===i&&void 0!==n)return 0!==t||r?`${Gt(o,t)}:${Ht(n)}`:`${Ht(o)}:${Ht(n)}`;if(void 0===n&&void 0!==i)return 0!==o||r?`${Gt(o,t)}:${i+1}`:`${t+1}:${i+1}`;if(void 0!==i&&void 0!==n)return a?Gt(o,t):`${Gt(o,t)}:${Gt(n,i)}`;throw new Error(s("Bad zone format"))}function $i(e,t,i,o,n){const s="left"===t?"columns":"rows",r="before"===o?i-1:i,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?no(e,s,"RESIZE",n):r<e[t]?no(e,s,"MOVE",n):{...e}}function Wi(e,t,i,o,n){const s="left"===t?"columns":"rows",r="before"===o?i-1:i,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?no(e,s,"RESIZE",n):r<e[t]?no(e,s,"MOVE",n):{...e}}function Gi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],s=e[o];for(let r of i.sort(((e,t)=>t-e)))e[t]>r&&(n--,s--),e[t]<r&&e[o]>=r&&s--;return{...e,[t]:n,[o]:s}}function qi(e,t,i){const o="left"===t?"right":"bottom";let n=e[t],s=e[o];const r=e[o];for(let o of i.sort(((e,t)=>t-e)))e[t]>o&&(n--,void 0!==s&&s--),void 0!==r&&void 0!==s&&e[t]<=o&&r>=o&&s--;if(!(void 0!==s&&n>s))return{...e,[t]:n,[o]:s}}function Zi(...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 ji(e,t){if(Yi(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 Xi(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Yi(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Ki(e,t,i){const{left:o,right:n,top:s,bottom:r}=i;return e>=o&&e<=n&&t>=s&&t<=r}function Qi(e,t){return Xi(Zi(t,e),t)}function Ji(e,t){const i=e.map(Vi),o=t.map(zi),n=Math.max(...i.concat(o).map((e=>e.bottom||0))),s=Math.max(...i.concat(o).map((e=>e.right||0))),r=i.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),a=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),l=function(e,t){const i=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!i.has(`${e}-${t}`)))}(r.map(oo).flat(),a.map(oo).flat()),c=function(e){if(0===e.length)return[];const[t,...i]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),o=[];let n=ao(t);for(const{col:e,row:t}of i)if(!Ki(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else o.push(n),n=ao({col:e,row:t});return[...o,n]}(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=[],i=eo(e),o=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;i.length;){const e=i.reduce(((e,t)=>o(e,t)?Zi(e,t):e),i.shift());t.push(e)}return eo(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===s+1?void 0:e.right}))).map(Hi)}function eo(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(),i=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Qi(e,t)))||i.push(e)}return i.reverse()}function to(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function io(e){const{numberOfCols:t,numberOfRows:i}=to(e);return 1===t||1===i}function oo(e){const t=[],[i,o]=[e.right,e.left].sort(((e,t)=>e-t)),[n,s]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of $e(i,o+1))for(const i of $e(n,s+1))t.push({col:e,row:i});return t}function no(e,t,i,o){const n="both"===t?o[0]:"columns"===t?o:0,s="both"===t?o[1]:"rows"===t?o:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(lo(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===i&&(l.left+=n,l.top+=s),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=s),l}function so(e,t){let i,o;const{left:n,right:s,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return i=l!=n?l:c!=s?c:l,o=h!=r?h:d!=a?d:h,{col:i,row:o}}function ro(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 ao(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function lo(e){return void 0===e.right}function co(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function ho(...e){return e.length<2||1===Ji(e.map(Hi),[]).length}class uo 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;ht(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,i,o,n,s;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===(i=r.options)||void 0===i?void 0:i.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=null===(o=r.options)||void 0===o?void 0:o.tooltips,this.chart.config.options.legend=null===(n=r.options)||void 0===n?void 0:n.legend,this.chart.config.options.scales=null===(s=r.options)||void 0===s?void 0:s.scales,this.chart.update({duration:0})}}uo.template="o-spreadsheet-ChartJsComponent",uo.props={figure:Object};const go={};let po=0;function mo(e,...t){const i="__sheet__"+po++;return function(e,t){const i=document.createElement("style");i.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),i=[],o=[];let n=[];function s(e,t){const o=[];for(const n of i[e]){let r=t&&t+" "+n||n;r.includes("&")&&(r=n.replace(/&/g,t||"")),e<i.length-1&&(r=s(e+1,r)),o.push(r)}return o.join(", ")}function r(){n.length&&(o.push(s(0)+" {"),o.push(...n),o.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),i.pop()):("{"===t[0]&&(r(),i.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return o.join("\n")}(t),go[e]=i}(i,String.raw(e,...t)),function(e){const t=go[e];t.setAttribute("component",e),document.head.appendChild(t)}(i),i}function fo({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function vo(e){const t=bo(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function bo(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 i=e.strikethrough?"line-through":"";i=e.underline?i+" underline":i,t["text-decoration"]=i}return e.textColor&&(t.color=e.textColor),t}function So(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const Co=1.2;mo`
2
2
  div.o-scorecard {
3
3
  font-family: ${Z};
4
4
  user-select: none;
@@ -17,15 +17,15 @@
17
17
 
18
18
  .o-title-text {
19
19
  text-align: left;
20
- height: ${So+"em"};
21
- line-height: ${So+"em"};
20
+ height: ${Co+"em"};
21
+ line-height: ${Co+"em"};
22
22
  overflow: hidden;
23
23
  white-space: nowrap;
24
24
  }
25
25
 
26
26
  .o-key-text {
27
- line-height: ${So+"em"};
28
- height: ${So+"em"};
27
+ line-height: ${Co+"em"};
28
+ height: ${Co+"em"};
29
29
  overflow: hidden;
30
30
  white-space: nowrap;
31
31
  }
@@ -40,8 +40,8 @@
40
40
  }
41
41
 
42
42
  .o-baseline-text {
43
- line-height: ${So+"em"};
44
- height: ${So+"em"};
43
+ line-height: ${Co+"em"};
44
+ height: ${Co+"em"};
45
45
  overflow: hidden;
46
46
  white-space: nowrap;
47
47
 
@@ -50,7 +50,7 @@
50
50
  }
51
51
  }
52
52
  }
53
- `;class Co 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 It(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get figure(){return this.props.figure}get chartStyle(){return bo({padding:`${this.chartPadding}px`,background:this.backgroundColor})}get chartContentStyle(){return bo({height:`${this.getDrawableHeight()}px`})}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),i=t.getElementMaxFontSize(this.getDrawableHeight(),this);let o=function(e,t,i,o=.25){let n=1;if(i(n)>e)return n;if(i(t)<e)return t;let s=(n+t)/2,r=i(s),a=0;for(;Math.abs(r-e)>o&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,s=(n+t)/2,r=i(s),a++;return s}(e,i,(e=>t.getElementWidth(e,this.ctx,this)))/i;const n=(new wo).getElementMaxFontSize(this.getDrawableHeight(),this)*o,s=(new Eo).getElementMaxFontSize(this.getDrawableHeight(),this)*o;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:n,cellStyle:this.runtime.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:s}),baselineValueStyle:this.getTextStyle({fontSize:s,cellStyle:this.runtime.baselineStyle,color:this.runtime.baselineColor||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*s,color:this.secondaryFontColor})}}getTextStyle(e){const t=vo(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),bo(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*So:0,t}getWidestElement(){const e=new Eo,t=new wo;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}Co.template="o-spreadsheet-ScorecardChart";class Eo{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.baseline,n="neutral"!==i.baselineArrowDirection?"A "+o:o;t.font=`${e}px ${Z}`;let s=t.measureText(n).width;return t.font=`${.9*e}px ${Z}`,s+=t.measureText(i.baselineDescr).width,s}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/So}}class wo{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.keyValue||"";return t.font=`${e}px ${Z}`,t.measureText(o).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/So}}Co.props={figure:Object};class yo{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]}}function xo(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const Io=new yo;function Ro(e,t){return{url:e=xo(e),label:t||e,isExternal:!0,isUrlEditable:!0}}Io.add("sheet_URL",{match:e=>Je(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const i=tt(e);return t.tryGetSheetName(i)||s("Invalid sheet")},open(e,t){const i=tt(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:i})},sequence:0});const To={createLink:Ro,match:e=>Xe(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function Ao(e){return Io.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||To}function Mo(e,t){return Ao(e.url).urlRepresentation(e.url,t)}function Oo(e,t){Ao(e.url).open(e.url,t)}function No(e){if("string"==typeof e){if(je(e)){const{label:t,url:i}=Ke(e);return Ao(i).createLink(i,t)}return Xe(e)?Ro(e):void 0}}const _o=["number","string","boolean","undefined"];function Fo(e,t){if(!e())throw new Error(t)}const Do=e=>s("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function ko(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(ti(e)||""===e)return oi(e);const t=Ce(e);if(t)return t.value;throw new Error(Do(e));default:return 0}}function Lo(e){if(""===e)throw new Error(Do(e));return ko(e)}function Po(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function Uo(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const Vo=e=>s("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function zo(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(Vo(e))}return!1;case"number":return!!e;default:return!1}}function Bo(e){return we(ko(e))}function Ho(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)t(o[i][n])}else i(o)}function $o(e,t){Ho(e,t,t)}function Wo(e,t){Ho(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Lo(e))}))}function Go(e,t,i,o){let n=o;for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let s=0;s<i;s++)for(let i=0;i<e;i++)n=t(n,o[i][s])}else n=i(n,o);return n}function qo(e,t,i){return Go(e,t,t,i)}function Zo(e,t,i){return Go(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Lo(i))),i)}function jo(e,t,i){return Go(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?ko(i):0):e),((e,i)=>t(e,ko(i))),i)}function Xo(e,t){return function(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)if(!t(o[i][n]))return}else if(!i(o))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Vo(e));return zo(e)}(e))))}function Yo(e,t){let i,o,n=e.substring(0,2);"<="===n||">="===n||"<>"===n?(i=n,o=e.substring(2)):(n=e.substring(0,1),"<"===n||">"===n||"="===n?(i=n,o=e.substring(1)):(i="=",o=e)),ti(o)?o=ko(o):"TRUE"!==o&&"FALSE"!==o||(o=zo(o));const s={operator:i,operand:o};return"string"==typeof o&&(t&&(o+="*"),s.regexp=function(e){let t="",i="";for(let o of e)"?"===o&&"~"!==i?t+=".":"*"===o&&"~"!==i?t+=".*":("*"!==o&&"?"!==o||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(o)&&(t+="\\"),t+=o),i=o;return new RegExp("^"+t+"$","i")}(o)),s}function Ko(e,t){const{operator:i,operand:o}=t;if(void 0===e||void 0===o)return!1;if("number"==typeof o&&"="===i)return Po(e)===Po(o);if("<>"===i||"="===i){let n;return n=typeof e==typeof o&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===o),"="===i?n:!n}if(typeof e==typeof o)switch(i){case"<":return e<o;case">":return e>o;case"<=":return e<=o;case">=":return e>=o}return!1}function Qo(e,t,i=!1){const o=e.length;if(o%2==1)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=e[0].length,r=e[0][0].length;let a=[];for(let t=0;t<o-1;t+=2){const o=e[t];if(!Array.isArray(o)||o.length!==n||o[0].length!==r)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Po(e[t+1]);a.push(Yo(l,i))}for(let i=0;i<n;i++)for(let n=0;n<r;n++){let s=!0;for(let t=0;t<o-1;t+=2){if(s=Ko(e[t][i][n],a[t/2]),!s)break}s&&t(i,n)}}function Jo(e,t){return Uo(e[0][t])}function en(e,t){return Uo(e[t][0])}function tn(e,t,i,o,n,s){if(null==t)return-1;const r=typeof t;let a,l,c,h,d,u,g=0,p=n-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=s(e,h),u=typeof d;g<h&&r!==u;)h--,d=s(e,h),u=typeof d;u===r&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h),"asc"===o&&d>t||"desc"===o&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function on(e,t,i,o,n,s=!1){if(null==t)return-1;const r=s?(e,t)=>n(e,o-t-1):n;let a,l=-1;for(let n=0;n<o;n++){const c=r(e,n);if(c===t)return s?o-n-1:n;"nextSmaller"===i?(!a&&nn(t,c)>=0||nn(t,c)>=0&&nn(c,a)>0)&&(a=c,l=n):"nextGreater"===i&&(!a&&nn(t,c)<=0||nn(t,c)<=0&&nn(c,a)<0)&&(a=c,l=n)}return s?o-l-1:l}function nn(e,t){let i=_o.indexOf(typeof e)-_o.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}var sn,rn;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(sn||(sn={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(rn||(rn={}));const an=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),ln=new Set([...an,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),cn=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","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),hn=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","CREATE_IMAGE"]);function dn(e){return hn.has(e.type)}class un{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new un}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var gn,pn,mn;function fn(e,t){return bn(vn(e||""),t)}function vn(e){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return ti(e)||Ge(e)?ko(e):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function bn(e,t){const i=No(e);return i?{...Sn(vn(i.label),t||xi(i.label)),link:i}:Sn(e,t)}function Sn(e,t){try{for(const i of yn){const o=i(e,t);if(o)return o}return function(e,t){return{type:sn.text,value:e,format:t,isAutoSummable:!0,defaultAlign:"left",formattedValue:gi(e,t)}}((e||"").toString(),t)}catch(t){return wn((e||"").toString(),new c(a.GenericError,t.message||le))}}function Cn(e,t){return{type:sn.number,value:e||0,format:t,isAutoSummable:!0,defaultAlign:"right",formattedValue:gi(e,t)}}e.CommandResult=void 0,(gn=e.CommandResult||(e.CommandResult={}))[gn.Success=0]="Success",gn[gn.CancelledForUnknownReason=1]="CancelledForUnknownReason",gn[gn.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",gn[gn.MergeIsDestructive=3]="MergeIsDestructive",gn[gn.CellIsMerged=4]="CellIsMerged",gn[gn.InvalidTarget=5]="InvalidTarget",gn[gn.EmptyUndoStack=6]="EmptyUndoStack",gn[gn.EmptyRedoStack=7]="EmptyRedoStack",gn[gn.NotEnoughElements=8]="NotEnoughElements",gn[gn.NotEnoughSheets=9]="NotEnoughSheets",gn[gn.MissingSheetName=10]="MissingSheetName",gn[gn.DuplicatedSheetName=11]="DuplicatedSheetName",gn[gn.DuplicatedSheetId=12]="DuplicatedSheetId",gn[gn.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",gn[gn.WrongSheetMove=14]="WrongSheetMove",gn[gn.WrongSheetPosition=15]="WrongSheetPosition",gn[gn.InvalidAnchorZone=16]="InvalidAnchorZone",gn[gn.SelectionOutOfBound=17]="SelectionOutOfBound",gn[gn.TargetOutOfSheet=18]="TargetOutOfSheet",gn[gn.WrongCutSelection=19]="WrongCutSelection",gn[gn.WrongPasteSelection=20]="WrongPasteSelection",gn[gn.WrongPasteOption=21]="WrongPasteOption",gn[gn.WrongFigurePasteOption=22]="WrongFigurePasteOption",gn[gn.EmptyClipboard=23]="EmptyClipboard",gn[gn.EmptyRange=24]="EmptyRange",gn[gn.InvalidRange=25]="InvalidRange",gn[gn.InvalidZones=26]="InvalidZones",gn[gn.InvalidSheetId=27]="InvalidSheetId",gn[gn.InvalidFigureId=28]="InvalidFigureId",gn[gn.InputAlreadyFocused=29]="InputAlreadyFocused",gn[gn.MaximumRangesReached=30]="MaximumRangesReached",gn[gn.InvalidChartDefinition=31]="InvalidChartDefinition",gn[gn.InvalidDataSet=32]="InvalidDataSet",gn[gn.InvalidLabelRange=33]="InvalidLabelRange",gn[gn.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",gn[gn.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",gn[gn.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",gn[gn.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",gn[gn.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",gn[gn.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",gn[gn.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",gn[gn.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",gn[gn.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",gn[gn.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",gn[gn.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",gn[gn.InvalidAutofillSelection=45]="InvalidAutofillSelection",gn[gn.WrongComposerSelection=46]="WrongComposerSelection",gn[gn.MinBiggerThanMax=47]="MinBiggerThanMax",gn[gn.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",gn[gn.MidBiggerThanMax=49]="MidBiggerThanMax",gn[gn.MinBiggerThanMid=50]="MinBiggerThanMid",gn[gn.FirstArgMissing=51]="FirstArgMissing",gn[gn.SecondArgMissing=52]="SecondArgMissing",gn[gn.MinNaN=53]="MinNaN",gn[gn.MidNaN=54]="MidNaN",gn[gn.MaxNaN=55]="MaxNaN",gn[gn.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",gn[gn.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",gn[gn.MinInvalidFormula=58]="MinInvalidFormula",gn[gn.MidInvalidFormula=59]="MidInvalidFormula",gn[gn.MaxInvalidFormula=60]="MaxInvalidFormula",gn[gn.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",gn[gn.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",gn[gn.InvalidSortZone=63]="InvalidSortZone",gn[gn.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",gn[gn.MergeOverlap=65]="MergeOverlap",gn[gn.TooManyHiddenElements=66]="TooManyHiddenElements",gn[gn.Readonly=67]="Readonly",gn[gn.InvalidViewportSize=68]="InvalidViewportSize",gn[gn.InvalidScrollingDirection=69]="InvalidScrollingDirection",gn[gn.FigureDoesNotExist=70]="FigureDoesNotExist",gn[gn.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",gn[gn.InvalidCellPopover=72]="InvalidCellPopover",gn[gn.EmptyTarget=73]="EmptyTarget",gn[gn.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",gn[gn.FrozenPaneOverlap=75]="FrozenPaneOverlap",gn[gn.ValuesNotChanged=76]="ValuesNotChanged",gn[gn.InvalidFilterZone=77]="InvalidFilterZone",gn[gn.FilterOverlap=78]="FilterOverlap",gn[gn.FilterNotFound=79]="FilterNotFound",gn[gn.MergeInFilter=80]="MergeInFilter",gn[gn.NonContinuousTargets=81]="NonContinuousTargets",gn[gn.DuplicatedFigureId=82]="DuplicatedFigureId",gn[gn.InvalidSelectionStep=83]="InvalidSelectionStep",gn[gn.DuplicatedChartId=84]="DuplicatedChartId",gn[gn.ChartDoesNotExist=85]="ChartDoesNotExist",gn[gn.InvalidHeaderIndex=86]="InvalidHeaderIndex",gn[gn.InvalidQuantity=87]="InvalidQuantity",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(pn||(pn={})),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.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(mn||(mn={}));const En={type:sn.empty,value:"",format:void 0,isAutoSummable:!0,defaultAlign:"left",formattedValue:""};function wn(e,t){return{type:sn.error,value:t.errorType,error:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:t.errorType}}const yn=[function(e,t){if(""===e)return function(e){return void 0===e?En:{type:sn.empty,value:"",format:e,isAutoSummable:!0,defaultAlign:"left",formattedValue:""}}(t)},function(e,t){if(t&&"number"==typeof e&&Si(t))return function(e,t){const i=gi(e,t);return{type:sn.number,value:e,format:t,isAutoSummable:!1,defaultAlign:"right",formattedValue:i}}(e,t)},function(e,t){return"number"==typeof e?Cn(e,t):null===e?Cn(0,t):void 0},function(e,t){if("boolean"==typeof e)return function(e,t){const i=e?"TRUE":"FALSE";return{type:sn.boolean,value:e,format:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:i}}(e,t)}],xn=new yo;xn.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const i=`${e.prefix}${e.current.toString().padStart(e.numberPostfixLength||0,"0")}`;return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i},tooltip:{props:{content:i}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t)=>{var i;e.current+=e.increment;const o=e.current.toString(),n=gi(e.current,null===(i=t.cell)||void 0===i?void 0:i.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:o?{props:{content:n}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,i)=>{var o,n,s;const r=(null===(o=t.cell)||void 0===o?void 0:o.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:fn(null===(n=t.cell)||void 0===n?void 0:n.content,null===(s=t.cell)||void 0===s?void 0:s.format).formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,i,o)=>{e.current+=e.increment;let n=0,s=0;switch(o){case"up":n=0,s=-e.current;break;case"down":n=0,s=e.current;break;case"left":n=-e.current,s=0;break;case"right":n=e.current,s=0}const r=t.cell;if(!r||!r.isFormula)return{cellData:{}};const a=t.sheetId,l=i.createAdaptedRanges(r.dependencies,n,s,a),c=i.buildFormulaContent(a,r,l);return{cellData:{border:t.border,style:r.style,format:r.format,content:c},tooltip:c?{props:{content:c}}:void 0}}});const In=new yo,Rn=/(\d+)$/,Tn=/^(.*\D+)/,An=/^(.*\D+)(\d+)$/;function Mn(e,t,i){let o=[],n=!1;for(let s of t){s===e&&(n=!0);const t=fn(null==s?void 0:s.content);if(i(t))o.push(t);else{if(n)return o;o=[]}}return o}function On(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let i=e[0];for(let o=1;o<e.length;o++){const n=e[o];t.push(n-i),i=n}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}In.add("simple_value_copy",{condition:(e,t)=>{var i;return 1===t.length&&!e.isFormula&&!(null===(i=e.format)||void 0===i?void 0:i.match(Y))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&fn(e.content).type===sn.text&&An.test(e.content),generateRule:(e,t)=>{const i=parseInt(e.content.match(Rn)[0]),o=e.content.match(Tn)[0],n=e.content.length-o.length,s=Mn(e,t,(e=>e.type===sn.text&&An.test(e.value))).filter((e=>o===e.value.toString().match(Tn)[0])).map((e=>parseInt(e.value.toString().match(Rn)[0]))),r=On(s);return{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:o,current:i,increment:r,numberPostfixLength:n}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&fn(e.content).type===sn.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.isFormula&&fn(e.content).type===sn.number,generateRule:(e,t)=>{const i=On(Mn(e,t,(e=>e.type===sn.number)).map((e=>Number(e.value)))),o=fn(e.content);return{type:"INCREMENT_MODIFIER",increment:i,current:o.type===sn.number?o.value:0}},sequence:40});po`
53
+ `;class Eo 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 Rt(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get figure(){return this.props.figure}get chartStyle(){return So({padding:`${this.chartPadding}px`,background:this.backgroundColor})}get chartContentStyle(){return So({height:`${this.getDrawableHeight()}px`})}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),i=t.getElementMaxFontSize(this.getDrawableHeight(),this);let o=function(e,t,i,o=.25){let n=1;if(i(n)>e)return n;if(i(t)<e)return t;let s=(n+t)/2,r=i(s),a=0;for(;Math.abs(r-e)>o&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,s=(n+t)/2,r=i(s),a++;return s}(e,i,(e=>t.getElementWidth(e,this.ctx,this)))/i;const n=(new yo).getElementMaxFontSize(this.getDrawableHeight(),this)*o,s=(new wo).getElementMaxFontSize(this.getDrawableHeight(),this)*o;return{titleStyle:this.getTextStyle({fontSize:18,color:this.secondaryFontColor}),keyStyle:this.getTextStyle({fontSize:n,cellStyle:this.runtime.keyValueStyle,color:this.primaryFontColor}),baselineStyle:this.getTextStyle({fontSize:s}),baselineValueStyle:this.getTextStyle({fontSize:s,cellStyle:this.runtime.baselineStyle,color:this.runtime.baselineColor||this.secondaryFontColor}),baselineDescrStyle:this.getTextStyle({fontSize:.9*s,color:this.secondaryFontColor})}}getTextStyle(e){const t=bo(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),So(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*Co:0,t}getWidestElement(){const e=new wo,t=new yo;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}Eo.template="o-spreadsheet-ScorecardChart";class wo{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.baseline,n="neutral"!==i.baselineArrowDirection?"A "+o:o;t.font=`${e}px ${Z}`;let s=t.measureText(n).width;return t.font=`${.9*e}px ${Z}`,s+=t.measureText(i.baselineDescr).width,s}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/Co}}class yo{getElementWidth(e,t,i){if(!i.runtime)return 0;const o=i.keyValue||"";return t.font=`${e}px ${Z}`,t.measureText(o).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/Co}}Eo.props={figure:Object};class xo{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]}}function Io(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const Ro=new xo;function To(e,t){return{url:e=Io(e),label:t||e,isExternal:!0,isUrlEditable:!0}}Ro.add("sheet_URL",{match:e=>et(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const i=it(e);return t.tryGetSheetName(i)||s("Invalid sheet")},open(e,t){const i=it(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:i})},sequence:0});const Ao={createLink:To,match:e=>Ye(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function Mo(e){return Ro.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||Ao}function Oo(e,t){return Mo(e.url).urlRepresentation(e.url,t)}function No(e,t){Mo(e.url).open(e.url,t)}function _o(e){if("string"==typeof e){if(Xe(e)){const{label:t,url:i}=Qe(e);return Mo(i).createLink(i,t)}return Ye(e)?To(e):void 0}}const Fo=["number","string","boolean","undefined"];function Do(e,t){if(!e())throw new Error(t)}const ko=e=>s("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Lo(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(ii(e)||""===e)return ni(e);const t=Ee(e);if(t)return t.value;throw new Error(ko(e));default:return 0}}function Po(e){if(""===e)throw new Error(ko(e));return Lo(e)}function Uo(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function Vo(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const zo=e=>s("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Bo(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(zo(e))}return!1;case"number":return!!e;default:return!1}}function Ho(e){return ye(Lo(e))}function $o(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)t(o[i][n])}else i(o)}function Wo(e,t){$o(e,t,t)}function Go(e,t){$o(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Po(e))}))}function qo(e,t,i,o){let n=o;for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let s=0;s<i;s++)for(let i=0;i<e;i++)n=t(n,o[i][s])}else n=i(n,o);return n}function Zo(e,t,i){return qo(e,t,t,i)}function jo(e,t,i){return qo(e,((e,i)=>"number"==typeof i?t(e,i):e),((e,i)=>t(e,Po(i))),i)}function Xo(e,t,i){return qo(e,((e,i)=>null!=i?t(e,"number"==typeof i?i:"boolean"==typeof i?Lo(i):0):e),((e,i)=>t(e,Lo(i))),i)}function Yo(e,t){return function(e,t,i){for(let o of e)if(Array.isArray(o)){const e=o.length,i=o[0].length;for(let n=0;n<i;n++)for(let i=0;i<e;i++)if(!t(o[i][n]))return}else if(!i(o))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(zo(e));return Bo(e)}(e))))}function Ko(e,t){let i,o,n=e.substring(0,2);"<="===n||">="===n||"<>"===n?(i=n,o=e.substring(2)):(n=e.substring(0,1),"<"===n||">"===n||"="===n?(i=n,o=e.substring(1)):(i="=",o=e)),ii(o)?o=Lo(o):"TRUE"!==o&&"FALSE"!==o||(o=Bo(o));const s={operator:i,operand:o};return"string"==typeof o&&(t&&(o+="*"),s.regexp=function(e){let t="",i="";for(let o of e)"?"===o&&"~"!==i?t+=".":"*"===o&&"~"!==i?t+=".*":("*"!==o&&"?"!==o||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(o)&&(t+="\\"),t+=o),i=o;return new RegExp("^"+t+"$","i")}(o)),s}function Qo(e,t){const{operator:i,operand:o}=t;if(void 0===e||void 0===o)return!1;if("number"==typeof o&&"="===i)return Uo(e)===Uo(o);if("<>"===i||"="===i){let n;return n=typeof e==typeof o&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===o),"="===i?n:!n}if(typeof e==typeof o)switch(i){case"<":return e<o;case">":return e>o;case"<=":return e<=o;case">=":return e>=o}return!1}function Jo(e,t,i=!1){const o=e.length;if(o%2==1)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=e[0].length,r=e[0][0].length;let a=[];for(let t=0;t<o-1;t+=2){const o=e[t];if(!Array.isArray(o)||o.length!==n||o[0].length!==r)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Uo(e[t+1]);a.push(Ko(l,i))}for(let i=0;i<n;i++)for(let n=0;n<r;n++){let s=!0;for(let t=0;t<o-1;t+=2){if(s=Qo(e[t][i][n],a[t/2]),!s)break}s&&t(i,n)}}function en(e,t){return Vo(e[0][t])}function tn(e,t){return Vo(e[t][0])}function on(e,t,i,o,n,s){if(null==t)return-1;const r=typeof t;let a,l,c,h,d,u,g=0,p=n-1;for(;p-g>=0;){for(c=Math.floor((g+p)/2),h=c,d=s(e,h),u=typeof d;g<h&&r!==u;)h--,d=s(e,h),u=typeof d;u===r&&void 0!==d?("strict"===i&&d===t?(a=d,l=h):"nextSmaller"===i&&d<=t?(void 0===a||a<d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h):"nextGreater"===i&&d>=t&&(void 0===a||a>d||a===d&&"asc"===o&&l<h||a===d&&"desc"===o&&l>h)&&(a=d,l=h),"asc"===o&&d>t||"desc"===o&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function nn(e,t,i,o,n,s=!1){if(null==t)return-1;const r=s?(e,t)=>n(e,o-t-1):n;let a,l=-1;for(let n=0;n<o;n++){const c=r(e,n);if(c===t)return s?o-n-1:n;"nextSmaller"===i?(!a&&sn(t,c)>=0||sn(t,c)>=0&&sn(c,a)>0)&&(a=c,l=n):"nextGreater"===i&&(!a&&sn(t,c)<=0||sn(t,c)<=0&&sn(c,a)<0)&&(a=c,l=n)}return s?o-l-1:l}function sn(e,t){let i=Fo.indexOf(typeof e)-Fo.indexOf(typeof t);return 0===i&&("string"==typeof e&&"string"==typeof t?i=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?i=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(i=Number(e)-Number(t))),i}var rn,an;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(rn||(rn={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(an||(an={}));const ln=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),cn=new Set([...ln,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),hn=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","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),dn=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","CREATE_IMAGE"]);function un(e){return dn.has(e.type)}class gn{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new gn}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var pn,mn,fn;function vn(e,t){return Sn(bn(e||""),t)}function bn(e){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return ii(e)||qe(e)?Lo(e):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function Sn(e,t){const i=_o(e);return i?{...Cn(bn(i.label),t||Ii(i.label)),link:i}:Cn(e,t)}function Cn(e,t){try{for(const i of xn){const o=i(e,t);if(o)return o}return function(e,t){return{type:rn.text,value:e,format:t,isAutoSummable:!0,defaultAlign:"left",formattedValue:pi(e,t)}}((e||"").toString(),t)}catch(t){return yn((e||"").toString(),new c(a.GenericError,t.message||le))}}function En(e,t){return{type:rn.number,value:e||0,format:t,isAutoSummable:!0,defaultAlign:"right",formattedValue:pi(e,t)}}e.CommandResult=void 0,(pn=e.CommandResult||(e.CommandResult={}))[pn.Success=0]="Success",pn[pn.CancelledForUnknownReason=1]="CancelledForUnknownReason",pn[pn.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",pn[pn.MergeIsDestructive=3]="MergeIsDestructive",pn[pn.CellIsMerged=4]="CellIsMerged",pn[pn.InvalidTarget=5]="InvalidTarget",pn[pn.EmptyUndoStack=6]="EmptyUndoStack",pn[pn.EmptyRedoStack=7]="EmptyRedoStack",pn[pn.NotEnoughElements=8]="NotEnoughElements",pn[pn.NotEnoughSheets=9]="NotEnoughSheets",pn[pn.MissingSheetName=10]="MissingSheetName",pn[pn.DuplicatedSheetName=11]="DuplicatedSheetName",pn[pn.DuplicatedSheetId=12]="DuplicatedSheetId",pn[pn.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",pn[pn.WrongSheetMove=14]="WrongSheetMove",pn[pn.WrongSheetPosition=15]="WrongSheetPosition",pn[pn.InvalidAnchorZone=16]="InvalidAnchorZone",pn[pn.SelectionOutOfBound=17]="SelectionOutOfBound",pn[pn.TargetOutOfSheet=18]="TargetOutOfSheet",pn[pn.WrongCutSelection=19]="WrongCutSelection",pn[pn.WrongPasteSelection=20]="WrongPasteSelection",pn[pn.WrongPasteOption=21]="WrongPasteOption",pn[pn.WrongFigurePasteOption=22]="WrongFigurePasteOption",pn[pn.EmptyClipboard=23]="EmptyClipboard",pn[pn.EmptyRange=24]="EmptyRange",pn[pn.InvalidRange=25]="InvalidRange",pn[pn.InvalidZones=26]="InvalidZones",pn[pn.InvalidSheetId=27]="InvalidSheetId",pn[pn.InvalidFigureId=28]="InvalidFigureId",pn[pn.InputAlreadyFocused=29]="InputAlreadyFocused",pn[pn.MaximumRangesReached=30]="MaximumRangesReached",pn[pn.InvalidChartDefinition=31]="InvalidChartDefinition",pn[pn.InvalidDataSet=32]="InvalidDataSet",pn[pn.InvalidLabelRange=33]="InvalidLabelRange",pn[pn.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",pn[pn.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",pn[pn.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",pn[pn.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",pn[pn.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",pn[pn.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",pn[pn.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",pn[pn.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",pn[pn.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",pn[pn.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",pn[pn.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",pn[pn.InvalidAutofillSelection=45]="InvalidAutofillSelection",pn[pn.WrongComposerSelection=46]="WrongComposerSelection",pn[pn.MinBiggerThanMax=47]="MinBiggerThanMax",pn[pn.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",pn[pn.MidBiggerThanMax=49]="MidBiggerThanMax",pn[pn.MinBiggerThanMid=50]="MinBiggerThanMid",pn[pn.FirstArgMissing=51]="FirstArgMissing",pn[pn.SecondArgMissing=52]="SecondArgMissing",pn[pn.MinNaN=53]="MinNaN",pn[pn.MidNaN=54]="MidNaN",pn[pn.MaxNaN=55]="MaxNaN",pn[pn.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",pn[pn.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",pn[pn.MinInvalidFormula=58]="MinInvalidFormula",pn[pn.MidInvalidFormula=59]="MidInvalidFormula",pn[pn.MaxInvalidFormula=60]="MaxInvalidFormula",pn[pn.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",pn[pn.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",pn[pn.InvalidSortZone=63]="InvalidSortZone",pn[pn.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",pn[pn.MergeOverlap=65]="MergeOverlap",pn[pn.TooManyHiddenElements=66]="TooManyHiddenElements",pn[pn.Readonly=67]="Readonly",pn[pn.InvalidViewportSize=68]="InvalidViewportSize",pn[pn.InvalidScrollingDirection=69]="InvalidScrollingDirection",pn[pn.FigureDoesNotExist=70]="FigureDoesNotExist",pn[pn.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",pn[pn.InvalidCellPopover=72]="InvalidCellPopover",pn[pn.EmptyTarget=73]="EmptyTarget",pn[pn.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",pn[pn.FrozenPaneOverlap=75]="FrozenPaneOverlap",pn[pn.ValuesNotChanged=76]="ValuesNotChanged",pn[pn.InvalidFilterZone=77]="InvalidFilterZone",pn[pn.FilterOverlap=78]="FilterOverlap",pn[pn.FilterNotFound=79]="FilterNotFound",pn[pn.MergeInFilter=80]="MergeInFilter",pn[pn.NonContinuousTargets=81]="NonContinuousTargets",pn[pn.DuplicatedFigureId=82]="DuplicatedFigureId",pn[pn.InvalidSelectionStep=83]="InvalidSelectionStep",pn[pn.DuplicatedChartId=84]="DuplicatedChartId",pn[pn.ChartDoesNotExist=85]="ChartDoesNotExist",pn[pn.InvalidHeaderIndex=86]="InvalidHeaderIndex",pn[pn.InvalidQuantity=87]="InvalidQuantity",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(mn||(mn={})),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.Autofill=5]="Autofill",e[e.Selection=6]="Selection",e[e.Headers=7]="Headers"}(fn||(fn={}));const wn={type:rn.empty,value:"",format:void 0,isAutoSummable:!0,defaultAlign:"left",formattedValue:""};function yn(e,t){return{type:rn.error,value:t.errorType,error:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:t.errorType}}const xn=[function(e,t){if(""===e)return function(e){return void 0===e?wn:{type:rn.empty,value:"",format:e,isAutoSummable:!0,defaultAlign:"left",formattedValue:""}}(t)},function(e,t){if(t&&"number"==typeof e&&Ci(t))return function(e,t){const i=pi(e,t);return{type:rn.number,value:e,format:t,isAutoSummable:!1,defaultAlign:"right",formattedValue:i}}(e,t)},function(e,t){return"number"==typeof e?En(e,t):null===e?En(0,t):void 0},function(e,t){if("boolean"==typeof e)return function(e,t){const i=e?"TRUE":"FALSE";return{type:rn.boolean,value:e,format:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:i}}(e,t)}],In=new xo;In.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const i=`${e.prefix}${e.current.toString().padStart(e.numberPostfixLength||0,"0")}`;return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i},tooltip:{props:{content:i}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t)=>{var i;e.current+=e.increment;const o=e.current.toString(),n=pi(e.current,null===(i=t.cell)||void 0===i?void 0:i.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:o},tooltip:o?{props:{content:n}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,i)=>{var o,n,s;const r=(null===(o=t.cell)||void 0===o?void 0:o.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:vn(null===(n=t.cell)||void 0===n?void 0:n.content,null===(s=t.cell)||void 0===s?void 0:s.format).formattedValue}}:void 0}}}).add("FORMULA_MODIFIER",{apply:(e,t,i,o)=>{e.current+=e.increment;let n=0,s=0;switch(o){case"up":n=0,s=-e.current;break;case"down":n=0,s=e.current;break;case"left":n=-e.current,s=0;break;case"right":n=e.current,s=0}const r=t.cell;if(!r||!r.isFormula)return{cellData:{}};const a=t.sheetId,l=i.createAdaptedRanges(r.dependencies,n,s,a),c=i.buildFormulaContent(a,r,l);return{cellData:{border:t.border,style:r.style,format:r.format,content:c},tooltip:c?{props:{content:c}}:void 0}}});const Rn=new xo,Tn=/(\d+)$/,An=/^(.*\D+)/,Mn=/^(.*\D+)(\d+)$/;function On(e,t,i){let o=[],n=!1;for(let s of t){s===e&&(n=!0);const t=vn(null==s?void 0:s.content);if(i(t))o.push(t);else{if(n)return o;o=[]}}return o}function Nn(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let i=e[0];for(let o=1;o<e.length;o++){const n=e[o];t.push(n-i),i=n}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}Rn.add("simple_value_copy",{condition:(e,t)=>{var i;return 1===t.length&&!e.isFormula&&!(null===(i=e.format)||void 0===i?void 0:i.match(Y))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&vn(e.content).type===rn.text&&Mn.test(e.content),generateRule:(e,t)=>{const i=parseInt(e.content.match(Tn)[0]),o=e.content.match(An)[0],n=e.content.length-o.length,s=On(e,t,(e=>e.type===rn.text&&Mn.test(e.value))).filter((e=>o===e.value.toString().match(An)[0])).map((e=>parseInt(e.value.toString().match(Tn)[0]))),r=Nn(s);return{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:o,current:i,increment:r,numberPostfixLength:n}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&vn(e.content).type===rn.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.isFormula&&vn(e.content).type===rn.number,generateRule:(e,t)=>{const i=Nn(On(e,t,(e=>e.type===rn.number)).map((e=>Number(e.value)))),o=vn(e.content);return{type:"INCREMENT_MODIFIER",increment:i,current:o.type===rn.number?o.value:0}},sequence:40});mo`
54
54
  .o-error-tooltip {
55
55
  font-size: 13px;
56
56
  background-color: white;
@@ -60,7 +60,7 @@
60
60
  box-sizing: border-box !important;
61
61
  overflow-wrap: break-word;
62
62
  }
63
- `;class Nn extends t.Component{}Nn.maxSize={maxHeight:80},Nn.template="o-spreadsheet-ErrorToolTip",Nn.components={},Nn.props={text:String,onClosed:{type:Function,optional:!0}};const _n={onHover:(e,t)=>{const i=t.getEvaluatedCell(e);return i.type===sn.error&&i.error.logLevel>l.silent?{isOpen:!0,props:{text:i.error.message},Component:Nn,cellCorner:"TopRight"}:{isOpen:!1}}};po`
63
+ `;class _n extends t.Component{}_n.maxSize={maxHeight:80},_n.template="o-spreadsheet-ErrorToolTip",_n.components={},_n.props={text:String,onClosed:{type:Function,optional:!0}};const Fn={onHover:(e,t)=>{const i=t.getEvaluatedCell(e);return i.type===rn.error&&i.error.logLevel>l.silent?{isOpen:!0,props:{text:i.error.message},Component:_n,cellCorner:"TopRight"}:{isOpen:!1}}};mo`
64
64
  .o-filter-menu-value {
65
65
  padding: 4px;
66
66
  line-height: 20px;
@@ -69,7 +69,7 @@
69
69
  width: 20px;
70
70
  }
71
71
  }
72
- `;class Fn 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"}))}}Fn.template="o-spreadsheet-FilterMenuValueItem",Fn.props={value:String,isChecked:Boolean,isSelected:Boolean,onMouseMove:Function,onClick:Function,scrolledTo:{type:String,optional:!0}};const Dn=po`
72
+ `;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",Dn.props={value:String,isChecked:Boolean,isSelected:Boolean,onMouseMove:Function,onClick:Function,scrolledTo:{type:String,optional:!0}};const kn=mo`
73
73
  .o-filter-menu {
74
74
  box-sizing: border-box;
75
75
  padding: 8px 16px;
@@ -162,7 +162,7 @@
162
162
  }
163
163
  }
164
164
  }
165
- `;class kn extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{ct(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}get isReadonly(){return this.env.model.getters.isReadonly()}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getFilter({sheetId:t,...e});if(!i)return[];const o=(i.filteredZone?io(i.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:i})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:i}).formattedValue)),n=this.env.model.getters.getFilterValues({sheetId:t,...e}),s=[...o,...n],r=n.map(ut);return[...new Set(s.map(ut))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===r.findIndex((t=>t===e)),string:s.find((t=>ut(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({sheetId:e,...t})}get displayedValues(){return this.state.textFilter?ki(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const i=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...i,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 i;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));i=-1===e?void 0:e}switch(e.key){case"ArrowDown":i=void 0===i?0:Math.min(i+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":i=void 0===i?t.length-1:Math.max(i-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==i&&this.checkValue(t[i]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==i?t[i].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,i;const o=this.props.filterPosition,n=this.filterTable;if(!o||!n||!n.contentZone)return;const s=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:s,col:o.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(i=(t=this.props).onClosed)||void 0===i||i.call(t)}}kn.size={width:$,height:295},kn.template="o-spreadsheet-FilterMenu",kn.style=Dn,kn.components={FilterMenuValueItem:Fn},kn.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const Ln={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:kn,cellCorner:"BottomLeft"})};function Pn(e,t){return!!t.target&&e.contains(t.target)}function Un(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function Vn(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*zn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*zn(t)}function Bn(){const e=t.useState({x:0,y:0,width:0,height:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o,width:n,height:s}=i.getBoundingClientRect();e.x=o,e.y=t,e.width=n,e.height=s}}return o(),t.onMounted(o),t.onPatched(o),e}function Hn(e){const i=t.useState({x:0,y:0,width:0,height:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n,width:s,height:r}=t.getBoundingClientRect();i.x=n,i.y=o,i.width=s,i.height=r}return t.onMounted(o),t.onPatched(o),i}function $n(e,t){return(i=Zi(Wn(e),Wn(t)))?{x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top}:void 0;var i}function Wn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}po`
165
+ `;class Ln extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{ht(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}get isReadonly(){return this.env.model.getters.isReadonly()}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getFilter({sheetId:t,...e});if(!i)return[];const o=(i.filteredZone?oo(i.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:i})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:i}).formattedValue)),n=this.env.model.getters.getFilterValues({sheetId:t,...e}),s=[...o,...n],r=n.map(gt);return[...new Set(s.map(gt))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===r.findIndex((t=>t===e)),string:s.find((t=>gt(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({sheetId:e,...t})}get displayedValues(){return this.state.textFilter?Li(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const i=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...i,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 i;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));i=-1===e?void 0:e}switch(e.key){case"ArrowDown":i=void 0===i?0:Math.min(i+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":i=void 0===i?t.length-1:Math.max(i-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==i&&this.checkValue(t[i]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==i?t[i].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,i;const o=this.props.filterPosition,n=this.filterTable;if(!o||!n||!n.contentZone)return;const s=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:s,col:o.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(i=(t=this.props).onClosed)||void 0===i||i.call(t)}}Ln.size={width:$,height:295},Ln.template="o-spreadsheet-FilterMenu",Ln.style=kn,Ln.components={FilterMenuValueItem:Dn},Ln.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const Pn={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:Ln,cellCorner:"BottomLeft"})};function Un(e,t){return!!t.target&&e.contains(t.target)}function Vn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function zn(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Bn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Bn(t)}function Hn(){const e=t.useState({x:0,y:0,width:0,height:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o,width:n,height:s}=i.getBoundingClientRect();e.x=o,e.y=t,e.width=n,e.height=s}}return o(),t.onMounted(o),t.onPatched(o),e}function $n(e){const i=t.useState({x:0,y:0,width:0,height:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n,width:s,height:r}=t.getBoundingClientRect();i.x=n,i.y=o,i.width=s,i.height=r}return t.onMounted(o),t.onPatched(o),i}function Wn(e,t){return(i=ji(Gn(e),Gn(t)))?{x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top}:void 0;var i}function Gn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}mo`
166
166
  .o-popover {
167
167
  position: absolute;
168
168
  z-index: ${ce.Popover};
@@ -171,7 +171,7 @@
171
171
  width: fit-content;
172
172
  height: fit-content;
173
173
  }
174
- `;class Gn extends t.Component{constructor(){super(...arguments),this.popoverRef=t.useRef("popover"),this.currentPosition=void 0,this.currentDisplayValue=void 0,this.spreadsheetRect=Bn()}setup(){this.containerRect=function(){const e=t.useState({x:0,y:0,width:0,height:0}),i=t.useComponent(),o=Bn();function n(){const t=i.env,n="getPopoverContainerRect"in t?t.getPopoverContainerRect():o;e.x=n.x,e.y=n.y,e.width=n.width,e.height=n.height}return n(),t.onMounted(n),t.onPatched(n),e}(),t.useEffect((()=>{var e,t,i,o;if(!this.containerRect)throw new Error("Popover container is not defined");const n=this.popoverRef.el,s=$n(this.props.anchorRect,this.containerRect),r=s?"block":"none";if("none"!==this.currentDisplayValue&&"none"===r&&(null===(t=(e=this.props).onPopoverHidden)||void 0===t||t.call(e)),n.style.display=r,this.currentDisplayValue=r,!s)return;const a={width:this.props.maxWidth,height:this.props.maxHeight},l={width:n.getBoundingClientRect().width,height:n.getBoundingClientRect().height},c=this.spreadsheetRect,h="BottomLeft"===this.props.positioning?new Zn(s,this.containerRect,a,c):new jn(s,this.containerRect,a,c),d=h.getCss(l,this.props.verticalOffset);for(const e of Object.keys(d))n.style[e]=d[e];const u=h.getCurrentPosition(l);this.currentPosition&&u!==this.currentPosition&&(null===(o=(i=this.props).onPopoverMoved)||void 0===o||o.call(i)),this.currentPosition=u}))}get popoverStyle(){return bo({"z-index":`${this.props.zIndex}`})}}Gn.template="o-spreadsheet-Popover",Gn.defaultProps={positioning:"BottomLeft",verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{},zIndex:ce.Popover},Gn.props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},zIndex:{type:Number,optional:!0},slots:Object};class qn{constructor(e,t,i,o){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=i,this.spreadsheetOffset=o}shouldRenderAtBottom(e){return e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){const t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){const t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){const i=this.getMaxHeight(e.height),o=this.getMaxWidth(e.width),n=Math.min(i,e.height),s=Math.min(o,e.width),r=this.shouldRenderAtBottom(e.height),a=this.shouldRenderAtRight(e.width);t=r?t:-t;return{"max-height":i+"px","max-width":o+"px",top:this.getTopCoordinate(n,r)-this.spreadsheetOffset.y-t+"px",left:this.getLeftCoordinate(s,a)-this.spreadsheetOffset.x+"px"}}getCurrentPosition(e){const t=this.shouldRenderAtBottom(e.height),i=this.shouldRenderAtRight(e.width);return t&&i?"BottomRight":t&&!i?"BottomLeft":!t&&i?"TopRight":"TopLeft"}}class Zn extends qn{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}}class jn extends qn{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}}po`
174
+ `;class qn extends t.Component{constructor(){super(...arguments),this.popoverRef=t.useRef("popover"),this.currentPosition=void 0,this.currentDisplayValue=void 0,this.spreadsheetRect=Hn()}setup(){this.containerRect=function(){const e=t.useState({x:0,y:0,width:0,height:0}),i=t.useComponent(),o=Hn();function n(){const t=i.env,n="getPopoverContainerRect"in t?t.getPopoverContainerRect():o;e.x=n.x,e.y=n.y,e.width=n.width,e.height=n.height}return n(),t.onMounted(n),t.onPatched(n),e}(),t.useEffect((()=>{var e,t,i,o;if(!this.containerRect)throw new Error("Popover container is not defined");const n=this.popoverRef.el,s=Wn(this.props.anchorRect,this.containerRect),r=s?"block":"none";if("none"!==this.currentDisplayValue&&"none"===r&&(null===(t=(e=this.props).onPopoverHidden)||void 0===t||t.call(e)),n.style.display=r,this.currentDisplayValue=r,!s)return;const a={width:this.props.maxWidth,height:this.props.maxHeight},l={width:n.getBoundingClientRect().width,height:n.getBoundingClientRect().height},c=this.spreadsheetRect,h="BottomLeft"===this.props.positioning?new jn(s,this.containerRect,a,c):new Xn(s,this.containerRect,a,c),d=h.getCss(l,this.props.verticalOffset);for(const e of Object.keys(d))n.style[e]=d[e];const u=h.getCurrentPosition(l);this.currentPosition&&u!==this.currentPosition&&(null===(o=(i=this.props).onPopoverMoved)||void 0===o||o.call(i)),this.currentPosition=u}))}get popoverStyle(){return So({"z-index":`${this.props.zIndex}`})}}qn.template="o-spreadsheet-Popover",qn.defaultProps={positioning:"BottomLeft",verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{},zIndex:ce.Popover},qn.props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},zIndex:{type:Number,optional:!0},slots:Object};class Zn{constructor(e,t,i,o){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=i,this.spreadsheetOffset=o}shouldRenderAtBottom(e){return e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){const t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){const t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){const i=this.getMaxHeight(e.height),o=this.getMaxWidth(e.width),n=Math.min(i,e.height),s=Math.min(o,e.width),r=this.shouldRenderAtBottom(e.height),a=this.shouldRenderAtRight(e.width);t=r?t:-t;return{"max-height":i+"px","max-width":o+"px",top:this.getTopCoordinate(n,r)-this.spreadsheetOffset.y-t+"px",left:this.getLeftCoordinate(s,a)-this.spreadsheetOffset.x+"px"}}getCurrentPosition(e){const t=this.shouldRenderAtBottom(e.height),i=this.shouldRenderAtRight(e.width);return t&&i?"BottomRight":t&&!i?"BottomLeft":!t&&i?"TopRight":"TopLeft"}}class jn extends Zn{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}}class Xn extends Zn{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}}mo`
175
175
  .o-menu {
176
176
  background-color: white;
177
177
  padding: ${8}px 0px;
@@ -221,7 +221,7 @@
221
221
  }
222
222
  }
223
223
  }
224
- `;class Xn extends t.Component{constructor(){super(...arguments),this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=Hn(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 visibleMenuItems(){return this.props.menuItems.filter((e=>e.isVisible(this.env)))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){const e=this.visibleMenuItems;let t=this.getMenuItemsHeight(e);e[e.length-1].separator&&(t-=11);const i=16+t;return this.props.maxHeight?Math.min(i,this.props.maxHeight):i}get popoverProps(){const e=1===this.props.depth;return{anchorRect:{x:this.props.position.x-$*(this.props.depth-1),y:this.props.position.y,width:e?0:$,height:e?0:28},positioning:"TopRight",verticalOffset:e?0:8,onPopoverHidden:()=>this.closeSubMenu(),onPopoverMoved:()=>this.closeSubMenu(),maxHeight:this.menuHeight}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,i,o;const n=await(null===(t=e.action)||void 0===t?void 0:t.call(e,this.env));this.close(),null===(o=(i=this.props).onMenuClicked)||void 0===o||o.call(i,{detail:n})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.visibleMenuItems.slice(0,e);return this.position.y+this.getMenuItemsHeight(t)+8}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>Pn(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}getMenuItemsHeight(e){const t=e.filter((e=>e.separator)).length;return 28*e.length+11*t}getName(e){return e.name(this.env)}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 i=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+this.props.depth*$,y:i-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=e.children(this.env),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var i;return(null===(i=e.parentMenu)||void 0===i?void 0:i.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())}}Xn.template="o-spreadsheet-Menu",Xn.components={Menu:Xn,Popover:Gn},Xn.defaultProps={depth:1},Xn.props={position:Object,menuItems:Array,depth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},onClose:Function,onMenuClicked:{type:Function,optional:!0},menuId:{type:String,optional:!0}};po`
224
+ `;class Yn extends t.Component{constructor(){super(...arguments),this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=$n(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 visibleMenuItems(){return this.props.menuItems.filter((e=>e.isVisible(this.env)))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){const e=this.visibleMenuItems;let t=this.getMenuItemsHeight(e);e[e.length-1].separator&&(t-=11);const i=16+t;return this.props.maxHeight?Math.min(i,this.props.maxHeight):i}get popoverProps(){const e=1===this.props.depth;return{anchorRect:{x:this.props.position.x-$*(this.props.depth-1),y:this.props.position.y,width:e?0:$,height:e?0:28},positioning:"TopRight",verticalOffset:e?0:8,onPopoverHidden:()=>this.closeSubMenu(),onPopoverMoved:()=>this.closeSubMenu(),maxHeight:this.menuHeight}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,i,o;const n=await(null===(t=e.action)||void 0===t?void 0:t.call(e,this.env));this.close(),null===(o=(i=this.props).onMenuClicked)||void 0===o||o.call(i,{detail:n})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.visibleMenuItems.slice(0,e);return this.position.y+this.getMenuItemsHeight(t)+8}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>Un(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}getMenuItemsHeight(e){const t=e.filter((e=>e.separator)).length;return 28*e.length+11*t}getName(e){return e.name(this.env)}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 i=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+this.props.depth*$,y:i-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=e.children(this.env),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var i;return(null===(i=e.parentMenu)||void 0===i?void 0:i.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())}}Yn.template="o-spreadsheet-Menu",Yn.components={Menu:Yn,Popover:qn},Yn.defaultProps={depth:1},Yn.props={position:Object,menuItems:Array,depth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},onClose:Function,onMenuClicked:{type:Function,optional:!0},menuId:{type:String,optional:!0}};mo`
225
225
  .o-link-tool {
226
226
  font-size: 13px;
227
227
  background-color: white;
@@ -268,7 +268,7 @@
268
268
  cursor: pointer;
269
269
  color: #000;
270
270
  }
271
- `;class Yn extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;const{col:e,row:t}=this.props.cellPosition;throw new Error(`LinkDisplay Component can only be used with link cells. ${Wt(e,t)} is not a link.`)}getUrlRepresentation(e){return Mo(e,this.env.model.getters)}openLink(){Oo(this.link,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:i}=this.props.cellPosition,o=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:i}),n=(null==o?void 0:o.textColor)===I||null==o?void 0:o.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:i,sheetId:e,content:this.link.label,style:{...o,textColor:n,underline:void 0}})}}Yn.components={Menu:Xn},Yn.template="o-spreadsheet-LinkDisplay";const Kn={onHover:(e,t)=>{const i=t.getEvaluatedCell(e);return!t.isDashboard()&&i.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:Yn,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}};function Qn(e){return e.map(es).sort(((e,t)=>e.sequence-t.sequence))}Yn.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Jn=new Pi;function es(e){const t=e.name,i=e.children;return{id:e.id||Jn.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,action:e.action,children:i?e=>i.map((t=>"function"==typeof t?t(e):t)).flat().map(es):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon,description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class ts extends yo{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,i){"function"!=typeof i&&void 0===i.id&&(i.id=e);const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t){const i=n.children;if(!i||"function"==typeof i)throw new Error(`${e} is either not a node or it's dynamically computed`);if(n=i.find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`)}return n.children||(n.children=[]),n.children.push(i),this}getMenuItems(){return Qn(this.getAll())}}const is=new ts;is.add("sheet",{name:s("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map((e=>({id:e.id,name:e.name,action:()=>Ye(e.name,et(e.id))})))));po`
271
+ `;class Kn extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;const{col:e,row:t}=this.props.cellPosition;throw new Error(`LinkDisplay Component can only be used with link cells. ${Gt(e,t)} is not a link.`)}getUrlRepresentation(e){return Oo(e,this.env.model.getters)}openLink(){No(this.link,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:i}=this.props.cellPosition,o=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:i}),n=(null==o?void 0:o.textColor)===I||null==o?void 0:o.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:i,sheetId:e,content:this.link.label,style:{...o,textColor:n,underline:void 0}})}}Kn.components={Menu:Yn},Kn.template="o-spreadsheet-LinkDisplay";const Qn={onHover:(e,t)=>{const i=t.getEvaluatedCell(e);return!t.isDashboard()&&i.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:Kn,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}};function Jn(e){return e.map(ts).sort(((e,t)=>e.sequence-t.sequence))}Kn.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const es=new Ui;function ts(e){const t=e.name,i=e.children;return{id:e.id||es.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,action:e.action,children:i?e=>i.map((t=>"function"==typeof t?t(e):t)).flat().map(ts):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon,description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class is extends xo{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,i){"function"!=typeof i&&void 0===i.id&&(i.id=e);const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t){const i=n.children;if(!i||"function"==typeof i)throw new Error(`${e} is either not a node or it's dynamically computed`);if(n=i.find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`)}return n.children||(n.children=[]),n.children.push(i),this}getMenuItems(){return Jn(this.getAll())}}const os=new is;os.add("sheet",{name:s("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map((e=>({id:e.id,name:e.name,action:()=>Ke(e.name,tt(e.id))})))));mo`
272
272
  .o-link-editor {
273
273
  font-size: 13px;
274
274
  background-color: white;
@@ -341,13 +341,13 @@
341
341
  }
342
342
  }
343
343
  }
344
- `;class os extends t.Component{constructor(){super(...arguments),this.menuItems=is.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Hn(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,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t});return o.link?{url:o.link.url,label:o.formattedValue,isUrlEditable:o.link.isUrlEditable}:{label:o.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,i=No(t);i&&(this.link.url=i.url,this.link.label=i.label,this.link.isUrlEditable=i.isUrlEditable)}getUrlRepresentation(e){return Mo(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:Ye(n,this.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.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}os.template="o-spreadsheet-LinkEditor",os.components={Menu:Xn};const ns={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:os,cellCorner:"BottomLeft"})};os.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const ss=new yo;function rs(e){return 8===(e=Et(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}ss.add("ErrorToolTip",_n).add("LinkCell",Kn).add("LinkEditor",ns).add("FilterMenu",Ln);class as{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}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 ls(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Gi(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Hi(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function cs(e,t,i,o){let n=!1;const s=[];for(let o in i){let r=i[o];if(r.labelCell){const e=us(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=us(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===K?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[o]=r}let r=o;const a=us(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(it),labelRange:r}}function hs(e,t,i){return i.map((i=>({dataRange:Fi(e,t,i.dataRange),labelCell:i.labelCell?Fi(e,t,i.labelCell):void 0})))}function ds(e,t,i){return i?Fi(e,t,i):void 0}function us(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function gs(e,t,i,o){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(i,s),{unboundedZone:r,sheetId:a,invalidSheetName:l}=t;if(!l)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const i={...r,left:t,right:t};n.push(ps(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?o||n.push(ps(e,a,r,void 0)):n.push(ps(e,a,r,o?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function ps(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${Bi(i)}`);if(o){const n=Bi(i),s=Bi(o);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Bi(i))}}function ms(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=eo(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const s=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function fs(e,t){let i;if(e.labelRange){const o=ls(Ui(e.labelRange),t);i=o?Bi(o):void 0}const o=e.dataSets.map(Ui).map((e=>ls(e,t))).filter(it).map(Bi);return{...e,labelRange:i,dataSets:o}}const vs=["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 bs{constructor(){this.graphColorIndex=0}next(){return vs[this.graphColorIndex++%vs.length]}}function Ss(e){return e&&It(e)<.3?"#FFFFFF":"#000000"}function Cs(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!kt.test(e)));if(t)return 32;if(e.dataSets.map(Ui).some((e=>e.top!==e.bottom&&ao(e))))return 32}return 0}function Es(e){if(e.labelRange){if(!kt.test(e.labelRange||""))return 33}return 0}function ws(e,t,i){if(e){if("text"===i||(null==t?void 0:t.type)!==sn.number||e.type!==sn.number)return e.formattedValue;{let o=t.value-e.value;if("percentage"===i&&0!==o&&(o=o/e.value*100),"percentage"!==i&&e.format)return gi(o,e.format);const n=Math.abs(parseFloat(o.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function ys(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==sn.number||(null==i?void 0:i.type)!==sn.number)return;const s=i.value-e.value;return s>0?o:s<0?n:void 0}function xs(e,t,i){if("text"===i||(null==e?void 0:e.type)!==sn.number||(null==t?void 0:t.type)!==sn.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}const Is={Errors:{25:s("The range is invalid"),51:s("The argument is missing. Please provide a value"),52:s("The second argument is missing. Please provide a value"),53:s("The minpoint must be a number"),54:s("The midpoint must be a number"),55:s("The maxpoint must be a number"),56:s("The first value must be a number"),57:s("The second value must be a number"),47:s("Minimum must be smaller then Maximum"),50:s("Minimum must be smaller then Midpoint"),49:s("Midpoint must be smaller then Maximum"),48:s("Lower inflection point must be smaller than upper inflection point"),58:s("Invalid Minpoint formula"),60:s("Invalid Maxpoint formula"),59:s("Invalid Midpoint formula"),61:s("Invalid upper inflection point formula"),62:s("Invalid lower inflection point formula"),24:s("A range needs to be defined"),Unexpected:s("The rule is invalid for an unknown reason")},ColorScale:s("Color scale"),IconSet:s("Icon set")},Rs={IsEmpty:s("Is empty"),IsNotEmpty:s("Is not empty"),ContainsText:s("Contains"),NotContains:s("Does not contain"),BeginsWith:s("Starts with"),EndsWith:s("Ends with"),Equal:s("Is equal to"),NotEqual:s("Is not equal to"),GreaterThan:s("Is greater than"),GreaterThanOrEqual:s("Is greater than or equal to"),LessThan:s("Is less than"),LessThanOrEqual:s("Is less than or equal to"),Between:s("Is between"),NotBetween:s("Is not between")},Ts={Series:s("Series"),Errors:{Unexpected:s("The chart definition is invalid for an unknown reason"),32:s("The dataset is invalid"),33:s("Labels are invalid"),34:s("The key value is invalid"),35:s("The baseline value is invalid"),36:s("The data range is invalid"),37:s("A minimum range limit value is needed"),38:s("The minimum range limit value must be a number"),39:s("A maximum range limit value is needed"),40:s("The maximum range limit value must be a number"),41:s("Minimum range limit must be smaller than maximum range limit"),42:s("The lower inflection point value must be a number"),43:s("The upper inflection point value must be a number")}},As={Automatic:s("Automatic"),Number:s("Number"),Percent:s("Percent"),Currency:s("Currency"),CurrencyRounded:s("Currency rounded"),Date:s("Date"),Time:s("Time"),DateTime:s("Date time"),Duration:s("Duration"),CustomCurrency:s("Custom currency")},Ms={Custom:s("Custom")},Os=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function Ns(e,t){if(t.dataRange){const i=t.labelCell?[Bi(t.labelCell.zone)]:[],o=Qi([Bi(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function _s(e,t){const i=He(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function Fs(e,t){const i=new Set(e),o={};i.forEach((e=>{o[e]=new Array(t.length).fill(0)}));for(const i of He(0,e.length)){const s=e[i];for(const e of He(0,t.length))o[s][e]+="number"==typeof(n=t[e].data[i])?n:0}var n;return{labels:Object.keys(o),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(o).map((e=>e[t]))})))}}function Ds(e){return e?e.length>J?e.substring(0,J)+"…":e:""}function ks(e,t,i,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:n(e.title),fontColor:i},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var i,n,s,r,a;let l=null===(n=null===(i=t.datasets)||void 0===i?void 0:i[e.datasetIndex||0])||void 0===n?void 0:n.label;const c=""!==e.yLabel?e.yLabel:null===(a=null===(r=null===(s=t.datasets)||void 0===s?void 0:s[e.datasetIndex||0])||void 0===r?void 0:r.data)||void 0===a?void 0:a[e.index||0],h=o&&"number"==typeof c?gi(c,o):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(Ds),datasets:[]}}}function Ls(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>String(e)))});else if(1===t.length)for(let i=0;i<Ns(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:He(0,Ns(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function Ps(e,t){for(const i of t){const t=e.getRangeFormats(i.dataRange).find((e=>void 0!==e&&!Si(e)));if(t)return t}}function Us(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,s=i?e.getEvaluatedCell({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}):void 0;t=s&&i?Ds(s.formattedValue):t=`${Ts.Series} ${parseInt(o)+1}`}else t=t=`${Ts.Series} ${parseInt(o)+1}`;let s=n.dataRange?Ns(e,n):[];i.push({data:s,label:t})}return i}function Vs(e){return 0===e?"origin":e-1}class zs extends as{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=gs(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Di(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return fs(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Cs,Es)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!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=hs(this.sheetId,e,this.dataSets),i=ds(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new zs(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new zs(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>ms(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:rs(this.background||w),fontColor:rs(Ss(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=cs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new zs(n,this.sheetId,this.getters)}}function Bs(e){return e.dataRange&&!kt.test(e.dataRange)?36:0}function Hs(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function $s(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function Ws(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function Gs(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class qs extends as{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Di(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Bs,e.chainValidations(Hs(Ws,e.batchValidations),Hs(Gs,e.batchValidations),$s),e.chainValidations((i=Gs,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=ls(Ui(e.dataRange),t)),{...e,dataRange:i?Bi(i):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=ds(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new qs(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new qs(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=us(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new qs(i,this.sheetId,this.getters)}}const Zs={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},js={inSeconds:function(e){return Math.floor(e/Zs.second)},inMinutes:function(e){return Math.floor(e/Zs.minute)},inHours:function(e){return Math.floor(e/Zs.hour)},inDays:function(e){return Math.floor(e/Zs.day)},inMonths:function(e){return Math.floor(e/Zs.month)},inYears:function(e){return Math.floor(e/Zs.year)}},Xs=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Ys(e,t){const i=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),o=function(e,t){const i=e.map((e=>{var t;return null===(t=Ce(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),s=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(Zs.second>=Zs[s]&&js.inSeconds(n)<180)return"second";if(Zs.minute>=Zs[s]&&js.inMinutes(n)<180)return"minute";if(Zs.hour>=Zs[s]&&js.inHours(n)<96)return"hour";if(Zs.day>=Zs[s]&&js.inDays(n)<90)return"day";if(Zs.month>=Zs[s]&&js.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}class Ks extends as{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=gs(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Di(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,this.aggregated=e.aggregated,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,Cs,Es)}static transformDefinition(e,t){return fs(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,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative}}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:i,isStale:o}=cs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Ks(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>ms(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:rs(this.background||w),fontColor:rs(Ss(this.background)),dataSets:e}}copyForSheetId(e){const t=hs(this.sheetId,e,this.dataSets),i=ds(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Ks(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Ks(t,e,this.getters)}}function Qs(e,t){return er(e,t)||tr(e,t)}function Js(e,t){return function(e,t){return!e.labelsAsText&&er(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&tr(e.labelRange,t)}(e,t)?"linear":"category"}function er(e,t){if(!e||!tr(e,t))return!1;const i=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(i&&Xs.test(i))}function tr(e,t){if(!e)return!1;const i=t.getRangeValues(e);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}class ir extends as{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=gs(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Di(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return fs(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Cs,Es)}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,aggregated:!1}}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,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=hs(this.sheetId,e,this.dataSets),i=ds(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new ir(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ir(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>ms(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:rs(this.background||w),fontColor:rs(Ss(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=cs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new ir(n,this.sheetId,this.getters)}}function or(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function nr(e){return e.keyValue&&!kt.test(e.keyValue)?34:0}function sr(e){return e.baseline&&!kt.test(e.baseline)?35:0}class rr extends as{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Di(i,t,e.keyValue),this.baseline=Di(i,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,nr,sr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:te,baselineColorUp:ie,baselineColorDown:oe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=ls(Ui(e.baseline),t)),e.keyValue&&(o=ls(Ui(e.keyValue),t)),{...e,baseline:i?Bi(i):void 0,keyValue:o?Bi(o):void 0}}copyForSheetId(e){const t=ds(this.sheetId,e,this.baseline),i=ds(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new rr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new rr(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,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=us(this.baseline,e),i=us(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new rr(o,this.sheetId,this.getters)}}const ar=new yo;ar.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new zs(e,t,i),getChartRuntime:function(e,t){let i=Ls(t,e.dataSets,e.labelRange).formattedValues,o=Us(t,e.dataSets);({labels:i,dataSetsValues:o}=_s(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Fs(i,o));const n=function(e,t,i){var o;const n=Ss(e.background),s=ks(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?gi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,i,Ps(t,e.dataSets)),s=new bs;for(let{label:e,data:t}of o){const i=s.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>zs.validateChartDefinition(e,t),transformDefinition:(e,t)=>zs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>zs.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),ar.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new Ks(e,t,i),getChartRuntime:function(e,t){const i=Js(e,t),o=Ls(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,s=Us(t,e.dataSets);({labels:n,dataSetsValues:s}=_s(n,s)),"time"===i&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=_e(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=at(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=Fs(n,s));const r=Ps(t,e.dataSets),a=function(e,t,i){var o;const n=Ss(e.background),s=ks(e,t,n,i),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?gi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,n,r),l=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===i?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=Ys(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>gi(e,l),a.options.tooltips.callbacks.title=e=>{var t;return gi((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new bs;for(let[t,{label:o,data:r}]of s.entries()){["linear","time"].includes(i)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=Tt(s);if(e.stacked&&(l.a=ne),e.cumulative){let e=0;r=r.map((t=>isNaN(t)?t:(e+=parseFloat(t),e)))}const h={label:o,data:r,lineTension:0,borderColor:s,backgroundColor:Rt(l),pointBackgroundColor:s,fill:!!e.stacked&&Vs(t)};a.data.datasets.push(h)}return{chartJsConfig:a,background:e.background||w}},validateChartDefinition:(e,t)=>Ks.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ks.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ks.getDefinitionFromContextCreation(e),name:s("Line"),sequence:20}),ar.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new ir(e,t,i),getChartRuntime:function(e,t){let i=Ls(t,e.dataSets,e.labelRange).formattedValues,o=Us(t,e.dataSets);({labels:i,dataSetsValues:o}=_s(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Fs(i,o));const n=function(e,t,i){var o;const n=Ss(e.background),s=ks(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,i,Ps(t,e.dataSets)),s=new bs;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:or(s,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>ir.validateChartDefinition(e,t),transformDefinition:(e,t)=>ir.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>ir.getDefinitionFromContextCreation(e),name:s("Pie"),sequence:30}),ar.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new rr(e,t,i),getChartRuntime:function(e,t){let i,o,s="",r="";if(e.keyValue){const o={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};i=t.getEvaluatedCell(o),s=String(i.value),r=i.formattedValue}const a=e.baseline;if(a){const i={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};o=t.getEvaluatedCell(i)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:ws(o,i,e.baselineMode),baselineArrow:xs(o,i,e.baselineMode),baselineColor:ys(o,e.baselineMode,i,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:Ss(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>rr.validateChartDefinition(e,t),transformDefinition:(e,t)=>rr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>rr.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),ar.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new qs(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=ks(e,[],Ss(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.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},t}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,s=e.sectionRule.upperInflectionPoint,r=Number(n.value),a=Number(s.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?r:l+h*r/100;d.push({value:ke(e,l,c),color:o.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:ke(e,l,c),color:o.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(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===sn.number&&(f=ke(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>qs.validateChartDefinition(e,t),transformDefinition:(e,t)=>qs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>qs.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const lr=new yo;lr.add("line",ho),lr.add("bar",ho),lr.add("pie",ho),lr.add("gauge",ho),lr.add("scorecard",Co);const cr=new yo;po`
344
+ `;class ns extends t.Component{constructor(){super(...arguments),this.menuItems=os.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=$n(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,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t});return o.link?{url:o.link.url,label:o.formattedValue,isUrlEditable:o.link.isUrlEditable}:{label:o.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,i=_o(t);i&&(this.link.url=i.url,this.link.label=i.label,this.link.isUrlEditable=i.isUrlEditable)}getUrlRepresentation(e){return Oo(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:Ke(n,this.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.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}ns.template="o-spreadsheet-LinkEditor",ns.components={Menu:Yn};const ss={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:ns,cellCorner:"BottomLeft"})};ns.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const rs=new xo;function as(e){return 8===(e=wt(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}rs.add("ErrorToolTip",Fn).add("LinkCell",Qn).add("LinkEditor",ss).add("FilterMenu",Pn);class ls{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}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 cs(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?qi(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?$i(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function hs(e,t,i,o){let n=!1;const s=[];for(let o in i){let r=i[o];if(r.labelCell){const e=gs(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=gs(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===K?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[o]=r}let r=o;const a=gs(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(ot),labelRange:r}}function ds(e,t,i){return i.map((i=>({dataRange:Di(e,t,i.dataRange),labelCell:i.labelCell?Di(e,t,i.labelCell):void 0})))}function us(e,t,i){return i?Di(e,t,i):void 0}function gs(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function ps(e,t,i,o){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(i,s),{unboundedZone:r,sheetId:a,invalidSheetName:l}=t;if(!l)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const i={...r,left:t,right:t};n.push(ms(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?o||n.push(ms(e,a,r,void 0)):n.push(ms(e,a,r,o?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function ms(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${Hi(i)}`);if(o){const n=Hi(i),s=Hi(o);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Hi(i))}}function fs(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=to(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const s=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function vs(e,t){let i;if(e.labelRange){const o=cs(Vi(e.labelRange),t);i=o?Hi(o):void 0}const o=e.dataSets.map(Vi).map((e=>cs(e,t))).filter(ot).map(Hi);return{...e,labelRange:i,dataSets:o}}const bs=["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 Ss{constructor(){this.graphColorIndex=0}next(){return bs[this.graphColorIndex++%bs.length]}}function Cs(e){return e&&Rt(e)<.3?"#FFFFFF":"#000000"}function Es(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Lt.test(e)));if(t)return 32;if(e.dataSets.map(Vi).some((e=>e.top!==e.bottom&&lo(e))))return 32}return 0}function ws(e){if(e.labelRange){if(!Lt.test(e.labelRange||""))return 33}return 0}function ys(e,t,i){if(e){if("text"===i||(null==t?void 0:t.type)!==rn.number||e.type!==rn.number)return e.formattedValue;{let o=t.value-e.value;if("percentage"===i&&0!==o&&(o=o/e.value*100),"percentage"!==i&&e.format)return pi(o,e.format);const n=Math.abs(parseFloat(o.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function xs(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==rn.number||(null==i?void 0:i.type)!==rn.number)return;const s=i.value-e.value;return s>0?o:s<0?n:void 0}function Is(e,t,i){if("text"===i||(null==e?void 0:e.type)!==rn.number||(null==t?void 0:t.type)!==rn.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}const Rs={Errors:{25:s("The range is invalid"),51:s("The argument is missing. Please provide a value"),52:s("The second argument is missing. Please provide a value"),53:s("The minpoint must be a number"),54:s("The midpoint must be a number"),55:s("The maxpoint must be a number"),56:s("The first value must be a number"),57:s("The second value must be a number"),47:s("Minimum must be smaller then Maximum"),50:s("Minimum must be smaller then Midpoint"),49:s("Midpoint must be smaller then Maximum"),48:s("Lower inflection point must be smaller than upper inflection point"),58:s("Invalid Minpoint formula"),60:s("Invalid Maxpoint formula"),59:s("Invalid Midpoint formula"),61:s("Invalid upper inflection point formula"),62:s("Invalid lower inflection point formula"),24:s("A range needs to be defined"),Unexpected:s("The rule is invalid for an unknown reason")},ColorScale:s("Color scale"),IconSet:s("Icon set")},Ts={IsEmpty:s("Is empty"),IsNotEmpty:s("Is not empty"),ContainsText:s("Contains"),NotContains:s("Does not contain"),BeginsWith:s("Starts with"),EndsWith:s("Ends with"),Equal:s("Is equal to"),NotEqual:s("Is not equal to"),GreaterThan:s("Is greater than"),GreaterThanOrEqual:s("Is greater than or equal to"),LessThan:s("Is less than"),LessThanOrEqual:s("Is less than or equal to"),Between:s("Is between"),NotBetween:s("Is not between")},As={Series:s("Series"),Errors:{Unexpected:s("The chart definition is invalid for an unknown reason"),32:s("The dataset is invalid"),33:s("Labels are invalid"),34:s("The key value is invalid"),35:s("The baseline value is invalid"),36:s("The data range is invalid"),37:s("A minimum range limit value is needed"),38:s("The minimum range limit value must be a number"),39:s("A maximum range limit value is needed"),40:s("The maximum range limit value must be a number"),41:s("Minimum range limit must be smaller than maximum range limit"),42:s("The lower inflection point value must be a number"),43:s("The upper inflection point value must be a number")}},Ms={Automatic:s("Automatic"),Number:s("Number"),Percent:s("Percent"),Currency:s("Currency"),CurrencyRounded:s("Currency rounded"),Date:s("Date"),Time:s("Time"),DateTime:s("Date time"),Duration:s("Duration"),CustomCurrency:s("Custom currency")},Os={Custom:s("Custom")},Ns=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function _s(e,t){if(t.dataRange){const i=t.labelCell?[Hi(t.labelCell.zone)]:[],o=Ji([Hi(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Fs(e,t){const i=$e(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function Ds(e,t){const i=new Set(e),o={};i.forEach((e=>{o[e]=new Array(t.length).fill(0)}));for(const i of $e(0,e.length)){const s=e[i];for(const e of $e(0,t.length))o[s][e]+="number"==typeof(n=t[e].data[i])?n:0}var n;return{labels:Object.keys(o),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(o).map((e=>e[t]))})))}}function ks(e){return e?e.length>J?e.substring(0,J)+"…":e:""}function Ls(e,t,i,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:n(e.title),fontColor:i},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var i,n,s,r,a;let l=null===(n=null===(i=t.datasets)||void 0===i?void 0:i[e.datasetIndex||0])||void 0===n?void 0:n.label;const c=""!==e.yLabel?e.yLabel:null===(a=null===(r=null===(s=t.datasets)||void 0===s?void 0:s[e.datasetIndex||0])||void 0===r?void 0:r.data)||void 0===a?void 0:a[e.index||0],h=o&&"number"==typeof c?pi(c,o):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(ks),datasets:[]}}}function Ps(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>String(e)))});else if(1===t.length)for(let i=0;i<_s(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:$e(0,_s(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function Us(e,t){for(const i of t){const t=e.getRangeFormats(i.dataRange).find((e=>void 0!==e&&!Ci(e)));if(t)return t}}function Vs(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,s=i?e.getEvaluatedCell({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}):void 0;t=s&&i?ks(s.formattedValue):t=`${As.Series} ${parseInt(o)+1}`}else t=t=`${As.Series} ${parseInt(o)+1}`;let s=n.dataRange?_s(e,n):[];i.push({data:s,label:t})}return i}function zs(e){return 0===e?"origin":e-1}class Bs extends ls{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=ps(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=ki(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return vs(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Es,ws)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!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=ds(this.sheetId,e,this.dataSets),i=us(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Bs(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Bs(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>fs(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:as(this.background||w),fontColor:as(Cs(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=hs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Bs(n,this.sheetId,this.getters)}}function Hs(e){return e.dataRange&&!Lt.test(e.dataRange)?36:0}function $s(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Ws(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function Gs(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function qs(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class Zs extends ls{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=ki(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Hs,e.chainValidations($s(Gs,e.batchValidations),$s(qs,e.batchValidations),Ws),e.chainValidations((i=qs,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=cs(Vi(e.dataRange),t)),{...e,dataRange:i?Hi(i):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=us(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new Zs(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Zs(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=gs(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new Zs(i,this.sheetId,this.getters)}}const js={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Xs={inSeconds:function(e){return Math.floor(e/js.second)},inMinutes:function(e){return Math.floor(e/js.minute)},inHours:function(e){return Math.floor(e/js.hour)},inDays:function(e){return Math.floor(e/js.day)},inMonths:function(e){return Math.floor(e/js.month)},inYears:function(e){return Math.floor(e/js.year)}},Ys=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Ks(e,t){const i=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),o=function(e,t){const i=e.map((e=>{var t;return null===(t=Ee(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),s=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(js.second>=js[s]&&Xs.inSeconds(n)<180)return"second";if(js.minute>=js[s]&&Xs.inMinutes(n)<180)return"minute";if(js.hour>=js[s]&&Xs.inHours(n)<96)return"hour";if(js.day>=js[s]&&Xs.inDays(n)<90)return"day";if(js.month>=js[s]&&Xs.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}class Qs extends ls{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=ps(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=ki(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,this.aggregated=e.aggregated,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,Es,ws)}static transformDefinition(e,t){return vs(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,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative}}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:i,isStale:o}=hs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Qs(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>fs(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:as(this.background||w),fontColor:as(Cs(this.background)),dataSets:e}}copyForSheetId(e){const t=ds(this.sheetId,e,this.dataSets),i=us(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Qs(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Qs(t,e,this.getters)}}function Js(e,t){return tr(e,t)||ir(e,t)}function er(e,t){return function(e,t){return!e.labelsAsText&&tr(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&ir(e.labelRange,t)}(e,t)?"linear":"category"}function tr(e,t){if(!e||!ir(e,t))return!1;const i=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(i&&Ys.test(i))}function ir(e,t){if(!e)return!1;const i=t.getRangeValues(e);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}class or extends ls{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=ps(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=ki(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return vs(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Es,ws)}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,aggregated:!1}}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,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=ds(this.sheetId,e,this.dataSets),i=us(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new or(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new or(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>fs(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:as(this.background||w),fontColor:as(Cs(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=hs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new or(n,this.sheetId,this.getters)}}function nr(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function sr(e){return e.keyValue&&!Lt.test(e.keyValue)?34:0}function rr(e){return e.baseline&&!Lt.test(e.baseline)?35:0}class ar extends ls{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=ki(i,t,e.keyValue),this.baseline=ki(i,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,sr,rr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:te,baselineColorUp:ie,baselineColorDown:oe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=cs(Vi(e.baseline),t)),e.keyValue&&(o=cs(Vi(e.keyValue),t)),{...e,baseline:i?Hi(i):void 0,keyValue:o?Hi(o):void 0}}copyForSheetId(e){const t=us(this.sheetId,e,this.baseline),i=us(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new ar(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new ar(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,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=gs(this.baseline,e),i=gs(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new ar(o,this.sheetId,this.getters)}}const lr=new xo;lr.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new Bs(e,t,i),getChartRuntime:function(e,t){let i=Ps(t,e.dataSets,e.labelRange).formattedValues,o=Vs(t,e.dataSets);({labels:i,dataSetsValues:o}=Fs(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Ds(i,o));const n=function(e,t,i){var o;const n=Cs(e.background),s=Ls(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?pi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,i,Us(t,e.dataSets)),s=new Ss;for(let{label:e,data:t}of o){const i=s.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>Bs.validateChartDefinition(e,t),transformDefinition:(e,t)=>Bs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Bs.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),lr.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new Qs(e,t,i),getChartRuntime:function(e,t){const i=er(e,t),o=Ps(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,s=Vs(t,e.dataSets);({labels:n,dataSetsValues:s}=Fs(n,s)),"time"===i&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=Fe(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=lt(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=Ds(n,s));const r=Us(t,e.dataSets),a=function(e,t,i){var o;const n=Cs(e.background),s=Ls(e,t,n,i),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?pi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,n,r),l=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===i?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=Ks(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>pi(e,l),a.options.tooltips.callbacks.title=e=>{var t;return pi((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new Ss;for(let[t,{label:o,data:r}]of s.entries()){["linear","time"].includes(i)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=At(s);if(e.stacked&&(l.a=ne),e.cumulative){let e=0;r=r.map((t=>isNaN(t)?t:(e+=parseFloat(t),e)))}const h={label:o,data:r,lineTension:0,borderColor:s,backgroundColor:Tt(l),pointBackgroundColor:s,fill:!!e.stacked&&zs(t)};a.data.datasets.push(h)}return{chartJsConfig:a,background:e.background||w}},validateChartDefinition:(e,t)=>Qs.validateChartDefinition(e,t),transformDefinition:(e,t)=>Qs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Qs.getDefinitionFromContextCreation(e),name:s("Line"),sequence:20}),lr.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new or(e,t,i),getChartRuntime:function(e,t){let i=Ps(t,e.dataSets,e.labelRange).formattedValues,o=Vs(t,e.dataSets);({labels:i,dataSetsValues:o}=Fs(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Ds(i,o));const n=function(e,t,i){var o;const n=Cs(e.background),s=Ls(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,i,Us(t,e.dataSets)),s=new Ss;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:nr(s,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>or.validateChartDefinition(e,t),transformDefinition:(e,t)=>or.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>or.getDefinitionFromContextCreation(e),name:s("Pie"),sequence:30}),lr.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new ar(e,t,i),getChartRuntime:function(e,t){let i,o,s="",r="";if(e.keyValue){const o={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};i=t.getEvaluatedCell(o),s=String(i.value),r=i.formattedValue}const a=e.baseline;if(a){const i={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};o=t.getEvaluatedCell(i)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:ys(o,i,e.baselineMode),baselineArrow:Is(o,i,e.baselineMode),baselineColor:xs(o,e.baselineMode,i,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:Cs(l),background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>ar.validateChartDefinition(e,t),transformDefinition:(e,t)=>ar.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>ar.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),lr.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new Zs(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=Ls(e,[],Cs(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.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},t}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,s=e.sectionRule.upperInflectionPoint,r=Number(n.value),a=Number(s.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?r:l+h*r/100;d.push({value:Le(e,l,c),color:o.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:Le(e,l,c),color:o.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(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===rn.number&&(f=Le(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>Zs.validateChartDefinition(e,t),transformDefinition:(e,t)=>Zs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Zs.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const cr=new xo;cr.add("line",uo),cr.add("bar",uo),cr.add("pie",uo),cr.add("gauge",uo),cr.add("scorecard",Eo);const hr=new xo;mo`
345
345
  .o-chart-container {
346
346
  width: 100%;
347
347
  height: 100%;
348
348
  position: relative;
349
349
  }
350
- `;class hr extends t.Component{get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=lr.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}hr.template="o-spreadsheet-ChartFigure",hr.components={},hr.props={figure:Object,onFigureDeleted:Function};class dr extends t.Component{get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function ur(e,t){const i=_e(t),o=e.getSheetViewDimension(),n=o.width,s=o.height;if(i.width>n){const e=n/i.width;i.width=n,i.height=i.height*e}if(i.height>s){const e=s/i.height;i.height=s,i.width=i.width*e}return i}dr.template="o-spreadsheet-ImageFigure",dr.components={},dr.props={figure:Object,onFigureDeleted:Function};const gr=new yo;function pr(e,t){return{id:"copy",name:s("Copy"),sequence:2,description:"Ctrl+C",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function mr(e,t){return{id:"cut",name:s("Cut"),sequence:3,description:"Ctrl+X",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function fr(e,t,i){return{id:"delete",name:s("Delete"),sequence:10,action:()=>{i.model.dispatch("DELETE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e}),t()}}}gr.add("chart",{Component:hr,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,i){return Qn([{id:"edit",name:s("Edit"),sequence:1,action:()=>{i.model.dispatch("SELECT_FIGURE",{id:e}),i.openSidePanel("ChartPanel")}},pr(e,i),mr(e,i),fr(e,t,i)])}}),gr.add("image",{Component:dr,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,i){return Qn([pr(e,i),mr(e,i),{id:"reset_size",name:s("Reset size"),sequence:4,action:()=>{const t=i.model.getters.getImageSize(e),{height:o,width:n}=ur(i.model.getters,t);i.model.dispatch("UPDATE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e,height:o,width:n})}},fr(e,t,i)])}});const vr=(new yo).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of $e(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}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 hn.values())vr.contains(e)||vr.add(e,br);function br(e){return[e]}function Sr(e,t){const i=ar.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function Cr(e,t){var i;let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[Bi(o)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===lo(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(i=a.style)||void 0===i?void 0:i.fillColor)||void 0,keyValue:Bi(e),baselineMode:te,baselineColorUp:ie,baselineColorDown:oe};let l="";const c=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),h=!!c.find((e=>e.type!==sn.empty&&e.type!==sn.number));if(h){const e=c.filter((e=>e.type!==sn.error&&e.type!==sn.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=Bi({...e,right:e.left,top:h?e.top+1:e.top}));const u=o.right===o.left?"none":"top";return Qs(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:s,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}const Er=[sn.number,sn.error,sn.text,sn.boolean];function wr(e,t,i,o,n){let r=un.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let s=o.left;s<=o.right;s++){let o=e.model.getters.getMerge({sheetId:t,col:s,row:n});o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);ji(i,o)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(s("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?"),(()=>{o=i,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function yr(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}const xr={filterOverlap:s("You cannot create overlapping filters."),nonContinuousTargets:s("A filter can only be created on a continuous selection."),mergeInFilter:s("You can't create a filter over a range that contains a merge.")};function Ir(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(78)?e.raiseError(xr.filterOverlap):o.isCancelledBecause(80)?e.raiseError(xr.mergeInFilter):o.isCancelledBecause(81)&&e.raiseError(xr.nonContinuousTargets)}const Rr={wrongPasteSelection:s("This operation is not allowed with multiple selections."),willRemoveExistingMerge:s("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:s("Cannot do a special paste of a figure."),frozenPaneOverlap:s("Cannot paste merged cells over a frozen pane.")};function Tr(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Rr.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Rr.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Rr.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(Rr.frozenPaneOverlap))}function Ar(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Tr(e,o)}function Mr(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Tr(e,o)}function Or(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 Nr(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 _r(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Fr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const Dr=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},kr=async e=>{yr(e),await e.clipboard.write(e.model.getters.getClipboardContent())},Lr=async e=>Ur(e),Pr=async e=>Ur(e,"onlyValue");async function Ur(e,t){const i=e.model.getters.getClipboardTextContent(),o=await e.clipboard.readText();switch(o.status){case"ok":const n=e.model.getters.getSelectedZones();o&&o.content!==i?Mr(e,n,o.content):Ar(e,n,t);break;case"notImplemented":e.raiseError(s("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(s("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const Vr=e=>Ar(e,e.model.getters.getSelectedZones(),"onlyFormat"),zr=e=>!e.model.getters.isCutOperation(),Br=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},Hr=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},$r=(e,t)=>{const i=t.model.getters.getActiveSheetId(),o=t.model.getters.getElementsFromSelection(e),n=t.model.getters.checkElementsIncludeAllVisibleHeaders(i,e,o),s=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(i,e,o);return!n&&!s},Wr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Delete column %s",Bt(t)):s("Delete columns %s - %s",Bt(t),Bt(i))},Gr=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},qr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Tr(e,i)},Zr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Tr(e,i)},jr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Tr(e,i)},Xr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Tr(e,i)},Yr=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},Kr=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},Qr=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},Jr=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})};const ea=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},ta=e=>{let{col:t,row:i}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},ia=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},oa=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();wr(e,o,t.cell,i[0],"ascending")},na=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();wr(e,o,t.cell,i[0],"descending")},sa=e=>1===e.model.getters.getSelectedZones().length,ra=new ts;ra.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:kr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Dr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Lr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:zr}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:Pr}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Vr}).add("add_row_before",{name:e=>{const t=Nr(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:Yr,isVisible:sa}).add("add_column_before",{name:e=>{const t=Or(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:Qr,isVisible:sa}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:sa,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:qr}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:Zr}).add("delete_row",{name:Br,sequence:110,action:Hr,isVisible:sa}).add("delete_column",{name:Wr,sequence:120,action:Gr,isVisible:sa}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:sa}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:jr}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:Xr}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:ta});const aa=new ts;aa.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:kr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Dr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Lr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:zr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Pr}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Vr}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:sa,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:oa}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:na}).add("add_column_before",{name:e=>{const t=Or(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:Qr}).add("add_column_after",{name:e=>{const t=Or(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:Jr}).add("delete_column",{name:Wr,sequence:90,action:Gr,isVisible:e=>$r("COL",e)}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Clear column %s",Bt(t)):s("Clear columns %s - %s",Bt(t),Bt(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide column %s",Bt(i).toString()):o-i+1===t.length?s("Hide columns %s - %s",Bt(i).toString(),Bt(o).toString()):s("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(),i=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",i)},separator:!0}).add("unhide_columns",{name:s("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:s("Conditional formatting"),sequence:110,action:ea});const la=new ts;la.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:kr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Dr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Lr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:zr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Pr}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Vr}).add("add_row_before",{name:e=>{const t=Nr(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:Yr}).add("add_row_after",{name:e=>{const t=Nr(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:Kr}).add("delete_row",{name:Br,sequence:70,action:Hr,isVisible:e=>$r("ROW",e)}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide row %s",(i+1).toString()):o-i+1===t.length?s("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):s("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(),i=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",i)},separator:!0}).add("unhide_rows",{name:s("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:s("Conditional formatting"),sequence:90,action:ea});const ca=/(.*?)\((.*?)\)(.*)/,ha=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function da(e,t=""){return function(e){let t,i=e.match(ca),o=i[1].trim(),n=[],s=!1,r=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let o=ha.find((e=>i===e));o?n.push(o):"RANGE<ANY>"===i?n.push("RANGE"):"OPTIONAL"===i?s=!0:"REPEATING"===i?r=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}let l=i[3].trim();const c={name:o,description:l,type:n};s&&(c.optional=!0);r&&(c.repeating=!0);a&&(c.lazy=!0);void 0!==t&&(c.default=!0,c.defaultValue=t);return c}(`${e} ${t}`)}function ua(e){let t=0,i=0,o=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||i++,n.repeating&&o++;const n=e;return n.minArgRequired=i,n.maxArgPossible=o?1/0:t,n.nbrArgRepeating=o,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,o),n.hidden=e.hidden||!1,n}const ga={description:s("Apply a large number format"),args:[da("value (number)",s("The number.")),da("unit (string, optional)",s("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(ko(e.value)),o=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return Ii(o,1e3,"k");case"m":return Ii(o,1e6,"m");case"b":return Ii(o,1e9,"b");default:throw new Error(s("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?Ii(o,0,""):i<1e8?Ii(o,1e3,"k"):i<1e11?Ii(o,1e6,"m"):Ii(o,1e9,"b")},compute:function(e){return ko(e)}};var pa=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:ga});const ma={description:s("Absolute value of a number."),args:[da("value (number)",s("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(ko(e))},isExported:!0},fa={description:s("Inverse cosine of a value, in radians."),args:[da("value (number)",s("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},va={description:s("Inverse hyperbolic cosine of a number."),args:[da("value (number)",s("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>t>=1),s("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ba={description:s("Inverse cotangent of a value."),args:[da("value (number)",s("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Sa={description:s("Inverse hyperbolic cotangent of a value."),args:[da("value (number)",s("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>Math.abs(t)>1),s("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Ca={description:s("Inverse sine of a value, in radians."),args:[da("value (number)",s("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ea={description:s("Inverse hyperbolic sine of a number."),args:[da("value (number)",s("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(ko(e))},isExported:!0},wa={description:s("Inverse tangent of a value, in radians."),args:[da("value (number)",s("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(ko(e))},isExported:!0},ya={description:s("Angle from the X axis to a point (x,y), in radians."),args:[da("x (number)",s("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),da("y (number)",s("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const i=ko(e),o=ko(t);return Fo((()=>0!==i||0!==o),s("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(o,i)},isExported:!0},xa={description:s("Inverse hyperbolic tangent of a number."),args:[da("value (number)",s("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>Math.abs(t)<1),s("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ia={description:s("Rounds number up to nearest multiple of factor."),args:[da("value (number)",s("The value to round up to the nearest integer multiple of factor.")),da("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=ko(e),o=ko(t);return Fo((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.ceil(i/o)*o:0},isExported:!0},Ra={description:s("Rounds number up to nearest multiple of factor."),args:[da("number (number)",s("The value to round up to the nearest integer multiple of significance.")),da("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),da("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=ko(t);if(0===o)return 0;const n=ko(e);if(o=Math.abs(o),n>=0)return Math.ceil(n/o)*o;return 0===ko(i)?-Math.floor(Math.abs(n)/o)*o:-Math.ceil(Math.abs(n)/o)*o},isExported:!0},Ta={description:s("Rounds number up to nearest multiple of factor."),args:[da("number (number)",s("The value to round up to the nearest integer multiple of significance.")),da("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return Ra.compute(e,t,0)},isExported:!0},Aa={description:s("Cosine of an angle provided in radians."),args:[da("angle (number)",s("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(ko(e))},isExported:!0},Ma={description:s("Hyperbolic cosine of any real number."),args:[da("value (number)",s("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(ko(e))},isExported:!0},Oa={description:s("Cotangent of an angle provided in radians."),args:[da("angle (number)",s("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Na={description:s("Hyperbolic cotangent of any real number."),args:[da("value (number)",s("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},_a={description:s("Number of empty values."),args:[da("value1 (any, range)",s("The first value or range in which to count the number of blanks.")),da("value2 (any, range, repeating)",s("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return qo(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Fa={description:s("A conditional count across a range."),args:[da("range (range)",s("The range that is tested against criterion.")),da("criterion (string)",s("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return Qo(e,((e,i)=>{t+=1})),t},isExported:!0},Da={description:s("Count values depending on multiple criteria."),args:[da("criteria_range1 (range)",s("The range to check against criterion1.")),da("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),da("criteria_range2 (any, range, repeating)",s("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.")),da("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return Qo(e,((e,i)=>{t+=1})),t},isExported:!0};function ka(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const La={description:s("Counts number of unique values in a range."),args:[da("value1 (any, range)",s("The first value or range to consider for uniqueness.")),da("value2 (any, range, repeating)",s("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return qo(e,((e,t)=>ka(t)?e.add(t):e),new Set).size}},Pa={description:s("Counts number of unique values in a range, filtered by a set of criteria."),args:[da("range (range)",s("The range of cells from which the number of unique values will be counted.")),da("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),da("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),da("criteria_range2 (any, range, repeating)",s("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.")),da("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=new Set;return Qo(t,((t,o)=>{const n=e[t][o];ka(n)&&i.add(n)})),i.size}},Ua={description:s("Cosecant of an angle provided in radians."),args:[da("angle (number)",s("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Va={description:s("Hyperbolic cosecant of any real number."),args:[da("value (number)",s("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},za={description:s("Converts from another base to decimal."),args:[da("value (string)",s("The number to convert.")),da(",base (number)",s("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let i=ko(t);i=Math.floor(i),Fo((()=>2<=i&&i<=36),s("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const o=Po(e);if(""===o)return 0;Fo((()=>!!o.match(/^-?[a-z0-9]+$/i)),s("The value (%s) must be a valid base %s representation.",o,i.toString()));const n=parseInt(o,i);return Fo((()=>!isNaN(n)),s("The value (%s) must be a valid base %s representation.",o,i.toString())),n},isExported:!0},Ba={description:s("Converts an angle value in radians to degrees."),args:[da("angle (number)",s("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*ko(e)/Math.PI},isExported:!0},Ha={description:s("Euler's number, e (~2.718) raised to a power."),args:[da("value (number)",s("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(ko(e))},isExported:!0},$a={description:s("Rounds number down to nearest multiple of factor."),args:[da("value (number)",s("The value to round down to the nearest integer multiple of factor.")),da("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=ko(e),o=ko(t);return Fo((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.floor(i/o)*o:0},isExported:!0},Wa={description:s("Rounds number down to nearest multiple of factor."),args:[da("number (number)",s("The value to round down to the nearest integer multiple of significance.")),da("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),da("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=ko(t);if(0===o)return 0;const n=ko(e);if(o=Math.abs(o),n>=0)return Math.floor(n/o)*o;return 0===ko(i)?-Math.ceil(Math.abs(n)/o)*o:-Math.floor(Math.abs(n)/o)*o},isExported:!0},Ga={description:s("Rounds number down to nearest multiple of factor."),args:[da("number (number)",s("The value to round down to the nearest integer multiple of significance.")),da("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Wa.compute(e,t,0)},isExported:!0},qa={description:s("Whether the provided value is even."),args:[da("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Lo(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Za={description:s("Rounds number up to nearest multiple of factor."),args:[da("number (number)",s("The value to round up to the nearest integer multiple of significance.")),da("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ra.compute(e,t,0)},isExported:!0},ja={description:s("Whether the provided value is even."),args:[da("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Lo(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Xa={description:s("The logarithm of a number, base e (euler's number)."),args:[da("value (number)",s("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return Fo((()=>t>0),s("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ya={description:s("Modulo (remainder) operator."),args:[da("dividend (number)",s("The number to be divided to find the remainder.")),da("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=ko(t);Fo((()=>0!==i),s("The divisor must be different from 0."));const o=ko(e)%i;return o>0&&i<0||o<0&&i>0?o+i:o},isExported:!0},Ka={description:s("Rounds a number up to the nearest odd integer."),args:[da("value (number)",s("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=ko(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Qa={description:s("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Ja={description:s("A number raised to a power."),args:[da("base (number)",s("The number to raise to the exponent power.")),da("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=ko(e),o=ko(t);return Fo((()=>i>=0||Number.isInteger(o)),s("The exponent (%s) must be an integer when the base is negative.",o.toString())),Math.pow(i,o)},isExported:!0},el={description:s("Result of multiplying a series of numbers together."),args:[da("factor1 (number, range<number>)",s("The first number or range to calculate for the product.")),da("factor2 (number, range<number>, repeating)",s("More numbers or ranges to calculate for the product."))],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,i=1;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(i*=o,t+=1);else null!=o&&(i*=Lo(o),t+=1);return 0===t?0:i},isExported:!0},tl={description:s("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},il={description:s("Random integer between two values, inclusive."),args:[da("low (number)",s("The low end of the random range.")),da("high (number)",s("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=ko(e);Number.isInteger(i)||(i=Math.ceil(i));let o=ko(t);return Number.isInteger(o)||(o=Math.floor(o)),Fo((()=>i<=o),s("The high (%s) must be greater than or equal to the low (%s).",o.toString(),i.toString())),i+Math.ceil((o-i+1)*Math.random())-1},isExported:!0},ol={description:s("Rounds a number according to standard rules."),args:[da("value (number)",s("The value to round to places number of places.")),da("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=ko(e);let o=ko(t);const n=Math.abs(i);let s;return 0===o?s=Math.round(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.round(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},nl={description:s("Rounds down a number."),args:[da("value (number)",s("The value to round to places number of places, always rounding down.")),da("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=ko(e);let o=ko(t);const n=Math.abs(i);let s;return 0===o?s=Math.floor(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.floor(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},sl={description:s("Rounds up a number."),args:[da("value (number)",s("The value to round to places number of places, always rounding up.")),da("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=ko(e);let o=ko(t);const n=Math.abs(i);let s;return 0===o?s=Math.ceil(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.ceil(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},rl={description:s("Secant of an angle provided in radians."),args:[da("angle (number)",s("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(ko(e))},isExported:!0},al={description:s("Hyperbolic secant of any real number."),args:[da("value (number)",s("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(ko(e))},isExported:!0},ll={description:s("Sine of an angle provided in radians."),args:[da("angle (number)",s("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(ko(e))},isExported:!0},cl={description:s("Hyperbolic sine of any real number."),args:[da("value (number)",s("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(ko(e))},isExported:!0},hl={description:s("Positive square root of a positive number."),args:[da("value (number)",s("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=ko(e);return Fo((()=>t>=0),s("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},dl={description:s("Sum of a series of numbers and/or cells."),args:[da("value1 (number, range<number>)",s("The first number or range to add together.")),da("value2 (number, range<number>, repeating)",s("Additional numbers or ranges to add to value1."))],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 Zo(e,((e,t)=>e+t),0)},isExported:!0},ul={description:s("A conditional sum across a range."),args:[da("criteria_range (range)",s("The range which is tested against criterion.")),da("criterion (string)",s("The pattern or test to apply to range.")),da("sum_range (range, default=criteria_range)",s("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let o=0;return Qo([e,t],((e,t)=>{const n=i[e][t];"number"==typeof n&&(o+=n)})),o},isExported:!0},gl={description:s("Sums a range depending on multiple criteria."),args:[da("sum_range (range)",s("The range to sum.")),da("criteria_range1 (range)",s("The range to check against criterion1.")),da("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),da("criteria_range2 (any, range, repeating)",s("Additional ranges to check.")),da("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let i=0;return Qo(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i+=n)})),i},isExported:!0},pl={description:s("Tangent of an angle provided in radians."),args:[da("angle (number)",s("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(ko(e))},isExported:!0},ml={description:s("Hyperbolic tangent of any real number."),args:[da("value (number)",s("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(ko(e))},isExported:!0},fl={description:s("Truncates a number."),args:[da("value (number)",s("The value to be truncated.")),da("places (number, default=0)",s("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=ko(e);let o=ko(t);return 0===o?Math.trunc(i):(Number.isInteger(o)||(o=Math.trunc(o)),Math.trunc(i*Math.pow(10,o))/Math.pow(10,o))},isExported:!0};var vl=Object.freeze({__proto__:null,ABS:ma,ACOS:fa,ACOSH:va,ACOT:ba,ACOTH:Sa,ASIN:Ca,ASINH:Ea,ATAN:wa,ATAN2:ya,ATANH:xa,CEILING:Ia,CEILING_MATH:Ra,CEILING_PRECISE:Ta,COS:Aa,COSH:Ma,COT:Oa,COTH:Na,COUNTBLANK:_a,COUNTIF:Fa,COUNTIFS:Da,COUNTUNIQUE:La,COUNTUNIQUEIFS:Pa,CSC:Ua,CSCH:Va,DECIMAL:za,DEGREES:Ba,EXP:Ha,FLOOR:$a,FLOOR_MATH:Wa,FLOOR_PRECISE:Ga,ISEVEN:qa,ISO_CEILING:Za,ISODD:ja,LN:Xa,MOD:Ya,ODD:Ka,PI:Qa,POWER:Ja,PRODUCT:el,RAND:tl,RANDBETWEEN:il,ROUND:ol,ROUNDDOWN:nl,ROUNDUP:sl,SEC:rl,SECH:al,SIN:ll,SINH:cl,SQRT:hl,SUM:dl,SUMIF:ul,SUMIFS:gl,TAN:pl,TANH:ml,TRUNC:fl});function bl(e,t,i){let o=[],n=[],r=0,a=0;$o([e],(e=>{o.push(e),r+=1})),$o([t],(e=>{n.push(e),a+=1})),Fo((()=>r===a),s("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",r.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}Fo((()=>0!==l&&(!i||1!==l)),s("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<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function Sl(e,t,i){let o=0,n=0;const r=i?jo:Zo;n=r(e,((e,t)=>(o+=1,e+t)),0),Fo((()=>0!==o&&(!t||1!==o)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/o;return r(e,((e,t)=>e+Math.pow(t-a,2)),0)/(o-(t?1:0))}function Cl(e,t,i){const o=ko(t);Fo((()=>i?0<=o&&o<=1:0<o&&o<1),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return $o(e,(e=>{"number"==typeof e&&(n=tn(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,e),a++)})),Fo((()=>0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),i||Fo((()=>1/(a+1)<=o&&o<=a/(a+1)),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),ni(r,o,i)}const El={description:s("Average magnitude of deviations from mean."),args:[da("value1 (number, range<number>)",s("The first value or range of the sample.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const i=Zo(e,((e,i)=>(t+=1,e+i)),0);Fo((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const o=i/t;return Zo(e,((e,t)=>e+Math.abs(o-t)),0)/t},isExported:!0},wl={description:s("Numerical average value in a dataset, ignoring text."),args:[da("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],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 i=Zo(e,((e,i)=>(t+=1,e+i)),0);return Fo((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},yl=s("[[FUNCTION_NAME]] has mismatched range sizes."),xl=s("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Il={description:s("Weighted average."),args:[da("values (number, range<number>)",s("Values to average.")),da("weights (number, range<number>)",s("Weights for each corresponding value.")),da("additional_values (number, range<number>, repeating)",s("Additional values to average.")),da("additional_weights (number, range<number>, repeating)",s("Additional weights."))],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,i,o=0,n=0;Fo((()=>e.length%2==0),s("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let r=0;r<e.length-1;r+=2)if(t=e[r],i=e[r+1],Array.isArray(t)){Fo((()=>Array.isArray(i)),yl);let e=t.length,r=t[0].length;Fo((()=>e===i.length&&r===i[0].length),yl);for(let a=0;a<e;a++)for(let e=0;e<r;e++){let r=t[a][e],l=i[a][e],c="number"==typeof r,h="number"==typeof l;Fo((()=>c===h),s("[[FUNCTION_NAME]] expects number values.")),h&&(Fo((()=>l>=0),xl),o+=r*l,n+=l)}}else i=ko(i),t=ko(t),Fo((()=>i>=0),xl),o+=t*i,n+=i;return Fo((()=>0!==n),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n}},Rl={description:s("Numerical average value in a dataset."),args:[da("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],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 i=jo(e,((e,i)=>(t+=1,e+i)),0);return Fo((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Tl={description:s("Average of values depending on criteria."),args:[da("criteria_range (range)",s("The range to check against criterion.")),da("criterion (string)",s("The pattern or test to apply to criteria_range.")),da("average_range (range, default=criteria_range)",s("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let o=0,n=0;return Qo([e,t],((t,s)=>{const r=(i||e)[t][s];"number"==typeof r&&(o+=1,n+=r)})),Fo((()=>0!==o),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},Al={description:s("Average of values depending on multiple criteria."),args:[da("average_range (range)",s("The range to average.")),da("criteria_range1 (range)",s("The range to check against criterion1.")),da("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),da("criteria_range2 (any, range, repeating)",s("Additional criteria_range and criterion to check.")),da("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=0,o=0;return Qo(t,((t,n)=>{const s=e[t][n];"number"==typeof s&&(i+=1,o+=s)})),Fo((()=>0!==i),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},Ml={description:s("The number of numeric values in dataset."),args:[da("value1 (number, range<number>)",s("The first value or range to consider when counting.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||ti(i)||Ce(i))&&(t+=1);return t},isExported:!0},Ol={description:s("The number of values in a dataset."),args:[da("value1 (any, range)",s("The first value or range to consider when counting.")),da("value2 (any, range, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return qo(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Nl={description:s("The covariance of a dataset."),args:[da("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),da("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return bl(e,t,!1)},isExported:!0},_l={description:s("The covariance of a dataset."),args:[da("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),da("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return bl(e,t,!1)},isExported:!0},Fl={description:s("The sample covariance of a dataset."),args:[da("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),da("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return bl(e,t,!0)},isExported:!0},Dl={description:s("Nth largest element from a data set."),args:[da("data (any, range)",s("Array or range containing the dataset to consider.")),da("n (number)",s("The rank from largest to smallest of the element to return."))],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 i=Math.trunc(ko(t));let o,n=[],r=0;$o([e],(e=>{"number"==typeof e&&(o=tn(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.shift(),r--))}));const a=n.shift();return Fo((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Fo((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},kl={description:s("Maximum value in a numeric dataset."),args:[da("value1 (number, range<number>)",s("The first value or range to consider when calculating the maximum value.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],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=Zo(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Ll={description:s("Maximum numeric value in a dataset."),args:[da("value1 (any, range)",s("The first value or range to consider when calculating the maximum value.")),da("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],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=jo(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Pl={description:s("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[da("range (range)",s("The range of cells from which the maximum will be determined.")),da("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),da("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),da("criteria_range2 (any, range, repeating)",s("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.")),da("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return Qo(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i<n?n:i)})),i===-1/0?0:i},isExported:!0},Ul={description:s("Median value in a numeric dataset."),args:[da("value1 (any, range)",s("The first value or range to consider when calculating the median value.")),da("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the median value."))],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 Wo(e,(e=>{t.push(e)})),Cl(t,.5,!0)},isExported:!0},Vl={description:s("Minimum value in a numeric dataset."),args:[da("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],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=Zo(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},zl={description:s("Minimum numeric value in a dataset."),args:[da("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],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=jo(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Bl={description:s("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[da("range (range)",s("The range of cells from which the minimum will be determined.")),da("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),da("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),da("criteria_range2 (any, range, repeating)",s("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.")),da("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=1/0;return Qo(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i>n?n:i)})),i===1/0?0:i},isExported:!0},Hl={description:s("Value at a given percentile of a dataset."),args:[da("data (any, range)",s("The array or range containing the dataset to consider.")),da("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],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},$l={description:s("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[da("data (any, range)",s("The array or range containing the dataset to consider.")),da("percentile (number)",s("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],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([e],t,!1)},isExported:!0},Wl={description:s("Value at a given percentile of a dataset."),args:[da("data (any, range)",s("The array or range containing the dataset to consider.")),da("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],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([e],t,!0)},isExported:!0},Gl={description:s("Value nearest to a specific quartile of a dataset."),args:[da("data (any, range)",s("The array or range containing the dataset to consider.")),da("quartile_number (number)",s("Which quartile value to return."))],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 Zl.compute(e,t)},isExported:!0},ql={description:s("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[da("data (any, range)",s("The array or range containing the dataset to consider.")),da("quartile_number (number)",s("Which quartile value, exclusive of 0 and 4, to return."))],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([e],.25*Math.trunc(ko(t)),!1)},isExported:!0},Zl={description:s("Value nearest to a specific quartile of a dataset."),args:[da("data (any, range)",s("The array or range containing the dataset to consider.")),da("quartile_number (number)",s("Which quartile value to return."))],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([e],.25*Math.trunc(ko(t)),!0)},isExported:!0},jl={description:s("Nth smallest element in a data set."),args:[da("data (any, range)",s("The array or range containing the dataset to consider.")),da("n (number)",s("The rank from smallest to largest of the element to return."))],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 i=Math.trunc(ko(t));let o,n=[],r=0;$o([e],(e=>{"number"==typeof e&&(o=tn(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.pop(),r--))}));const a=n.pop();return Fo((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Fo((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Xl={description:s("Standard deviation."),args:[da("value1 (number, range<number>)",s("The first value or range of the sample.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(tc.compute(...e))},isExported:!0},Yl={description:s("Standard deviation of entire population."),args:[da("value1 (number, range<number>)",s("The first value or range of the population.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ic.compute(...e))},isExported:!0},Kl={description:s("Standard deviation."),args:[da("value1 (number, range<number>)",s("The first value or range of the sample.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(oc.compute(...e))},isExported:!0},Ql={description:s("Standard deviation of sample (text as 0)."),args:[da("value1 (number, range<number>)",s("The first value or range of the sample.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(nc.compute(...e))},isExported:!0},Jl={description:s("Standard deviation of entire population."),args:[da("value1 (number, range<number>)",s("The first value or range of the population.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(sc.compute(...e))},isExported:!0},ec={description:s("Standard deviation of entire population (text as 0)."),args:[da("value1 (number, range<number>)",s("The first value or range of the population.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(rc.compute(...e))},isExported:!0},tc={description:s("Variance."),args:[da("value1 (number, range<number>)",s("The first value or range of the sample.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sl(e,!0,!1)},isExported:!0},ic={description:s("Variance of entire population."),args:[da("value1 (number, range<number>)",s("The first value or range of the population.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sl(e,!1,!1)},isExported:!0},oc={description:s("Variance."),args:[da("value1 (number, range<number>)",s("The first value or range of the sample.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sl(e,!0,!1)},isExported:!0},nc={description:s("Variance of sample (text as 0)."),args:[da("value1 (number, range<number>)",s("The first value or range of the sample.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Sl(e,!0,!0)},isExported:!0},sc={description:s("Variance of entire population."),args:[da("value1 (number, range<number>)",s("The first value or range of the population.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sl(e,!1,!1)},isExported:!0},rc={description:s("Variance of entire population (text as 0)."),args:[da("value1 (number, range<number>)",s("The first value or range of the population.")),da("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Sl(e,!1,!0)},isExported:!0};var ac=Object.freeze({__proto__:null,AVEDEV:El,AVERAGE:wl,AVERAGE_WEIGHTED:Il,AVERAGEA:Rl,AVERAGEIF:Tl,AVERAGEIFS:Al,COUNT:Ml,COUNTA:Ol,COVAR:Nl,COVARIANCE_P:_l,COVARIANCE_S:Fl,LARGE:Dl,MAX:kl,MAXA:Ll,MAXIFS:Pl,MEDIAN:Ul,MIN:Vl,MINA:zl,MINIFS:Bl,PERCENTILE:Hl,PERCENTILE_EXC:$l,PERCENTILE_INC:Wl,QUARTILE:Gl,QUARTILE_EXC:ql,QUARTILE_INC:Zl,SMALL:jl,STDEV:Xl,STDEV_P:Yl,STDEV_S:Kl,STDEVA:Ql,STDEVP:Jl,STDEVPA:ec,VAR:tc,VAR_P:ic,VAR_S:oc,VARA:nc,VARP:sc,VARPA:rc});function lc(e,t,i){var o;const n=new Map,r=e.length;for(let t=r-1;t>=0;t--)n.set(Po(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(s("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||r-1<a)throw new Error(s("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),r.toString()))}else{const e=Po(t).toUpperCase();if(a=null!==(o=n.get(e))&&void 0!==o?o:-1,-1===a)throw new Error(s("The field (%s) must be one of %s.",Po(t),[...n.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(s("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 o=[],s=!0;for(let r=0;r<i.length;r++){const a=Po(i[r][0]).toUpperCase(),l=n.get(a),c=i[r][t];if(void 0!==c){if(void 0===l){s=!1;break}o.push([e[l].slice(1,h)]),o.push(c)}}if(s){if(!(o.length>0)){c=new Set(Array(h-1).keys());break}Qo(o,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const cc=[da("database (range)",s("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.")),da("field (any)",s("Indicates which column in database contains the values to be extracted and operated on.")),da("criteria (range)",s("An array or range containing zero or more criteria to filter the database values by before operating."))],hc={description:s("Average of a set of values from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return wl.compute([o])},isExported:!0},dc={description:s("Counts values from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return Ml.compute([o])},isExported:!0},uc={description:s("Counts values and text from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return Ol.compute([o])},isExported:!0},gc={description:s("Single value from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return Fo((()=>1===o.length),s("More than one match found in DGET evaluation.")),o[0]},isExported:!0},pc={description:s("Maximum of values from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return kl.compute([o])},isExported:!0},mc={description:s("Minimum of values from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return Vl.compute([o])},isExported:!0},fc={description:s("Product of values from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return el.compute([o])},isExported:!0},vc={description:s("Standard deviation of population sample from table."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return Xl.compute([o])},isExported:!0},bc={description:s("Standard deviation of entire population from table."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return Jl.compute([o])},isExported:!0},Sc={description:s("Sum of values from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return dl.compute([o])},isExported:!0},Cc={description:s("Variance of population sample from table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return tc.compute([o])},isExported:!0},Ec={description:s("Variance of a population from a table-like range."),args:cc,returns:["NUMBER"],compute:function(e,t,i){const o=lc(e,t,i);return sc.compute([o])},isExported:!0};var wc=Object.freeze({__proto__:null,DAVERAGE:hc,DCOUNT:dc,DCOUNTA:uc,DGET:gc,DMAX:pc,DMIN:mc,DPRODUCT:fc,DSTDEV:vc,DSTDEVP:bc,DSUM:Sc,DVAR:Cc,DVARP:Ec});const yc={description:s("Converts year/month/day into a date."),args:[da("year (number)",s("The year component of the date.")),da("month (number)",s("The month component of the date.")),da("day (number)",s("The day component of the date."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let o=Math.trunc(ko(e));const n=Math.trunc(ko(t)),r=Math.trunc(ko(i));Fo((()=>0<=o&&o<=9999),s("The year (%s) must be between 0 and 9999 inclusive.",o.toString())),o<1900&&(o+=1900);const a=ye(new Date(o,n-1,r));return Fo((()=>a>=0),s("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},xc={description:s("Converts a date string to a date value."),args:[da("date_string (string)",s("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=Po(e),i=Ce(t);return Fo((()=>null!==i),s("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},Ic={description:s("Day of the month that a specific date falls on."),args:[da("date (string)",s("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Bo(e).getDate()},isExported:!0},Rc={description:s("Number of days between two dates."),args:[da("end_date (date)",s("The end of the date range.")),da("start_date (date)",s("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const i=Bo(e),o=Bo(t),n=i.getTime()-o.getTime();return Math.round(n/ge)},isExported:!0},Tc={description:s("Number of days between two dates on a 360-day year (months of 30 days)."),args:[da("start_date (date)",s("The start date to consider in the calculation.")),da("end_date (date)",s("The end date to consider in the calculation.")),da("method (number, default=0)",s("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,i=0){const o=ko(e),n=ko(t),s=zo(i)?4:0,r=Zc.compute(e,t,s);return Math.sign(n-o)*Math.round(360*r)},isExported:!0},Ac={description:s("Date a number of months before/after another date."),args:[da("start_date (date)",s("The date from which to calculate the result.")),da("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return ye(Re(Bo(e),Math.trunc(ko(t)),!1))},isExported:!0},Mc={description:s("Last day of a month before or after a date."),args:[da("start_date (date)",s("The date from which to calculate the result.")),da("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Bo(e),o=Math.trunc(ko(t)),n=i.getFullYear(),s=i.getMonth();return ye(new Date(n,s+o+1,0))},isExported:!0},Oc={description:s("Hour component of a specific time."),args:[da("time (date)",s("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Bo(e).getHours()},isExported:!0},Nc={description:s("ISO week number of the year."),args:[da("date (date)",s("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],returns:["NUMBER"],compute:function(e){const t=Bo(e),i=t.getFullYear();let o=1;for(;4!==new Date(i,0,o).getDay();)o+=1;const n=new Date(i,0,o-3);let s=31;for(;4!==new Date(i,11,s).getDay();)s-=1;const r=new Date(i,11,s+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Date(i,11,s+3+1);break;case-1:let e=1;for(;4!==new Date(i-1,0,e).getDay();)e+=1;l=new Date(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ge;return Math.floor(c/7)+1},isExported:!0},_c={description:s("Minute component of a specific time."),args:[da("time (date)",s("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Bo(e).getMinutes()},isExported:!0},Fc={description:s("Month of the year a specific date falls in"),args:[da("date (date)",s("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Bo(e).getMonth()+1},isExported:!0},Dc={description:s("Net working days between two provided days."),args:[da("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),da("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),da("holidays (date, range<date>, optional)",s("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,i){return Lc.compute(e,t,1,i)},isExported:!0};function kc(e){if("string"==typeof e){Fo((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),s('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return Fo((()=>1<=e&&e<=7||11<=e&&e<=17),s("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(s("The weekend must be a number or a string."))}const Lc={description:s("Net working days between two dates (specifying weekends)."),args:[da("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),da("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),da("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),da("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,i=1,o){const n=Bo(e),s=Bo(t),r=kc(i);let a=new Set;void 0!==o&&$o([o],(e=>{const t=Bo(e);a.add(t.getTime())}));const l=n.getTime()>s.getTime(),c=new Date((l?n:s).getTime());let h=new Date((l?s:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Pc={description:s("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()-ue.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ge)+i},isExported:!0},Uc={description:s("Minute component of a specific time."),args:[da("time (date)",s("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Bo(e).getSeconds()},isExported:!0},Vc={description:s("Converts hour/minute/second into a time."),args:[da("hour (number)",s("The hour component of the time.")),da("minute (number)",s("The minute component of the time.")),da("second (number)",s("The second component of the time."))],returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let o=Math.trunc(ko(e)),n=Math.trunc(ko(t)),r=Math.trunc(ko(i));return n+=Math.floor(r/60),r=r%60+(r<0?60:0),o+=Math.floor(n/60),n=n%60+(n<0?60:0),o%=24,Fo((()=>o>=0),s("The function [[FUNCTION_NAME]] result cannot be negative")),o/24+n/1440+r/86400},isExported:!0},zc={description:s("Converts a time string into its serial number representation."),args:[da("time_string (string)",s("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=Po(e),i=Ce(t);Fo((()=>null!==i),s("The time_string (%s) cannot be parsed to date/time.",t));const o=i.value-Math.trunc(i.value);return o<0?1+o:o},isExported:!0},Bc={description:s("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return ye(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Hc={description:s("Day of the week of the date provided (as number)."),args:[da("date (date)",s("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.")),da("type (number, default=1)",s("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Bo(e),o=Math.round(ko(t)),n=i.getDay();return Fo((()=>[1,2,3].includes(o)),s("The type (%s) must be 1, 2 or 3.",o.toString())),1===o?n+1:2===o?0===n?7:n:0===n?6:n-1},isExported:!0},$c={description:s("Week number of the year."),args:[da("date (date)",s("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.")),da("type (number, default=1)",s("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Bo(e),o=Math.round(ko(t));if(Fo((()=>1===o||2===o||11<=o&&o<=17||21===o),s("The type (%s) is out of range.",o.toString())),21===o)return Nc.compute(e);let n;n=1===o||2===o?o-1:o-10==7?0:o-10;const r=i.getFullYear();let a=1,l=new Date(r,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(r,0,a);const c=(i.getTime()-l.getTime())/ge;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Wc={description:s("Date after a number of workdays."),args:[da("start_date (date)",s("The date from which to begin counting.")),da("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),da("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Gc.compute(e,t,1,i)},isExported:!0},Gc={description:s("Date after a number of workdays (specifying weekends)."),args:[da("start_date (date)",s("The date from which to begin counting.")),da("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),da("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),da("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,o){let n=Bo(e),r=Math.trunc(ko(t));"string"==typeof i&&Fo((()=>"1111111"!==i),s("The weekend (%s) must be different from '1111111'.",i));const a=kc(i);let l=new Set;void 0!==o&&$o([o],(e=>{const t=Bo(e);l.add(t.getTime())}));let c=new Date(n.getTime()),h=c.getTime();const d=Math.sign(r);let u=Math.abs(r);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-ue.getTime();return Math.round(g/ge)},isExported:!0},qc={description:s("Year specified by a given date."),args:[da("date (date)",s("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Bo(e).getFullYear()},isExported:!0},Zc={description:s("Exact number of years between two dates."),args:[da("start_date (date)",s("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.")),da("end_date (date)",s("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.")),da("day_count_convention (number, default=0)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i=0){let o=Math.trunc(ko(e)),n=Math.trunc(ko(t));const r=Math.trunc(ko(i));return Fo((()=>o>=0),s("The start_date (%s) must be positive or null.",o.toString())),Fo((()=>n>=0),s("The end_date (%s) must be positive or null.",n.toString())),Fo((()=>0<=r&&r<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",r.toString())),Ae(o,n,r)}},jc={description:s("First day of the month preceding a date."),args:[da("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Bo(e),i=t.getFullYear(),o=t.getMonth();return ye(new Date(i,o,1))}},Xc={description:s("Last day of the month following a date."),args:[da("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Mc.compute(e,0)}},Yc={description:s("Quarter of the year a specific date falls in"),args:[da("date (date)",s("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Bo(e).getMonth()+1)/3)}},Kc={description:s("First day of the quarter of the year a specific date falls in."),args:[da("date (date)",s("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Yc.compute(e),i=qc.compute(e);return ye(new Date(i,3*(t-1),1))}},Qc={description:s("Last day of the quarter of the year a specific date falls in."),args:[da("date (date)",s("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Yc.compute(e),i=qc.compute(e);return ye(new Date(i,3*t,0))}},Jc={description:s("First day of the year a specific date falls in."),args:[da("date (date)",s("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=qc.compute(e);return ye(new Date(t,0,1))}},eh={description:s("Last day of the year a specific date falls in."),args:[da("date (date)",s("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=qc.compute(e);return ye(new Date(t+1,0,0))}};var th=Object.freeze({__proto__:null,DATE:yc,DATEVALUE:xc,DAY:Ic,DAYS:Rc,DAYS360:Tc,EDATE:Ac,EOMONTH:Mc,HOUR:Oc,ISOWEEKNUM:Nc,MINUTE:_c,MONTH:Fc,NETWORKDAYS:Dc,NETWORKDAYS_INTL:Lc,NOW:Pc,SECOND:Uc,TIME:Vc,TIMEVALUE:zc,TODAY:Bc,WEEKDAY:Hc,WEEKNUM:$c,WORKDAY:Wc,WORKDAY_INTL:Gc,YEAR:qc,YEARFRAC:Zc,MONTH_START:jc,MONTH_END:Xc,QUARTER:Yc,QUARTER_START:Kc,QUARTER_END:Qc,YEAR_START:Jc,YEAR_END:eh});const ih={description:s("Compare two numeric values, returning 1 if they're equal."),args:[da(" (number)",s("The first number to compare.")),da(" (number, default=0)",s("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return ko(e)===ko(t)?1:0},isExported:!0};var oh=Object.freeze({__proto__:null,DELTA:ih});function nh(e,t){Fo((()=>e<t),s("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function sh(e,t){Fo((()=>t<e),s("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function rh(e){Fo((()=>[1,2,4].includes(e)),s("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function ah(e){Fo((()=>0<=e&&e<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function lh(e){Fo((()=>e>0),s("The redemption (%s) must be strictly positive.",e.toString()))}function ch(e){Fo((()=>e>0),s("The price (%s) must be strictly positive.",e.toString()))}function hh(e){Fo((()=>e>0),s("The number_of_periods (%s) must be greater than 0.",e.toString()))}function dh(e){Fo((()=>e>0),s("The rate (%s) must be strictly positive.",e.toString()))}function uh(e){Fo((()=>e>0),s("The life (%s) must be strictly positive.",e.toString()))}function gh(e){Fo((()=>e>=0),s("The cost (%s) must be positive or null.",e.toString()))}function ph(e){Fo((()=>e>0),s("The period (%s) must be strictly positive.",e.toString()))}function mh(e){Fo((()=>e>=0),s("The salvage (%s) must be positive or null.",e.toString()))}function fh(e){Fo((()=>e>0),s("The present value (%s) must be strictly positive.",e.toString()))}function vh(e,t){Fo((()=>e<=t),s("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function bh(e){Fo((()=>e>0),s("The investment (%s) must be strictly positive.",e.toString()))}function Sh(e){Fo((()=>e>0),s("The discount (%s) must be strictly positive.",e.toString()))}function Ch(e){Fo((()=>e<1),s("The discount (%s) must be smaller than 1.",e.toString()))}function Eh(e){Fo((()=>e>0),s("The depreciation factor (%s) must be strictly positive.",e.toString()))}function wh(e,t){const i=Bo(e),o=Bo(t),n=new Date(i);n.setFullYear(i.getFullYear()+1),Fo((()=>o.getTime()<=n.getTime()),s("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function yh(e,t,i){hh(i),Fo((()=>e>0),s("The first_period (%s) must be strictly positive.",e.toString())),Fo((()=>t>0),s("The last_period (%s) must be strictly positive.",t.toString())),Fo((()=>e<=t),s("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Fo((()=>t<=i),s("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function xh(e){Fo((()=>e>-1),s("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Ih(e,t){Fo((()=>e.length===t.length&&e[0].length===t[0].length),s("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Rh(e){Fo((()=>e.every((t=>t>=e[0]))),s("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Th=[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))];function Ah(e,t,i,o,n=1e-10,r){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(Fo((()=>g<o&&void 0!==r),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=r(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<n||Math.abs(c)<n,Fo((()=>g<o),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Mh={description:s("Accrued interest of security paying at maturity."),args:[da("issue (date)",s("The date the security was initially issued.")),da("maturity (date)",s("The maturity date of the security.")),da("rate (number)",s("The annualized rate of interest.")),da("redemption (number)",s("The redemption amount per 100 face value, or par.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(ko(e)),r=Math.trunc(ko(t)),a=ko(o),l=ko(i),c=Math.trunc(ko(n));sh(r,s),ah(c),lh(a),dh(l);return a*l*Zc.compute(s,r,n)},isExported:!0},Oh={description:s("Depreciation for an accounting period."),args:[da("cost (number)",s("The initial cost of the asset.")),da("purchase_date (date)",s("The date the asset was purchased.")),da("first_period_end (date)",s("The date the first period ended.")),da("salvage (number)",s("The value of the asset at the end of depreciation.")),da("period (number)",s("The single period within life for which to calculate depreciation.")),da("rate (number)",s("The deprecation rate.")),da(" (number, optional)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=ko(e),c=Math.trunc(ko(t)),h=Math.trunc(ko(i)),d=ko(o),u=ko(n),g=ko(r),p=Math.trunc(ko(a));!function(e){Fo((()=>e>0),s("The cost (%s) must be strictly positive.",e.toString()))}(l),mh(d),function(e,t){Fo((()=>e<=t),s("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Fo((()=>e>=0),s("The period (%s) must be positive or null.",e.toString()))}(u),dh(g),ah(p),Fo((()=>c<=h),s("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=Zc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},Nh={description:s("Days in coupon period containing settlement date."),args:Th,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(ko(e)),s=Math.trunc(ko(t)),r=Math.trunc(ko(i)),a=Math.trunc(ko(o));if(nh(n,s),rh(r),ah(a),1===a){const n=Lh.compute(e,t,i,o);return Dh.compute(e,t,i,o)-n}return(3===a?365:360)/r},isExported:!0},_h={description:s("Days from settlement until next coupon."),args:Th,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(ko(e)),s=Math.trunc(ko(t)),r=Math.trunc(ko(i)),a=Math.trunc(ko(o));nh(n,s),rh(r),ah(a);const l=Lh.compute(n,s,i,o);if([1,2,3].includes(a))return n-l;if(4===a){const e=Ae(l,n,a);return Math.round(360*e)}const c=Bo(n),h=Bo(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Ie(h)&&Ie(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Ie(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Fh={description:s("Days from settlement until next coupon."),args:Th,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(ko(e)),s=Math.trunc(ko(t)),r=Math.trunc(ko(i)),a=Math.trunc(ko(o));nh(n,s),rh(r),ah(a);const l=Dh.compute(n,s,i,o);if([1,2,3].includes(a))return l-n;if(4===a){const e=Ae(n,l,a);return Math.round(360*e)}const c=_h.compute(e,t,i,a);return Nh.compute(e,t,i,a)-c},isExported:!0},Dh={description:s("Next coupon date after the settlement date."),args:Th,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(ko(e)),s=Math.trunc(ko(t)),r=Math.trunc(ko(i)),a=Math.trunc(ko(o));nh(n,s),rh(r),ah(a);const l=12/r,c=kh.compute(e,t,i,o);return ye(Re(Bo(s),-(c-1)*l,!0))},isExported:!0},kh={description:s("Number of coupons between settlement and maturity."),args:Th,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(ko(e)),s=Math.trunc(ko(t)),r=Math.trunc(ko(i)),a=Math.trunc(ko(o));nh(n,s),rh(r),ah(a);let l=1,c=s;const h=12/r;for(;c>n;)c=ye(Re(Bo(c),-h,!1)),l++;return l-1},isExported:!0},Lh={description:s("Last coupon date prior to or on the settlement date."),args:Th,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(ko(e)),s=Math.trunc(ko(t)),r=Math.trunc(ko(i)),a=Math.trunc(ko(o));nh(n,s),rh(r),ah(a);const l=12/r,c=kh.compute(e,t,i,o);return ye(Re(Bo(s),-c*l,!0))},isExported:!0},Ph={description:s("Cumulative interest paid over a set of periods."),args:[da("rate (number)",s("The interest rate.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("present_value (number)",s("The current value of the annuity.")),da("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),da("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=ko(o),a=ko(n),l=ko(e),c=ko(i),h=ko(t);yh(r,a,h),dh(l),fh(c);let d=0;for(let t=r;t<=a;t++){d+=Xh.compute(e,t,h,i,0,s)}return d},isExported:!0},Uh={description:s("Cumulative principal paid over a set of periods."),args:[da("rate (number)",s("The interest rate.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("present_value (number)",s("The current value of the annuity.")),da("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),da("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=ko(o),a=ko(n),l=ko(e),c=ko(i),h=ko(t);yh(r,a,h),dh(l),fh(c);let d=0;for(let t=r;t<=a;t++){d+=sd.compute(e,t,h,i,0,s)}return d},isExported:!0},Vh={description:s("Depreciation via declining balance method."),args:[da("cost (number)",s("The initial cost of the asset.")),da("salvage (number)",s("The value of the asset at the end of depreciation.")),da("life (number)",s("The number of periods over which the asset is depreciated.")),da("period (number)",s("The single period within life for which to calculate depreciation.")),da("month (number, optional)",s("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,...n){const r=ko(e),a=ko(t),l=ko(i),c=Math.trunc(ko(o)),h=n.length?Math.trunc(ko(n[0])):12,d=l+(12===h?0:1);gh(r),mh(a),ph(c),uh(l),Fo((()=>1<=h&&h<=12),s("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Fo((()=>c<=d),s("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/r,1/l);g=Math.round(1e3*g)/1e3;let p=r,m=r*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},zh={description:s("Depreciation via double-declining balance method."),args:[da("cost (number)",s("The initial cost of the asset.")),da("salvage (number)",s("The value of the asset at the end of depreciation.")),da("life (number)",s("The number of periods over which the asset is depreciated.")),da("period (number)",s("The single period within life for which to calculate depreciation.")),da("factor (number, default=2)",s("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=2){n=n||0;const s=ko(e),r=ko(t),a=ko(i),l=ko(o),c=ko(n);if(gh(s),mh(r),ph(l),uh(a),vh(l,a),Eh(c),0===s||r>=s)return 0;const h=c/a;if(h>1)return 1===o?s-r:0;if(l<=1)return s*h;const d=s*Math.pow(1-h,l-1),u=s*Math.pow(1-h,l),g=u<r?d-r:d-u;return Math.max(g,0)},isExported:!0},Bh={description:s("Discount rate of a security based on price."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("price (number)",s("The price at which the security is bought per 100 face value.")),da("redemption (number)",s("The redemption amount per 100 face value, or par.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(ko(e)),r=Math.trunc(ko(t)),a=ko(i),l=ko(o),c=Math.trunc(ko(n));nh(s,r),ah(c),ch(a),lh(l);return(l-a)/l/Zc.compute(s,r,c)},isExported:!0},Hh={description:s("Convert a decimal fraction to decimal value."),args:[da("fractional_price (number)",s("The price quotation given using fractional decimal conventions.")),da("unit (number)",s("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=ko(e),o=Math.trunc(ko(t));Fo((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(10**Math.ceil(Math.log10(o))/o)},isExported:!0},$h={description:s("Convert a decimal value to decimal fraction."),args:[da("decimal_price (number)",s("The price quotation given as a decimal value.")),da("unit (number)",s("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=ko(e),o=Math.trunc(ko(t));Fo((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(o/10**Math.ceil(Math.log10(o)))},isExported:!0},Wh={description:s("Number of periods for an investment to reach a value."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("rate (number)",s("The annualized rate of interest.")),da("yield (number)",s("The expected annual yield of the security.")),da("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(ko(e)),l=Math.trunc(ko(t)),c=ko(i),h=ko(o),d=Math.trunc(ko(n)),u=Math.trunc(ko(r));nh(a,l),rh(d),ah(u),Fo((()=>c>=0),s("The rate (%s) must be positive or null.",c.toString())),Fo((()=>h>=0),s("The yield (%s) must be positive or null.",h.toString()));const g=Zc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Gh={description:s("Annual effective interest rate."),args:[da("nominal_rate (number)",s("The nominal interest rate per year.")),da("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=ko(e),o=Math.trunc(ko(t));return Fo((()=>i>0),s("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Fo((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),Math.pow(1+i/o,o)-1},isExported:!0},qh={description:s("Future value of an annuity investment."),args:[da("rate (number)",s("The interest rate.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("payment_amount (number)",s("The amount per period to be paid.")),da("present_value (number, default=0)",s("The current value of the annuity.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=ko(e),r=ko(t),a=ko(i),l=ko(o),c=zo(n)?1:0;return s?-l*(1+s)**r-a*(1+s*c)*((1+s)**r-1)/s:-(l+a*r)},isExported:!0},Zh={description:s("Future value of principal from series of rates."),args:[da("principal (number)",s("The amount of initial capital or value to compound against.")),da("rate_schedule (number, range<number>)",s("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return qo([t],((e,t)=>e*(1+ko(t))),ko(e))},isExported:!0},jh={description:s("Calculates effective interest rate."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("investment (number)",s("The amount invested in the security.")),da("redemption (number)",s("The amount to be received at maturity.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){const s=Math.trunc(ko(e)),r=Math.trunc(ko(t)),a=ko(o),l=ko(i);nh(s,r),bh(l),lh(a);return(a-l)/l/Zc.compute(s,r,n)},isExported:!0},Xh={description:s("Payment on the principal of an investment."),args:[da("rate (number)",s("The annualized rate of interest.")),da("period (number)",s("The amortization period, in terms of number of periods.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("present_value (number)",s("The current value of the annuity.")),da("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,s=0){return nd.compute(e,i,o,n,s)-sd.compute(e,t,i,o,n,s)},isExported:!0},Yh={description:s("Internal rate of return given periodic cashflows."),args:[da("cashflow_amounts (number, range<number>)",s("An array or range containing the income or payments associated with the investment.")),da("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=ko(t);xh(i);let o=!1,n=!1,r=[];Wo([e],(e=>{e>0&&(o=!0),e<0&&(n=!0),r.push(e)})),Fo((()=>o&&n),s("The cashflow_amounts must include negative and positive values."));const a=r.shift();return Ah((function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*e**(o-n))),t*e**o)}(e,a,r)}),(function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*(o-n)*e**(o-n-1))),t*o*e**(o-1))}(e,a,r)}),i+1,20,1e-5)-1},isExported:!0},Kh={description:s("Returns the interest paid at a particular period of an investment."),args:[da("rate (number)",s("The interest rate.")),da("period (number)",s("The period for which you want to view the interest payment.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("present_value (number)",s("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=ko(e),r=ko(t),a=ko(i),l=ko(o);Fo((()=>0!==a),s("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(r/a))*n},isExported:!0},Qh={description:s("Modified Macaulay duration."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("rate (number)",s("The annualized rate of interest.")),da("yield (number)",s("The expected annual yield of the security.")),da("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){return Wh.compute(e,t,i,o,n,s)/(1+ko(o)/Math.trunc(ko(n)))},isExported:!0},Jh={description:s("Modified internal rate of return."),args:[da("cashflow_amounts (range<number>)",s("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),da("financing_rate (number)",s("The interest rate paid on funds invested.")),da("reinvestment_return_rate (number)",s("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=ko(t),n=ko(i),r=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(it).map(ko);var a;const l=r.length;let c=0,h=0;for(const e of He(0,l)){const t=r[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(o+1)**e}Fo((()=>0!==h&&0!==c),s("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},ed={description:s("Annual nominal interest rate."),args:[da("effective_rate (number)",s("The effective interest rate per year.")),da("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=ko(e),o=Math.trunc(ko(t));return Fo((()=>i>0),s("The effective rate (%s) must must strictly greater than 0.",i.toString())),Fo((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),(Math.pow(i+1,1/o)-1)*o},isExported:!0},td={description:s("Number of payment periods for an investment."),args:[da("rate (number)",s("The interest rate.")),da("payment_amount (number)",s("The amount of each payment made.")),da("present_value (number)",s("The current value of the annuity.")),da("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=ko(e),r=ko(t),a=ko(i),l=ko(o),c=zo(n)?1:0;if(0===s)return-(l+a)/r;const h=r*(1+s*c)/s;return Math.log((h-l)/(a+h))/Math.log(1+s)},isExported:!0};const id={description:s("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[da("discount (number)",s("The discount rate of the investment over one period.")),da("cashflow1 (number, range<number>)",s("The first future cash flow.")),da("cashflow2 (number, range<number>, repeating)",s("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=ko(e);return Fo((()=>-1!==i),s("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let o=0;return Zo(i,((t,i)=>(o++,t+i/(1+e)**o)),t)}(i,0,t)},isExported:!0},od={description:s("Computes the number of periods needed for an investment to reach a value."),args:[da("rate (number)",s("The rate at which the investment grows each period.")),da("present_value (number)",s("The investment's current value.")),da("future_value (number)",s("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,i){const o=ko(e),n=ko(t),r=ko(i);return dh(o),Fo((()=>n>0),s("The present_value (%s) must be strictly positive.",n.toString())),Fo((()=>r>0),s("The future_value (%s) must be strictly positive.",r.toString())),(Math.log(r)-Math.log(n))/Math.log(1+o)},isExported:!0},nd={description:s("Periodic payment for an annuity investment."),args:[da("rate (number)",s("The annualized rate of interest.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("present_value (number)",s("The current value of the annuity.")),da("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=ko(t),r=ko(e),a=zo(n)?1:0;let l=ko(o),c=ko(i);if(hh(s),0===r)return-(l+c)/s;let h=-(c*(1+r)**s+l);return h=h*r/((1+r*a)*((1+r)**s-1)),h},isExported:!0},sd={description:s("Payment on the principal of an investment."),args:[da("rate (number)",s("The annualized rate of interest.")),da("period (number)",s("The amortization period, in terms of number of periods.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("present_value (number)",s("The current value of the annuity.")),da("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,r=0){n=n||0,r=r||0;const a=ko(i),l=ko(e),c=ko(t),h=zo(r)?1:0,d=ko(n),u=ko(o);hh(a),Fo((()=>c>0&&c<=a),s("The period must be between 1 and number_of_periods",a.toString()));const g=nd.compute(l,a,u,d,r);if(1===h&&1===c)return g;return g+-qh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},rd={description:s("Present value of an annuity investment."),args:[da("rate (number)",s("The interest rate.")),da("number_of_periods (number)",s("The number of payments to be made.")),da("payment_amount (number)",s("The amount per period to be paid.")),da("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=ko(e),r=ko(t),a=ko(i),l=ko(o),c=zo(n)?1:0;return s?-(a*(1+s*c)*((1+s)**r-1)/s+l)/(1+s)**r:-(l+a*r)},isExported:!0},ad={description:s("Price of a security paying periodic interest."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("rate (number)",s("The annualized rate of interest.")),da("yield (number)",s("The expected annual yield of the security.")),da("redemption (number)",s("The redemption amount per 100 face value, or par.")),da("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(ko(e)),c=Math.trunc(ko(t)),h=ko(i),d=ko(o),u=ko(n),g=Math.trunc(ko(r)),p=Math.trunc(ko(a));nh(l,c),rh(g),ah(p),Fo((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Fo((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString())),lh(u);const m=Zc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},ld={description:s("Price of a discount security."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("discount (number)",s("The discount rate of the security at time of purchase.")),da("redemption (number)",s("The redemption amount per 100 face value, or par.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(ko(e)),r=Math.trunc(ko(t)),a=ko(i),l=ko(o),c=Math.trunc(ko(n));nh(s,r),ah(c),Sh(a),lh(l);return l-a*l*Zc.compute(s,r,c)},isExported:!0},cd={description:s("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("issue (date)",s("The date the security was initially issued.")),da("rate (number)",s("The annualized rate of interest.")),da("yield (number)",s("The expected annual yield of the security.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(ko(e)),l=Math.trunc(ko(t)),c=Math.trunc(ko(i)),h=ko(o),d=ko(n),u=Math.trunc(ko(r));sh(a,c),nh(a,l),ah(u),Fo((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Fo((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString()));const g=Zc.compute(a,l,u),p=Zc.compute(a,c,u);return(100+Zc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},hd=.1,dd={description:s("Interest rate of an annuity investment."),args:[da("number_of_periods (number)",s("The number of payments to be made.")),da("payment_per_period (number)",s("The amount per period to be paid.")),da("present_value (number)",s("The current value of the annuity.")),da("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),da("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period.")),da("rate_guess (number, default=0.1)",s("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,o=0,n=0,r=.1){o=o||0,n=n||0,r=r||hd;const a=ko(e),l=ko(t),c=zo(n)?1:0,h=ko(r);let d=ko(o),u=ko(i);hh(a),Fo((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),s("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),xh(h),d-=l*c,u+=l*c;return Ah((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),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},ud={description:s("Amount received at maturity for a security."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("investment (number)",s("The amount invested (irrespective of face value of each security).")),da("discount (number)",s("The discount rate of the security invested in.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(ko(e)),r=Math.trunc(ko(t)),a=ko(i),l=ko(o),c=Math.trunc(ko(n));nh(s,r),ah(c),bh(a),Sh(l);return a/(1-l*Zc.compute(s,r,c))},isExported:!0},gd={description:s("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[da("number_of_periods (number)",s("The number of periods.")),da("present_value (number)",s("The present value of the investment.")),da("future_value (number)",s("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=ko(e),n=ko(t),s=ko(i);return hh(o),(s/n)**(1/o)-1},isExported:!0},pd={description:s("Depreciation of an asset using the straight-line method."),args:[da("cost (number)",s("The initial cost of the asset.")),da("salvage (number)",s("The value of the asset at the end of depreciation.")),da("life (number)",s("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(ko(e)-ko(t))/ko(i)},isExported:!0},md={description:s("Depreciation via sum of years digit method."),args:[da("cost (number)",s("The initial cost of the asset.")),da("salvage (number)",s("The value of the asset at the end of depreciation.")),da("life (number)",s("The number of periods over which the asset is depreciated.")),da("period (number)",s("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o){const n=ko(e),s=ko(t),r=ko(i),a=ko(o);ph(a),uh(r),vh(a,r);return(r-a+1)/(r*(r+1)/2)*(n-s)},isExported:!0},fd={description:s("Price of a US Treasury bill."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(ko(e)),n=Math.trunc(ko(t)),s=ko(i);nh(o,n),wh(o,n),Sh(s),Ch(s);return 100*(1-s*Zc.compute(o,n,2))},isExported:!0},vd={description:s("Equivalent rate of return for a US Treasury bill."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(ko(e)),n=Math.trunc(ko(t)),s=ko(i);nh(o,n),wh(o,n),Sh(s),Ch(s);const r=Rc.compute(n,o);if(r<=182)return 365*s/(360-s*r);const a=fd.compute(o,n,s)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},bd={description:s("The yield of a US Treasury bill based on price."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("price (number)",s("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(ko(e)),n=Math.trunc(ko(t)),s=ko(i);nh(o,n),wh(o,n),ch(s);return(100-s)/s*(1/Zc.compute(o,n,2))},isExported:!0},Sd={description:s("Variable declining balance. WARNING : does not handle decimal periods."),args:[da("cost (number)",s("The initial cost of the asset.")),da("salvage (number)",s("The value of the asset at the end of depreciation.")),da("life (number)",s("The number of periods over which the asset is depreciated.")),da("start (number)",s("Starting period to calculate depreciation.")),da("end (number)",s("Ending period to calculate depreciation.")),da("factor (number, default=2)",s("The number of months in the first year of depreciation.")),da("no_switch (number, default=false)",s("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=2,a=false){r=r||0;const l=ko(e),c=ko(t),h=ko(i),d=Math.trunc(ko(o)),u=Math.trunc(ko(n)),g=ko(r),p=zo(a);if(gh(l),mh(c),function(e,t,i){uh(i),Fo((()=>e>=0),s("The start_period (%s) must be greater or equal than 0.",e.toString())),Fo((()=>t>=0),s("The end_period (%s) must be greater or equal than 0.",t.toString())),Fo((()=>e<=t),s("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Fo((()=>t<=i),s("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),Eh(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},Cd={description:s("Internal rate of return given non-periodic cash flows."),args:[da("cashflow_amounts (range<number>)",s("An range containing the income or payments associated with the investment.")),da("cashflow_dates (range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts.")),da("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,i=.1){const o=ko(i=i||0),n=e.flat().map(ko),r=t.flat().map(ko);var a;Ih(e,t),a=n,Fo((()=>a.some((e=>e>0))&&a.some((e=>e<0))),s("There must be both positive and negative values in cashflow_amounts.")),Rh(r),xh(o);const l=new Map;for(const e of He(0,r.length)){const t=r[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Ah((e=>{let t=h[0];for(const i of He(1,h.length)){const o=(c[0]-c[i])/365;t+=h[i]*(1+e)**o}return t}),(e=>{let t=0;for(const i of He(1,h.length)){const o=(c[0]-c[i])/365;t+=o*h[i]*(1+e)**(o-1)}return t}),o,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Ed={description:s("Net present value given to non-periodic cash flows.."),args:[da("discount (number)",s("The discount rate of the investment over one period.")),da("cashflow_amounts (number, range<number>)",s("An range containing the income or payments associated with the investment.")),da("cashflow_dates (number, range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,i){const o=ko(e),n=Array.isArray(t)?t.flat().map(Lo):[Lo(t)],r=Array.isArray(i)?i.flat().map(Lo):[Lo(i)];if(Array.isArray(i)&&Array.isArray(t)?Ih(t,i):Fo((()=>n.length===r.length),s("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Rh(r),dh(o),1===n.length)return n[0];const a=new Map;for(const e of He(0,r.length)){const t=r[e];a.has(t)?a.set(t,a.get(t)+n[e]):a.set(t,n[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of He(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+o)**t}return h},isExported:!0},wd={description:s("Annual yield of a security paying periodic interest."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("rate (number)",s("The annualized rate of interest.")),da("price (number)",s("The price at which the security is bought per 100 face value.")),da("redemption (number)",s("The redemption amount per 100 face value, or par.")),da("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(ko(e)),c=Math.trunc(ko(t)),h=ko(i),d=ko(o),u=ko(n),g=Math.trunc(ko(r)),p=Math.trunc(ko(a));nh(l,c),rh(g),ah(p),Fo((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ch(d),lh(u);const m=Zc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=Ah((function(e){return function(e,t,i,o,n,s){let r=s-(e+n*(1-t))*o**(i-1+t);for(let e=1;e<=i;e++)r+=n*o**(e-1);return r}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,o,n){let s=-(e+n*(1-t))*(i-1+t)*o**(i-2+t);for(let e=1;e<=i;e++)s+=n*(e-1)*o**(e-2);return s}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},yd={description:s("Annual yield of a discount security."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("price (number)",s("The price at which the security is bought per 100 face value.")),da("redemption (number)",s("The redemption amount per 100 face value, or par.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(ko(e)),r=Math.trunc(ko(t)),a=ko(i),l=ko(o),c=Math.trunc(ko(n));nh(s,r),ah(c),ch(a),lh(l);return(l/a-1)/Zc.compute(e,t,n)},isExported:!0},xd={description:s("Annual yield of a security paying interest at maturity."),args:[da("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),da("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),da("issue (date)",s("The date the security was initially issued.")),da("rate (number)",s("The annualized rate of interest.")),da("price (number)",s("The price at which the security is bought.")),da("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(ko(e)),l=Math.trunc(ko(t)),c=Math.trunc(ko(i)),h=ko(o),d=ko(n),u=Math.trunc(ko(r));nh(a,l),ah(u),Fo((()=>a>=c),s("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Fo((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ch(d);const g=Zc.compute(c,l,u),p=Zc.compute(c,a,u),m=Zc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Id=Object.freeze({__proto__:null,ACCRINTM:Mh,AMORLINC:Oh,COUPDAYS:Nh,COUPDAYBS:_h,COUPDAYSNC:Fh,COUPNCD:Dh,COUPNUM:kh,COUPPCD:Lh,CUMIPMT:Ph,CUMPRINC:Uh,DB:Vh,DDB:zh,DISC:Bh,DOLLARDE:Hh,DOLLARFR:$h,DURATION:Wh,EFFECT:Gh,FV:qh,FVSCHEDULE:Zh,INTRATE:jh,IPMT:Xh,IRR:Yh,ISPMT:Kh,MDURATION:Qh,MIRR:Jh,NOMINAL:ed,NPER:td,NPV:id,PDURATION:od,PMT:nd,PPMT:sd,PV:rd,PRICE:ad,PRICEDISC:ld,PRICEMAT:cd,RATE:dd,RECEIVED:ud,RRI:gd,SLN:pd,SYD:md,TBILLPRICE:fd,TBILLEQ:vd,TBILLYIELD:bd,VDB:Sd,XIRR:Cd,XNPV:Ed,YIELD:wd,YIELDDISC:yd,YIELDMAT:xd});const Rd={description:s("Whether a value is an error other than #N/A."),args:[da("value (any, lazy)",s("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},Td={description:s("Whether a value is an error."),args:[da("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},Ad={description:s("Whether a value is `true` or `false`."),args:[da("value (any, lazy)",s("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},Md={description:s("Whether a value is the error #N/A."),args:[da("value (any, lazy)",s("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:s("Whether a value is non-textual."),args:[da("value (any, lazy)",s("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},Nd={description:s("Whether a value is a number."),args:[da("value (any, lazy)",s("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},_d={description:s("Whether a value is text."),args:[da("value (any, lazy)",s("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Fd={description:s("Whether the referenced cell is empty"),args:[da("value (any, lazy)",s("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},Dd={description:s("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var kd=Object.freeze({__proto__:null,ISERR:Rd,ISERROR:Td,ISLOGICAL:Ad,ISNA:Md,ISNONTEXT:Od,ISNUMBER:Nd,ISTEXT:_d,ISBLANK:Fd,NA:Dd});const Ld={description:s("Logical `and` operator."),args:[da("logical_expression1 (boolean, range<boolean>)",s("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.")),da("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return Xo(e,(e=>(t=!0,i=i&&e,i))),Fo((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Pd={description:s("Returns value depending on logical expression."),args:[da("logical_expression (boolean)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),da("value_if_true (any, lazy)",s("The value the function returns if logical_expression is TRUE.")),da("value_if_false (any, lazy, default=FALSE)",s("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,i=(()=>!1)){const o=zo(e)?t():i();return null==o?"":o},isExported:!0},Ud={description:s("Value if it is not an error, otherwise 2nd argument."),args:[da("value (any, lazy)",s("The value to return if value itself is not an error.")),da('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an error."))],returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},Vd={description:s("Value if it is not an #N/A error, otherwise 2nd argument."),args:[da("value (any, lazy)",s("The value to return if value itself is not #N/A an error.")),da('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(o){i=o.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},zd={description:s("Returns a value depending on multiple logical expressions."),args:[da("condition1 (boolean, lazy)",s("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),da("value1 (any, lazy)",s("The returned value if condition1 is TRUE.")),da("condition2 (boolean, lazy, repeating)",s("Additional conditions to be evaluated if the previous ones are FALSE.")),da("value2 (any, lazy, repeating)",s("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){Fo((()=>e.length%2==0),s("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(zo(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(s("No match."))},isExported:!0},Bd={description:s("Returns opposite of provided logical value."),args:[da("logical_expression (boolean)",s("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!zo(e)},isExported:!0},Hd={description:s("Logical `or` operator."),args:[da("logical_expression1 (boolean, range<boolean>)",s("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.")),da("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Xo(e,(e=>(t=!0,i=i||e,!i))),Fo((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},$d={description:s("Logical `xor` operator."),args:[da("logical_expression1 (boolean, range<boolean>)",s("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.")),da("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Xo(e,(e=>(t=!0,i=i?!e:e,!0))),Fo((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Wd=Object.freeze({__proto__:null,AND:Ld,IF:Pd,IFERROR:Ud,IFNA:Vd,IFS:zd,NOT:Bd,OR:Hd,XOR:$d});function Gd(e,t){if(void 0===e)throw new g(s("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Po(t)))}const qd={description:s("Column number of a specified cell."),args:[da("cell_reference (meta, default='this cell')",s("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Fo((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Vi(i).left+1},isExported:!0},Zd={description:s("Number of columns in a specified array or range."),args:[da("range (meta)",s("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Vi(e);return t.right-t.left+1},isExported:!0},jd={description:s("Horizontal lookup"),args:[da("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),da("range (range)",s("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),da("index (number)",s("The row index of the value to be returned, where the first row in range is numbered 1.")),da("is_sorted (boolean, default=true)",s("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(ko(i)),r=Uo(e);Fo((()=>1<=n&&n<=t[0].length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=zo(o)?tn(t,r,"nextSmaller","asc",t.length,en):on(t,r,"strict",t.length,en);const l=t[a];return Gd(l,e),l[n-1]},isExported:!0},Xd={description:s("Look up a value."),args:[da("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),da("search_array (range)",s("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.")),da("result_range (range, optional)",s("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],returns:["ANY"],compute:function(e,t,i){let o=t.length,n=t[0].length;const r=Uo(e),a=n>=o,l=tn(t,r,"nextSmaller","asc",a?n:o,a?Jo:en);return-1===l&&Gd(void 0,e),Gd(a?t[0][l]:t[l][n-1],e),void 0===i?a?t[o-1][l]:t[l][n-1]:(o=i.length,n=i[0].length,Fo((()=>1===o||1===n),s("The result_range must be a single row or a single column.")),o>1?(Fo((()=>l<=o-1),s("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Fo((()=>l<=n-1),s("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Yd={description:s("Position of item in range that matches value."),args:[da("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),da("range (any, range)",s("The one-dimensional array to be searched.")),da("search_type (number, default=1)",s("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,i=1){let o=ko(i);const n=Uo(e),r=t.length,a=t[0].length;Fo((()=>1===r||1===a),s("The range must be a single row or a single column."));let l=-1;const c=1===r?Jo:en,h=1===r?t[0].length:t.length;switch(o=Math.sign(o),o){case 1:l=tn(t,n,"nextSmaller","asc",h,c);break;case 0:l=on(t,n,"strict",h,c);break;case-1:l=tn(t,n,"nextGreater","desc",h,c)}return Gd(1===r?t[0][l]:t[l],e),l+1},isExported:!0},Kd={description:s("Row number of a specified cell."),args:[da("cell_reference (meta, default='this cell')",s("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),Fo((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Vi(e).top+1},isExported:!0},Qd={description:s("Number of rows in a specified array or range."),args:[da("range (meta)",s("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Vi(e);return t.bottom-t.top+1},isExported:!0},Jd={description:s("Vertical lookup."),args:[da("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),da("range (any, range)",s("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),da("index (number)",s("The column index of the value to be returned, where the first column in range is numbered 1.")),da("is_sorted (boolean, default=true)",s("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(ko(i)),r=Uo(e);Fo((()=>1<=n&&n<=t.length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=zo(o)?tn(t,r,"nextSmaller","asc",t[0].length,Jo):on(t,r,"strict",t[0].length,Jo);const l=t[n-1][a];return Gd(l,e),l},isExported:!0},eu={description:s("Search a range for a match and return the corresponding item from a second range."),args:[da("search_key (any)",s("The value to search for.")),da("lookup_range (any, range)",s("The range to consider for the search. Should be a single column or a single row.")),da("return_range (any, range)",s("The range containing the return value. Should have the same dimensions as lookup_range.")),da("if_not_found (any, lazy, optional)",s("If a valid match is not found, return this value.")),da("match_mode (any, default=0)",s("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),da("search_mode (any, default=1)",s("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,i,o,n=0,r=1){const a=Math.trunc(ko(n)),l=Math.trunc(ko(r)),c=Uo(e);Fo((()=>1===t.length||1===t[0].length),s("lookup_range should be either a single row or single column.")),Fo((()=>1===i.length||1===i[0].length),s("return_range should be either a single row or single column.")),Fo((()=>i.length===t.length&&i[0].length===t[0].length),s("return_range should have the same dimensions as lookup_range.")),Fo((()=>[-1,1,-2,2].includes(l)),s("searchMode should be a value in [-1, 1, -2, 2].")),Fo((()=>[-1,0,1].includes(a)),s("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?Jo:en,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=tn(t,c,u,2===l?"asc":"desc",d,h)}else p=on(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==o?void 0:o();return Gd(m,e),m},isExported:!0};var tu=Object.freeze({__proto__:null,COLUMN:qd,COLUMNS:Zd,HLOOKUP:jd,LOOKUP:Xd,MATCH:Yd,ROW:Kd,ROWS:Qd,VLOOKUP:Jd,XLOOKUP:eu});const iu={description:s("Sum of two numbers."),args:[da("value1 (number)",s("The first addend.")),da("value2 (number)",s("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return ko(e)+ko(t)}},ou={description:s("Concatenation of two values."),args:[da("value1 (string)",s("The value to which value2 will be appended.")),da("value2 (string)",s("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return Po(e)+Po(t)},isExported:!0},nu={description:s("One number divided by another."),args:[da("dividend (number)",s("The number to be divided.")),da("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=ko(t);return Fo((()=>0!==i),s("The divisor must be different from zero.")),ko(e)/i}};function su(e){return null==e}const ru={number:0,string:"",boolean:!1},au={description:s("Equal."),args:[da("value1 (any)",s("The first value.")),da("value2 (any)",s("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=su(e)?ru[typeof t]:e,t=su(t)?ru[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function lu(e,t,i){e=su(e)?ru[typeof t]:e,t=su(t)?ru[typeof e]:t,"number"!=typeof e&&(e=Po(e).toUpperCase()),"number"!=typeof t&&(t=Po(t).toUpperCase());const o=typeof e,n=typeof t;return"string"===o&&"number"===n||("string"!==n||"number"!==o)&&i(e,t)}const cu={description:s("Strictly greater than."),args:[da("value1 (any)",s("The value to test as being greater than value2.")),da("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return lu(e,t,((e,t)=>e>t))}},hu={description:s("Greater than or equal to."),args:[da("value1 (any)",s("The value to test as being greater than or equal to value2.")),da("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return lu(e,t,((e,t)=>e>=t))}},du={description:s("Less than."),args:[da("value1 (any)",s("The value to test as being less than value2.")),da("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!hu.compute(e,t)}},uu={description:s("Less than or equal to."),args:[da("value1 (any)",s("The value to test as being less than or equal to value2.")),da("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!cu.compute(e,t)}},gu={description:s("Difference of two numbers."),args:[da("value1 (number)",s("The minuend, or number to be subtracted from.")),da("value2 (number)",s("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return ko(e)-ko(t)}},pu={description:s("Product of two numbers"),args:[da("factor1 (number)",s("The first multiplicand.")),da("factor2 (number)",s("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return ko(e)*ko(t)}},mu={description:s("Not equal."),args:[da("value1 (any)",s("The first value.")),da("value2 (any)",s("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!au.compute(e,t)}},fu={description:s("A number raised to a power."),args:[da("base (number)",s("The number to raise to the exponent power.")),da("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return Ja.compute(e,t)}},vu={description:s("A number with the sign reversed."),args:[da("value (number)",s("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-ko(e)}},bu={description:s("Value interpreted as a percentage."),args:[da("percentage (number)",s("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return ko(e)/100}},Su={description:s("A specified number, unchanged."),args:[da("value (any)",s("The number to return."))],returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var Cu=Object.freeze({__proto__:null,ADD:iu,CONCAT:ou,DIVIDE:nu,EQ:au,GT:cu,GTE:hu,LT:du,LTE:uu,MINUS:gu,MULTIPLY:pu,NE:mu,POW:fu,UMINUS:vu,UNARY_PERCENT:bu,UPLUS:Su});const Eu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,wu={description:s("Gets character associated with number."),args:[da("table_number (number)",s("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(ko(e));return Fo((()=>t>=1),s("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},yu={description:s("Remove non-printable characters from a piece of text."),args:[da("text (string)",s("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=Po(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},xu={description:s("Appends strings to one another."),args:[da("string1 (string, range<string>)",s("The initial string.")),da("string2 (string, range<string>, repeating)",s("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return qo(e,((e,t)=>e+Po(t)),"")},isExported:!0},Iu={description:s("Tests whether two strings are identical."),args:[da("string1 (string)",s("The first string to compare.")),da("string2 (string)",s("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return Po(e)===Po(t)},isExported:!0},Ru={description:s("First position of string found in text, case-sensitive."),args:[da("search_for (string)",s("The string to look for within text_to_search.")),da("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),da("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Po(e),n=Po(t),r=ko(i);Fo((()=>""!==n),s("The text_to_search must be non-empty.")),Fo((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return Fo((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o.toString(),n)),a+1},isExported:!0},Tu={description:s("Concatenates elements of arrays with delimiter."),args:[da("delimiter (string)",s("The character or string to place between each concatenated value.")),da("value_or_array1 (string, range<string>)",s("The value or values to be appended using delimiter.")),da("value_or_array2 (string, range<string>, repeating)",s("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const i=Po(e);return qo(t,((e,t)=>(e?e+i:"")+Po(t)),"")}},Au={description:s("Substring from beginning of specified string."),args:[da("text (string)",s("The string from which the left portion will be returned.")),da("number_of_characters (number, optional)",s("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?ko(t[0]):1;return Fo((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString())),Po(e).substring(0,i)},isExported:!0},Mu={description:s("Length of a string."),args:[da("text (string)",s("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return Po(e).length},isExported:!0},Ou={description:s("Converts a specified string to lowercase."),args:[da("text (string)",s("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return Po(e).toLowerCase()},isExported:!0},Nu={description:s("A segment of a string."),args:[da("text (string)",s("The string to extract a segment from.")),da(" (number)",s("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),da(" (number)",s("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,i){const o=Po(e),n=ko(t),r=ko(i);return Fo((()=>n>=1),s("The starting_at argument (%s) must be positive greater than one.",n.toString())),Fo((()=>r>=0),s("The extract_length argument (%s) must be positive or null.",r.toString())),o.slice(n-1,n+r-1)},isExported:!0},_u={description:s("Capitalizes each word in a specified string."),args:[da("text_to_capitalize (string)",s("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return Po(e).replace(Eu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Fu={description:s("Replaces part of a text string with different text."),args:[da("text (string)",s("The text, a part of which will be replaced.")),da("position (number)",s("The position where the replacement will begin (starting from 1).")),da("length (number)",s("The number of characters in the text to be replaced.")),da("new_text (string)",s("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,i,o){const n=ko(t);Fo((()=>n>=1),s("The position (%s) must be greater than or equal to 1.",n.toString()));const r=Po(e),a=ko(i),l=Po(o);return r.substring(0,n-1)+l+r.substring(n-1+a)},isExported:!0},Du={description:s("A substring from the end of a specified string."),args:[da("text (string)",s("The string from which the right portion will be returned.")),da("number_of_characters (number, optional)",s("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?ko(t[0]):1;Fo((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString()));const o=Po(e),n=o.length;return o.substring(n-i,n)},isExported:!0},ku={description:s("First position of string found in text, ignoring case."),args:[da("search_for (string)",s("The string to look for within text_to_search.")),da("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),da("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Po(e).toLowerCase(),n=Po(t).toLowerCase(),r=ko(i);Fo((()=>""!==n),s("The text_to_search must be non-empty.")),Fo((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return Fo((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o,n)),a+1},isExported:!0},Lu={description:s("Replaces existing text with new text in a string."),args:[da("text_to_search (string)",s("The text within which to search and replace.")),da("search_for (string)",s("The string to search for within text_to_search.")),da("replace_with (string)",s("The string that will replace search_for.")),da("occurrence_number (number, optional)",s("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=ko(o);Fo((()=>n>=0),s("The occurrenceNumber (%s) must be positive or null.",n.toString()));const r=Po(e),a=Po(t);if(""===a)return r;const l=Po(i),c=new RegExp(Ne(a),"g");if(0===n)return r.replace(c,l);let h=0;return r.replace(c,(e=>++h===n?l:e))},isExported:!0},Pu={description:s("Combines text from multiple strings and/or arrays."),args:[da("delimiter (string)",s(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),da("ignore_empty (boolean)",s("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),da("text1 (string, range<string>)",s("Any text item. This could be a string, or an array of strings in a range.")),da("text2 (string, range<string>, repeating)",s("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...i){const o=Po(e),n=zo(t);let s=0;return qo(i,((e,t)=>n&&""===Po(t)?e:(s++?e+o:"")+Po(t)),"")},isExported:!0},Uu={description:s("Removes space characters."),args:[da("text (string)",s("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Po(e).trim()},isExported:!0},Vu={description:s("Converts a specified string to uppercase."),args:[da("text (string)",s("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return Po(e).toUpperCase()},isExported:!0},zu={description:s("Converts a number to text according to a specified format."),args:[da("number (number)",s("The number, date or time to format.")),da("format (string)",s("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return gi(ko(e),Po(t))},isExported:!0};var Bu=Object.freeze({__proto__:null,CHAR:wu,CLEAN:yu,CONCATENATE:xu,EXACT:Iu,FIND:Ru,JOIN:Tu,LEFT:Au,LEN:Mu,LOWER:Ou,MID:Nu,PROPER:_u,REPLACE:Fu,RIGHT:Du,SEARCH:ku,SUBSTITUTE:Lu,TEXTJOIN:Pu,TRIM:Uu,UPPER:Vu,TEXT:zu});const Hu={description:s("Creates a hyperlink in a cell."),args:[da("url (string)",s("The full URL of the link enclosed in quotation marks.")),da("link_label (string, optional)",s("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const i=Po(e).trim(),o=Po(t)||i;return""===i?o:Ye(o,i)},isExported:!0};var $u=Object.freeze({__proto__:null,HYPERLINK:Hu});const Wu=[{name:s("Database"),functions:wc},{name:s("Date"),functions:th},{name:s("Financial"),functions:Id},{name:s("Info"),functions:kd},{name:s("Lookup"),functions:tu},{name:s("Logical"),functions:Wd},{name:s("Math"),functions:vl},{name:s("Misc"),functions:pa},{name:s("Operator"),functions:Cu},{name:s("Statistical"),functions:ac},{name:s("Text"),functions:Bu},{name:s("Engineering"),functions:oh},{name:s("Web"),functions:$u}],Gu=/^[A-Z0-9\_\.]+$/;function qu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Zu(e()):Zu(e)}))}function Zu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const ju=new class extends yo{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Gu))throw new Error(s("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=ua(t);return function(e){let t=!1,i=!1,o=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(s("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&&!n.repeating)throw new Error(s("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||o,r=!(n.optional||n.repeating||n.default);if(e&&r)throw new Error(s("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,i=n.optional,o=n.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),o=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...qu(e)),format:o(...e)}},super.add(e,i),this}};for(let e of Wu){const t=e.functions;for(let i in t){const o=t[i];o.category=o.category||e.name,i=i.replace(/_/g,"."),ju.add(i,{isExported:!1,...o})}}function Xu(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(65)&&e.raiseError(Os)}const Yu=new ts;Yu.add("file",{name:s("File"),sequence:10}).add("edit",{name:s("Edit"),sequence:20}).add("view",{name:s("View"),sequence:30}).add("insert",{name:s("Insert"),sequence:40}).add("format",{name:s("Format"),sequence:50}).add("data",{name:s("Data"),sequence:60}).addChild("save",["file"],{name:s("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:s("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:s("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:s("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:Dr}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:kr}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:Lr}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:zr}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:Pr}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:Vr}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:sa,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:oa}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:na}).addChild("find_and_replace",["edit"],{name:s("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:s("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:Br,sequence:80,action:Hr,isVisible:e=>$r("ROW",e)}).addChild("edit_delete_column",["edit"],{name:Wr,sequence:90,action:Gr,isVisible:e=>$r("COL",e)}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:jr}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:Xr}).addChild("edit_unhide_columns",["edit"],{name:s("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:s("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=Nr(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:Yr,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Nr(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:Kr,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Or(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:Qr,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Or(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:Jr,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:s("Insert cells and shift down"),sequence:43,action:qr}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:Zr,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=e.model.uuidGenerator.uuidv4(),o=t.getActiveSheetId();1===lo(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:i+n+Math.max(0,(r-t.width)/2),y:o+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:o,id:i,position:s,size:n,definition:Cr(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4(),o=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(s("An unexpected error occurred during the image transfer"))}}(e);if(!o)throw new Error("No image provider was given to the environment");const n=ur(e.model.getters,o.size),r=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-i),c=Math.min(a.height,r.height-o);return{x:i+n+Math.max(0,(l-t.width)/2),y:o+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:i,position:r,size:n,definition:o})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_function",["insert"],{name:s("Function"),sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{name:s("SUM"),action:e=>e.startCellEdition("=SUM("),sequence:0}).addChild("insert_function_average",["insert","insert_function"],{name:s("AVERAGE"),action:e=>e.startCellEdition("=AVERAGE("),sequence:10}).addChild("insert_function_count",["insert","insert_function"],{name:s("COUNT"),action:e=>e.startCellEdition("=COUNT("),sequence:20}).addChild("insert_function_max",["insert","insert_function"],{name:s("MAX"),action:e=>e.startCellEdition("=MAX("),sequence:30}).addChild("insert_function_min",["insert","insert_function"],{name:s("MIN"),action:e=>e.startCellEdition("=MIN("),sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{name:s("All"),sequence:50}).addChild("all_function_list",["insert","insert_function","categorie_function_all"],(()=>Ku(ju.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=ju.content;return[...new Set(ju.getAll().map((e=>e.category)))].filter(it).sort().map(((t,i)=>{const o=Object.keys(e).filter((i=>e[i].category===t));return{name:t,sequence:60+10*i,children:Ku(o)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:ta}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:s("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:s("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:s("1 row"),action:e=>Xu(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>Xu(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:s("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Xu(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:s("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:s("1 column"),action:e=>Xu(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>Xu(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:s("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();Xu(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?s("Hide gridlines"):s("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()?s("Hide formulas"):s("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:s("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:As.Automatic,sequence:10,separator:!0,action:e=>_r(e,"")}).addChild("format_number_number",["format","format_number"],{name:As.Number,description:"1,000.12",sequence:20,action:e=>_r(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:As.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>_r(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:As.Currency,description:"$1,000.12",sequence:37,action:e=>_r(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:As.CurrencyRounded,description:"$1,000",sequence:38,action:e=>_r(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:As.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:As.Date,description:"9/26/2008",sequence:40,action:e=>_r(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:As.Time,description:"10:43:00 PM",sequence:50,action:e=>_r(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:As.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>_r(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:As.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>_r(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>Fr(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>Fr(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>Fr(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>Fr(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:s("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:s("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>Fr(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>Fr(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>Fr(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>Fr(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>Fr(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>Fr(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:s("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:s("Overflow"),sequence:10,action:e=>Fr(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>Fr(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>Fr(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:ea,separator:!0}).addChild("format_clearFormat",["format"],{name:s("Clear formatting"),sequence:100,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:s("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;Ir(e,t,i)},isVisible:e=>!ia(e),isEnabled:e=>(e=>co(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:s("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:ia});for(let e of de)Yu.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>Fr(t,{fontSize:e})});function Ku(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const Qu=new class extends yo{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Ju={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function eg(e,t){const i=Ju[e.key];e.shiftKey?t.resizeAnchorZone(i,e.ctrlKey?"end":1):t.moveAnchorCell(i,e.ctrlKey?"end":1)}const tg=new Pi;po`
350
+ `;class dr extends t.Component{get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=cr.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}dr.template="o-spreadsheet-ChartFigure",dr.components={},dr.props={figure:Object,onFigureDeleted:Function};class ur extends t.Component{get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function gr(e,t){const i=Fe(t),o=e.getSheetViewDimension(),n=o.width,s=o.height;if(i.width>n){const e=n/i.width;i.width=n,i.height=i.height*e}if(i.height>s){const e=s/i.height;i.height=s,i.width=i.width*e}return i}ur.template="o-spreadsheet-ImageFigure",ur.components={},ur.props={figure:Object,onFigureDeleted:Function};const pr=new xo;function mr(e,t){return{id:"copy",name:s("Copy"),sequence:2,description:"Ctrl+C",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function fr(e,t){return{id:"cut",name:s("Cut"),sequence:3,description:"Ctrl+X",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function vr(e,t,i){return{id:"delete",name:s("Delete"),sequence:10,action:()=>{i.model.dispatch("DELETE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e}),t()}}}pr.add("chart",{Component:dr,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,i){return Jn([{id:"edit",name:s("Edit"),sequence:1,action:()=>{i.model.dispatch("SELECT_FIGURE",{id:e}),i.openSidePanel("ChartPanel")}},mr(e,i),fr(e,i),vr(e,t,i)])}}),pr.add("image",{Component:ur,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,i){return Jn([mr(e,i),fr(e,i),{id:"reset_size",name:s("Reset size"),sequence:4,action:()=>{const t=i.model.getters.getImageSize(e),{height:o,width:n}=gr(i.model.getters,t);i.model.dispatch("UPDATE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e,height:o,width:n})}},vr(e,t,i)])}});const br=(new xo).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of We(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}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 dn.values())br.contains(e)||br.add(e,Sr);function Sr(e){return[e]}function Cr(e,t){const i=lr.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function Er(e,t){var i;let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[Hi(o)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===co(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(i=a.style)||void 0===i?void 0:i.fillColor)||void 0,keyValue:Hi(e),baselineMode:te,baselineColorUp:ie,baselineColorDown:oe};let l="";const c=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),h=!!c.find((e=>e.type!==rn.empty&&e.type!==rn.number));if(h){const e=c.filter((e=>e.type!==rn.error&&e.type!==rn.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=Hi({...e,right:e.left,top:h?e.top+1:e.top}));const u=o.right===o.left?"none":"top";return Js(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:s,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}const wr=[rn.number,rn.error,rn.text,rn.boolean];function yr(e,t,i,o,n){let r=gn.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let s=o.left;s<=o.right;s++){let o=e.model.getters.getMerge({sheetId:t,col:s,row:n});o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);Xi(i,o)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(s("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?"),(()=>{o=i,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function xr(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}const Ir={filterOverlap:s("You cannot create overlapping filters."),nonContinuousTargets:s("A filter can only be created on a continuous selection."),mergeInFilter:s("You can't create a filter over a range that contains a merge.")};function Rr(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(78)?e.raiseError(Ir.filterOverlap):o.isCancelledBecause(80)?e.raiseError(Ir.mergeInFilter):o.isCancelledBecause(81)&&e.raiseError(Ir.nonContinuousTargets)}const Tr={wrongPasteSelection:s("This operation is not allowed with multiple selections."),willRemoveExistingMerge:s("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:s("Cannot do a special paste of a figure."),frozenPaneOverlap:s("Cannot paste merged cells over a frozen pane.")};function Ar(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Tr.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Tr.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Tr.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(Tr.frozenPaneOverlap))}function Mr(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Ar(e,o)}function Or(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Ar(e,o)}function Nr(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 _r(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 Fr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Dr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const kr=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},Lr=async e=>{xr(e),await e.clipboard.write(e.model.getters.getClipboardContent())},Pr=async e=>Vr(e),Ur=async e=>Vr(e,"onlyValue");async function Vr(e,t){const i=e.model.getters.getClipboardTextContent(),o=await e.clipboard.readText();switch(o.status){case"ok":const n=e.model.getters.getSelectedZones();o&&o.content!==i?Or(e,n,o.content):Mr(e,n,t);break;case"notImplemented":e.raiseError(s("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(s("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const zr=e=>Mr(e,e.model.getters.getSelectedZones(),"onlyFormat"),Br=e=>!e.model.getters.isCutOperation(),Hr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},$r=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Wr=(e,t)=>{const i=t.model.getters.getActiveSheetId(),o=t.model.getters.getElementsFromSelection(e),n=t.model.getters.checkElementsIncludeAllVisibleHeaders(i,e,o),s=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(i,e,o);return!n&&!s},Gr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Delete column %s",Ht(t)):s("Delete columns %s - %s",Ht(t),Ht(i))},qr=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},Zr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Ar(e,i)},jr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Ar(e,i)},Xr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Ar(e,i)},Yr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Ar(e,i)},Kr=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},Qr=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},Jr=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},ea=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})};const ta=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},ia=e=>{let{col:t,row:i}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},oa=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},na=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();yr(e,o,t.cell,i[0],"ascending")},sa=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();yr(e,o,t.cell,i[0],"descending")},ra=e=>1===e.model.getters.getSelectedZones().length,aa=new is;aa.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Lr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:kr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Pr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Br}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:Ur}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:zr}).add("add_row_before",{name:e=>{const t=_r(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:Kr,isVisible:ra}).add("add_column_before",{name:e=>{const t=Nr(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:Jr,isVisible:ra}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:ra,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:Zr}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:jr}).add("delete_row",{name:Hr,sequence:110,action:$r,isVisible:ra}).add("delete_column",{name:Gr,sequence:120,action:qr,isVisible:ra}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:ra}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:Xr}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:Yr}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:ia});const la=new is;la.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Lr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:kr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Pr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Br}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Ur}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:zr}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:ra,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:na}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:sa}).add("add_column_before",{name:e=>{const t=Nr(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:Jr}).add("add_column_after",{name:e=>{const t=Nr(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:ea}).add("delete_column",{name:Gr,sequence:90,action:qr,isVisible:e=>Wr("COL",e)}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Clear column %s",Ht(t)):s("Clear columns %s - %s",Ht(t),Ht(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide column %s",Ht(i).toString()):o-i+1===t.length?s("Hide columns %s - %s",Ht(i).toString(),Ht(o).toString()):s("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(),i=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",i)},separator:!0}).add("unhide_columns",{name:s("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:s("Conditional formatting"),sequence:110,action:ta});const ca=new is;ca.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:Lr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:kr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Pr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Br}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Ur}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:zr}).add("add_row_before",{name:e=>{const t=_r(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:Kr}).add("add_row_after",{name:e=>{const t=_r(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:Qr}).add("delete_row",{name:Hr,sequence:70,action:$r,isVisible:e=>Wr("ROW",e)}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide row %s",(i+1).toString()):o-i+1===t.length?s("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):s("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(),i=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",i)},separator:!0}).add("unhide_rows",{name:s("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:s("Conditional formatting"),sequence:90,action:ta});const ha=/(.*?)\((.*?)\)(.*)/,da=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function ua(e,t=""){return function(e){let t,i=e.match(ha),o=i[1].trim(),n=[],s=!1,r=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let o=da.find((e=>i===e));o?n.push(o):"RANGE<ANY>"===i?n.push("RANGE"):"OPTIONAL"===i?s=!0:"REPEATING"===i?r=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}let l=i[3].trim();const c={name:o,description:l,type:n};s&&(c.optional=!0);r&&(c.repeating=!0);a&&(c.lazy=!0);void 0!==t&&(c.default=!0,c.defaultValue=t);return c}(`${e} ${t}`)}function ga(e){let t=0,i=0,o=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||i++,n.repeating&&o++;const n=e;return n.minArgRequired=i,n.maxArgPossible=o?1/0:t,n.nbrArgRepeating=o,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,o),n.hidden=e.hidden||!1,n}const pa={description:s("Apply a large number format"),args:[ua("value (number)",s("The number.")),ua("unit (string, optional)",s("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Lo(e.value)),o=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return Ri(o,1e3,"k");case"m":return Ri(o,1e6,"m");case"b":return Ri(o,1e9,"b");default:throw new Error(s("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?Ri(o,0,""):i<1e8?Ri(o,1e3,"k"):i<1e11?Ri(o,1e6,"m"):Ri(o,1e9,"b")},compute:function(e){return Lo(e)}};var ma=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:pa});const fa={description:s("Absolute value of a number."),args:[ua("value (number)",s("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Lo(e))},isExported:!0},va={description:s("Inverse cosine of a value, in radians."),args:[ua("value (number)",s("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},ba={description:s("Inverse hyperbolic cosine of a number."),args:[ua("value (number)",s("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>t>=1),s("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},Sa={description:s("Inverse cotangent of a value."),args:[ua("value (number)",s("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Ca={description:s("Inverse hyperbolic cotangent of a value."),args:[ua("value (number)",s("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>Math.abs(t)>1),s("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Ea={description:s("Inverse sine of a value, in radians."),args:[ua("value (number)",s("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},wa={description:s("Inverse hyperbolic sine of a number."),args:[ua("value (number)",s("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Lo(e))},isExported:!0},ya={description:s("Inverse tangent of a value, in radians."),args:[ua("value (number)",s("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Lo(e))},isExported:!0},xa={description:s("Angle from the X axis to a point (x,y), in radians."),args:[ua("x (number)",s("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),ua("y (number)",s("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const i=Lo(e),o=Lo(t);return Do((()=>0!==i||0!==o),s("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(o,i)},isExported:!0},Ia={description:s("Inverse hyperbolic tangent of a number."),args:[ua("value (number)",s("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>Math.abs(t)<1),s("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ra={description:s("Rounds number up to nearest multiple of factor."),args:[ua("value (number)",s("The value to round up to the nearest integer multiple of factor.")),ua("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Lo(e),o=Lo(t);return Do((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.ceil(i/o)*o:0},isExported:!0},Ta={description:s("Rounds number up to nearest multiple of factor."),args:[ua("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ua("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ua("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Lo(t);if(0===o)return 0;const n=Lo(e);if(o=Math.abs(o),n>=0)return Math.ceil(n/o)*o;return 0===Lo(i)?-Math.floor(Math.abs(n)/o)*o:-Math.ceil(Math.abs(n)/o)*o},isExported:!0},Aa={description:s("Rounds number up to nearest multiple of factor."),args:[ua("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ua("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return Ta.compute(e,t,0)},isExported:!0},Ma={description:s("Cosine of an angle provided in radians."),args:[ua("angle (number)",s("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Lo(e))},isExported:!0},Oa={description:s("Hyperbolic cosine of any real number."),args:[ua("value (number)",s("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Lo(e))},isExported:!0},Na={description:s("Cotangent of an angle provided in radians."),args:[ua("angle (number)",s("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},_a={description:s("Hyperbolic cotangent of any real number."),args:[ua("value (number)",s("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Fa={description:s("Number of empty values."),args:[ua("value1 (any, range)",s("The first value or range in which to count the number of blanks.")),ua("value2 (any, range, repeating)",s("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Zo(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Da={description:s("A conditional count across a range."),args:[ua("range (range)",s("The range that is tested against criterion.")),ua("criterion (string)",s("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return Jo(e,((e,i)=>{t+=1})),t},isExported:!0},ka={description:s("Count values depending on multiple criteria."),args:[ua("criteria_range1 (range)",s("The range to check against criterion1.")),ua("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ua("criteria_range2 (any, range, repeating)",s("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.")),ua("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return Jo(e,((e,i)=>{t+=1})),t},isExported:!0};function La(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Pa={description:s("Counts number of unique values in a range."),args:[ua("value1 (any, range)",s("The first value or range to consider for uniqueness.")),ua("value2 (any, range, repeating)",s("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Zo(e,((e,t)=>La(t)?e.add(t):e),new Set).size}},Ua={description:s("Counts number of unique values in a range, filtered by a set of criteria."),args:[ua("range (range)",s("The range of cells from which the number of unique values will be counted.")),ua("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ua("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ua("criteria_range2 (any, range, repeating)",s("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.")),ua("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=new Set;return Jo(t,((t,o)=>{const n=e[t][o];La(n)&&i.add(n)})),i.size}},Va={description:s("Cosecant of an angle provided in radians."),args:[ua("angle (number)",s("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},za={description:s("Hyperbolic cosecant of any real number."),args:[ua("value (number)",s("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Ba={description:s("Converts from another base to decimal."),args:[ua("value (string)",s("The number to convert.")),ua(",base (number)",s("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let i=Lo(t);i=Math.floor(i),Do((()=>2<=i&&i<=36),s("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const o=Uo(e);if(""===o)return 0;Do((()=>!!o.match(/^-?[a-z0-9]+$/i)),s("The value (%s) must be a valid base %s representation.",o,i.toString()));const n=parseInt(o,i);return Do((()=>!isNaN(n)),s("The value (%s) must be a valid base %s representation.",o,i.toString())),n},isExported:!0},Ha={description:s("Converts an angle value in radians to degrees."),args:[ua("angle (number)",s("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Lo(e)/Math.PI},isExported:!0},$a={description:s("Euler's number, e (~2.718) raised to a power."),args:[ua("value (number)",s("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Lo(e))},isExported:!0},Wa={description:s("Rounds number down to nearest multiple of factor."),args:[ua("value (number)",s("The value to round down to the nearest integer multiple of factor.")),ua("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Lo(e),o=Lo(t);return Do((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.floor(i/o)*o:0},isExported:!0},Ga={description:s("Rounds number down to nearest multiple of factor."),args:[ua("number (number)",s("The value to round down to the nearest integer multiple of significance.")),ua("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ua("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Lo(t);if(0===o)return 0;const n=Lo(e);if(o=Math.abs(o),n>=0)return Math.floor(n/o)*o;return 0===Lo(i)?-Math.ceil(Math.abs(n)/o)*o:-Math.floor(Math.abs(n)/o)*o},isExported:!0},qa={description:s("Rounds number down to nearest multiple of factor."),args:[ua("number (number)",s("The value to round down to the nearest integer multiple of significance.")),ua("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ga.compute(e,t,0)},isExported:!0},Za={description:s("Whether the provided value is even."),args:[ua("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Po(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},ja={description:s("Rounds number up to nearest multiple of factor."),args:[ua("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ua("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ta.compute(e,t,0)},isExported:!0},Xa={description:s("Whether the provided value is even."),args:[ua("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Po(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Ya={description:s("The logarithm of a number, base e (euler's number)."),args:[ua("value (number)",s("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Lo(e);return Do((()=>t>0),s("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ka={description:s("Modulo (remainder) operator."),args:[ua("dividend (number)",s("The number to be divided to find the remainder.")),ua("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Lo(t);Do((()=>0!==i),s("The divisor must be different from 0."));const o=Lo(e)%i;return o>0&&i<0||o<0&&i>0?o+i:o},isExported:!0},Qa={description:s("Rounds a number up to the nearest odd integer."),args:[ua("value (number)",s("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Lo(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},Ja={description:s("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},el={description:s("A number raised to a power."),args:[ua("base (number)",s("The number to raise to the exponent power.")),ua("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Lo(e),o=Lo(t);return Do((()=>i>=0||Number.isInteger(o)),s("The exponent (%s) must be an integer when the base is negative.",o.toString())),Math.pow(i,o)},isExported:!0},tl={description:s("Result of multiplying a series of numbers together."),args:[ua("factor1 (number, range<number>)",s("The first number or range to calculate for the product.")),ua("factor2 (number, range<number>, repeating)",s("More numbers or ranges to calculate for the product."))],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,i=1;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(i*=o,t+=1);else null!=o&&(i*=Po(o),t+=1);return 0===t?0:i},isExported:!0},il={description:s("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},ol={description:s("Random integer between two values, inclusive."),args:[ua("low (number)",s("The low end of the random range.")),ua("high (number)",s("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Lo(e);Number.isInteger(i)||(i=Math.ceil(i));let o=Lo(t);return Number.isInteger(o)||(o=Math.floor(o)),Do((()=>i<=o),s("The high (%s) must be greater than or equal to the low (%s).",o.toString(),i.toString())),i+Math.ceil((o-i+1)*Math.random())-1},isExported:!0},nl={description:s("Rounds a number according to standard rules."),args:[ua("value (number)",s("The value to round to places number of places.")),ua("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Lo(e);let o=Lo(t);const n=Math.abs(i);let s;return 0===o?s=Math.round(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.round(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},sl={description:s("Rounds down a number."),args:[ua("value (number)",s("The value to round to places number of places, always rounding down.")),ua("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Lo(e);let o=Lo(t);const n=Math.abs(i);let s;return 0===o?s=Math.floor(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.floor(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},rl={description:s("Rounds up a number."),args:[ua("value (number)",s("The value to round to places number of places, always rounding up.")),ua("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Lo(e);let o=Lo(t);const n=Math.abs(i);let s;return 0===o?s=Math.ceil(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.ceil(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},al={description:s("Secant of an angle provided in radians."),args:[ua("angle (number)",s("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Lo(e))},isExported:!0},ll={description:s("Hyperbolic secant of any real number."),args:[ua("value (number)",s("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Lo(e))},isExported:!0},cl={description:s("Sine of an angle provided in radians."),args:[ua("angle (number)",s("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Lo(e))},isExported:!0},hl={description:s("Hyperbolic sine of any real number."),args:[ua("value (number)",s("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Lo(e))},isExported:!0},dl={description:s("Positive square root of a positive number."),args:[ua("value (number)",s("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Lo(e);return Do((()=>t>=0),s("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},ul={description:s("Sum of a series of numbers and/or cells."),args:[ua("value1 (number, range<number>)",s("The first number or range to add together.")),ua("value2 (number, range<number>, repeating)",s("Additional numbers or ranges to add to value1."))],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 jo(e,((e,t)=>e+t),0)},isExported:!0},gl={description:s("A conditional sum across a range."),args:[ua("criteria_range (range)",s("The range which is tested against criterion.")),ua("criterion (string)",s("The pattern or test to apply to range.")),ua("sum_range (range, default=criteria_range)",s("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let o=0;return Jo([e,t],((e,t)=>{const n=i[e][t];"number"==typeof n&&(o+=n)})),o},isExported:!0},pl={description:s("Sums a range depending on multiple criteria."),args:[ua("sum_range (range)",s("The range to sum.")),ua("criteria_range1 (range)",s("The range to check against criterion1.")),ua("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ua("criteria_range2 (any, range, repeating)",s("Additional ranges to check.")),ua("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let i=0;return Jo(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i+=n)})),i},isExported:!0},ml={description:s("Tangent of an angle provided in radians."),args:[ua("angle (number)",s("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Lo(e))},isExported:!0},fl={description:s("Hyperbolic tangent of any real number."),args:[ua("value (number)",s("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Lo(e))},isExported:!0},vl={description:s("Truncates a number."),args:[ua("value (number)",s("The value to be truncated.")),ua("places (number, default=0)",s("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Lo(e);let o=Lo(t);return 0===o?Math.trunc(i):(Number.isInteger(o)||(o=Math.trunc(o)),Math.trunc(i*Math.pow(10,o))/Math.pow(10,o))},isExported:!0};var bl=Object.freeze({__proto__:null,ABS:fa,ACOS:va,ACOSH:ba,ACOT:Sa,ACOTH:Ca,ASIN:Ea,ASINH:wa,ATAN:ya,ATAN2:xa,ATANH:Ia,CEILING:Ra,CEILING_MATH:Ta,CEILING_PRECISE:Aa,COS:Ma,COSH:Oa,COT:Na,COTH:_a,COUNTBLANK:Fa,COUNTIF:Da,COUNTIFS:ka,COUNTUNIQUE:Pa,COUNTUNIQUEIFS:Ua,CSC:Va,CSCH:za,DECIMAL:Ba,DEGREES:Ha,EXP:$a,FLOOR:Wa,FLOOR_MATH:Ga,FLOOR_PRECISE:qa,ISEVEN:Za,ISO_CEILING:ja,ISODD:Xa,LN:Ya,MOD:Ka,ODD:Qa,PI:Ja,POWER:el,PRODUCT:tl,RAND:il,RANDBETWEEN:ol,ROUND:nl,ROUNDDOWN:sl,ROUNDUP:rl,SEC:al,SECH:ll,SIN:cl,SINH:hl,SQRT:dl,SUM:ul,SUMIF:gl,SUMIFS:pl,TAN:ml,TANH:fl,TRUNC:vl});function Sl(e,t,i){let o=[],n=[],r=0,a=0;Wo([e],(e=>{o.push(e),r+=1})),Wo([t],(e=>{n.push(e),a+=1})),Do((()=>r===a),s("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",r.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}Do((()=>0!==l&&(!i||1!==l)),s("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<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function Cl(e,t,i){let o=0,n=0;const r=i?Xo:jo;n=r(e,((e,t)=>(o+=1,e+t)),0),Do((()=>0!==o&&(!t||1!==o)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/o;return r(e,((e,t)=>e+Math.pow(t-a,2)),0)/(o-(t?1:0))}function El(e,t,i){const o=Lo(t);Do((()=>i?0<=o&&o<=1:0<o&&o<1),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return Wo(e,(e=>{"number"==typeof e&&(n=on(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,e),a++)})),Do((()=>0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),i||Do((()=>1/(a+1)<=o&&o<=a/(a+1)),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),si(r,o,i)}const wl={description:s("Average magnitude of deviations from mean."),args:[ua("value1 (number, range<number>)",s("The first value or range of the sample.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const i=jo(e,((e,i)=>(t+=1,e+i)),0);Do((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const o=i/t;return jo(e,((e,t)=>e+Math.abs(o-t)),0)/t},isExported:!0},yl={description:s("Numerical average value in a dataset, ignoring text."),args:[ua("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],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 i=jo(e,((e,i)=>(t+=1,e+i)),0);return Do((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},xl=s("[[FUNCTION_NAME]] has mismatched range sizes."),Il=s("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Rl={description:s("Weighted average."),args:[ua("values (number, range<number>)",s("Values to average.")),ua("weights (number, range<number>)",s("Weights for each corresponding value.")),ua("additional_values (number, range<number>, repeating)",s("Additional values to average.")),ua("additional_weights (number, range<number>, repeating)",s("Additional weights."))],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,i,o=0,n=0;Do((()=>e.length%2==0),s("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let r=0;r<e.length-1;r+=2)if(t=e[r],i=e[r+1],Array.isArray(t)){Do((()=>Array.isArray(i)),xl);let e=t.length,r=t[0].length;Do((()=>e===i.length&&r===i[0].length),xl);for(let a=0;a<e;a++)for(let e=0;e<r;e++){let r=t[a][e],l=i[a][e],c="number"==typeof r,h="number"==typeof l;Do((()=>c===h),s("[[FUNCTION_NAME]] expects number values.")),h&&(Do((()=>l>=0),Il),o+=r*l,n+=l)}}else i=Lo(i),t=Lo(t),Do((()=>i>=0),Il),o+=t*i,n+=i;return Do((()=>0!==n),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n}},Tl={description:s("Numerical average value in a dataset."),args:[ua("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],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 i=Xo(e,((e,i)=>(t+=1,e+i)),0);return Do((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Al={description:s("Average of values depending on criteria."),args:[ua("criteria_range (range)",s("The range to check against criterion.")),ua("criterion (string)",s("The pattern or test to apply to criteria_range.")),ua("average_range (range, default=criteria_range)",s("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let o=0,n=0;return Jo([e,t],((t,s)=>{const r=(i||e)[t][s];"number"==typeof r&&(o+=1,n+=r)})),Do((()=>0!==o),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},Ml={description:s("Average of values depending on multiple criteria."),args:[ua("average_range (range)",s("The range to average.")),ua("criteria_range1 (range)",s("The range to check against criterion1.")),ua("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ua("criteria_range2 (any, range, repeating)",s("Additional criteria_range and criterion to check.")),ua("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=0,o=0;return Jo(t,((t,n)=>{const s=e[t][n];"number"==typeof s&&(i+=1,o+=s)})),Do((()=>0!==i),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},Ol={description:s("The number of numeric values in dataset."),args:[ua("value1 (number, range<number>)",s("The first value or range to consider when counting.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||ii(i)||Ee(i))&&(t+=1);return t},isExported:!0},Nl={description:s("The number of values in a dataset."),args:[ua("value1 (any, range)",s("The first value or range to consider when counting.")),ua("value2 (any, range, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Zo(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},_l={description:s("The covariance of a dataset."),args:[ua("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ua("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Sl(e,t,!1)},isExported:!0},Fl={description:s("The covariance of a dataset."),args:[ua("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ua("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Sl(e,t,!1)},isExported:!0},Dl={description:s("The sample covariance of a dataset."),args:[ua("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ua("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return Sl(e,t,!0)},isExported:!0},kl={description:s("Nth largest element from a data set."),args:[ua("data (any, range)",s("Array or range containing the dataset to consider.")),ua("n (number)",s("The rank from largest to smallest of the element to return."))],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 i=Math.trunc(Lo(t));let o,n=[],r=0;Wo([e],(e=>{"number"==typeof e&&(o=on(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.shift(),r--))}));const a=n.shift();return Do((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Do((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Ll={description:s("Maximum value in a numeric dataset."),args:[ua("value1 (number, range<number>)",s("The first value or range to consider when calculating the maximum value.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],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=jo(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Pl={description:s("Maximum numeric value in a dataset."),args:[ua("value1 (any, range)",s("The first value or range to consider when calculating the maximum value.")),ua("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],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=Xo(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Ul={description:s("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[ua("range (range)",s("The range of cells from which the maximum will be determined.")),ua("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ua("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ua("criteria_range2 (any, range, repeating)",s("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.")),ua("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return Jo(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i<n?n:i)})),i===-1/0?0:i},isExported:!0},Vl={description:s("Median value in a numeric dataset."),args:[ua("value1 (any, range)",s("The first value or range to consider when calculating the median value.")),ua("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the median value."))],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 Go(e,(e=>{t.push(e)})),El(t,.5,!0)},isExported:!0},zl={description:s("Minimum value in a numeric dataset."),args:[ua("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],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=jo(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Bl={description:s("Minimum numeric value in a dataset."),args:[ua("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],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=Xo(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Hl={description:s("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[ua("range (range)",s("The range of cells from which the minimum will be determined.")),ua("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ua("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ua("criteria_range2 (any, range, repeating)",s("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.")),ua("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=1/0;return Jo(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i>n?n:i)})),i===1/0?0:i},isExported:!0},$l={description:s("Value at a given percentile of a dataset."),args:[ua("data (any, range)",s("The array or range containing the dataset to consider.")),ua("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],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 Gl.compute(e,t)},isExported:!0},Wl={description:s("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[ua("data (any, range)",s("The array or range containing the dataset to consider.")),ua("percentile (number)",s("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],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 El([e],t,!1)},isExported:!0},Gl={description:s("Value at a given percentile of a dataset."),args:[ua("data (any, range)",s("The array or range containing the dataset to consider.")),ua("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],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 El([e],t,!0)},isExported:!0},ql={description:s("Value nearest to a specific quartile of a dataset."),args:[ua("data (any, range)",s("The array or range containing the dataset to consider.")),ua("quartile_number (number)",s("Which quartile value to return."))],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 jl.compute(e,t)},isExported:!0},Zl={description:s("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[ua("data (any, range)",s("The array or range containing the dataset to consider.")),ua("quartile_number (number)",s("Which quartile value, exclusive of 0 and 4, to return."))],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 El([e],.25*Math.trunc(Lo(t)),!1)},isExported:!0},jl={description:s("Value nearest to a specific quartile of a dataset."),args:[ua("data (any, range)",s("The array or range containing the dataset to consider.")),ua("quartile_number (number)",s("Which quartile value to return."))],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 El([e],.25*Math.trunc(Lo(t)),!0)},isExported:!0},Xl={description:s("Nth smallest element in a data set."),args:[ua("data (any, range)",s("The array or range containing the dataset to consider.")),ua("n (number)",s("The rank from smallest to largest of the element to return."))],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 i=Math.trunc(Lo(t));let o,n=[],r=0;Wo([e],(e=>{"number"==typeof e&&(o=on(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.pop(),r--))}));const a=n.pop();return Do((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Do((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Yl={description:s("Standard deviation."),args:[ua("value1 (number, range<number>)",s("The first value or range of the sample.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ic.compute(...e))},isExported:!0},Kl={description:s("Standard deviation of entire population."),args:[ua("value1 (number, range<number>)",s("The first value or range of the population.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(oc.compute(...e))},isExported:!0},Ql={description:s("Standard deviation."),args:[ua("value1 (number, range<number>)",s("The first value or range of the sample.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(nc.compute(...e))},isExported:!0},Jl={description:s("Standard deviation of sample (text as 0)."),args:[ua("value1 (number, range<number>)",s("The first value or range of the sample.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(sc.compute(...e))},isExported:!0},ec={description:s("Standard deviation of entire population."),args:[ua("value1 (number, range<number>)",s("The first value or range of the population.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(rc.compute(...e))},isExported:!0},tc={description:s("Standard deviation of entire population (text as 0)."),args:[ua("value1 (number, range<number>)",s("The first value or range of the population.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ac.compute(...e))},isExported:!0},ic={description:s("Variance."),args:[ua("value1 (number, range<number>)",s("The first value or range of the sample.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Cl(e,!0,!1)},isExported:!0},oc={description:s("Variance of entire population."),args:[ua("value1 (number, range<number>)",s("The first value or range of the population.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Cl(e,!1,!1)},isExported:!0},nc={description:s("Variance."),args:[ua("value1 (number, range<number>)",s("The first value or range of the sample.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Cl(e,!0,!1)},isExported:!0},sc={description:s("Variance of sample (text as 0)."),args:[ua("value1 (number, range<number>)",s("The first value or range of the sample.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Cl(e,!0,!0)},isExported:!0},rc={description:s("Variance of entire population."),args:[ua("value1 (number, range<number>)",s("The first value or range of the population.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Cl(e,!1,!1)},isExported:!0},ac={description:s("Variance of entire population (text as 0)."),args:[ua("value1 (number, range<number>)",s("The first value or range of the population.")),ua("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Cl(e,!1,!0)},isExported:!0};var lc=Object.freeze({__proto__:null,AVEDEV:wl,AVERAGE:yl,AVERAGE_WEIGHTED:Rl,AVERAGEA:Tl,AVERAGEIF:Al,AVERAGEIFS:Ml,COUNT:Ol,COUNTA:Nl,COVAR:_l,COVARIANCE_P:Fl,COVARIANCE_S:Dl,LARGE:kl,MAX:Ll,MAXA:Pl,MAXIFS:Ul,MEDIAN:Vl,MIN:zl,MINA:Bl,MINIFS:Hl,PERCENTILE:$l,PERCENTILE_EXC:Wl,PERCENTILE_INC:Gl,QUARTILE:ql,QUARTILE_EXC:Zl,QUARTILE_INC:jl,SMALL:Xl,STDEV:Yl,STDEV_P:Kl,STDEV_S:Ql,STDEVA:Jl,STDEVP:ec,STDEVPA:tc,VAR:ic,VAR_P:oc,VAR_S:nc,VARA:sc,VARP:rc,VARPA:ac});function cc(e,t,i){var o;const n=new Map,r=e.length;for(let t=r-1;t>=0;t--)n.set(Uo(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(s("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||r-1<a)throw new Error(s("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),r.toString()))}else{const e=Uo(t).toUpperCase();if(a=null!==(o=n.get(e))&&void 0!==o?o:-1,-1===a)throw new Error(s("The field (%s) must be one of %s.",Uo(t),[...n.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(s("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 o=[],s=!0;for(let r=0;r<i.length;r++){const a=Uo(i[r][0]).toUpperCase(),l=n.get(a),c=i[r][t];if(void 0!==c){if(void 0===l){s=!1;break}o.push([e[l].slice(1,h)]),o.push(c)}}if(s){if(!(o.length>0)){c=new Set(Array(h-1).keys());break}Jo(o,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const hc=[ua("database (range)",s("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.")),ua("field (any)",s("Indicates which column in database contains the values to be extracted and operated on.")),ua("criteria (range)",s("An array or range containing zero or more criteria to filter the database values by before operating."))],dc={description:s("Average of a set of values from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return yl.compute([o])},isExported:!0},uc={description:s("Counts values from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return Ol.compute([o])},isExported:!0},gc={description:s("Counts values and text from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return Nl.compute([o])},isExported:!0},pc={description:s("Single value from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return Do((()=>1===o.length),s("More than one match found in DGET evaluation.")),o[0]},isExported:!0},mc={description:s("Maximum of values from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return Ll.compute([o])},isExported:!0},fc={description:s("Minimum of values from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return zl.compute([o])},isExported:!0},vc={description:s("Product of values from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return tl.compute([o])},isExported:!0},bc={description:s("Standard deviation of population sample from table."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return Yl.compute([o])},isExported:!0},Sc={description:s("Standard deviation of entire population from table."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return ec.compute([o])},isExported:!0},Cc={description:s("Sum of values from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return ul.compute([o])},isExported:!0},Ec={description:s("Variance of population sample from table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return ic.compute([o])},isExported:!0},wc={description:s("Variance of a population from a table-like range."),args:hc,returns:["NUMBER"],compute:function(e,t,i){const o=cc(e,t,i);return rc.compute([o])},isExported:!0};var yc=Object.freeze({__proto__:null,DAVERAGE:dc,DCOUNT:uc,DCOUNTA:gc,DGET:pc,DMAX:mc,DMIN:fc,DPRODUCT:vc,DSTDEV:bc,DSTDEVP:Sc,DSUM:Cc,DVAR:Ec,DVARP:wc});const xc={description:s("Converts year/month/day into a date."),args:[ua("year (number)",s("The year component of the date.")),ua("month (number)",s("The month component of the date.")),ua("day (number)",s("The day component of the date."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let o=Math.trunc(Lo(e));const n=Math.trunc(Lo(t)),r=Math.trunc(Lo(i));Do((()=>0<=o&&o<=9999),s("The year (%s) must be between 0 and 9999 inclusive.",o.toString())),o<1900&&(o+=1900);const a=xe(new Date(o,n-1,r));return Do((()=>a>=0),s("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Ic={description:s("Converts a date string to a date value."),args:[ua("date_string (string)",s("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=Uo(e),i=Ee(t);return Do((()=>null!==i),s("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},Rc={description:s("Day of the month that a specific date falls on."),args:[ua("date (string)",s("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Ho(e).getDate()},isExported:!0},Tc={description:s("Number of days between two dates."),args:[ua("end_date (date)",s("The end of the date range.")),ua("start_date (date)",s("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const i=Ho(e),o=Ho(t),n=i.getTime()-o.getTime();return Math.round(n/ge)},isExported:!0},Ac={description:s("Number of days between two dates on a 360-day year (months of 30 days)."),args:[ua("start_date (date)",s("The start date to consider in the calculation.")),ua("end_date (date)",s("The end date to consider in the calculation.")),ua("method (number, default=0)",s("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,i=0){const o=Lo(e),n=Lo(t),s=Bo(i)?4:0,r=jc.compute(e,t,s);return Math.sign(n-o)*Math.round(360*r)},isExported:!0},Mc={description:s("Date a number of months before/after another date."),args:[ua("start_date (date)",s("The date from which to calculate the result.")),ua("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return xe(Te(Ho(e),Math.trunc(Lo(t)),!1))},isExported:!0},Oc={description:s("Last day of a month before or after a date."),args:[ua("start_date (date)",s("The date from which to calculate the result.")),ua("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Ho(e),o=Math.trunc(Lo(t)),n=i.getFullYear(),s=i.getMonth();return xe(new Date(n,s+o+1,0))},isExported:!0},Nc={description:s("Hour component of a specific time."),args:[ua("time (date)",s("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Ho(e).getHours()},isExported:!0},_c={description:s("ISO week number of the year."),args:[ua("date (date)",s("The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number."))],returns:["NUMBER"],compute:function(e){const t=Ho(e),i=t.getFullYear();let o=1;for(;4!==new Date(i,0,o).getDay();)o+=1;const n=new Date(i,0,o-3);let s=31;for(;4!==new Date(i,11,s).getDay();)s-=1;const r=new Date(i,11,s+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Date(i,11,s+3+1);break;case-1:let e=1;for(;4!==new Date(i-1,0,e).getDay();)e+=1;l=new Date(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ge;return Math.floor(c/7)+1},isExported:!0},Fc={description:s("Minute component of a specific time."),args:[ua("time (date)",s("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Ho(e).getMinutes()},isExported:!0},Dc={description:s("Month of the year a specific date falls in"),args:[ua("date (date)",s("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Ho(e).getMonth()+1},isExported:!0},kc={description:s("Net working days between two provided days."),args:[ua("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),ua("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),ua("holidays (date, range<date>, optional)",s("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,i){return Pc.compute(e,t,1,i)},isExported:!0};function Lc(e){if("string"==typeof e){Do((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),s('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return Do((()=>1<=e&&e<=7||11<=e&&e<=17),s("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(s("The weekend must be a number or a string."))}const Pc={description:s("Net working days between two dates (specifying weekends)."),args:[ua("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),ua("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),ua("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),ua("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,i=1,o){const n=Ho(e),s=Ho(t),r=Lc(i);let a=new Set;void 0!==o&&Wo([o],(e=>{const t=Ho(e);a.add(t.getTime())}));const l=n.getTime()>s.getTime(),c=new Date((l?n:s).getTime());let h=new Date((l?s:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Uc={description:s("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()-ue.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ge)+i},isExported:!0},Vc={description:s("Minute component of a specific time."),args:[ua("time (date)",s("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Ho(e).getSeconds()},isExported:!0},zc={description:s("Converts hour/minute/second into a time."),args:[ua("hour (number)",s("The hour component of the time.")),ua("minute (number)",s("The minute component of the time.")),ua("second (number)",s("The second component of the time."))],returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let o=Math.trunc(Lo(e)),n=Math.trunc(Lo(t)),r=Math.trunc(Lo(i));return n+=Math.floor(r/60),r=r%60+(r<0?60:0),o+=Math.floor(n/60),n=n%60+(n<0?60:0),o%=24,Do((()=>o>=0),s("The function [[FUNCTION_NAME]] result cannot be negative")),o/24+n/1440+r/86400},isExported:!0},Bc={description:s("Converts a time string into its serial number representation."),args:[ua("time_string (string)",s("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=Uo(e),i=Ee(t);Do((()=>null!==i),s("The time_string (%s) cannot be parsed to date/time.",t));const o=i.value-Math.trunc(i.value);return o<0?1+o:o},isExported:!0},Hc={description:s("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return xe(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},$c={description:s("Day of the week of the date provided (as number)."),args:[ua("date (date)",s("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.")),ua("type (number, default=1)",s("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Ho(e),o=Math.round(Lo(t)),n=i.getDay();return Do((()=>[1,2,3].includes(o)),s("The type (%s) must be 1, 2 or 3.",o.toString())),1===o?n+1:2===o?0===n?7:n:0===n?6:n-1},isExported:!0},Wc={description:s("Week number of the year."),args:[ua("date (date)",s("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.")),ua("type (number, default=1)",s("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Ho(e),o=Math.round(Lo(t));if(Do((()=>1===o||2===o||11<=o&&o<=17||21===o),s("The type (%s) is out of range.",o.toString())),21===o)return _c.compute(e);let n;n=1===o||2===o?o-1:o-10==7?0:o-10;const r=i.getFullYear();let a=1,l=new Date(r,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(r,0,a);const c=(i.getTime()-l.getTime())/ge;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Gc={description:s("Date after a number of workdays."),args:[ua("start_date (date)",s("The date from which to begin counting.")),ua("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),ua("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return qc.compute(e,t,1,i)},isExported:!0},qc={description:s("Date after a number of workdays (specifying weekends)."),args:[ua("start_date (date)",s("The date from which to begin counting.")),ua("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),ua("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),ua("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,o){let n=Ho(e),r=Math.trunc(Lo(t));"string"==typeof i&&Do((()=>"1111111"!==i),s("The weekend (%s) must be different from '1111111'.",i));const a=Lc(i);let l=new Set;void 0!==o&&Wo([o],(e=>{const t=Ho(e);l.add(t.getTime())}));let c=new Date(n.getTime()),h=c.getTime();const d=Math.sign(r);let u=Math.abs(r);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-ue.getTime();return Math.round(g/ge)},isExported:!0},Zc={description:s("Year specified by a given date."),args:[ua("date (date)",s("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Ho(e).getFullYear()},isExported:!0},jc={description:s("Exact number of years between two dates."),args:[ua("start_date (date)",s("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.")),ua("end_date (date)",s("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.")),ua("day_count_convention (number, default=0)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i=0){let o=Math.trunc(Lo(e)),n=Math.trunc(Lo(t));const r=Math.trunc(Lo(i));return Do((()=>o>=0),s("The start_date (%s) must be positive or null.",o.toString())),Do((()=>n>=0),s("The end_date (%s) must be positive or null.",n.toString())),Do((()=>0<=r&&r<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",r.toString())),Me(o,n,r)}},Xc={description:s("First day of the month preceding a date."),args:[ua("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Ho(e),i=t.getFullYear(),o=t.getMonth();return xe(new Date(i,o,1))}},Yc={description:s("Last day of the month following a date."),args:[ua("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Oc.compute(e,0)}},Kc={description:s("Quarter of the year a specific date falls in"),args:[ua("date (date)",s("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Ho(e).getMonth()+1)/3)}},Qc={description:s("First day of the quarter of the year a specific date falls in."),args:[ua("date (date)",s("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Kc.compute(e),i=Zc.compute(e);return xe(new Date(i,3*(t-1),1))}},Jc={description:s("Last day of the quarter of the year a specific date falls in."),args:[ua("date (date)",s("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Kc.compute(e),i=Zc.compute(e);return xe(new Date(i,3*t,0))}},eh={description:s("First day of the year a specific date falls in."),args:[ua("date (date)",s("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zc.compute(e);return xe(new Date(t,0,1))}},th={description:s("Last day of the year a specific date falls in."),args:[ua("date (date)",s("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Zc.compute(e);return xe(new Date(t+1,0,0))}};var ih=Object.freeze({__proto__:null,DATE:xc,DATEVALUE:Ic,DAY:Rc,DAYS:Tc,DAYS360:Ac,EDATE:Mc,EOMONTH:Oc,HOUR:Nc,ISOWEEKNUM:_c,MINUTE:Fc,MONTH:Dc,NETWORKDAYS:kc,NETWORKDAYS_INTL:Pc,NOW:Uc,SECOND:Vc,TIME:zc,TIMEVALUE:Bc,TODAY:Hc,WEEKDAY:$c,WEEKNUM:Wc,WORKDAY:Gc,WORKDAY_INTL:qc,YEAR:Zc,YEARFRAC:jc,MONTH_START:Xc,MONTH_END:Yc,QUARTER:Kc,QUARTER_START:Qc,QUARTER_END:Jc,YEAR_START:eh,YEAR_END:th});const oh={description:s("Compare two numeric values, returning 1 if they're equal."),args:[ua(" (number)",s("The first number to compare.")),ua(" (number, default=0)",s("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Lo(e)===Lo(t)?1:0},isExported:!0};var nh=Object.freeze({__proto__:null,DELTA:oh});function sh(e,t){Do((()=>e<t),s("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function rh(e,t){Do((()=>t<e),s("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function ah(e){Do((()=>[1,2,4].includes(e)),s("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function lh(e){Do((()=>0<=e&&e<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function ch(e){Do((()=>e>0),s("The redemption (%s) must be strictly positive.",e.toString()))}function hh(e){Do((()=>e>0),s("The price (%s) must be strictly positive.",e.toString()))}function dh(e){Do((()=>e>0),s("The number_of_periods (%s) must be greater than 0.",e.toString()))}function uh(e){Do((()=>e>0),s("The rate (%s) must be strictly positive.",e.toString()))}function gh(e){Do((()=>e>0),s("The life (%s) must be strictly positive.",e.toString()))}function ph(e){Do((()=>e>=0),s("The cost (%s) must be positive or null.",e.toString()))}function mh(e){Do((()=>e>0),s("The period (%s) must be strictly positive.",e.toString()))}function fh(e){Do((()=>e>=0),s("The salvage (%s) must be positive or null.",e.toString()))}function vh(e){Do((()=>e>0),s("The present value (%s) must be strictly positive.",e.toString()))}function bh(e,t){Do((()=>e<=t),s("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function Sh(e){Do((()=>e>0),s("The investment (%s) must be strictly positive.",e.toString()))}function Ch(e){Do((()=>e>0),s("The discount (%s) must be strictly positive.",e.toString()))}function Eh(e){Do((()=>e<1),s("The discount (%s) must be smaller than 1.",e.toString()))}function wh(e){Do((()=>e>0),s("The depreciation factor (%s) must be strictly positive.",e.toString()))}function yh(e,t){const i=Ho(e),o=Ho(t),n=new Date(i);n.setFullYear(i.getFullYear()+1),Do((()=>o.getTime()<=n.getTime()),s("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function xh(e,t,i){dh(i),Do((()=>e>0),s("The first_period (%s) must be strictly positive.",e.toString())),Do((()=>t>0),s("The last_period (%s) must be strictly positive.",t.toString())),Do((()=>e<=t),s("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Do((()=>t<=i),s("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function Ih(e){Do((()=>e>-1),s("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Rh(e,t){Do((()=>e.length===t.length&&e[0].length===t[0].length),s("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Th(e){Do((()=>e.every((t=>t>=e[0]))),s("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Ah=[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))];function Mh(e,t,i,o,n=1e-10,r){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(Do((()=>g<o&&void 0!==r),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=r(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<n||Math.abs(c)<n,Do((()=>g<o),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Oh={description:s("Accrued interest of security paying at maturity."),args:[ua("issue (date)",s("The date the security was initially issued.")),ua("maturity (date)",s("The maturity date of the security.")),ua("rate (number)",s("The annualized rate of interest.")),ua("redemption (number)",s("The redemption amount per 100 face value, or par.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Lo(e)),r=Math.trunc(Lo(t)),a=Lo(o),l=Lo(i),c=Math.trunc(Lo(n));rh(r,s),lh(c),ch(a),uh(l);return a*l*jc.compute(s,r,n)},isExported:!0},Nh={description:s("Depreciation for an accounting period."),args:[ua("cost (number)",s("The initial cost of the asset.")),ua("purchase_date (date)",s("The date the asset was purchased.")),ua("first_period_end (date)",s("The date the first period ended.")),ua("salvage (number)",s("The value of the asset at the end of depreciation.")),ua("period (number)",s("The single period within life for which to calculate depreciation.")),ua("rate (number)",s("The deprecation rate.")),ua(" (number, optional)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Lo(e),c=Math.trunc(Lo(t)),h=Math.trunc(Lo(i)),d=Lo(o),u=Lo(n),g=Lo(r),p=Math.trunc(Lo(a));!function(e){Do((()=>e>0),s("The cost (%s) must be strictly positive.",e.toString()))}(l),fh(d),function(e,t){Do((()=>e<=t),s("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Do((()=>e>=0),s("The period (%s) must be positive or null.",e.toString()))}(u),uh(g),lh(p),Do((()=>c<=h),s("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=jc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},_h={description:s("Days in coupon period containing settlement date."),args:Ah,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Lo(e)),s=Math.trunc(Lo(t)),r=Math.trunc(Lo(i)),a=Math.trunc(Lo(o));if(sh(n,s),ah(r),lh(a),1===a){const n=Ph.compute(e,t,i,o);return kh.compute(e,t,i,o)-n}return(3===a?365:360)/r},isExported:!0},Fh={description:s("Days from settlement until next coupon."),args:Ah,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Lo(e)),s=Math.trunc(Lo(t)),r=Math.trunc(Lo(i)),a=Math.trunc(Lo(o));sh(n,s),ah(r),lh(a);const l=Ph.compute(n,s,i,o);if([1,2,3].includes(a))return n-l;if(4===a){const e=Me(l,n,a);return Math.round(360*e)}const c=Ho(n),h=Ho(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Re(h)&&Re(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Re(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Dh={description:s("Days from settlement until next coupon."),args:Ah,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Lo(e)),s=Math.trunc(Lo(t)),r=Math.trunc(Lo(i)),a=Math.trunc(Lo(o));sh(n,s),ah(r),lh(a);const l=kh.compute(n,s,i,o);if([1,2,3].includes(a))return l-n;if(4===a){const e=Me(n,l,a);return Math.round(360*e)}const c=Fh.compute(e,t,i,a);return _h.compute(e,t,i,a)-c},isExported:!0},kh={description:s("Next coupon date after the settlement date."),args:Ah,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Lo(e)),s=Math.trunc(Lo(t)),r=Math.trunc(Lo(i)),a=Math.trunc(Lo(o));sh(n,s),ah(r),lh(a);const l=12/r,c=Lh.compute(e,t,i,o);return xe(Te(Ho(s),-(c-1)*l,!0))},isExported:!0},Lh={description:s("Number of coupons between settlement and maturity."),args:Ah,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Lo(e)),s=Math.trunc(Lo(t)),r=Math.trunc(Lo(i)),a=Math.trunc(Lo(o));sh(n,s),ah(r),lh(a);let l=1,c=s;const h=12/r;for(;c>n;)c=xe(Te(Ho(c),-h,!1)),l++;return l-1},isExported:!0},Ph={description:s("Last coupon date prior to or on the settlement date."),args:Ah,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Lo(e)),s=Math.trunc(Lo(t)),r=Math.trunc(Lo(i)),a=Math.trunc(Lo(o));sh(n,s),ah(r),lh(a);const l=12/r,c=Lh.compute(e,t,i,o);return xe(Te(Ho(s),-c*l,!0))},isExported:!0},Uh={description:s("Cumulative interest paid over a set of periods."),args:[ua("rate (number)",s("The interest rate.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("present_value (number)",s("The current value of the annuity.")),ua("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),ua("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Lo(o),a=Lo(n),l=Lo(e),c=Lo(i),h=Lo(t);xh(r,a,h),uh(l),vh(c);let d=0;for(let t=r;t<=a;t++){d+=Yh.compute(e,t,h,i,0,s)}return d},isExported:!0},Vh={description:s("Cumulative principal paid over a set of periods."),args:[ua("rate (number)",s("The interest rate.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("present_value (number)",s("The current value of the annuity.")),ua("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),ua("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Lo(o),a=Lo(n),l=Lo(e),c=Lo(i),h=Lo(t);xh(r,a,h),uh(l),vh(c);let d=0;for(let t=r;t<=a;t++){d+=rd.compute(e,t,h,i,0,s)}return d},isExported:!0},zh={description:s("Depreciation via declining balance method."),args:[ua("cost (number)",s("The initial cost of the asset.")),ua("salvage (number)",s("The value of the asset at the end of depreciation.")),ua("life (number)",s("The number of periods over which the asset is depreciated.")),ua("period (number)",s("The single period within life for which to calculate depreciation.")),ua("month (number, optional)",s("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,...n){const r=Lo(e),a=Lo(t),l=Lo(i),c=Math.trunc(Lo(o)),h=n.length?Math.trunc(Lo(n[0])):12,d=l+(12===h?0:1);ph(r),fh(a),mh(c),gh(l),Do((()=>1<=h&&h<=12),s("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Do((()=>c<=d),s("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/r,1/l);g=Math.round(1e3*g)/1e3;let p=r,m=r*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},Bh={description:s("Depreciation via double-declining balance method."),args:[ua("cost (number)",s("The initial cost of the asset.")),ua("salvage (number)",s("The value of the asset at the end of depreciation.")),ua("life (number)",s("The number of periods over which the asset is depreciated.")),ua("period (number)",s("The single period within life for which to calculate depreciation.")),ua("factor (number, default=2)",s("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=2){n=n||0;const s=Lo(e),r=Lo(t),a=Lo(i),l=Lo(o),c=Lo(n);if(ph(s),fh(r),mh(l),gh(a),bh(l,a),wh(c),0===s||r>=s)return 0;const h=c/a;if(h>1)return 1===o?s-r:0;if(l<=1)return s*h;const d=s*Math.pow(1-h,l-1),u=s*Math.pow(1-h,l),g=u<r?d-r:d-u;return Math.max(g,0)},isExported:!0},Hh={description:s("Discount rate of a security based on price."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("price (number)",s("The price at which the security is bought per 100 face value.")),ua("redemption (number)",s("The redemption amount per 100 face value, or par.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Lo(e)),r=Math.trunc(Lo(t)),a=Lo(i),l=Lo(o),c=Math.trunc(Lo(n));sh(s,r),lh(c),hh(a),ch(l);return(l-a)/l/jc.compute(s,r,c)},isExported:!0},$h={description:s("Convert a decimal fraction to decimal value."),args:[ua("fractional_price (number)",s("The price quotation given using fractional decimal conventions.")),ua("unit (number)",s("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Lo(e),o=Math.trunc(Lo(t));Do((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(10**Math.ceil(Math.log10(o))/o)},isExported:!0},Wh={description:s("Convert a decimal value to decimal fraction."),args:[ua("decimal_price (number)",s("The price quotation given as a decimal value.")),ua("unit (number)",s("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Lo(e),o=Math.trunc(Lo(t));Do((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(o/10**Math.ceil(Math.log10(o)))},isExported:!0},Gh={description:s("Number of periods for an investment to reach a value."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("rate (number)",s("The annualized rate of interest.")),ua("yield (number)",s("The expected annual yield of the security.")),ua("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Lo(e)),l=Math.trunc(Lo(t)),c=Lo(i),h=Lo(o),d=Math.trunc(Lo(n)),u=Math.trunc(Lo(r));sh(a,l),ah(d),lh(u),Do((()=>c>=0),s("The rate (%s) must be positive or null.",c.toString())),Do((()=>h>=0),s("The yield (%s) must be positive or null.",h.toString()));const g=jc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},qh={description:s("Annual effective interest rate."),args:[ua("nominal_rate (number)",s("The nominal interest rate per year.")),ua("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Lo(e),o=Math.trunc(Lo(t));return Do((()=>i>0),s("The nominal rate (%s) must be strictly greater than 0.",i.toString())),Do((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),Math.pow(1+i/o,o)-1},isExported:!0},Zh={description:s("Future value of an annuity investment."),args:[ua("rate (number)",s("The interest rate.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("payment_amount (number)",s("The amount per period to be paid.")),ua("present_value (number, default=0)",s("The current value of the annuity.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Lo(e),r=Lo(t),a=Lo(i),l=Lo(o),c=Bo(n)?1:0;return s?-l*(1+s)**r-a*(1+s*c)*((1+s)**r-1)/s:-(l+a*r)},isExported:!0},jh={description:s("Future value of principal from series of rates."),args:[ua("principal (number)",s("The amount of initial capital or value to compound against.")),ua("rate_schedule (number, range<number>)",s("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Zo([t],((e,t)=>e*(1+Lo(t))),Lo(e))},isExported:!0},Xh={description:s("Calculates effective interest rate."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("investment (number)",s("The amount invested in the security.")),ua("redemption (number)",s("The amount to be received at maturity.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){const s=Math.trunc(Lo(e)),r=Math.trunc(Lo(t)),a=Lo(o),l=Lo(i);sh(s,r),Sh(l),ch(a);return(a-l)/l/jc.compute(s,r,n)},isExported:!0},Yh={description:s("Payment on the principal of an investment."),args:[ua("rate (number)",s("The annualized rate of interest.")),ua("period (number)",s("The amortization period, in terms of number of periods.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("present_value (number)",s("The current value of the annuity.")),ua("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,s=0){return sd.compute(e,i,o,n,s)-rd.compute(e,t,i,o,n,s)},isExported:!0},Kh={description:s("Internal rate of return given periodic cashflows."),args:[ua("cashflow_amounts (number, range<number>)",s("An array or range containing the income or payments associated with the investment.")),ua("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Lo(t);Ih(i);let o=!1,n=!1,r=[];Go([e],(e=>{e>0&&(o=!0),e<0&&(n=!0),r.push(e)})),Do((()=>o&&n),s("The cashflow_amounts must include negative and positive values."));const a=r.shift();return Mh((function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*e**(o-n))),t*e**o)}(e,a,r)}),(function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*(o-n)*e**(o-n-1))),t*o*e**(o-1))}(e,a,r)}),i+1,20,1e-5)-1},isExported:!0},Qh={description:s("Returns the interest paid at a particular period of an investment."),args:[ua("rate (number)",s("The interest rate.")),ua("period (number)",s("The period for which you want to view the interest payment.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("present_value (number)",s("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Lo(e),r=Lo(t),a=Lo(i),l=Lo(o);Do((()=>0!==a),s("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(r/a))*n},isExported:!0},Jh={description:s("Modified Macaulay duration."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("rate (number)",s("The annualized rate of interest.")),ua("yield (number)",s("The expected annual yield of the security.")),ua("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){return Gh.compute(e,t,i,o,n,s)/(1+Lo(o)/Math.trunc(Lo(n)))},isExported:!0},ed={description:s("Modified internal rate of return."),args:[ua("cashflow_amounts (range<number>)",s("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),ua("financing_rate (number)",s("The interest rate paid on funds invested.")),ua("reinvestment_return_rate (number)",s("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Lo(t),n=Lo(i),r=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(ot).map(Lo);var a;const l=r.length;let c=0,h=0;for(const e of $e(0,l)){const t=r[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(o+1)**e}Do((()=>0!==h&&0!==c),s("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},td={description:s("Annual nominal interest rate."),args:[ua("effective_rate (number)",s("The effective interest rate per year.")),ua("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Lo(e),o=Math.trunc(Lo(t));return Do((()=>i>0),s("The effective rate (%s) must must strictly greater than 0.",i.toString())),Do((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),(Math.pow(i+1,1/o)-1)*o},isExported:!0},id={description:s("Number of payment periods for an investment."),args:[ua("rate (number)",s("The interest rate.")),ua("payment_amount (number)",s("The amount of each payment made.")),ua("present_value (number)",s("The current value of the annuity.")),ua("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Lo(e),r=Lo(t),a=Lo(i),l=Lo(o),c=Bo(n)?1:0;if(0===s)return-(l+a)/r;const h=r*(1+s*c)/s;return Math.log((h-l)/(a+h))/Math.log(1+s)},isExported:!0};const od={description:s("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[ua("discount (number)",s("The discount rate of the investment over one period.")),ua("cashflow1 (number, range<number>)",s("The first future cash flow.")),ua("cashflow2 (number, range<number>, repeating)",s("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Lo(e);return Do((()=>-1!==i),s("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let o=0;return jo(i,((t,i)=>(o++,t+i/(1+e)**o)),t)}(i,0,t)},isExported:!0},nd={description:s("Computes the number of periods needed for an investment to reach a value."),args:[ua("rate (number)",s("The rate at which the investment grows each period.")),ua("present_value (number)",s("The investment's current value.")),ua("future_value (number)",s("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Lo(e),n=Lo(t),r=Lo(i);return uh(o),Do((()=>n>0),s("The present_value (%s) must be strictly positive.",n.toString())),Do((()=>r>0),s("The future_value (%s) must be strictly positive.",r.toString())),(Math.log(r)-Math.log(n))/Math.log(1+o)},isExported:!0},sd={description:s("Periodic payment for an annuity investment."),args:[ua("rate (number)",s("The annualized rate of interest.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("present_value (number)",s("The current value of the annuity.")),ua("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Lo(t),r=Lo(e),a=Bo(n)?1:0;let l=Lo(o),c=Lo(i);if(dh(s),0===r)return-(l+c)/s;let h=-(c*(1+r)**s+l);return h=h*r/((1+r*a)*((1+r)**s-1)),h},isExported:!0},rd={description:s("Payment on the principal of an investment."),args:[ua("rate (number)",s("The annualized rate of interest.")),ua("period (number)",s("The amortization period, in terms of number of periods.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("present_value (number)",s("The current value of the annuity.")),ua("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,r=0){n=n||0,r=r||0;const a=Lo(i),l=Lo(e),c=Lo(t),h=Bo(r)?1:0,d=Lo(n),u=Lo(o);dh(a),Do((()=>c>0&&c<=a),s("The period must be between 1 and number_of_periods",a.toString()));const g=sd.compute(l,a,u,d,r);if(1===h&&1===c)return g;return g+-Zh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},ad={description:s("Present value of an annuity investment."),args:[ua("rate (number)",s("The interest rate.")),ua("number_of_periods (number)",s("The number of payments to be made.")),ua("payment_amount (number)",s("The amount per period to be paid.")),ua("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Lo(e),r=Lo(t),a=Lo(i),l=Lo(o),c=Bo(n)?1:0;return s?-(a*(1+s*c)*((1+s)**r-1)/s+l)/(1+s)**r:-(l+a*r)},isExported:!0},ld={description:s("Price of a security paying periodic interest."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("rate (number)",s("The annualized rate of interest.")),ua("yield (number)",s("The expected annual yield of the security.")),ua("redemption (number)",s("The redemption amount per 100 face value, or par.")),ua("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Lo(e)),c=Math.trunc(Lo(t)),h=Lo(i),d=Lo(o),u=Lo(n),g=Math.trunc(Lo(r)),p=Math.trunc(Lo(a));sh(l,c),ah(g),lh(p),Do((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Do((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString())),ch(u);const m=jc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},cd={description:s("Price of a discount security."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("discount (number)",s("The discount rate of the security at time of purchase.")),ua("redemption (number)",s("The redemption amount per 100 face value, or par.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Lo(e)),r=Math.trunc(Lo(t)),a=Lo(i),l=Lo(o),c=Math.trunc(Lo(n));sh(s,r),lh(c),Ch(a),ch(l);return l-a*l*jc.compute(s,r,c)},isExported:!0},hd={description:s("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("issue (date)",s("The date the security was initially issued.")),ua("rate (number)",s("The annualized rate of interest.")),ua("yield (number)",s("The expected annual yield of the security.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Lo(e)),l=Math.trunc(Lo(t)),c=Math.trunc(Lo(i)),h=Lo(o),d=Lo(n),u=Math.trunc(Lo(r));rh(a,c),sh(a,l),lh(u),Do((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Do((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString()));const g=jc.compute(a,l,u),p=jc.compute(a,c,u);return(100+jc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},dd=.1,ud={description:s("Interest rate of an annuity investment."),args:[ua("number_of_periods (number)",s("The number of payments to be made.")),ua("payment_per_period (number)",s("The amount per period to be paid.")),ua("present_value (number)",s("The current value of the annuity.")),ua("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ua("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period.")),ua("rate_guess (number, default=0.1)",s("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,o=0,n=0,r=.1){o=o||0,n=n||0,r=r||dd;const a=Lo(e),l=Lo(t),c=Bo(n)?1:0,h=Lo(r);let d=Lo(o),u=Lo(i);dh(a),Do((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),s("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Ih(h),d-=l*c,u+=l*c;return Mh((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),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},gd={description:s("Amount received at maturity for a security."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("investment (number)",s("The amount invested (irrespective of face value of each security).")),ua("discount (number)",s("The discount rate of the security invested in.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Lo(e)),r=Math.trunc(Lo(t)),a=Lo(i),l=Lo(o),c=Math.trunc(Lo(n));sh(s,r),lh(c),Sh(a),Ch(l);return a/(1-l*jc.compute(s,r,c))},isExported:!0},pd={description:s("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[ua("number_of_periods (number)",s("The number of periods.")),ua("present_value (number)",s("The present value of the investment.")),ua("future_value (number)",s("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Lo(e),n=Lo(t),s=Lo(i);return dh(o),(s/n)**(1/o)-1},isExported:!0},md={description:s("Depreciation of an asset using the straight-line method."),args:[ua("cost (number)",s("The initial cost of the asset.")),ua("salvage (number)",s("The value of the asset at the end of depreciation.")),ua("life (number)",s("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Lo(e)-Lo(t))/Lo(i)},isExported:!0},fd={description:s("Depreciation via sum of years digit method."),args:[ua("cost (number)",s("The initial cost of the asset.")),ua("salvage (number)",s("The value of the asset at the end of depreciation.")),ua("life (number)",s("The number of periods over which the asset is depreciated.")),ua("period (number)",s("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o){const n=Lo(e),s=Lo(t),r=Lo(i),a=Lo(o);mh(a),gh(r),bh(a,r);return(r-a+1)/(r*(r+1)/2)*(n-s)},isExported:!0},vd={description:s("Price of a US Treasury bill."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Lo(e)),n=Math.trunc(Lo(t)),s=Lo(i);sh(o,n),yh(o,n),Ch(s),Eh(s);return 100*(1-s*jc.compute(o,n,2))},isExported:!0},bd={description:s("Equivalent rate of return for a US Treasury bill."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Lo(e)),n=Math.trunc(Lo(t)),s=Lo(i);sh(o,n),yh(o,n),Ch(s),Eh(s);const r=Tc.compute(n,o);if(r<=182)return 365*s/(360-s*r);const a=vd.compute(o,n,s)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},Sd={description:s("The yield of a US Treasury bill based on price."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("price (number)",s("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Lo(e)),n=Math.trunc(Lo(t)),s=Lo(i);sh(o,n),yh(o,n),hh(s);return(100-s)/s*(1/jc.compute(o,n,2))},isExported:!0},Cd={description:s("Variable declining balance. WARNING : does not handle decimal periods."),args:[ua("cost (number)",s("The initial cost of the asset.")),ua("salvage (number)",s("The value of the asset at the end of depreciation.")),ua("life (number)",s("The number of periods over which the asset is depreciated.")),ua("start (number)",s("Starting period to calculate depreciation.")),ua("end (number)",s("Ending period to calculate depreciation.")),ua("factor (number, default=2)",s("The number of months in the first year of depreciation.")),ua("no_switch (number, default=false)",s("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=2,a=false){r=r||0;const l=Lo(e),c=Lo(t),h=Lo(i),d=Math.trunc(Lo(o)),u=Math.trunc(Lo(n)),g=Lo(r),p=Bo(a);if(ph(l),fh(c),function(e,t,i){gh(i),Do((()=>e>=0),s("The start_period (%s) must be greater or equal than 0.",e.toString())),Do((()=>t>=0),s("The end_period (%s) must be greater or equal than 0.",t.toString())),Do((()=>e<=t),s("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Do((()=>t<=i),s("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),wh(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},Ed={description:s("Internal rate of return given non-periodic cash flows."),args:[ua("cashflow_amounts (range<number>)",s("An range containing the income or payments associated with the investment.")),ua("cashflow_dates (range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts.")),ua("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,i=.1){const o=Lo(i=i||0),n=e.flat().map(Lo),r=t.flat().map(Lo);var a;Rh(e,t),a=n,Do((()=>a.some((e=>e>0))&&a.some((e=>e<0))),s("There must be both positive and negative values in cashflow_amounts.")),Th(r),Ih(o);const l=new Map;for(const e of $e(0,r.length)){const t=r[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Mh((e=>{let t=h[0];for(const i of $e(1,h.length)){const o=(c[0]-c[i])/365;t+=h[i]*(1+e)**o}return t}),(e=>{let t=0;for(const i of $e(1,h.length)){const o=(c[0]-c[i])/365;t+=o*h[i]*(1+e)**(o-1)}return t}),o,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},wd={description:s("Net present value given to non-periodic cash flows.."),args:[ua("discount (number)",s("The discount rate of the investment over one period.")),ua("cashflow_amounts (number, range<number>)",s("An range containing the income or payments associated with the investment.")),ua("cashflow_dates (number, range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,i){const o=Lo(e),n=Array.isArray(t)?t.flat().map(Po):[Po(t)],r=Array.isArray(i)?i.flat().map(Po):[Po(i)];if(Array.isArray(i)&&Array.isArray(t)?Rh(t,i):Do((()=>n.length===r.length),s("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Th(r),uh(o),1===n.length)return n[0];const a=new Map;for(const e of $e(0,r.length)){const t=r[e];a.has(t)?a.set(t,a.get(t)+n[e]):a.set(t,n[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of $e(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+o)**t}return h},isExported:!0},yd={description:s("Annual yield of a security paying periodic interest."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("rate (number)",s("The annualized rate of interest.")),ua("price (number)",s("The price at which the security is bought per 100 face value.")),ua("redemption (number)",s("The redemption amount per 100 face value, or par.")),ua("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Lo(e)),c=Math.trunc(Lo(t)),h=Lo(i),d=Lo(o),u=Lo(n),g=Math.trunc(Lo(r)),p=Math.trunc(Lo(a));sh(l,c),ah(g),lh(p),Do((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),hh(d),ch(u);const m=jc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=Mh((function(e){return function(e,t,i,o,n,s){let r=s-(e+n*(1-t))*o**(i-1+t);for(let e=1;e<=i;e++)r+=n*o**(e-1);return r}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,o,n){let s=-(e+n*(1-t))*(i-1+t)*o**(i-2+t);for(let e=1;e<=i;e++)s+=n*(e-1)*o**(e-2);return s}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},xd={description:s("Annual yield of a discount security."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("price (number)",s("The price at which the security is bought per 100 face value.")),ua("redemption (number)",s("The redemption amount per 100 face value, or par.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Lo(e)),r=Math.trunc(Lo(t)),a=Lo(i),l=Lo(o),c=Math.trunc(Lo(n));sh(s,r),lh(c),hh(a),ch(l);return(l/a-1)/jc.compute(e,t,n)},isExported:!0},Id={description:s("Annual yield of a security paying interest at maturity."),args:[ua("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ua("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ua("issue (date)",s("The date the security was initially issued.")),ua("rate (number)",s("The annualized rate of interest.")),ua("price (number)",s("The price at which the security is bought.")),ua("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Lo(e)),l=Math.trunc(Lo(t)),c=Math.trunc(Lo(i)),h=Lo(o),d=Lo(n),u=Math.trunc(Lo(r));sh(a,l),lh(u),Do((()=>a>=c),s("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Do((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),hh(d);const g=jc.compute(c,l,u),p=jc.compute(c,a,u),m=jc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Rd=Object.freeze({__proto__:null,ACCRINTM:Oh,AMORLINC:Nh,COUPDAYS:_h,COUPDAYBS:Fh,COUPDAYSNC:Dh,COUPNCD:kh,COUPNUM:Lh,COUPPCD:Ph,CUMIPMT:Uh,CUMPRINC:Vh,DB:zh,DDB:Bh,DISC:Hh,DOLLARDE:$h,DOLLARFR:Wh,DURATION:Gh,EFFECT:qh,FV:Zh,FVSCHEDULE:jh,INTRATE:Xh,IPMT:Yh,IRR:Kh,ISPMT:Qh,MDURATION:Jh,MIRR:ed,NOMINAL:td,NPER:id,NPV:od,PDURATION:nd,PMT:sd,PPMT:rd,PV:ad,PRICE:ld,PRICEDISC:cd,PRICEMAT:hd,RATE:ud,RECEIVED:gd,RRI:pd,SLN:md,SYD:fd,TBILLPRICE:vd,TBILLEQ:bd,TBILLYIELD:Sd,VDB:Cd,XIRR:Ed,XNPV:wd,YIELD:yd,YIELDDISC:xd,YIELDMAT:Id});const Td={description:s("Whether a value is an error other than #N/A."),args:[ua("value (any, lazy)",s("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},Ad={description:s("Whether a value is an error."),args:[ua("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},Md={description:s("Whether a value is `true` or `false`."),args:[ua("value (any, lazy)",s("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},Od={description:s("Whether a value is the error #N/A."),args:[ua("value (any, lazy)",s("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:s("Whether a value is non-textual."),args:[ua("value (any, lazy)",s("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},_d={description:s("Whether a value is a number."),args:[ua("value (any, lazy)",s("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},Fd={description:s("Whether a value is text."),args:[ua("value (any, lazy)",s("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Dd={description:s("Whether the referenced cell is empty"),args:[ua("value (any, lazy)",s("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},kd={description:s("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Ld=Object.freeze({__proto__:null,ISERR:Td,ISERROR:Ad,ISLOGICAL:Md,ISNA:Od,ISNONTEXT:Nd,ISNUMBER:_d,ISTEXT:Fd,ISBLANK:Dd,NA:kd});const Pd={description:s("Logical `and` operator."),args:[ua("logical_expression1 (boolean, range<boolean>)",s("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.")),ua("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return Yo(e,(e=>(t=!0,i=i&&e,i))),Do((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Ud={description:s("Returns value depending on logical expression."),args:[ua("logical_expression (boolean)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),ua("value_if_true (any, lazy)",s("The value the function returns if logical_expression is TRUE.")),ua("value_if_false (any, lazy, default=FALSE)",s("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,i=(()=>!1)){const o=Bo(e)?t():i();return null==o?"":o},isExported:!0},Vd={description:s("Value if it is not an error, otherwise 2nd argument."),args:[ua("value (any, lazy)",s("The value to return if value itself is not an error.")),ua('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an error."))],returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},zd={description:s("Value if it is not an #N/A error, otherwise 2nd argument."),args:[ua("value (any, lazy)",s("The value to return if value itself is not #N/A an error.")),ua('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(o){i=o.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},Bd={description:s("Returns a value depending on multiple logical expressions."),args:[ua("condition1 (boolean, lazy)",s("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),ua("value1 (any, lazy)",s("The returned value if condition1 is TRUE.")),ua("condition2 (boolean, lazy, repeating)",s("Additional conditions to be evaluated if the previous ones are FALSE.")),ua("value2 (any, lazy, repeating)",s("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){Do((()=>e.length%2==0),s("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if(Bo(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(s("No match."))},isExported:!0},Hd={description:s("Returns opposite of provided logical value."),args:[ua("logical_expression (boolean)",s("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!Bo(e)},isExported:!0},$d={description:s("Logical `or` operator."),args:[ua("logical_expression1 (boolean, range<boolean>)",s("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.")),ua("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Yo(e,(e=>(t=!0,i=i||e,!i))),Do((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Wd={description:s("Logical `xor` operator."),args:[ua("logical_expression1 (boolean, range<boolean>)",s("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.")),ua("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Yo(e,(e=>(t=!0,i=i?!e:e,!0))),Do((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Gd=Object.freeze({__proto__:null,AND:Pd,IF:Ud,IFERROR:Vd,IFNA:zd,IFS:Bd,NOT:Hd,OR:$d,XOR:Wd});function qd(e,t){if(void 0===e)throw new g(s("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Uo(t)))}const Zd={description:s("Column number of a specified cell."),args:[ua("cell_reference (meta, default='this cell')",s("The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Do((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return zi(i).left+1},isExported:!0},jd={description:s("Number of columns in a specified array or range."),args:[ua("range (meta)",s("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=zi(e);return t.right-t.left+1},isExported:!0},Xd={description:s("Horizontal lookup"),args:[ua("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ua("range (range)",s("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),ua("index (number)",s("The row index of the value to be returned, where the first row in range is numbered 1.")),ua("is_sorted (boolean, default=true)",s("Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Lo(i)),r=Vo(e);Do((()=>1<=n&&n<=t[0].length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=Bo(o)?on(t,r,"nextSmaller","asc",t.length,tn):nn(t,r,"strict",t.length,tn);const l=t[a];return qd(l,e),l[n-1]},isExported:!0},Yd={description:s("Look up a value."),args:[ua("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ua("search_array (range)",s("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.")),ua("result_range (range, optional)",s("The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method."))],returns:["ANY"],compute:function(e,t,i){let o=t.length,n=t[0].length;const r=Vo(e),a=n>=o,l=on(t,r,"nextSmaller","asc",a?n:o,a?en:tn);return-1===l&&qd(void 0,e),qd(a?t[0][l]:t[l][n-1],e),void 0===i?a?t[o-1][l]:t[l][n-1]:(o=i.length,n=i[0].length,Do((()=>1===o||1===n),s("The result_range must be a single row or a single column.")),o>1?(Do((()=>l<=o-1),s("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(Do((()=>l<=n-1),s("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},Kd={description:s("Position of item in range that matches value."),args:[ua("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ua("range (any, range)",s("The one-dimensional array to be searched.")),ua("search_type (number, default=1)",s("The search method. 1 (default) finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order."))],returns:["NUMBER"],compute:function(e,t,i=1){let o=Lo(i);const n=Vo(e),r=t.length,a=t[0].length;Do((()=>1===r||1===a),s("The range must be a single row or a single column."));let l=-1;const c=1===r?en:tn,h=1===r?t[0].length:t.length;switch(o=Math.sign(o),o){case 1:l=on(t,n,"nextSmaller","asc",h,c);break;case 0:l=nn(t,n,"strict",h,c);break;case-1:l=on(t,n,"nextGreater","desc",h,c)}return qd(1===r?t[0][l]:t[l],e),l+1},isExported:!0},Qd={description:s("Row number of a specified cell."),args:[ua("cell_reference (meta, default='this cell')",s("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),Do((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return zi(e).top+1},isExported:!0},Jd={description:s("Number of rows in a specified array or range."),args:[ua("range (meta)",s("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=zi(e);return t.bottom-t.top+1},isExported:!0},eu={description:s("Vertical lookup."),args:[ua("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ua("range (any, range)",s("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),ua("index (number)",s("The column index of the value to be returned, where the first column in range is numbered 1.")),ua("is_sorted (boolean, default=true)",s("Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Lo(i)),r=Vo(e);Do((()=>1<=n&&n<=t.length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=Bo(o)?on(t,r,"nextSmaller","asc",t[0].length,en):nn(t,r,"strict",t[0].length,en);const l=t[n-1][a];return qd(l,e),l},isExported:!0},tu={description:s("Search a range for a match and return the corresponding item from a second range."),args:[ua("search_key (any)",s("The value to search for.")),ua("lookup_range (any, range)",s("The range to consider for the search. Should be a single column or a single row.")),ua("return_range (any, range)",s("The range containing the return value. Should have the same dimensions as lookup_range.")),ua("if_not_found (any, lazy, optional)",s("If a valid match is not found, return this value.")),ua("match_mode (any, default=0)",s("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),ua("search_mode (any, default=1)",s("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,i,o,n=0,r=1){const a=Math.trunc(Lo(n)),l=Math.trunc(Lo(r)),c=Vo(e);Do((()=>1===t.length||1===t[0].length),s("lookup_range should be either a single row or single column.")),Do((()=>1===i.length||1===i[0].length),s("return_range should be either a single row or single column.")),Do((()=>i.length===t.length&&i[0].length===t[0].length),s("return_range should have the same dimensions as lookup_range.")),Do((()=>[-1,1,-2,2].includes(l)),s("searchMode should be a value in [-1, 1, -2, 2].")),Do((()=>[-1,0,1].includes(a)),s("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?en:tn,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=on(t,c,u,2===l?"asc":"desc",d,h)}else p=nn(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==o?void 0:o();return qd(m,e),m},isExported:!0};var iu=Object.freeze({__proto__:null,COLUMN:Zd,COLUMNS:jd,HLOOKUP:Xd,LOOKUP:Yd,MATCH:Kd,ROW:Qd,ROWS:Jd,VLOOKUP:eu,XLOOKUP:tu});const ou={description:s("Sum of two numbers."),args:[ua("value1 (number)",s("The first addend.")),ua("value2 (number)",s("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Lo(e)+Lo(t)}},nu={description:s("Concatenation of two values."),args:[ua("value1 (string)",s("The value to which value2 will be appended.")),ua("value2 (string)",s("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return Uo(e)+Uo(t)},isExported:!0},su={description:s("One number divided by another."),args:[ua("dividend (number)",s("The number to be divided.")),ua("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Lo(t);return Do((()=>0!==i),s("The divisor must be different from zero.")),Lo(e)/i}};function ru(e){return null==e}const au={number:0,string:"",boolean:!1},lu={description:s("Equal."),args:[ua("value1 (any)",s("The first value.")),ua("value2 (any)",s("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=ru(e)?au[typeof t]:e,t=ru(t)?au[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function cu(e,t,i){e=ru(e)?au[typeof t]:e,t=ru(t)?au[typeof e]:t,"number"!=typeof e&&(e=Uo(e).toUpperCase()),"number"!=typeof t&&(t=Uo(t).toUpperCase());const o=typeof e,n=typeof t;return"string"===o&&"number"===n||("string"!==n||"number"!==o)&&i(e,t)}const hu={description:s("Strictly greater than."),args:[ua("value1 (any)",s("The value to test as being greater than value2.")),ua("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return cu(e,t,((e,t)=>e>t))}},du={description:s("Greater than or equal to."),args:[ua("value1 (any)",s("The value to test as being greater than or equal to value2.")),ua("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return cu(e,t,((e,t)=>e>=t))}},uu={description:s("Less than."),args:[ua("value1 (any)",s("The value to test as being less than value2.")),ua("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!du.compute(e,t)}},gu={description:s("Less than or equal to."),args:[ua("value1 (any)",s("The value to test as being less than or equal to value2.")),ua("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!hu.compute(e,t)}},pu={description:s("Difference of two numbers."),args:[ua("value1 (number)",s("The minuend, or number to be subtracted from.")),ua("value2 (number)",s("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Lo(e)-Lo(t)}},mu={description:s("Product of two numbers"),args:[ua("factor1 (number)",s("The first multiplicand.")),ua("factor2 (number)",s("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Lo(e)*Lo(t)}},fu={description:s("Not equal."),args:[ua("value1 (any)",s("The first value.")),ua("value2 (any)",s("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!lu.compute(e,t)}},vu={description:s("A number raised to a power."),args:[ua("base (number)",s("The number to raise to the exponent power.")),ua("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return el.compute(e,t)}},bu={description:s("A number with the sign reversed."),args:[ua("value (number)",s("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Lo(e)}},Su={description:s("Value interpreted as a percentage."),args:[ua("percentage (number)",s("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Lo(e)/100}},Cu={description:s("A specified number, unchanged."),args:[ua("value (any)",s("The number to return."))],returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var Eu=Object.freeze({__proto__:null,ADD:ou,CONCAT:nu,DIVIDE:su,EQ:lu,GT:hu,GTE:du,LT:uu,LTE:gu,MINUS:pu,MULTIPLY:mu,NE:fu,POW:vu,UMINUS:bu,UNARY_PERCENT:Su,UPLUS:Cu});const wu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,yu={description:s("Gets character associated with number."),args:[ua("table_number (number)",s("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Lo(e));return Do((()=>t>=1),s("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},xu={description:s("Remove non-printable characters from a piece of text."),args:[ua("text (string)",s("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=Uo(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},Iu={description:s("Appends strings to one another."),args:[ua("string1 (string, range<string>)",s("The initial string.")),ua("string2 (string, range<string>, repeating)",s("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Zo(e,((e,t)=>e+Uo(t)),"")},isExported:!0},Ru={description:s("Tests whether two strings are identical."),args:[ua("string1 (string)",s("The first string to compare.")),ua("string2 (string)",s("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return Uo(e)===Uo(t)},isExported:!0},Tu={description:s("First position of string found in text, case-sensitive."),args:[ua("search_for (string)",s("The string to look for within text_to_search.")),ua("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),ua("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Uo(e),n=Uo(t),r=Lo(i);Do((()=>""!==n),s("The text_to_search must be non-empty.")),Do((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return Do((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o.toString(),n)),a+1},isExported:!0},Au={description:s("Concatenates elements of arrays with delimiter."),args:[ua("delimiter (string)",s("The character or string to place between each concatenated value.")),ua("value_or_array1 (string, range<string>)",s("The value or values to be appended using delimiter.")),ua("value_or_array2 (string, range<string>, repeating)",s("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const i=Uo(e);return Zo(t,((e,t)=>(e?e+i:"")+Uo(t)),"")}},Mu={description:s("Substring from beginning of specified string."),args:[ua("text (string)",s("The string from which the left portion will be returned.")),ua("number_of_characters (number, optional)",s("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Lo(t[0]):1;return Do((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString())),Uo(e).substring(0,i)},isExported:!0},Ou={description:s("Length of a string."),args:[ua("text (string)",s("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return Uo(e).length},isExported:!0},Nu={description:s("Converts a specified string to lowercase."),args:[ua("text (string)",s("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return Uo(e).toLowerCase()},isExported:!0},_u={description:s("A segment of a string."),args:[ua("text (string)",s("The string to extract a segment from.")),ua(" (number)",s("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),ua(" (number)",s("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,i){const o=Uo(e),n=Lo(t),r=Lo(i);return Do((()=>n>=1),s("The starting_at argument (%s) must be positive greater than one.",n.toString())),Do((()=>r>=0),s("The extract_length argument (%s) must be positive or null.",r.toString())),o.slice(n-1,n+r-1)},isExported:!0},Fu={description:s("Capitalizes each word in a specified string."),args:[ua("text_to_capitalize (string)",s("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return Uo(e).replace(wu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Du={description:s("Replaces part of a text string with different text."),args:[ua("text (string)",s("The text, a part of which will be replaced.")),ua("position (number)",s("The position where the replacement will begin (starting from 1).")),ua("length (number)",s("The number of characters in the text to be replaced.")),ua("new_text (string)",s("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,i,o){const n=Lo(t);Do((()=>n>=1),s("The position (%s) must be greater than or equal to 1.",n.toString()));const r=Uo(e),a=Lo(i),l=Uo(o);return r.substring(0,n-1)+l+r.substring(n-1+a)},isExported:!0},ku={description:s("A substring from the end of a specified string."),args:[ua("text (string)",s("The string from which the right portion will be returned.")),ua("number_of_characters (number, optional)",s("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Lo(t[0]):1;Do((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString()));const o=Uo(e),n=o.length;return o.substring(n-i,n)},isExported:!0},Lu={description:s("First position of string found in text, ignoring case."),args:[ua("search_for (string)",s("The string to look for within text_to_search.")),ua("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),ua("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Uo(e).toLowerCase(),n=Uo(t).toLowerCase(),r=Lo(i);Do((()=>""!==n),s("The text_to_search must be non-empty.")),Do((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return Do((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o,n)),a+1},isExported:!0},Pu={description:s("Replaces existing text with new text in a string."),args:[ua("text_to_search (string)",s("The text within which to search and replace.")),ua("search_for (string)",s("The string to search for within text_to_search.")),ua("replace_with (string)",s("The string that will replace search_for.")),ua("occurrence_number (number, optional)",s("The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Lo(o);Do((()=>n>=0),s("The occurrenceNumber (%s) must be positive or null.",n.toString()));const r=Uo(e),a=Uo(t);if(""===a)return r;const l=Uo(i),c=new RegExp(_e(a),"g");if(0===n)return r.replace(c,l);let h=0;return r.replace(c,(e=>++h===n?l:e))},isExported:!0},Uu={description:s("Combines text from multiple strings and/or arrays."),args:[ua("delimiter (string)",s(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),ua("ignore_empty (boolean)",s("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),ua("text1 (string, range<string>)",s("Any text item. This could be a string, or an array of strings in a range.")),ua("text2 (string, range<string>, repeating)",s("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...i){const o=Uo(e),n=Bo(t);let s=0;return Zo(i,((e,t)=>n&&""===Uo(t)?e:(s++?e+o:"")+Uo(t)),"")},isExported:!0},Vu={description:s("Removes space characters."),args:[ua("text (string)",s("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Uo(e).trim()},isExported:!0},zu={description:s("Converts a specified string to uppercase."),args:[ua("text (string)",s("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return Uo(e).toUpperCase()},isExported:!0},Bu={description:s("Converts a number to text according to a specified format."),args:[ua("number (number)",s("The number, date or time to format.")),ua("format (string)",s("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return pi(Lo(e),Uo(t))},isExported:!0};var Hu=Object.freeze({__proto__:null,CHAR:yu,CLEAN:xu,CONCATENATE:Iu,EXACT:Ru,FIND:Tu,JOIN:Au,LEFT:Mu,LEN:Ou,LOWER:Nu,MID:_u,PROPER:Fu,REPLACE:Du,RIGHT:ku,SEARCH:Lu,SUBSTITUTE:Pu,TEXTJOIN:Uu,TRIM:Vu,UPPER:zu,TEXT:Bu});const $u={description:s("Creates a hyperlink in a cell."),args:[ua("url (string)",s("The full URL of the link enclosed in quotation marks.")),ua("link_label (string, optional)",s("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const i=Uo(e).trim(),o=Uo(t)||i;return""===i?o:Ke(o,i)},isExported:!0};var Wu=Object.freeze({__proto__:null,HYPERLINK:$u});const Gu=[{name:s("Database"),functions:yc},{name:s("Date"),functions:ih},{name:s("Financial"),functions:Rd},{name:s("Info"),functions:Ld},{name:s("Lookup"),functions:iu},{name:s("Logical"),functions:Gd},{name:s("Math"),functions:bl},{name:s("Misc"),functions:ma},{name:s("Operator"),functions:Eu},{name:s("Statistical"),functions:lc},{name:s("Text"),functions:Hu},{name:s("Engineering"),functions:nh},{name:s("Web"),functions:Wu}],qu=/^[A-Z0-9\_\.]+$/;function Zu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>ju(e()):ju(e)}))}function ju(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Xu=new class extends xo{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(qu))throw new Error(s("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=ga(t);return function(e){let t=!1,i=!1,o=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(s("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&&!n.repeating)throw new Error(s("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||o,r=!(n.optional||n.repeating||n.default);if(e&&r)throw new Error(s("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,i=n.optional,o=n.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),o=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Zu(e)),format:o(...e)}},super.add(e,i),this}};for(let e of Gu){const t=e.functions;for(let i in t){const o=t[i];o.category=o.category||e.name,i=i.replace(/_/g,"."),Xu.add(i,{isExported:!1,...o})}}function Yu(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(65)&&e.raiseError(Ns)}const Ku=new is;Ku.add("file",{name:s("File"),sequence:10}).add("edit",{name:s("Edit"),sequence:20}).add("view",{name:s("View"),sequence:30}).add("insert",{name:s("Insert"),sequence:40}).add("format",{name:s("Format"),sequence:50}).add("data",{name:s("Data"),sequence:60}).addChild("save",["file"],{name:s("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:s("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:s("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:s("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:kr}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:Lr}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:Pr}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:Br}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:Ur}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:zr}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:ra,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:na}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:sa}).addChild("find_and_replace",["edit"],{name:s("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:s("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:Hr,sequence:80,action:$r,isVisible:e=>Wr("ROW",e)}).addChild("edit_delete_column",["edit"],{name:Gr,sequence:90,action:qr,isVisible:e=>Wr("COL",e)}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:Xr}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:Yr}).addChild("edit_unhide_columns",["edit"],{name:s("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:s("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=_r(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:Kr,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=_r(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:Qr,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Nr(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:Jr,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Nr(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:ea,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:s("Insert cells and shift down"),sequence:43,action:Zr}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:jr,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=e.model.uuidGenerator.uuidv4(),o=t.getActiveSheetId();1===co(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:i+n+Math.max(0,(r-t.width)/2),y:o+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:o,id:i,position:s,size:n,definition:Er(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4(),o=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(s("An unexpected error occurred during the image transfer"))}}(e);if(!o)throw new Error("No image provider was given to the environment");const n=gr(e.model.getters,o.size),r=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-i),c=Math.min(a.height,r.height-o);return{x:i+n+Math.max(0,(l-t.width)/2),y:o+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:i,position:r,size:n,definition:o})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_function",["insert"],{name:s("Function"),sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{name:s("SUM"),action:e=>e.startCellEdition("=SUM("),sequence:0}).addChild("insert_function_average",["insert","insert_function"],{name:s("AVERAGE"),action:e=>e.startCellEdition("=AVERAGE("),sequence:10}).addChild("insert_function_count",["insert","insert_function"],{name:s("COUNT"),action:e=>e.startCellEdition("=COUNT("),sequence:20}).addChild("insert_function_max",["insert","insert_function"],{name:s("MAX"),action:e=>e.startCellEdition("=MAX("),sequence:30}).addChild("insert_function_min",["insert","insert_function"],{name:s("MIN"),action:e=>e.startCellEdition("=MIN("),sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{name:s("All"),sequence:50}).addChild("all_function_list",["insert","insert_function","categorie_function_all"],(()=>Qu(Xu.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=Xu.content;return[...new Set(Xu.getAll().map((e=>e.category)))].filter(ot).sort().map(((t,i)=>{const o=Object.keys(e).filter((i=>e[i].category===t));return{name:t,sequence:60+10*i,children:Qu(o)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:ia}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:s("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:s("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:s("1 row"),action:e=>Yu(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>Yu(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:s("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();Yu(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:s("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:s("1 column"),action:e=>Yu(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>Yu(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:s("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();Yu(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?s("Hide gridlines"):s("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()?s("Hide formulas"):s("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:s("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Ms.Automatic,sequence:10,separator:!0,action:e=>Fr(e,"")}).addChild("format_number_number",["format","format_number"],{name:Ms.Number,description:"1,000.12",sequence:20,action:e=>Fr(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Ms.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>Fr(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Ms.Currency,description:"$1,000.12",sequence:37,action:e=>Fr(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Ms.CurrencyRounded,description:"$1,000",sequence:38,action:e=>Fr(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Ms.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Ms.Date,description:"9/26/2008",sequence:40,action:e=>Fr(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Ms.Time,description:"10:43:00 PM",sequence:50,action:e=>Fr(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Ms.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>Fr(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Ms.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>Fr(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>Dr(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>Dr(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>Dr(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>Dr(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:s("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:s("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>Dr(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>Dr(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>Dr(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>Dr(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>Dr(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>Dr(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:s("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:s("Overflow"),sequence:10,action:e=>Dr(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>Dr(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>Dr(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:ta,separator:!0}).addChild("format_clearFormat",["format"],{name:s("Clear formatting"),sequence:100,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:s("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;Rr(e,t,i)},isVisible:e=>!oa(e),isEnabled:e=>(e=>ho(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:s("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:oa});for(let e of de)Ku.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>Dr(t,{fontSize:e})});function Qu(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const Ju=new class extends xo{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},eg={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function tg(e,t){const i=eg[e.key];e.shiftKey?t.resizeAnchorZone(i,e.ctrlKey?"end":1):t.moveAnchorCell(i,e.ctrlKey?"end":1)}const ig=new Ui;mo`
351
351
  .o-selection {
352
352
  .o-selection-input {
353
353
  display: flex;
@@ -397,7 +397,7 @@
397
397
  font-size: calc(100% + 4px);
398
398
  }
399
399
  }
400
- `;class ig extends t.Component{constructor(){super(...arguments),this.id=tg.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1,mode:"select-range"}),this.focusedInput=t.useRef("focusedInput")}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,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.useEffect((()=>{var e;return null===(e=this.focusedInput.el)||void 0===e?void 0:e.focus()}),(()=>[this.focusedInput.el])),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 i=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,i),this.previousRanges=i}onKeydown(e){if("F2"===e.key)e.preventDefault(),e.stopPropagation(),this.state.mode="select-range"===this.state.mode?"text-edit":"select-range";else if(e.key.startsWith("Arrow"))e.stopPropagation(),"select-range"===this.state.mode&&(e.preventDefault(),eg(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.state.mode="select-range",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,i;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(i=(t=this.props).onSelectionConfirmed)||void 0===i||i.call(t)}onInputChanged(e,t){const i=t.target,o=this.extractRanges(i.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o}),this.triggerChange()}confirm(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const i=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===i.length&&(this.state.isMissing=!0);const o=this.env.model.getters.getActiveSheetId();this.originSheet!==o&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}ig.template="o-spreadsheet-SelectionInput",ig.props={ranges:Array,hasSingleRange:{type:Boolean,optional:!0},required:{type:Boolean,optional:!0},isInvalid:{type:Boolean,optional:!0},class:{type:String,optional:!0},onSelectionChanged:{type:Function,optional:!0},onSelectionConfirmed:{type:Function,optional:!0}};class og 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=>Ts.Errors[e]||Ts.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}og.template="o-spreadsheet-LineBarPieConfigPanel",og.components={SelectionInput:ig},og.props={figureId:String,definition:Object,updateChart:Function};class ng extends og{onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}ng.template="o-spreadsheet-BarConfigPanel";const sg=218,rg=182;function ag(e){return Rt(At({h:360*e.offsetX/sg,s:100,l:100*e.offsetY/rg,a:1}))}po`
400
+ `;class og extends t.Component{constructor(){super(...arguments),this.id=ig.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1,mode:"select-range"}),this.focusedInput=t.useRef("focusedInput")}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,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.useEffect((()=>{var e;return null===(e=this.focusedInput.el)||void 0===e?void 0:e.focus()}),(()=>[this.focusedInput.el])),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 i=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,i),this.previousRanges=i}onKeydown(e){if("F2"===e.key)e.preventDefault(),e.stopPropagation(),this.state.mode="select-range"===this.state.mode?"text-edit":"select-range";else if(e.key.startsWith("Arrow"))e.stopPropagation(),"select-range"===this.state.mode&&(e.preventDefault(),tg(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.state.mode="select-range",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,i;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(i=(t=this.props).onSelectionConfirmed)||void 0===i||i.call(t)}onInputChanged(e,t){const i=t.target,o=this.extractRanges(i.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o}),this.triggerChange()}confirm(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const i=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===i.length&&(this.state.isMissing=!0);const o=this.env.model.getters.getActiveSheetId();this.originSheet!==o&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}og.template="o-spreadsheet-SelectionInput",og.props={ranges:Array,hasSingleRange:{type:Boolean,optional:!0},required:{type:Boolean,optional:!0},isInvalid:{type:Boolean,optional:!0},class:{type:String,optional:!0},onSelectionChanged:{type:Function,optional:!0},onSelectionConfirmed:{type:Function,optional:!0}};class ng 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=>As.Errors[e]||As.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}ng.template="o-spreadsheet-LineBarPieConfigPanel",ng.components={SelectionInput:og},ng.props={figureId:String,definition:Object,updateChart:Function};class sg extends ng{onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}sg.template="o-spreadsheet-BarConfigPanel";const rg=218,ag=182;function lg(e){return Tt(Mt({h:360*e.offsetX/rg,s:100,l:100*e.offsetY/ag,a:1}))}mo`
401
401
  .o-color-picker {
402
402
  padding: ${6}px 0px;
403
403
  box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
@@ -405,7 +405,7 @@
405
405
  line-height: 1.2;
406
406
  overflow-y: auto;
407
407
  overflow-x: hidden;
408
- width: ${sg+12}px;
408
+ width: ${rg+12}px;
409
409
 
410
410
  .o-color-picker-section-name {
411
411
  margin: 0px ${1}px;
@@ -506,8 +506,8 @@
506
506
  hsl(1turn 100% 50%) 100%
507
507
  );
508
508
  border: ${1}px solid #c0c0c0;
509
- width: ${sg}px;
510
- height: ${rg}px;
509
+ width: ${rg}px;
510
+ height: ${ag}px;
511
511
  &:hover {
512
512
  cursor: crosshair;
513
513
  }
@@ -534,7 +534,7 @@
534
534
  width: 30px;
535
535
  height: 30px;
536
536
  }
537
- `;class lg extends t.Component{constructor(){super(...arguments),this.COLORS=O,this.state=t.useState({showGradient:!1,currentColor:wt(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?bo({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}onColorClick(e){e&&this.props.onColorPicked(Et(e))}getCheckMarkColor(){return Ss(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!wt(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);const t=Et(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=ag(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=ag(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:i,top:o}=this.state.style;return bo({display:e,"background-color":"block"===e?t:void 0,left:i,top:o})}isSameColor(e,t){return function(e,t){return wt(e)&&wt(t)&&Et(e)===Et(t)}(e,t)}}lg.template="o-spreadsheet-ColorPicker",lg.defaultProps={currentColor:""},lg.components={Popover:Gn},lg.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},po`
537
+ `;class cg extends t.Component{constructor(){super(...arguments),this.COLORS=O,this.state=t.useState({showGradient:!1,currentColor:yt(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?So({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}onColorClick(e){e&&this.props.onColorPicked(wt(e))}getCheckMarkColor(){return Cs(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!yt(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);const t=wt(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=lg(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=lg(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:i,top:o}=this.state.style;return So({display:e,"background-color":"block"===e?t:void 0,left:i,top:o})}isSameColor(e,t){return function(e,t){return yt(e)&&yt(t)&&wt(e)===wt(t)}(e,t)}}cg.template="o-spreadsheet-ColorPicker",cg.defaultProps={currentColor:""},cg.components={Popover:qn},cg.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},mo`
538
538
  .o-color-picker-widget {
539
539
  display: inline-block;
540
540
  position: relative;
@@ -565,7 +565,7 @@
565
565
  }
566
566
  }
567
567
  }
568
- `;class cg extends t.Component{constructor(){super(...arguments),this.colorPickerButtonRef=t.useRef("colorPickerButton")}get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:"border-bottom-style: hidden"}get colorPickerAnchorRect(){const e=this.colorPickerButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}}cg.template="o-spreadsheet-ColorPickerWidget",cg.components={ColorPicker:lg},cg.props={currentColor:{type:String,optional:!0},toggleColorPicker:Function,showColorPicker:Boolean,onColorPicked:Function,icon:String,title:{type:String,optional:!0},disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};class hg 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(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}hg.template="o-spreadsheet-LineBarPieDesignPanel",hg.components={ColorPickerWidget:cg},hg.props={figureId:String,definition:Object,updateChart:Function};class dg extends hg{}dg.template="o-spreadsheet-BarChartDesignPanel";class ug 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=>Ts.Errors[e]||Ts.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}}ug.template="o-spreadsheet-GaugeChartConfigPanel",ug.components={SelectionInput:ig},ug.props={figureId:String,definition:Object,updateChart:Function},po`
568
+ `;class hg extends t.Component{constructor(){super(...arguments),this.colorPickerButtonRef=t.useRef("colorPickerButton")}get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:"border-bottom-style: hidden"}get colorPickerAnchorRect(){const e=this.colorPickerButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}}hg.template="o-spreadsheet-ColorPickerWidget",hg.components={ColorPicker:cg},hg.props={currentColor:{type:String,optional:!0},toggleColorPicker:Function,showColorPicker:Boolean,onColorPicked:Function,icon:String,title:{type:String,optional:!0},disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};class dg 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(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}dg.template="o-spreadsheet-LineBarPieDesignPanel",dg.components={ColorPickerWidget:hg},dg.props={figureId:String,definition:Object,updateChart:Function};class ug extends dg{}ug.template="o-spreadsheet-BarChartDesignPanel";class gg 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=>As.Errors[e]||As.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}}gg.template="o-spreadsheet-GaugeChartConfigPanel",gg.components={SelectionInput:og},gg.props={figureId:String,definition:Object,updateChart:Function},mo`
569
569
  .o-gauge-color-set {
570
570
  table {
571
571
  table-layout: fixed;
@@ -595,7 +595,7 @@
595
595
  box-sizing: border-box;
596
596
  }
597
597
  }
598
- `;class gg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Ts.Errors[e]||Ts.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}isRangeMinInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(37))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(38))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}isRangeMaxInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(39))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(40))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}get isLowerInflectionPointInvalid(){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(44)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(43))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(44)))}updateInflectionPointValue(e,t){const i=_e(this.props.definition.sectionRule);i[e].value=t.target.value,this.updateSectionRule(i)}updateInflectionPointType(e,t){const i=_e(this.props.definition.sectionRule);i[e].type=t.target.value,this.updateSectionRule(i)}updateSectionColor(e,t){const i=_e(this.props.definition.sectionRule);i.colors[e]=t,this.updateSectionRule(i),this.closeMenus()}updateRangeMin(e){let t=_e(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=_e(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(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}gg.template="o-spreadsheet-GaugeChartDesignPanel",gg.components={ColorPickerWidget:cg},gg.props={figureId:String,definition:Object,updateChart:Function};class pg extends og{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Ks)&&Qs(e.labelRange,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart(this.props.figureId,{labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}onUpdateCumulative(e){this.props.updateChart(this.props.figureId,{cumulative:e.target.checked})}}pg.template="o-spreadsheet-LineConfigPanel";class mg extends hg{}mg.template="o-spreadsheet-LineChartDesignPanel";class fg 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=>Ts.Errors[e]||Ts.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}fg.template="o-spreadsheet-ScorecardChartConfigPanel",fg.components={SelectionInput:ig},fg.props={figureId:String,definition:Object,updateChart:Function};class vg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}toggleColorPicker(e){this.state.openedColorPicker===e?this.state.openedColorPicker=void 0:this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart(this.props.figureId,{background:e});break;case"baselineColorDown":this.props.updateChart(this.props.figureId,{baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart(this.props.figureId,{baselineColorUp:e})}this.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}vg.template="o-spreadsheet-ScorecardChartDesignPanel",vg.components={ColorPickerWidget:cg},vg.props={figureId:String,definition:Object,updateChart:Function};const bg=new yo;bg.add("line",{configuration:pg,design:mg}).add("bar",{configuration:ng,design:dg}).add("pie",{configuration:og,design:hg}).add("gauge",{configuration:ug,design:gg}).add("scorecard",{configuration:fg,design:vg}),po`
598
+ `;class pg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>As.Errors[e]||As.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}isRangeMinInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(37))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(38))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}isRangeMaxInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(39))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(40))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}get isLowerInflectionPointInvalid(){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(44)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(43))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(44)))}updateInflectionPointValue(e,t){const i=Fe(this.props.definition.sectionRule);i[e].value=t.target.value,this.updateSectionRule(i)}updateInflectionPointType(e,t){const i=Fe(this.props.definition.sectionRule);i[e].type=t.target.value,this.updateSectionRule(i)}updateSectionColor(e,t){const i=Fe(this.props.definition.sectionRule);i.colors[e]=t,this.updateSectionRule(i),this.closeMenus()}updateRangeMin(e){let t=Fe(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=Fe(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(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}pg.template="o-spreadsheet-GaugeChartDesignPanel",pg.components={ColorPickerWidget:hg},pg.props={figureId:String,definition:Object,updateChart:Function};class mg extends ng{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Qs)&&Js(e.labelRange,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart(this.props.figureId,{labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}onUpdateCumulative(e){this.props.updateChart(this.props.figureId,{cumulative:e.target.checked})}}mg.template="o-spreadsheet-LineConfigPanel";class fg extends dg{}fg.template="o-spreadsheet-LineChartDesignPanel";class vg 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=>As.Errors[e]||As.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}vg.template="o-spreadsheet-ScorecardChartConfigPanel",vg.components={SelectionInput:og},vg.props={figureId:String,definition:Object,updateChart:Function};class bg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}toggleColorPicker(e){this.state.openedColorPicker===e?this.state.openedColorPicker=void 0:this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart(this.props.figureId,{background:e});break;case"baselineColorDown":this.props.updateChart(this.props.figureId,{baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart(this.props.figureId,{baselineColorUp:e})}this.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}bg.template="o-spreadsheet-ScorecardChartDesignPanel",bg.components={ColorPickerWidget:hg},bg.props={figureId:String,definition:Object,updateChart:Function};const Sg=new xo;Sg.add("line",{configuration:mg,design:fg}).add("bar",{configuration:sg,design:ug}).add("pie",{configuration:ng,design:dg}).add("gauge",{configuration:gg,design:pg}).add("scorecard",{configuration:vg,design:bg}),mo`
599
599
  .o-chart {
600
600
  .o-panel {
601
601
  display: flex;
@@ -618,7 +618,7 @@
618
618
  }
619
619
  }
620
620
  }
621
- `;class Sg extends t.Component{get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(s("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId&&(this.state.figureId=e),this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e,t){if(e!==this.figureId)return;const i={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:i,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const i=function(e,t){return ar.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:i,id:this.figureId,sheetId:this.env.model.getters.getFigureSheetId(this.figureId)})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=bg.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 ar.getKeys())e[t]=ar.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Sg.template="o-spreadsheet-ChartPanel",Sg.props={onCloseSidePanel:Function};function Cg(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 Eg={arrowGood:{template:"ARROW_UP",img:Cg('<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:Cg('<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:Cg('<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:Cg('<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:Cg('<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:Cg('<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:Cg('<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:Cg('<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:Cg('<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>')}},wg={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};po`
621
+ `;class Cg extends t.Component{get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(s("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId&&(this.state.figureId=e),this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e,t){if(e!==this.figureId)return;const i={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:i,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const i=function(e,t){return lr.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:i,id:this.figureId,sheetId:this.env.model.getters.getFigureSheetId(this.figureId)})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=Sg.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 lr.getKeys())e[t]=lr.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Cg.template="o-spreadsheet-ChartPanel",Cg.props={onCloseSidePanel:Function};function Eg(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 wg={arrowGood:{template:"ARROW_UP",img:Eg('<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:Eg('<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:Eg('<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:Eg('<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:Eg('<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:Eg('<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:Eg('<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:Eg('<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:Eg('<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>')}},yg={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};mo`
622
622
  .o-icon-picker {
623
623
  position: absolute;
624
624
  z-index: ${ce.IconPicker};
@@ -637,7 +637,7 @@
637
637
  outline: 1px solid gray;
638
638
  }
639
639
  }
640
- `;class yg extends t.Component{constructor(){super(...arguments),this.icons=Eg,this.iconSets=wg}onIconClick(e){e&&this.props.onIconPicked(e)}}yg.template="o-spreadsheet-IconPicker",yg.props={onIconPicked:Function},po`
640
+ `;class xg extends t.Component{constructor(){super(...arguments),this.icons=wg,this.iconSets=yg}onIconClick(e){e&&this.props.onIconPicked(e)}}xg.template="o-spreadsheet-IconPicker",xg.props={onIconPicked:Function},mo`
641
641
  label {
642
642
  vertical-align: middle;
643
643
  }
@@ -907,13 +907,13 @@
907
907
  }
908
908
  }
909
909
  }
910
- `;class xg extends t.Component{constructor(){super(...arguments),this.icons=Eg,this.cellIsOperators=Rs,this.iconSets=wg,this.getTextDecoration=mo,this.colorNumberString=Ct}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(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[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(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[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 Is.Errors[e]||Is.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 bo({"font-weight":e.style.bold?"bold":"normal","text-decoration":mo(e.style),"font-style":e.style.italic?"italic":"normal",color:e.style.textColor||"none","background-color":e.style.fillColor||"none"});if("ColorScaleRule"===e.type){const t=Ct(e.minimum.color),i=e.midpoint?Ct(e.midpoint.color):null,o=Ct(e.maximum.color),n="background-image: linear-gradient(to right, ";return i?n+t+", "+i+", "+o+")":n+t+", "+o+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Rs[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?n("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Is.ColorScale;case"IconSetRule":return Is.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(kt))))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(51))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(52))}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(58)||this.state.errors.includes(50)||this.state.errors.includes(47)||this.state.errors.includes(53);case"midpoint":return this.state.errors.includes(59)||this.state.errors.includes(54)||this.state.errors.includes(49);case"maximum":return this.state.errors.includes(60)||this.state.errors.includes(55);default:return!1}}setColorScaleColor(e,t){const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=Ct(t.minimum.color),o=Ct((null===(e=t.midpoint)||void 0===e?void 0:e.color)||x),n=Ct(t.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===t.midpoint?s+i+", "+n+")":s+i+", "+o+", "+n+")"}getThresholdColor(e){return Ct(e?e.color:x)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:x,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(48);case"upperInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(48);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}}xg.template="o-spreadsheet-ConditionalFormattingPanel",xg.components={SelectionInput:ig,IconPicker:yg,ColorPickerWidget:cg},xg.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},po`
910
+ `;class Ig extends t.Component{constructor(){super(...arguments),this.icons=wg,this.cellIsOperators=Ts,this.iconSets=yg,this.getTextDecoration=fo,this.colorNumberString=Et}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(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[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(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[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 Rs.Errors[e]||Rs.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 So({"font-weight":e.style.bold?"bold":"normal","text-decoration":fo(e.style),"font-style":e.style.italic?"italic":"normal",color:e.style.textColor||"none","background-color":e.style.fillColor||"none"});if("ColorScaleRule"===e.type){const t=Et(e.minimum.color),i=e.midpoint?Et(e.midpoint.color):null,o=Et(e.maximum.color),n="background-image: linear-gradient(to right, ";return i?n+t+", "+i+", "+o+")":n+t+", "+o+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=Ts[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?n("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Rs.ColorScale;case"IconSetRule":return Rs.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Lt))))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(51))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(52))}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(58)||this.state.errors.includes(50)||this.state.errors.includes(47)||this.state.errors.includes(53);case"midpoint":return this.state.errors.includes(59)||this.state.errors.includes(54)||this.state.errors.includes(49);case"maximum":return this.state.errors.includes(60)||this.state.errors.includes(55);default:return!1}}setColorScaleColor(e,t){const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=Et(t.minimum.color),o=Et((null===(e=t.midpoint)||void 0===e?void 0:e.color)||x),n=Et(t.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===t.midpoint?s+i+", "+n+")":s+i+", "+o+", "+n+")"}getThresholdColor(e){return Et(e?e.color:x)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:x,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(48);case"upperInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(48);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}}Ig.template="o-spreadsheet-ConditionalFormattingPanel",Ig.components={SelectionInput:og,IconPicker:xg,ColorPickerWidget:hg},Ig.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},mo`
911
911
  .o-custom-currency {
912
912
  .o-format-proposals {
913
913
  color: black;
914
914
  }
915
915
  }
916
- `;class Ig 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),i=e.position,o="before"===e.position?"after":"before",n=this.state.currencySymbol.trim()?this.state.currencySymbol:"",s=this.state.currencyCode.trim()?this.state.currencyCode:"";return s||n?[...this.createFormatProposals(t,n,s,i),...this.createFormatProposals(t,n,s,o)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===cr.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{cr.add(t.toString(),e)}))}const i={name:this.env._t(Ms.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[i,...cr.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const i=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=i.code,this.state.currencySymbol=i.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"}],i=e?"."+"0".repeat(e):"";return i&&t.push({format:"#,##0"+i,example:"1,000"+i}),t}createFormatProposals(e,t,i,o){let n=[];if(t)for(let i of e)n.push(this.createFormatProposal(o,i.example,i.format,t));if(i)for(let s of e){const e=("after"===o?" ":"")+i+" "+t;n.push(this.createFormatProposal(o,s.example,s.format,e))}return n}createFormatProposal(e,t,i,o){const n="[$"+o+"]";return{example:"before"===e?o+t:t+o,format:"before"===e?n+i:i+n}}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),i=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),o=i[0].format;return i.every((e=>e.format===o))?o:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}Ig.template="o-spreadsheet-CustomCurrencyPanel",Ig.props={onCloseSidePanel:Function},po`
916
+ `;class Rg 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),i=e.position,o="before"===e.position?"after":"before",n=this.state.currencySymbol.trim()?this.state.currencySymbol:"",s=this.state.currencyCode.trim()?this.state.currencyCode:"";return s||n?[...this.createFormatProposals(t,n,s,i),...this.createFormatProposals(t,n,s,o)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===hr.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{hr.add(t.toString(),e)}))}const i={name:this.env._t(Os.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[i,...hr.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const i=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=i.code,this.state.currencySymbol=i.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"}],i=e?"."+"0".repeat(e):"";return i&&t.push({format:"#,##0"+i,example:"1,000"+i}),t}createFormatProposals(e,t,i,o){let n=[];if(t)for(let i of e)n.push(this.createFormatProposal(o,i.example,i.format,t));if(i)for(let s of e){const e=("after"===o?" ":"")+i+" "+t;n.push(this.createFormatProposal(o,s.example,s.format,e))}return n}createFormatProposal(e,t,i,o){const n="[$"+o+"]";return{example:"before"===e?o+t:t+o,format:"before"===e?n+i:i+n}}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),i=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),o=i[0].format;return i.every((e=>e.format===o))?o:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}Rg.template="o-spreadsheet-CustomCurrencyPanel",Rg.props={onCloseSidePanel:Function},mo`
917
917
  .o-find-and-replace {
918
918
  .o-far-item {
919
919
  display: block;
@@ -946,7 +946,7 @@
946
946
  }
947
947
  }
948
948
  }
949
- `;class Rg 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()}get pendingSearch(){return void 0!==this.debounceTimeoutId}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{clearTimeout(this.debounceTimeoutId),this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})})),t.useEffect((()=>{this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.searchFormulas()}),(()=>[this.env.model.getters.shouldShowFormulas()]))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.replace())}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.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),200)}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}}}}Rg.template="o-spreadsheet-FindAndReplacePanel",Rg.props={onCloseSidePanel:Function};const Tg=new yo;Tg.add("ConditionalFormatting",{title:s("Conditional formatting"),Body:xg}),Tg.add("ChartPanel",{title:s("Chart"),Body:Sg}),Tg.add("FindAndReplace",{title:s("Find and Replace"),Body:Rg}),Tg.add("CustomCurrency",{title:s("Custom currency format"),Body:Ig});const Ag=new class extends yo{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new Pi}add(e,t){const i={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,i)}};po`
949
+ `;class Tg 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()}get pendingSearch(){return void 0!==this.debounceTimeoutId}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{clearTimeout(this.debounceTimeoutId),this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})})),t.useEffect((()=>{this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.searchFormulas()}),(()=>[this.env.model.getters.shouldShowFormulas()]))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.replace())}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.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),200)}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}}}}Tg.template="o-spreadsheet-FindAndReplacePanel",Tg.props={onCloseSidePanel:Function};const Ag=new xo;Ag.add("ConditionalFormatting",{title:s("Conditional formatting"),Body:Ig}),Ag.add("ChartPanel",{title:s("Chart"),Body:Cg}),Ag.add("FindAndReplace",{title:s("Find and Replace"),Body:Tg}),Ag.add("CustomCurrency",{title:s("Custom currency format"),Body:Rg});const Mg=new class extends xo{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new Ui}add(e,t){const i={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,i)}};mo`
950
950
  div.o-figure {
951
951
  box-sizing: border-box;
952
952
  position: absolute;
@@ -1019,7 +1019,7 @@
1019
1019
  }
1020
1020
  }
1021
1021
  }
1022
- `;class Mg extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.figureRef=t.useRef("figure"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=Hn(this.menuButtonRef)}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return gr}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:o}=this.props.figure;return bo({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${o}px`,"z-index":String(ce.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)",bo(t)}setup(){const e=gr.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}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.stopPropagation(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const i={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+i[0],y:t.y+i[1]}),e.stopPropagation(),e.preventDefault()}}onContextMenu(e){if(this.env.isDashboard())return;const t={x:e.clientX,y:e.clientY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:i}=this.menuButtonRect,o={x:e>=$?e-$:e+i,y:t};this.openContextMenu(o)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e,this.menuState.menuItems=gr.get(this.props.figure.tag).menuBuilder(this.props.figure.id,this.props.onFigureDeleted,this.env)}}function Og(e,t,i=(()=>{})){const o=s=>{t(s),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",o),window.removeEventListener("dragstart",n),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function n(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",o),window.addEventListener("dragstart",n),window.addEventListener("mousemove",e),window.addEventListener("wheel",e,{passive:!1})}function Ng(e,t,i,o=!1){let n,s,r,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Un();let g,p;const m=i=>{if(n=i,c)return;const{x:r,y:f}=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 I=!1,R=Gt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=s.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.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-r}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=s.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.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-f}}I||(-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,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),s=n};Og(m,(()=>{clearTimeout(c),i()}),(e=>{s=e,r=e,a=r.clientX-u.left,l=r.clientY-u.top}))}Mg.template="o-spreadsheet-FigureComponent",Mg.components={Menu:Xn},Mg.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},Mg.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}},po`
1022
+ `;class Og extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.figureRef=t.useRef("figure"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=$n(this.menuButtonRef)}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return pr}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:o}=this.props.figure;return So({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${o}px`,"z-index":String(ce.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)",So(t)}setup(){const e=pr.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}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.stopPropagation(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const i={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+i[0],y:t.y+i[1]}),e.stopPropagation(),e.preventDefault()}}onContextMenu(e){if(this.env.isDashboard())return;const t={x:e.clientX,y:e.clientY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:i}=this.menuButtonRect,o={x:e>=$?e-$:e+i,y:t};this.openContextMenu(o)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e,this.menuState.menuItems=pr.get(this.props.figure.tag).menuBuilder(this.props.figure.id,this.props.onFigureDeleted,this.env)}}function Ng(e,t,i=(()=>{})){const o=s=>{t(s),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",o),window.removeEventListener("dragstart",n),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function n(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",o),window.addEventListener("dragstart",n),window.addEventListener("mousemove",e),window.addEventListener("wheel",e,{passive:!1})}function _g(e,t,i,o=!1){let n,s,r,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Vn();let g,p;const m=i=>{if(n=i,c)return;const{x:r,y:f}=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 I=!1,R=qt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=s.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.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-r}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=s.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.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-f}}I||(-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,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),s=n};Ng(m,(()=>{clearTimeout(c),i()}),(e=>{s=e,r=e,a=r.clientX-u.left,l=r.clientY-u.top}))}Og.template="o-spreadsheet-FigureComponent",Og.components={Menu:Yn},Og.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},Og.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}},mo`
1023
1023
  .o-autofill {
1024
1024
  position: absolute;
1025
1025
  height: ${8}px;
@@ -1047,9 +1047,9 @@
1047
1047
  pointer-events: none;
1048
1048
  white-space: nowrap;
1049
1049
  }
1050
- `;class _g 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 bo({top:`${t}px`,left:`${e}px`,visibility:this.props.isVisible?"visible":"hidden"})}get handlerStyle(){const{left:e,top:t}=this.state.handler?this.state.position:this.props.position;return bo({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return bo({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=Fg),e}onMouseDown(e){let t,i;this.state.handler=!0;const o=e.clientX-this.props.position.left,n=e.clientY-this.props.position.top;Ng(this.env,((e,s,r)=>{if(this.state.position={left:r.clientX-o,top:r.clientY-n},t!==e||i!==s){const o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getNumberCols(o),r=this.env.model.getters.getNumberRows(o);t=-1===e?t:ke(e,0,n),i=-1===s?i:ke(s,0,r),void 0!==t&&void 0!==i&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:i})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}_g.template="o-spreadsheet-Autofill",_g.props={position:Object,isVisible:Boolean};class Fg extends t.Component{}Fg.template=t.xml`
1050
+ `;class Fg 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 So({top:`${t}px`,left:`${e}px`,visibility:this.props.isVisible?"visible":"hidden"})}get handlerStyle(){const{left:e,top:t}=this.state.handler?this.state.position:this.props.position;return So({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return So({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=Dg),e}onMouseDown(e){let t,i;this.state.handler=!0;const o=e.clientX-this.props.position.left,n=e.clientY-this.props.position.top;_g(this.env,((e,s,r)=>{if(this.state.position={left:r.clientX-o,top:r.clientY-n},t!==e||i!==s){const o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getNumberCols(o),r=this.env.model.getters.getNumberRows(o);t=-1===e?t:Le(e,0,n),i=-1===s?i:Le(s,0,r),void 0!==t&&void 0!==i&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:i})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}Fg.template="o-spreadsheet-Autofill",Fg.props={position:Object,isVisible:Boolean};class Dg extends t.Component{}Dg.template=t.xml`
1051
1051
  <div t-esc="props.content"/>
1052
- `,Fg.props={content:String},po`
1052
+ `,Dg.props={content:String},mo`
1053
1053
  .o-client-tag {
1054
1054
  position: absolute;
1055
1055
  border-top-left-radius: 4px;
@@ -1059,7 +1059,7 @@
1059
1059
  opacity: 0;
1060
1060
  pointer-events: none;
1061
1061
  }
1062
- `;class Dg extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:o}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:n,y:s}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return bo({bottom:o-s+15+"px",left:n-1+"px",border:`1px solid ${i}`,"background-color":i,opacity:this.props.active?"opacity:1 !important":void 0})}}Dg.template="o-spreadsheet-ClientTag",Dg.props={active:Boolean,name:String,color:String,col:Number,row:Number},po`
1062
+ `;class kg extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:o}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:n,y:s}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return So({bottom:o-s+15+"px",left:n-1+"px",border:`1px solid ${i}`,"background-color":i,opacity:this.props.active?"opacity:1 !important":void 0})}}kg.template="o-spreadsheet-ClientTag",kg.props={active:Boolean,name:String,color:String,col:Number,row:Number},mo`
1063
1063
  .o-autocomplete-dropdown {
1064
1064
  pointer-events: auto;
1065
1065
  background-color: #fff;
@@ -1078,7 +1078,7 @@
1078
1078
  }
1079
1079
  }
1080
1080
  }
1081
- `;class kg extends t.Component{}kg.template="o-spreadsheet-TextValueProvider",kg.props={values:Array,selectedIndex:Number,onValueSelected:Function};class Lg{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let i=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),i.addRange(o);else{const n=this.getText().length;(e<0||t>n)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${n}`),e<0&&(e=0),t>n&&(t=n),e>n&&(e=n));let s=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);o.setStart(s.node,s.offset),i.addRange(o),i.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,i,o=zn(this.el),n=e,s=!0;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<n?n-=t.value.textContent.length:t.value.textContent&&t.value.textContent.length>=n&&o.return(t.value),i=t.value),t.done||"P"!==t.value.nodeName||(s?s=!1:n--)}while(!t.done&&n);return t.value?{node:t.value,offset:n}:{node:i,offset:n}}setText(e){if(this.el.innerHTML="",0!==e.length)for(const t of e){const e=document.createElement("p");if(0===t.length||t.every((e=>!e.value&&!e.class)))e.appendChild(document.createElement("br")),this.el.appendChild(e);else{for(const i of t){if(!i.value&&!i.class)continue;const t=document.createElement("span");t.innerText=i.value,t.style.color=i.color||"",i.class&&t.classList.add(i.class),e.appendChild(t)}this.el.appendChild(e)}}}scrollSelectionIntoView(){var e;const t=null===(e=document.getSelection())||void 0===e?void 0:e.focusNode;if(!t||!this.el.contains(t))return;const i=t instanceof HTMLElement?t:t.parentElement;null==i||i.scrollIntoView({block:"nearest"})}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:i,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,i),end:this.findSelectionIndex(t,o)}}findSelectionIndex(e,t){let i=0,o=zn(this.el),n=o.next(),s=!0;for(;!n.done&&n.value!==e;)n.value.hasChildNodes()||n.value.textContent&&(i+=n.value.textContent.length),("P"===n.value.nodeName||"DIV"===n.value.nodeName&&n.value!==this.el)&&(s?s=!1:i++),n=o.next();if(n.value!==e)return 0;if(n.value.hasChildNodes()){const e=[...n.value.childNodes].slice(0,t);i+=e.reduce(((t,i,o)=>{if(null!==i.textContent){let n=i.textContent.length;return"P"===i.nodeName&&o!==e.length-1&&n++,t+n}return t}),0)}else i+=t;return"P"!==e.nodeName||s||""!=e.textContent||i++,i}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}getText(){let e="",t=zn(this.el),i=t.next(),o=!0;for(;!i.done;)i.value.hasChildNodes()||(e+=i.value.textContent),("P"===i.value.nodeName||"DIV"===i.value.nodeName&&i.value!==this.el)&&(o?o=!1:e+=he),i=t.next();return e}}po`
1081
+ `;class Lg extends t.Component{}Lg.template="o-spreadsheet-TextValueProvider",Lg.props={values:Array,selectedIndex:Number,onValueSelected:Function};class Pg{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let i=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),i.addRange(o);else{const n=this.getText().length;(e<0||t>n)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${n}`),e<0&&(e=0),t>n&&(t=n),e>n&&(e=n));let s=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);o.setStart(s.node,s.offset),i.addRange(o),i.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,i,o=Bn(this.el),n=e,s=!0;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<n?n-=t.value.textContent.length:t.value.textContent&&t.value.textContent.length>=n&&o.return(t.value),i=t.value),t.done||"P"!==t.value.nodeName||(s?s=!1:n--)}while(!t.done&&n);return t.value?{node:t.value,offset:n}:{node:i,offset:n}}setText(e){if(this.el.innerHTML="",0!==e.length)for(const t of e){const e=document.createElement("p");if(0===t.length||t.every((e=>!e.value&&!e.class)))e.appendChild(document.createElement("br")),this.el.appendChild(e);else{for(const i of t){if(!i.value&&!i.class)continue;const t=document.createElement("span");t.innerText=i.value,t.style.color=i.color||"",i.class&&t.classList.add(i.class),e.appendChild(t)}this.el.appendChild(e)}}}scrollSelectionIntoView(){var e;const t=null===(e=document.getSelection())||void 0===e?void 0:e.focusNode;if(!t||!this.el.contains(t))return;const i=t instanceof HTMLElement?t:t.parentElement;null==i||i.scrollIntoView({block:"nearest"})}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:i,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,i),end:this.findSelectionIndex(t,o)}}findSelectionIndex(e,t){let i=0,o=Bn(this.el),n=o.next(),s=!0;for(;!n.done&&n.value!==e;)n.value.hasChildNodes()||n.value.textContent&&(i+=n.value.textContent.length),("P"===n.value.nodeName||"DIV"===n.value.nodeName&&n.value!==this.el)&&(s?s=!1:i++),n=o.next();if(n.value!==e)return 0;if(n.value.hasChildNodes()){const e=[...n.value.childNodes].slice(0,t);i+=e.reduce(((t,i,o)=>{if(null!==i.textContent){let n=i.textContent.length;return"P"===i.nodeName&&o!==e.length-1&&n++,t+n}return t}),0)}else i+=t;return"P"!==e.nodeName||s||""!=e.textContent||i++,i}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}getText(){let e="",t=Bn(this.el),i=t.next(),o=!0;for(;!i.done;)i.value.hasChildNodes()||(e+=i.value.textContent),("P"===i.value.nodeName||"DIV"===i.value.nodeName&&i.value!==this.el)&&(o?o=!1:e+=he),i=t.next();return e}}mo`
1082
1082
  .o-formula-assistant {
1083
1083
  .o-formula-assistant-head {
1084
1084
  background-color: #f2f2f2;
@@ -1104,7 +1104,7 @@
1104
1104
  color: gray;
1105
1105
  }
1106
1106
  }
1107
- `;class Pg 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)}}Pg.template="o-spreadsheet-FunctionDescriptionProvider",Pg.props={functionName:String,functionDescription:Object,argToFocus:Number};const Ug=ju.content,Vg="selector-flag",zg="#4a4e4d",Bg="#3da4ab",Hg={OPERATOR:Bg,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:zg,DEBUGGER:Bg,LEFT_PAREN:zg,RIGHT_PAREN:zg,COMMA:zg,MATCHING_PAREN:"#000000"};po`
1107
+ `;class Ug 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)}}Ug.template="o-spreadsheet-FunctionDescriptionProvider",Ug.props={functionName:String,functionDescription:Object,argToFocus:Number};const Vg=Xu.content,zg="selector-flag",Bg="#4a4e4d",Hg="#3da4ab",$g={OPERATOR:Hg,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:Bg,DEBUGGER:Hg,LEFT_PAREN:Bg,RIGHT_PAREN:Bg,COMMA:Bg,MATCHING_PAREN:"#000000"};mo`
1108
1108
  .o-composer-container {
1109
1109
  .o-composer {
1110
1110
  overflow-y: auto;
@@ -1129,7 +1129,7 @@
1129
1129
 
1130
1130
  span {
1131
1131
  white-space: pre-wrap;
1132
- &.${Vg}:after {
1132
+ &.${zg}:after {
1133
1133
  content: "${"␣"}";
1134
1134
  color: ${"#a9a9a9"};
1135
1135
  }
@@ -1143,12 +1143,12 @@
1143
1143
  pointer-events: none;
1144
1144
  }
1145
1145
  }
1146
- `;class $g extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Lg(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0}),this.functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,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:i}=this.props.rect;let o={};return t>this.props.delimitation.height-(t+i)&&(o.top="-3px",o.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(o.right="0px"),o.width="300px",bo(o)}return bo({width:"300px"})}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent(),this.contentHelper.scrollSelectionIntoView()})),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,e.preventDefault(),e.stopPropagation(),void eg(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length),this.updateCursorIfNeeded()}processTabKey(e){var t;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const i=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(i,1)}processEnterKey(e){var t;if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey){const e=this.contentHelper.getCurrentSelection(),t=this.env.model.getters.getCurrentContent(),i=t.slice(0,e.start)+he+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:e.start+1,end:e.start+1}}),this.processContent(),void this.contentHelper.scrollSelectionIntoView()}if(this.isKeyStillDown=!1,this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const i=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(i,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(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!this.env.model.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){"inactive"!==this.props.focus&&this.shouldProcessInputEvents&&(this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:this.contentHelper.getText(),selection:this.contentHelper.getCurrentSelection()}))}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Alt","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.showAutocomplete(""),void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:i}=this.env.model.getters.getComposerSelection(),{start:o,end:n}=this.contentHelper.getCurrentSelection();o===t&&n===i||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}showAutocomplete(e){this.autoCompleteState.showProvider=!0;let t=Object.entries(ju.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?"true"===e.toLowerCase()||"false"===e.toLowerCase()?[]:ki(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}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}processContent(){if(this.compositionActive)return;const e=(null==(t=this.composerRef.el)?void 0:t.scrollTop)||0;var t;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&(this.contentHelper.el.focus(),this.contentHelper.selectRange(0,0));const i=this.getContentLines();if(0!==i.length&&0!==i.length[0]){this.contentHelper.setText(i);const{start:t,end:o}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,o),function(e,t){e&&(e.scrollTop=t)}(this.composerRef.el,e)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),i=[],{end:o,start:n}=this.env.model.getters.getComposerSelection();for(const s of e){switch(s.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":i.push({value:s.value,color:Hg[s.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:o}=zt(s.value);i.push({value:s.value,color:this.rangeColor(e,o)||"#000"});break;case"SYMBOL":let n=s.value;["TRUE","FALSE"].includes(n.toUpperCase())?i.push({value:s.value,color:Hg.NUMBER}):i.push({value:s.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===s.parenIndex?i.push({value:s.value,color:Hg.MATCHING_PAREN}):i.push({value:s.value,color:Hg[s.type]||"#000"});break;default:i.push({value:s.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&o===n&&o===s.end&&(i[i.length-1].class=Vg)}return i}splitHtmlContentIntoLines(e){const t=[];let i=[];for(const o of e)if(o.value.includes(he)){const e=o.value.split(he),n=e.pop();for(const n of e)i.push({color:o.color,value:n}),t.push(i),i=[];i.push({...o,value:n})}else i.push(o);i.length&&t.push(i);const o=[];for(const e of t)e.every(this.isContentEmpty)?o.push([e[0]]):o.push(e.filter((e=>!this.isContentEmpty(e))));return o}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const i=this.env.model.getters.getHighlights(),o=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=i.find((t=>{if(t.sheetId!==o)return!1;let i=this.env.model.getters.getRangeFromSheetXC(o,e).zone;return i=1===lo(i)?this.env.model.getters.expandZone(o,i):i,ji(i,t.zone)}));return n&&n.color?n.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}=zt(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!kt.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,i=t.parent.toUpperCase(),o=Ug[i],n=t.argPosition;this.functionDescriptionState.functionName=i,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let i=t.end,o=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(i=t.start);const n=this.env.model.getters.getCurrentTokens();if(n.length){e+="(";const i=n.map((e=>e.start)).indexOf(t.start);if(i+1<n.length){"LEFT_PAREN"===n[i+1].type&&o++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}$g.template="o-spreadsheet-Composer",$g.components={TextValueProvider:kg,FunctionDescriptionProvider:Pg},$g.defaultProps={inputStyle:""},$g.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerUnmounted:{type:Function,optional:!0}};const Wg=3*.4*window.devicePixelRatio||1;po`
1146
+ `;class Wg extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Pg(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0}),this.functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,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:i}=this.props.rect;let o={};return t>this.props.delimitation.height-(t+i)&&(o.top="-3px",o.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(o.right="0px"),o.width="300px",So(o)}return So({width:"300px"})}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent(),this.contentHelper.scrollSelectionIntoView()})),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,e.preventDefault(),e.stopPropagation(),void tg(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length),this.updateCursorIfNeeded()}processTabKey(e){var t;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const i=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(i,1)}processEnterKey(e){var t;if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey){const e=this.contentHelper.getCurrentSelection(),t=this.env.model.getters.getCurrentContent(),i=t.slice(0,e.start)+he+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:e.start+1,end:e.start+1}}),this.processContent(),void this.contentHelper.scrollSelectionIntoView()}if(this.isKeyStillDown=!1,this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const i=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(i,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(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!this.env.model.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){"inactive"!==this.props.focus&&this.shouldProcessInputEvents&&(this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:this.contentHelper.getText(),selection:this.contentHelper.getCurrentSelection()}))}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Alt","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.showAutocomplete(""),void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:i}=this.env.model.getters.getComposerSelection(),{start:o,end:n}=this.contentHelper.getCurrentSelection();o===t&&n===i||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}showAutocomplete(e){this.autoCompleteState.showProvider=!0;let t=Object.entries(Xu.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?"true"===e.toLowerCase()||"false"===e.toLowerCase()?[]:Li(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}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}processContent(){if(this.compositionActive)return;const e=(null==(t=this.composerRef.el)?void 0:t.scrollTop)||0;var t;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&(this.contentHelper.el.focus(),this.contentHelper.selectRange(0,0));const i=this.getContentLines();if(0!==i.length&&0!==i.length[0]){this.contentHelper.setText(i);const{start:t,end:o}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,o),function(e,t){e&&(e.scrollTop=t)}(this.composerRef.el,e)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),i=[],{end:o,start:n}=this.env.model.getters.getComposerSelection();for(const s of e){switch(s.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":i.push({value:s.value,color:$g[s.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:o}=Bt(s.value);i.push({value:s.value,color:this.rangeColor(e,o)||"#000"});break;case"SYMBOL":let n=s.value;["TRUE","FALSE"].includes(n.toUpperCase())?i.push({value:s.value,color:$g.NUMBER}):i.push({value:s.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===s.parenIndex?i.push({value:s.value,color:$g.MATCHING_PAREN}):i.push({value:s.value,color:$g[s.type]||"#000"});break;default:i.push({value:s.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&o===n&&o===s.end&&(i[i.length-1].class=zg)}return i}splitHtmlContentIntoLines(e){const t=[];let i=[];for(const o of e)if(o.value.includes(he)){const e=o.value.split(he),n=e.pop();for(const n of e)i.push({color:o.color,value:n}),t.push(i),i=[];i.push({...o,value:n})}else i.push(o);i.length&&t.push(i);const o=[];for(const e of t)e.every(this.isContentEmpty)?o.push([e[0]]):o.push(e.filter((e=>!this.isContentEmpty(e))));return o}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const i=this.env.model.getters.getHighlights(),o=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=i.find((t=>{if(t.sheetId!==o)return!1;let i=this.env.model.getters.getRangeFromSheetXC(o,e).zone;return i=1===co(i)?this.env.model.getters.expandZone(o,i):i,Xi(i,t.zone)}));return n&&n.color?n.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}=Bt(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Lt.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,i=t.parent.toUpperCase(),o=Vg[i],n=t.argPosition;this.functionDescriptionState.functionName=i,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let i=t.end,o=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(i=t.start);const n=this.env.model.getters.getCurrentTokens();if(n.length){e+="(";const i=n.map((e=>e.start)).indexOf(t.start);if(i+1<n.length){"LEFT_PAREN"===n[i+1].type&&o++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Wg.template="o-spreadsheet-Composer",Wg.components={TextValueProvider:Lg,FunctionDescriptionProvider:Ug},Wg.defaultProps={inputStyle:""},Wg.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerUnmounted:{type:Function,optional:!0}};const Gg=3*.4*window.devicePixelRatio||1;mo`
1147
1147
  div.o-grid-composer {
1148
1148
  z-index: ${ce.GridComposer};
1149
1149
  box-sizing: border-box;
1150
1150
  position: absolute;
1151
- border: ${Wg}px solid ${E};
1151
+ border: ${Gg}px solid ${E};
1152
1152
 
1153
1153
  display: flex;
1154
1154
  align-items: center;
@@ -1164,7 +1164,7 @@
1164
1164
  padding: 6px 7px;
1165
1165
  border-radius: 4px;
1166
1166
  }
1167
- `;class Gg extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:void 0,delimitation:void 0});const{sheetId:e,col:i,row:o}=this.env.model.getters.getActivePosition();this.zone=this.env.model.getters.expandZone(e,ro({col:i,row:o})),this.rect=this.env.model.getters.getVisibleRect(this.zone),this.isCellReferenceVisible=!1,t.onMounted((()=>{const e=this.gridComposerRef.el;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}})),t.onWillUpdateProps((()=>{if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();ct(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){const{col:e,row:t,sheetId:i}=this.env.model.getters.getCurrentEditedCell();return`${i!==this.env.model.getters.getActiveSheetId()?De(this.env.model.getters.getSheetName(i))+"!":""}${Wt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return bo({left:e-Wg+"px",top:t-28+"px"})}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),i=this.env.model.getters.getActivePosition(),o=this.env.model.getters.getCellComputedStyle(i),{x:n,y:s,width:r,height:a}=this.rect,l=!e&&o.fillColor||"#ffffff",c=!e&&o.textColor||"#000000",h=!e&&o.fontSize||10,d=!e&&o.bold?"bold":void 0,u=!e&&o.italic?"italic":"normal",g=e?"none":mo(o);let p="left";return e||(p=o.align||t.defaultAlign),bo({left:n-1+"px",top:`${s}px`,"min-width":`${r+1}px`,"min-height":`${a+1}px`,background:l,color:c,"font-size":`${Ve(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}get composerStyle(){const e=this.props.gridDims.height-this.rect.y;return bo({"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${e}px`})}}Gg.template="o-spreadsheet-GridComposer",Gg.components={Composer:$g},Gg.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerUnmounted:Function,onComposerContentFocused:Function,gridDims:Object};const qg=po`
1167
+ `;class qg extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:void 0,delimitation:void 0});const{sheetId:e,col:i,row:o}=this.env.model.getters.getActivePosition();this.zone=this.env.model.getters.expandZone(e,ao({col:i,row:o})),this.rect=this.env.model.getters.getVisibleRect(this.zone),this.isCellReferenceVisible=!1,t.onMounted((()=>{const e=this.gridComposerRef.el;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}})),t.onWillUpdateProps((()=>{if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();ht(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){const{col:e,row:t,sheetId:i}=this.env.model.getters.getCurrentEditedCell();return`${i!==this.env.model.getters.getActiveSheetId()?ke(this.env.model.getters.getSheetName(i))+"!":""}${Gt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return So({left:e-Gg+"px",top:t-28+"px"})}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),i=this.env.model.getters.getActivePosition(),o=this.env.model.getters.getCellComputedStyle(i),{x:n,y:s,width:r,height:a}=this.rect,l=!e&&o.fillColor||"#ffffff",c=!e&&o.textColor||"#000000",h=!e&&o.fontSize||10,d=!e&&o.bold?"bold":void 0,u=!e&&o.italic?"italic":"normal",g=e?"none":fo(o);let p="left";return e||(p=o.align||t.defaultAlign),So({left:n-1+"px",top:`${s}px`,"min-width":`${r+1}px`,"min-height":`${a+1}px`,background:l,color:c,"font-size":`${ze(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}get composerStyle(){const e=this.props.gridDims.height-this.rect.y;return So({"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${e}px`})}}qg.template="o-spreadsheet-GridComposer",qg.components={Composer:Wg},qg.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerUnmounted:Function,onComposerContentFocused:Function,gridDims:Object};const Zg=mo`
1168
1168
  .o-filter-icon {
1169
1169
  color: ${R};
1170
1170
  position: absolute;
@@ -1188,7 +1188,7 @@
1188
1188
  }
1189
1189
  }
1190
1190
  }
1191
- `;class Zg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Zg.style=qg,Zg.template="o-spreadsheet-FilterIcon",Zg.props={position:Object,isActive:Boolean,onClick:Function};const jg=po``;class Xg 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(),i=this.env.model.getters.getRowDimensionsInViewport(t,e.row),o=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((i.size-H)/2);return{x:o.end-H+this.props.gridPosition.x-2-1,y:i.end-H+this.props.gridPosition.y-n}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}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:i,row:o}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:i,row:o,popoverType:"FilterMenu"})}isPositionVisible(e,t){const i=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===i.width||0===i.height)}}Xg.style=jg,Xg.template="o-spreadsheet-FilterIconsOverlay",Xg.components={FilterIcon:Zg},Xg.defaultProps={gridPosition:{x:0,y:0}},Xg.props={gridPosition:{type:Object,optional:!0}};class Yg 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 i of["topLeft","topRight","bottomLeft","bottomRight"]){const o=e.filter((e=>this.getFigureContainer(e)===i));o.length>0&&t.push({type:i,figures:o,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}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:i}=this.env.model.getters.getMainViewportRect(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),s=["bottomRight","topRight"].includes(e)?o:0,r=t-s,a=["bottomRight","bottomLeft"].includes(e)?n:0;return bo({left:`${s}px`,top:`${a}px`,width:`${r}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates();return bo({left:`${["bottomRight","topRight"].includes(e)?-(o+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"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 i=this.env.model.getters.getActiveSheetId(),o=t.clientX,n=t.clientY,{x:s,y:r}=this.internalToScreenCoordinates(e);this.dnd.x=s,this.dnd.y=r,this.dnd.width=e.width,this.dnd.height=e.height;Og((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-o;this.dnd.x=Math.max(s+u,h);let g=t.clientY-n;this.dnd.y=Math.max(r+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:o,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:o,y:n})}))}startResize(e,t,i,o){o.stopPropagation();const n=o.clientX,s=o.clientY,{x:r,y:a}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height;const l=gr.get(e.tag).keepRatio||!1,c=gr.get(e.tag).minFigSize||80;let h;h=l&&0!=t&&0!=i?o=>{this.dnd.figId=e.id;const l=Math.min(t*(n-o.clientX),e.width-c),h=Math.min(i*(s-o.clientY),e.height-c),d=Math.min(l/e.width,h/e.height);this.dnd.width=e.width*(1-d),this.dnd.height=e.height*(1-d),t<0&&(this.dnd.x=r+e.width*d),i<0&&(this.dnd.y=a+e.height*d),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)}:o=>{this.dnd.figId=e.id;const l=Math.max(t*(o.clientX-n),c-e.width),h=Math.max(i*(o.clientY-s),c-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+h,t<0&&(this.dnd.x=r-l),i<0&&(this.dnd.y=a-h),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)};Og(h,(o=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:n,y:s}=this.screenCoordinatesToInternal(this.dnd);const r={x:n,y:s};t&&(r.width=this.dnd.width),i&&(r.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...r})}))}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?"":bo({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-n,y:t=t<o?t:t-s}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+n,y:t=o&&t<o?t:t+s}}}function Kg(e,i,o){let n={col:void 0,row:void 0};const{Date:s}=window;let r=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(r),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let o;const{setInterval:n,clearInterval:s}=window;return t.useEffect((()=>(o=n(e,i),()=>s(o))),(()=>[i])),{pause:()=>{s(o),o=void 0},resume:()=>{void 0===o&&(o=n(e,i))}}}((function(){const{col:e,row:t}=c(),i=s.now()-l;i>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){i.el===e.target&&(r=e.offsetX,a=e.offsetY,l=s.now())}function g(){const{col:e,row:t}=c();e===n.col&&t===n.row||p(void 0,void 0)}function p(e,t){e===n.col&&t===n.row||(n.col=e,n.row=t,o({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}Yg.template="o-spreadsheet-FiguresContainer",Yg.components={FigureComponent:Mg},Yg.props={onFigureDeleted:Function};class Qg extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),Kg(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,i,o){let n=null,s=null;function r(e){1===e.touches.length&&(n=e.touches[0].clientX,s=e.touches[0].clientY)}function a(){n=null,s=null}function l(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;i(n-t,s-r),n=t,s=r}t.onMounted((()=>{e.el.addEventListener("touchstart",r),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",r),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,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Qg.template="o-spreadsheet-GridOverlay",Qg.components={FiguresContainer:Yg},Qg.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}},Qg.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class Jg extends t.Component{constructor(){super(...arguments),this.zIndex=ce.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}Jg.template="o-spreadsheet-GridPopover",Jg.components={Popover:Gn},Jg.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class ep 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),i=this._getElementIndex(t);if(i<0)return;const o=this._getDimensionsInViewport(i);t-o.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.start,this.state.activeElement=this._getPreviousVisibleElement(i)):o.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),o=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();i.has(o)&&o<=t&&t<=n?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),i=this.state.draggerLinePosition,o=this._getElementSize(this.state.activeElement),n=i-o+this.MIN_ELEMENT_SIZE,s=this._getMaxSize();Og((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-o),this.state.draggerLinePosition>s&&(this.state.draggerLinePosition=s,this.state.delta=s-i)}),(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()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),o=t.start;this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=i.end-t.start;Ng(this.env,((e,i)=>{let o="COL"===this._getType()?e:i;if(o>=0){const e=this._getDimensionsInViewport(o);o<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=o):this._getSelectedZoneEnd()<o?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=o+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;Ng(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{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 i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}po`
1191
+ `;class jg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}jg.style=Zg,jg.template="o-spreadsheet-FilterIcon",jg.props={position:Object,isActive:Boolean,onClick:Function};const Xg=mo``;class Yg 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(),i=this.env.model.getters.getRowDimensionsInViewport(t,e.row),o=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((i.size-H)/2);return{x:o.end-H+this.props.gridPosition.x-2-1,y:i.end-H+this.props.gridPosition.y-n}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}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:i,row:o}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:i,row:o,popoverType:"FilterMenu"})}isPositionVisible(e,t){const i=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===i.width||0===i.height)}}Yg.style=Xg,Yg.template="o-spreadsheet-FilterIconsOverlay",Yg.components={FilterIcon:jg},Yg.defaultProps={gridPosition:{x:0,y:0}},Yg.props={gridPosition:{type:Object,optional:!0}};class Kg 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 i of["topLeft","topRight","bottomLeft","bottomRight"]){const o=e.filter((e=>this.getFigureContainer(e)===i));o.length>0&&t.push({type:i,figures:o,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}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:i}=this.env.model.getters.getMainViewportRect(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),s=["bottomRight","topRight"].includes(e)?o:0,r=t-s,a=["bottomRight","bottomLeft"].includes(e)?n:0;return So({left:`${s}px`,top:`${a}px`,width:`${r}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates();return So({left:`${["bottomRight","topRight"].includes(e)?-(o+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"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 i=this.env.model.getters.getActiveSheetId(),o=t.clientX,n=t.clientY,{x:s,y:r}=this.internalToScreenCoordinates(e);this.dnd.x=s,this.dnd.y=r,this.dnd.width=e.width,this.dnd.height=e.height;Ng((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-o;this.dnd.x=Math.max(s+u,h);let g=t.clientY-n;this.dnd.y=Math.max(r+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:o,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:o,y:n})}))}startResize(e,t,i,o){o.stopPropagation();const n=o.clientX,s=o.clientY,{x:r,y:a}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height;const l=pr.get(e.tag).keepRatio||!1,c=pr.get(e.tag).minFigSize||80;let h;h=l&&0!=t&&0!=i?o=>{this.dnd.figId=e.id;const l=Math.min(t*(n-o.clientX),e.width-c),h=Math.min(i*(s-o.clientY),e.height-c),d=Math.min(l/e.width,h/e.height);this.dnd.width=e.width*(1-d),this.dnd.height=e.height*(1-d),t<0&&(this.dnd.x=r+e.width*d),i<0&&(this.dnd.y=a+e.height*d),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)}:o=>{this.dnd.figId=e.id;const l=Math.max(t*(o.clientX-n),c-e.width),h=Math.max(i*(o.clientY-s),c-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+h,t<0&&(this.dnd.x=r-l),i<0&&(this.dnd.y=a-h),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)};Ng(h,(o=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:n,y:s}=this.screenCoordinatesToInternal(this.dnd);const r={x:n,y:s};t&&(r.width=this.dnd.width),i&&(r.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...r})}))}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?"":So({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-n,y:t=t<o?t:t-s}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+n,y:t=o&&t<o?t:t+s}}}function Qg(e,i,o){let n={col:void 0,row:void 0};const{Date:s}=window;let r=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(r),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let o;const{setInterval:n,clearInterval:s}=window;return t.useEffect((()=>(o=n(e,i),()=>s(o))),(()=>[i])),{pause:()=>{s(o),o=void 0},resume:()=>{void 0===o&&(o=n(e,i))}}}((function(){const{col:e,row:t}=c(),i=s.now()-l;i>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){i.el===e.target&&(r=e.offsetX,a=e.offsetY,l=s.now())}function g(){const{col:e,row:t}=c();e===n.col&&t===n.row||p(void 0,void 0)}function p(e,t){e===n.col&&t===n.row||(n.col=e,n.row=t,o({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}Kg.template="o-spreadsheet-FiguresContainer",Kg.components={FigureComponent:Og},Kg.props={onFigureDeleted:Function};class Jg extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),Qg(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,i,o){let n=null,s=null;function r(e){1===e.touches.length&&(n=e.touches[0].clientX,s=e.touches[0].clientY)}function a(){n=null,s=null}function l(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;i(n-t,s-r),n=t,s=r}t.onMounted((()=>{e.el.addEventListener("touchstart",r),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",r),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,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Jg.template="o-spreadsheet-GridOverlay",Jg.components={FiguresContainer:Kg},Jg.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}},Jg.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class ep extends t.Component{constructor(){super(...arguments),this.zIndex=ce.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}ep.template="o-spreadsheet-GridPopover",ep.components={Popover:qn},ep.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class tp 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),i=this._getElementIndex(t);if(i<0)return;const o=this._getDimensionsInViewport(i);t-o.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.start,this.state.activeElement=this._getPreviousVisibleElement(i)):o.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),o=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();i.has(o)&&o<=t&&t<=n?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),i=this.state.draggerLinePosition,o=this._getElementSize(this.state.activeElement),n=i-o+this.MIN_ELEMENT_SIZE,s=this._getMaxSize();Ng((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-o),this.state.draggerLinePosition>s&&(this.state.draggerLinePosition=s,this.state.delta=s-i)}),(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.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),o=t.start;this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=i.end-t.start;_g(this.env,((e,i)=>{let o="COL"===this._getType()?e:i;if(o>=0){const e=this._getDimensionsInViewport(o);o<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=o):this._getSelectedZoneEnd()<o?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=o+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;_g(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{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 i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}mo`
1192
1192
  .o-col-resizer {
1193
1193
  position: absolute;
1194
1194
  top: 0;
@@ -1247,7 +1247,7 @@
1247
1247
  top: calc(${P}px / 2 - ${L}px / 2);
1248
1248
  }
1249
1249
  }
1250
- `,ep.props={onOpenContextMenu:Function};class tp extends ep{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),i=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Os)}_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 i;for(i=e-1;i>=0&&this.env.model.getters.isColHidden(t,i);i--);return i}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}}tp.template="o-spreadsheet-ColResizer",po`
1250
+ `,tp.props={onOpenContextMenu:Function};class ip extends tp{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),i=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Ns)}_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 i;for(i=e-1;i>=0&&this.env.model.getters.isColHidden(t,i);i--);return i}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}}ip.template="o-spreadsheet-ColResizer",mo`
1251
1251
  .o-row-resizer {
1252
1252
  position: absolute;
1253
1253
  top: ${N}px;
@@ -1308,7 +1308,7 @@
1308
1308
  background-color: lightgrey;
1309
1309
  }
1310
1310
  }
1311
- `,tp.props={onOpenContextMenu:Function};class ip extends ep{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),i=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Os)}_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 i;for(i=e-1;i>=0&&this.env.model.getters.isRowHidden(t,i);i--);return i}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}}ip.template="o-spreadsheet-RowResizer",po`
1311
+ `,ip.props={onOpenContextMenu:Function};class op extends tp{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),i=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Ns)}_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 i;for(i=e-1;i>=0&&this.env.model.getters.isRowHidden(t,i);i--);return i}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}}op.template="o-spreadsheet-RowResizer",mo`
1312
1312
  .o-overlay {
1313
1313
  .all {
1314
1314
  position: absolute;
@@ -1319,7 +1319,7 @@
1319
1319
  height: ${N}px;
1320
1320
  }
1321
1321
  }
1322
- `,ip.props={onOpenContextMenu:Function};class op extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function np(e,i,o){const n=t.useRef(e);t.useEffect((function(){const e=n.el,t=window.devicePixelRatio||1,s=e.getContext("2d",{alpha:!1}),r={ctx:s,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=o();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;`),s.translate(-m,-m),s.scale(t,t),i.drawGrid(r)}))}function sp(e){function t(e,t){return e*(0===t?1:D)}return i=>{const o=t(i.shiftKey?i.deltaY:i.deltaX,i.deltaMode),n=t(i.shiftKey?i.deltaX:i.deltaY,i.deltaMode);e(o,n)}}op.template="o-spreadsheet-HeadersOverlay",op.components={ColResizer:tp,RowResizer:ip},op.props={onOpenContextMenu:Function},po`
1322
+ `,op.props={onOpenContextMenu:Function};class np extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function sp(e,i,o){const n=t.useRef(e);t.useEffect((function(){const e=n.el,t=window.devicePixelRatio||1,s=e.getContext("2d",{alpha:!1}),r={ctx:s,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=o();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;`),s.translate(-m,-m),s.scale(t,t),i.drawGrid(r)}))}function rp(e){function t(e,t){return e*(0===t?1:D)}return i=>{const o=t(i.shiftKey?i.deltaY:i.deltaX,i.deltaMode),n=t(i.shiftKey?i.deltaX:i.deltaY,i.deltaMode);e(o,n)}}np.template="o-spreadsheet-HeadersOverlay",np.components={ColResizer:ip,RowResizer:op},np.props={onOpenContextMenu:Function},mo`
1323
1323
  .o-border {
1324
1324
  position: absolute;
1325
1325
  &:hover {
@@ -1329,7 +1329,7 @@
1329
1329
  .o-moving {
1330
1330
  cursor: grabbing;
1331
1331
  }
1332
- `;class rp extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),i=["n","s"].includes(this.props.orientation),o=["w","e"].includes(this.props.orientation),n=this.props.zone,s=this.env.model.getters.getVisibleRect(n),r=s.x,a=s.x+s.width-4,l=s.y,c=s.y+s.height-4;return bo({left:`${t?r:a}px`,top:`${e?l:c}px`,width:`${i?a-r:4}px`,height:`${o?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}rp.template="o-spreadsheet-Border",rp.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},po`
1332
+ `;class ap extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),i=["n","s"].includes(this.props.orientation),o=["w","e"].includes(this.props.orientation),n=this.props.zone,s=this.env.model.getters.getVisibleRect(n),r=s.x,a=s.x+s.width-4,l=s.y,c=s.y+s.height-4;return So({left:`${t?r:a}px`,top:`${e?l:c}px`,width:`${i?a-r:4}px`,height:`${o?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}ap.template="o-spreadsheet-Border",ap.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},mo`
1333
1333
  .o-corner {
1334
1334
  position: absolute;
1335
1335
  height: 6px;
@@ -1351,11 +1351,11 @@
1351
1351
  .o-resizing {
1352
1352
  cursor: grabbing;
1353
1353
  }
1354
- `;class ap 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,i=this.isTop?e.top:e.bottom,o=this.env.model.getters.getVisibleRect({left:t,right:t,top:i,bottom:i});if(o.width*o.height==0)return"display:none";return bo({left:(this.isLeft?o.x:o.x+o.width)-4+"px",top:(this.isTop?o.y:o.y+o.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}ap.template="o-spreadsheet-Corner",ap.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},po`
1354
+ `;class lp 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,i=this.isTop?e.top:e.bottom,o=this.env.model.getters.getVisibleRect({left:t,right:t,top:i,bottom:i});if(o.width*o.height==0)return"display:none";return So({left:(this.isLeft?o.x:o.x+o.width)-4+"px",top:(this.isTop?o.y:o.y+o.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}lp.template="o-spreadsheet-Corner",lp.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},mo`
1355
1355
  .o-highlight {
1356
1356
  z-index: ${ce.Highlight};
1357
1357
  }
1358
- `;class lp extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const i=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const o=this.props.zone,n=e?o.right:o.left,s=t?o.bottom:o.top;let r=e?o.left:o.right,a=t?o.top:o.bottom,l=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,l)});Ng(this.env,((e,t)=>{if(r!==e||a!==t){const o=this.env.model.getters.getActiveSheetId();r=ke(-1===e?r:e,0,this.env.model.getters.getNumberCols(o)-1),a=ke(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let c={left:Math.min(n,r),top:Math.min(s,a),right:Math.max(n,r),bottom:Math.max(s,a)};c=this.env.model.getters.expandZone(o,c),ji(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const i=this.props.zone,o=Un(),n=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getColIndex(e-o.left),r=this.env.model.getters.getRowIndex(t-o.top),a=-i.left,l=this.env.model.getters.getNumberCols(n)-i.right-1,c=-i.top,h=this.env.model.getters.getNumberRows(n)-i.bottom-1;let d=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,d)});let u=s,g=r;Ng(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const o=ke(u-s,a,l),p=ke(g-r,c,h);let m={left:i.left+o,top:i.top+p,right:i.right+o,bottom:i.bottom+p};m=this.env.model.getters.expandZone(n,m),ji(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,m)}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}lp.template="o-spreadsheet-Highlight",lp.components={Corner:ap,Border:rp},lp.props={zone:Object,color:String};class cp{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}}po`
1358
+ `;class cp extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const i=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const o=this.props.zone,n=e?o.right:o.left,s=t?o.bottom:o.top;let r=e?o.left:o.right,a=t?o.top:o.bottom,l=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,l)});_g(this.env,((e,t)=>{if(r!==e||a!==t){const o=this.env.model.getters.getActiveSheetId();r=Le(-1===e?r:e,0,this.env.model.getters.getNumberCols(o)-1),a=Le(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let c={left:Math.min(n,r),top:Math.min(s,a),right:Math.max(n,r),bottom:Math.max(s,a)};c=this.env.model.getters.expandZone(o,c),Xi(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const i=this.props.zone,o=Vn(),n=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getColIndex(e-o.left),r=this.env.model.getters.getRowIndex(t-o.top),a=-i.left,l=this.env.model.getters.getNumberCols(n)-i.right-1,c=-i.top,h=this.env.model.getters.getNumberRows(n)-i.bottom-1;let d=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,d)});let u=s,g=r;_g(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const o=Le(u-s,a,l),p=Le(g-r,c,h);let m={left:i.left+o,top:i.top+p,right:i.right+o,bottom:i.bottom+p};m=this.env.model.getters.expandZone(n,m),Xi(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,m)}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}cp.template="o-spreadsheet-Highlight",cp.components={Corner:lp,Border:ap},cp.props={zone:Object,color:String};class hp{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}}mo`
1359
1359
  .o-scrollbar {
1360
1360
  position: absolute;
1361
1361
  overflow: auto;
@@ -1371,7 +1371,7 @@
1371
1371
  border-left: 1px solid #e2e3e3;
1372
1372
  }
1373
1373
  }
1374
- `;class hp extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new cp(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 bo({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return bo(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}hp.template=t.xml`
1374
+ `;class dp extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new hp(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 So({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return So(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}dp.template=t.xml`
1375
1375
  <div
1376
1376
  t-attf-class="o-scrollbar {{props.direction}}"
1377
1377
  t-on-scroll="onScroll"
@@ -1379,7 +1379,7 @@
1379
1379
  t-att-style="positionCss">
1380
1380
  <div t-att-style="sizeCss"/>
1381
1381
  </div>
1382
- `,hp.defaultProps={width:1,height:1},hp.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class dp 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.leftOffset+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})}}dp.components={ScrollBar:hp},dp.template=t.xml`
1382
+ `,dp.defaultProps={width:1,height:1},dp.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class up 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.leftOffset+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})}}up.components={ScrollBar:dp},up.template=t.xml`
1383
1383
  <ScrollBar
1384
1384
  t-if="isDisplayed"
1385
1385
  width="width"
@@ -1387,7 +1387,7 @@
1387
1387
  offset="offset"
1388
1388
  direction="'horizontal'"
1389
1389
  onScroll.bind="onScroll"
1390
- />`,dp.defaultProps={leftOffset:0},dp.props={leftOffset:{type:Number,optional:!0}};class up 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.topOffset+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})}}up.components={ScrollBar:hp},up.template=t.xml`
1390
+ />`,up.defaultProps={leftOffset:0},up.props={leftOffset:{type:Number,optional:!0}};class gp 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.topOffset+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})}}gp.components={ScrollBar:dp},gp.template=t.xml`
1391
1391
  <ScrollBar
1392
1392
  t-if="isDisplayed"
1393
1393
  height="height"
@@ -1395,13 +1395,13 @@
1395
1395
  offset="offset"
1396
1396
  direction="'vertical'"
1397
1397
  onScroll.bind="onScroll"
1398
- />`,up.defaultProps={topOffset:0},up.props={topOffset:{type:Number,optional:!0}};const gp={ROW:la,COL:aa,CELL:ra};class pp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=N,this.HEADER_WIDTH=_,this.keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===sn.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===sn.empty?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()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():this.env.model.dispatch("CLEAN_CLIPBOARD_HIGHLIGHT")},"CTRL+A":()=>this.env.model.selection.loopSelection(),"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(),i=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,i,o.cell);if(this.env.model.getters.isSingleCellOrMerge(t,i)||this.env.model.getters.isEmpty(t,i)&&n.length<=1){const i=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",o=`=SUM(${i})`;this.props.onGridComposerCellFocused(o,{start:5,end:5+i.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,i)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),i=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,i)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,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},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,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"),"CTRL+K":()=>ta(this.env)}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=Hn(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),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())),np("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=sp(((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 bo({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}focus(){var e;this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||null===(e=this.hiddenInput.el)||void 0===e||e.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}}get isAutofillVisible(){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:_,gridOffsetY:N})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getClientPositionKey(e){var t,i,o;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(i=e.position)||void 0===i?void 0:i.col}-${null===(o=e.position)||void 0===o?void 0:o.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{ctrlKey:i,shiftKey:o}){i&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),o?this.env.model.selection.setAnchorCorner(e,t):i?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,s=t;Ng(this.env,((e,t,i)=>{i.preventDefault(),(e!==n&&-1!=e||t!==s&&-1!=t)&&(n=-1===e?n:e,s=-1===t?s:t,this.env.model.selection.setAnchorCorner(n,s))}),(()=>{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 i=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:i,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t}).type===sn.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),eg(e,this.env.model.selection),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 i=this.keyDownMapping[t];return i?(e.preventDefault(),e.stopPropagation(),void i()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:i,top:o}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(i)?n="COL":this.env.model.getters.getActiveRows().has(o)&&(n="ROW");const{x:s,y:r,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(n,s+a,r+l)}onCellRightClicked(e,t,{x:i,y:o}){const n=this.env.model.getters.getSelectedZones();let s="CELL";Yi(e,t,n[n.length-1])?this.env.model.getters.getActiveCols().has(e)?s="COL":this.env.model.getters.getActiveRows().has(t)&&(s="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(s,i,o)}toggleContextMenu(e,t,i){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:i},this.menuState.menuItems=gp[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const i=t.clipboardData;if(!i)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?yr(this.env):this.env.model.dispatch("COPY");const o=this.env.model.getters.getClipboardContent();for(const e in o)i.setData(e,o[e]);t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(rn.PlainText)>-1){const e=t.getData(rn.PlainText),i=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?Ar(this.env,i):Mr(this.env,i,e)}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(s("Copy/Paste is not supported in this browser."))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}pp.template="o-spreadsheet-Grid",pp.components={GridComposer:Gg,GridOverlay:Qg,GridPopover:Jg,HeadersOverlay:op,Menu:Xn,Autofill:_g,ClientTag:Dg,Highlight:lp,Popover:Gn,VerticalScrollBar:up,HorizontalScrollBar:dp,FilterIconsOverlay:Xg},pp.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class mp{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"],vp="000000",bp={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Sp={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"},Cp="http://schemas.openxmlformats.org/drawingml/2006/main",Ep="http://schemas.openxmlformats.org/drawingml/2006/chart",wp={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"},yp={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",image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"},xp="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Ip=.75,Rp=.1317,Tp=8.43,Ap=12.75,Mp=30,Op=100,Np=164,_p={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}]},Fp=["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"],Dp="[Content_Types].xml";var kp;!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"}(kp||(kp={}));class Lp{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,i){let o=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;i&&(o+=`Only ${i.join(", ")} are currently supported.`),this._conversionWarnings.has(o)||this._conversionWarnings.add(o)}}const Pp=["thin"],Up=["general","left","center","right"],Vp=["Arial"],zp=["solid"],Bp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Hp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},$p={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"},Wp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Gp={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},qp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},Zp={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"},jp={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},Xp={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},Yp={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"},Kp={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},Qp={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},Jp={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"},em={"image/avif":"avif","image/bmp":"bmp","image/gif":"gif","image/vnd.microsoft.icon":"ico","image/jpeg":"jpeg","image/png":"png","image/tiff":"tiff","image/webp":"webp"};function tm(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=vp;else{if(!e.indexed)return;t=Jp[e.indexed]}var i;return t=6===(i=t).length?"#"+i+"FF":"#"+i.slice(2)+i.slice(0,2),e.tint&&(t=function(e,t){const i=Tt(e),o=Mt(i);t<0&&(o.l=o.l*(1+t));t>0&&(o.l=o.l*(1-t)+(100-100*(1-t)));return Rt(At(o))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function im(e,t){const i=e.split("/"),o=t.split("/");let n="",s=0;for(let e=0;e<i.length-1;e++)i[e]===o[e]?s++:n+="../";return n+=o.slice(s).join("/"),n}function om(e,t=0){const i={};for(let o=0;o<e.length;o++)e[o]&&(i[o+t]=e[o]);return i}function nm(e){const t=[];for(let i of Object.keys(e).map(Number))t[i]=e[i];return t}function sm(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const rm=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function am(e,t,i){var o,n,s;if(0===e)return;let r=Kp[e]||(null===(o=t.find((t=>t.id===e)))||void 0===o?void 0:o.format);if(r)try{let e=r.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(n=e.match(/"/g))||void 0===n?void 0:n.length)||0;if(t/2+((null===(s=e.match(/\[/g))||void 0===s?void 0:s.length)||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return null!==e.match(rm)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,"mmm"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return gi(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}i.generateNotSupportedWarning(kp.NumFmtIdNotSupported,r||`nmFmtId ${e}`)}function lm(e,t){const i=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(kp.DiagonalBorderNotSupported)}(e,t);const i={top:cm(e.top,t),bottom:cm(e.bottom,t),left:cm(e.left,t),right:cm(e.right,t)};return Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e])),i}));return om(i,1)}function cm(e,t){if(!e)return;!function(e,t){Pp.includes(e.style)||t.generateNotSupportedWarning(kp.BorderStyleNotSupported,e.style,Pp)}(e,t);const i=$p[e.style];return i?[i,tm(e.color)]:void 0}function hm(e,t){return om(e.styles.map((i=>dm({fontStyle:e.fonts[i.fontId],fillStyle:e.fills[i.fillId],alignment:i.alignment},t))),1)}function dm(e,t){var i,o,n,s,r,a,l,c,h,d,u,g;return function(e,t,i){e&&e.name&&!Vp.includes(e.name)&&i.generateNotSupportedWarning(kp.FontNotSupported,e.name,Vp);t&&t.patternType&&!zp.includes(t.patternType)&&i.generateNotSupportedWarning(kp.FillStyleNotSupported,t.patternType,zp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!Up.includes(e)&&t.generateNotSupportedWarning(kp.HorizontalAlignmentNotSupported,e,Up)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(kp.VerticalAlignmentNotSupported)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.vertical,t),{bold:null===(n=e.fontStyle)||void 0===n?void 0:n.bold,italic:null===(s=e.fontStyle)||void 0===s?void 0:s.italic,strikethrough:null===(r=e.fontStyle)||void 0===r?void 0:r.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)?Wp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?tm(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):tm(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:tm(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:null===(g=e.fontStyle)||void 0===g?void 0:g.size}}function um(e,t){const i=[];for(let o of e.styles){const n=am(o.numFmtId,e.numFmts,t);n&&(i[o.numFmtId]=n)}return om(i,1)}function gm(e,t,i){const o=[];let n=1;for(let r of e){if(0===r.cfRules.length)continue;vm(r,t,i);const e=r.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=pm(n++,r);t&&o.push(t);continue;case"iconSet":const c=mm(n++,r,i);c&&o.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Gp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Gp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(s=e.operator).slice(0,1).toUpperCase()+s.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&o.push({id:(n++).toString(),ranges:r.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:dm({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},i)}})}}var s;return o}function pm(e,t){const i=t.cfRules[0].colorScale;if(!i||i.cfvos.length!==i.colors.length||i.cfvos.length<2||i.cfvos.length>3)return;const o=[];for(let e=0;e<i.cfvos.length;e++)o.push({color:(n=tm(i.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:qp[i.cfvos[e].type],value:i.cfvos[e].value});var n;const s=o[0],r=2===o.length?o[1]:o[2],a=3===o.length?o[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:s,midpoint:a,maximum:r}}}function mm(e,t,i){const o=t.cfRules[0].iconSet;if(!o)return;let n=o.cfvos,s=o.cfIcons;if(n.length<3||s&&s.length<3)return;n.length>3&&(n=[n[0],n[Math.floor(n.length/2)],n[n.length-1]]),s&&s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]);const r=[];for(let e=1;e<=2;e++){const t=qp[n[e].type];if("value"===t)return;r.push({value:n[e].value||"",operator:n[e].gte?"ge":"gt",type:t})}let a={lower:s?fm(s[0].iconSet,s[0].iconId):fm(o.iconSet,0),middle:s?fm(s[1].iconSet,s[1].iconId):fm(o.iconSet,1),upper:s?fm(s[2].iconSet,s[2].iconId):fm(o.iconSet,2)};o.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(i.generateNotSupportedWarning(kp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=wg.dots.good;break;case"middle":a[e]=wg.dots.neutral;break;case"lower":a[e]=wg.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:r[1],lowerInflectionPoint:r[0]}}}function fm(e,t){const i=Zp[e];return i?0===t?wg[i].bad:1===t?wg[i].neutral:wg[i].good:""}function vm(e,t,i){if(e.cfRules.length>1&&i.generateNotSupportedWarning(kp.MultipleRulesCfNotSupported),Bp.includes(e.cfRules[0].type)||i.generateNotSupportedWarning(kp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const o=t[e.cfRules[0].dxfId];o.border&&i.generateNotSupportedWarning(kp.CfFormatBorderNotSupported),o.alignment&&i.generateNotSupportedWarning(kp.CfFormatAlignmentNotSupported),o.numFmt&&i.generateNotSupportedWarning(kp.CfFormatNumFmtNotSupported)}}class bm{constructor(e=new Cm){this.scope=e,this.code=""}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new Sm(this.scope,this.code,e)}toString(){return Em(this.code)}}class Sm{constructor(e,t,i){this.scope=e,this.returnExpression=i,this.code=Em(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new bm(this.scope);return t.append(`const ${e} = () => {`),t.append(this.code),t.append(`return ${this.returnExpression};`),t.append("}"),t.return(e)}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new bm(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class Cm{constructor(){this.nextId=1,this.declaredVariables=new Set}nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function Em(e){let t="",i=0;const o=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of o)e.startsWith("}")&&i--,t+="\t".repeat(i)+e+"\n",e.endsWith("{")&&i++;return t.trim()}const wm=ju.content,ym=["%"],xm="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(ym);function Im(e){const t=(e=ft(e)).split(""),i=[];for(;t.length;){let e=km(t)||Am(t)||Om(t)||_m(t)||Rm(t)||Lm(t)||Nm(t)||Dm(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Rm(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Tm={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Am(e){if(e[0]in Tm){const t=e.shift();return{type:Tm[t],value:t}}return null}function Mm(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Om(e){for(let t of xm)if(Mm(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Nm(e){const t=st(e).match(Xt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function _m(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const Fm=/\w|\.|!|\$/;function Dm(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Fm);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in wm)return{type:"FUNCTION",value:e};return e.match(kt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function km(e){let t=0;for(;e[0]===he;)t++,e.shift();if(t)return{type:"SPACE",value:he.repeat(t)};for(;" "===e[0];)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Lm(e){return Mm(e,K)?(e.splice(0,K.length),{type:"INVALID_REFERENCE",value:K}):null}const Pm=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Um=["-","+"],Vm=["%"],zm=["*","+","&"],Bm={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Hm(e){var t,i,o;const n=e.shift();if(!n)throw new h(le);switch(n.type){case"DEBUGGER":const r=Gm(e,1e3);return r.debug=!0,r;case"NUMBER":return{type:"NUMBER",value:oi(n.value)};case"STRING":return{type:"STRING",value:Oe(n.value)};case"FUNCTION":const a=function(e){var t;Wm(e,"LEFT_PAREN",s("Missing opening parenthesis"));const i=e[0];if("RIGHT_PAREN"===(null==i?void 0:i.type))return Wm(e,"RIGHT_PAREN"),[];const o=[];o.push($m(e));for(;"RIGHT_PAREN"!==(null===(t=e[0])||void 0===t?void 0:t.type);)Wm(e,"COMMA",s("Wrong function call")),o.push($m(e));return Wm(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:n.value,args:a};case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(t=e[0])||void 0===t?void 0:t.value)&&"REFERENCE"===(null===(i=e[1])||void 0===i?void 0:i.type)){e.shift();const t=e.shift();return{type:"REFERENCE",value:`${n.value}:${null==t?void 0:t.value}`}}return{type:"REFERENCE",value:n.value};case"SYMBOL":if(["TRUE","FALSE"].includes(n.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===n.value.toUpperCase()};if(n.value&&Pm.test(n.value)&&"LEFT_PAREN"===(null===(o=e[0])||void 0===o?void 0:o.type))throw new p(n.value);throw new h(s("Invalid formula"));case"LEFT_PAREN":const l=Gm(e);return Wm(e,"RIGHT_PAREN",s("Missing closing parenthesis")),l;case"OPERATOR":const c=n.value;if(Um.includes(c))return{type:"UNARY_OPERATION",value:c,operand:Gm(e,Bm[c])};throw new h(s("Unexpected token: %s",n.value));default:throw new h(s("Unexpected token: %s",n.value))}}function $m(e){const t=e[0];return"COMMA"===(null==t?void 0:t.type)||"RIGHT_PAREN"===(null==t?void 0:t.type)?{type:"EMPTY",value:""}:Gm(e)}function Wm(e,t,i=le){const o=e.shift();if(!o||o.type!==t)throw new h(i)}function Gm(e,t=0){var i;if(0===e.length)throw new h(le);let o=Hm(e);for(;"OPERATOR"===(null===(i=e[0])||void 0===i?void 0:i.type)&&Bm[e[0].value]>t;){const t=e.shift().value;if(Vm.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:Gm(e,Bm[t])}}}return o}function qm(e){return Zm(Im(e))}function Zm(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=Gm(e);if(e.length)throw new h(le);return t}function jm(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>jm(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:jm(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:jm(e.right,t,i),left:jm(e.left,t,i)};default:return e}}function Xm(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Xm(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?Ym(e)+e.value:e.value+Km(e);case"BIN_OPERATION":return Ym(e)+e.value+Km(e)}}function Ym(e){const t=e.value,i="left"in e?e.left:e.operand,o=i.value;return"BIN_OPERATION"===i.type&&Bm[o]<Bm[t]?`(${Xm(i)})`:Xm(i)}function Km(e){const t=e.value,i="right"in e?e.right:e.operand,o=Bm[i.value],n=Bm[t];let s=!1;return"BIN_OPERATION"!==i.type?s=!1:o<n?s=!0:o!==n||zm.includes(t)||(s=!0),s?`(${Xm(i)})`:Xm(i)}var Qm;!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"}(Qm||(Qm={}));const Jm=(e,t=(()=>!0))=>[{goTo:e,guard:t}],ef=(e,t=(()=>!0))=>({goTo:e,guard:t}),tf={[Qm.LeftRef]:{REFERENCE:Jm(Qm.Separator),NUMBER:Jm(Qm.FullRowSeparator),SYMBOL:[ef(Qm.FullColumnSeparator,(e=>Lt(e.value))),ef(Qm.FullRowSeparator,(e=>Pt(e.value)))]},[Qm.FullColumnSeparator]:{SPACE:Jm(Qm.FullColumnSeparator),OPERATOR:Jm(Qm.RightColumnRef,(e=>":"===e.value))},[Qm.FullRowSeparator]:{SPACE:Jm(Qm.FullRowSeparator),OPERATOR:Jm(Qm.RightRowRef,(e=>":"===e.value))},[Qm.Separator]:{SPACE:Jm(Qm.Separator),OPERATOR:Jm(Qm.RightRef,(e=>":"===e.value))},[Qm.RightRef]:{SPACE:Jm(Qm.RightRef),NUMBER:Jm(Qm.Found),REFERENCE:Jm(Qm.Found,(e=>Vt(e.value))),SYMBOL:Jm(Qm.Found,(e=>Ut(e.value)))},[Qm.RightColumnRef]:{SPACE:Jm(Qm.RightColumnRef),SYMBOL:Jm(Qm.Found,(e=>Ut(e.value))),REFERENCE:Jm(Qm.Found,(e=>Vt(e.value)))},[Qm.RightRowRef]:{SPACE:Jm(Qm.RightRowRef),NUMBER:Jm(Qm.Found),REFERENCE:Jm(Qm.Found,(e=>Vt(e.value)))},[Qm.Found]:{}};function of(e){var t;let i=0,o=tf[Qm.LeftRef];const n=[];for(;void 0!==o;){const s=e[i++];if(!s)return null;const r=null===(t=o[s.type])||void 0===t?void 0:t.find((e=>e.guard(s))),a=r?r.goTo:void 0;switch(a){case void 0:return null;case Qm.Found:return n.push(s),e.splice(0,i),{type:"REFERENCE",value:st(n.map((e=>e.value)))};default:o=tf[a],n.push(s)}}return null}function nf(e){const t=Im(e),i=[];for(;t.length;)i.push(of(t)||t.shift());return i}const sf=ju.content,rf={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},af={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},lf={};function cf(e){const t=nf(e),{dependencies:i,constantValues:o}=function(e){const t={numbers:[],strings:[]},i=[];for(const o of e)switch(o.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(o.value);break;case"STRING":const e=Oe(o.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=oi(o.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),n=function(e,t,i){return st(e.map((e=>{switch(e.type){case"STRING":const o=Oe(e.value);return`|S${i.strings.indexOf(o)}|`;case"NUMBER":return`|N${i.numbers.indexOf(oi(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,o);if(!lf[n]){const r=Zm([...t]),a=new Cm;if("BIN_OPERATION"===r.type&&":"===r.value)throw new h(s("Invalid formula"));if("EMPTY"===r.type)throw new h(s("Invalid formula"));const l=g(r),c=new bm;c.append(`// ${n}`),c.append(l),c.append(`return ${l.returnExpression};`);let d=new Function("deps","ref","range","ctx",c.toString());function u(e){const t=sf[e.value.toUpperCase()],i=e.args,o=i.length;if(o<t.minArgRequired)throw new h(s("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),o.toString()));if(o>t.maxArgPossible)throw new h(s("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),o.toString()));const n=t.nbrArgRepeating;if(n>1){const i=t.args.length-n;if((o-i)%n!=0)throw new h(s("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(),i.toString(),n.toString()))}let r=[];for(let n=0;n<o;n++){const o=t.getArgToFocus(n+1)-1;if(0<=o&&o<t.args.length){const a=i[n],l=t.args[o],c=l.type||[],d=c.includes("META"),u=l.lazy,p=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),m=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(m&&"REFERENCE"!==a.type)throw new h(s("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(n+1).toString(),a.type.toLowerCase()));const f=g(a,d,p,{functionName:e.value.toUpperCase(),paramIndex:n+1});r.push(u?f.wrapInClosure():f)}}return r}function g(e,t=!1,n=!1,r={}){const l=new bm(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new h(s("Argument must be a reference to a cell or range."));switch(e.debug&&l.append("debugger;"),e.type){case"BOOLEAN":return l.return(`{ value: ${e.value} }`);case"NUMBER":return l.return(`{ value: this.constantValues.numbers[${o.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${o.strings.indexOf(e.value)}] }`);case"REFERENCE":const s=i.indexOf(e.value);return n?l.return(`range(deps[${s}])`):l.return(`ref(deps[${s}], ${t?"true":"false"}, "${r.functionName||rf["="]}", ${r.paramIndex})`);case"FUNCALL":const a=u(e).map((e=>e.assignResultToVariable()));l.append(...a);const c=e.value.toUpperCase();return l.append(`ctx.__lastFnCalled = '${c}';`),l.return(`ctx['${c}'](${a.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=af[e.value],i=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression})`)}case"BIN_OPERATION":{const t=rf[e.value],i=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),o=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression}, ${o.returnExpression})`)}case"EMPTY":return l.return("undefined")}}lf[n]={execute:d}}return{execute:lf[n].execute,dependencies:i,constantValues:o,tokens:t}}function hf(e){return function(e){let t=[],i="";return e.map(((e,o)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,o=Object.assign({},e,{start:t,end:t+i,length:i});return t=o.end,o}))}(nf(e))))}function df(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function uf(e){return Math.round(Ip*e*100)/100}function gf(e){return Math.round(Rp*e*100)/100}function pf(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function mf(e,t){let i={};e.style&&(i=t.styles[e.style]);const o=function(e,t){if(e.format)return t.formats[e.format];if(e.isFormula){const t=Im(e.content||""),i=ju.content;if(!t.filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)))return e.computedFormat}return}(e,t),n={};if(e.border){const i=t.borders[e.border];n.left=pf(i.left),n.right=pf(i.right),n.bottom=pf(i.bottom),n.top=pf(i.top)}const s={font:{size:(null==i?void 0:i.fontSize)||q,color:{rgb:(null==i?void 0:i.textColor)?i.textColor:"000000"},family:2,name:"Arial"},fill:(null==i?void 0:i.fillColor)?{fgColor:{rgb:i.fillColor}}:{reservedAttribute:"none"},numFmt:o?{format:o,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:i.align}};return s.font.strike=!!(null==i?void 0:i.strikethrough)||void 0,s.font.underline=!!(null==i?void 0:i.underline)||void 0,s.font.bold=!!(null==i?void 0:i.bold)||void 0,s.font.italic=!!(null==i?void 0:i.italic)||void 0,s}function ff(e,t){const{id:i}=bf(t.font,e.fonts),{id:o}=bf(t.fill,e.fills),{id:n}=bf(t.border,e.borders),s=function(e,t){if(!e)return 0;let i=Qp[e.format];if(!i){const{id:o}=bf(e,t);i=o+Np}return i}(t.numFmt,e.numFmts),r={fontId:i,fillId:o,borderId:n,numFmtId:s,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=bf(r,e.styles);return a}function vf(e,t,i){let o,n=e.find((e=>e.path===t));return n?(o=`rId${(n.rels.length+1).toString()}`,n.rels.push({...i,id:o})):(o="rId1",e.push({path:t,rels:[{...i,id:o}]})),o}function bf(e,t){for(let[i,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(i,10),list:t};let i=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===i&&(t.push(e),i=t.length-1),{id:i,list:t}}const Sf=[];function Cf(e){const t=Sf.findIndex((t=>t===e));return-1===t?(Sf.push(e),Sf.length):t+1}const Ef=[];function wf(e){const t=Ef.findIndex((t=>t===e));return-1===t?(Ef.push(e),Ef.length):t+1}function yf(e){return Math.round(914400*e/96)}function xf(e,t,i){let o,n,s=e;if(({xc:s,sheetName:o}=zt(e)),o){const e=i.sheets.findIndex((e=>e.name===o));if(e<0)throw new Error("Unable to find a sheet with the name "+o);n=e}else n=Number(t);const r=Ui(s);return void 0===r.right&&(r.right=i.sheets[n].colNumber),void 0===r.bottom&&(r.bottom=i.sheets[n].rowNumber),(r.right-r.left+1)*(r.bottom-r.top+1)}function If(e){return Math.round(96*e/914400)}function Rf(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.cols.find((e=>n>=e.min&&n<=e.max));(null==e?void 0:e.width)?o+=e.width:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?o+=t.sheetFormat.defaultColWidth:o+=Tp}return o/Rp}function Tf(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?o+=e.height:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?o+=t.sheetFormat.defaultRowHeight:o+=Ap}return o/Ip}function Af(e){let t=1;return e.figures.map((i=>function(e,t,i){const o=Rf(e.anchors[0].col,i)+If(e.anchors[0].colOffset),n=Rf(e.anchors[1].col,i)+If(e.anchors[1].colOffset),s=Tf(e.anchors[0].row,i)+If(e.anchors[0].rowOffset),r=Tf(e.anchors[1].row,i)+If(e.anchors[1].rowOffset),a=n-o,l=r-s,c=Mf(e.data);return c?{id:t,x:o,y:s,width:a,height:l,tag:"chart",data:Mf(e.data)}:void 0}(i,(t++).toString(),e))).filter(it)}function Mf(e){var t;const i=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let o=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&o.reverse(),{dataSets:o,dataSetsHaveTitle:!1,labelRange:i,title:e.title||"",type:e.type,background:tm({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1}}const Of=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Nf=new RegExp(/SUBTOTAL\(([0-9]*),/g),_f=new RegExp(Ot.source,"ig");function Ff(e,t){const i=function(e){const t={};for(let i of e.rows)for(let e of i.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 o of e.rows.map((e=>e.cells)).flat())(null==o?void 0:o.formula)&&(o.formula.content=void 0===o.formula.sharedIndex||o.formula.content?"="+o.formula.content:"="+kf(o.xc,i[o.formula.sharedIndex]),o.formula.content=Df(o.formula.content,t))}function Df(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(Nf,((e,t)=>{const i=Yp[t];return i?i+"(":e}))).replace(Of,((e,i,o,n)=>{var s;i=Number(i)-1,n=n.replace(/\$/g,"");const r=t.externalBooks[i].sheetNames.findIndex((e=>e===o));if(-1===r)return e;const a=null===(s=t.externalBooks[i].datasets.find((e=>e.sheetId===r)))||void 0===s?void 0:s.data;if(!a)return e;const l=a&&a[n];return(Number(l)?l:`"${l}"`)||e}))}function kf(e,t){const i=$t(t.refCellXc);let o,n=t.formula.slice();do{if(o=_f.exec(n),o){const t=$t(o[0].replace("$","")),s=$t(e),r={colFixed:o[0].startsWith("$"),rowFixed:o[0].includes("$",1)},a={col:s.col-i.col,row:s.row-i.row},l={col:r.colFixed?t.col:t.col+a.col,row:r.rowFixed?t.row:t.row+a.row};n=n.slice(0,o.index)+Wt(l.col,l.row,r)+n.slice(o.index+o[0].length)}}while(o);return n}function Lf(e,t){return e.sheets.map((i=>{Ff(i,e);const o=function(e){const t=[0,0];for(let i of e.rows)t[0]=Math.max(t[0],...i.cells.map((e=>$t(e.xc).col))),t[1]=Math.max(t[1],i.index);return t[0]=Math.max(t[0],Mp),t[1]=Math.max(t[1],Op),t}(i),n=i.sheetViews[0];return{id:i.sheetName,areGridLinesVisible:!n||n.showGridLines,name:i.sheetName,colNumber:o[0],rowNumber:o[1],cells:Vf(i,e,o,t),merges:i.merges,cols:Pf(i,o[0]),rows:Uf(i,o[1]),conditionalFormats:gm(i.cfs,e.dxfs,t),figures:Af(i),isVisible:i.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Pf(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?e.sheetFormat.defaultColWidth:Tp,o[s-1]={size:(n=r,n?Math.round(n/Rp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Uf(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?e.sheetFormat.defaultRowHeight:Ap,o[s-1]={size:(n=r,n?Math.round(n/Ip*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Vf(e,t,i,o){const n={},s=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const r=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let i of e.rows)for(let e of i.cells)n[e.xc]={content:zf(e,r,s,o),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 o of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=i[0];e++){const i=Wt(e-1,o.index-1);let s=n[i];s||(s={},n[i]=s),s.style=s.style?s.style:o.styleIndex+1,s.border=s.border?s.border:t.styles[o.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[o.styleIndex].numFmtId+1}for(let o of e.cols.filter((e=>e.styleIndex)))for(let e=o.min;e<=Math.min(o.max,i[0]);e++)for(let s=1;s<=i[1];s++){const i=Wt(e-1,s-1);let r=n[i];r||(r={},n[i]=r),r.style=r.style?r.style:o.styleIndex+1,r.border=r.border?r.border:t.styles[o.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[o.styleIndex].numFmtId+1}return n}function zf(e,t,i,o){let n;switch(e.type){case"sharedString":n=i[parseInt(e.value,10)];break;case"boolean":n=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":n=e.value}return n&&t[e.xc]&&(n=function(e,t,i){const o=e.display||t;e.relTarget||e.location||i.generateNotSupportedWarning(kp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:et(zt(e.location).sheetName);return Ye(o,n)}(t[e.xc],n,o)),e.formula&&(n=e.formula.content),n}const Bf={fillColor:"#000000",textColor:"#ffffff",bold:!0},Hf={bold:!0},$f=["thin","#000000FF"];function Wf(e,t){for(const i of t.sheets)for(const t of i.tables){const o=e.sheets.find((e=>e.name===i.sheetName));o&&t.autoFilter&&(o.filterTables||(o.filterTables=[]),o.filterTables.push({range:t.ref}))}!function(e,t){var i,o,n,s;const r=nm(e.styles),a=nm(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=Vi(t.ref);for(let e=0;e<t.headerRowCount;e++)Gf(Bf,{...h,bottom:h.top+e},c.cells,r);for(let e=0;e<t.totalsRowCount;e++)Gf(Hf,{...h,top:h.bottom-e},c.cells,r);(null===(i=t.style)||void 0===i?void 0:i.showFirstColumn)&&Gf(Hf,{...h,right:h.left},c.cells,r),(null===(o=t.style)||void 0===o?void 0:o.showLastColumn)&&Gf(Hf,{...h,left:h.right},c.cells,r);for(let e=h.left;e<=h.right;e++)for(let i=h.top;i<=h.bottom;i++){const o=Wt(e,i),r=c.cells[o],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?$f:void 0,right:e===h.right?$f:void 0,top:i===h.top||(null===(s=t.style)||void 0===s?void 0:s.showRowStripes)||i>h.bottom-t.totalsRowCount?$f:void 0,bottom:i===h.bottom?$f:void 0},d=(null==r?void 0:r.border)?{...a[r.border],...l}:l;let u=a.findIndex((e=>ct(e,d)));-1===u&&(u=a.length,a.push(d)),r?r.border=u:c.cells[o]={border:u}}}e.styles=om(r),e.borders=om(a)}(e,t),function(e,t){for(let i of e){const e=t.find((e=>e.sheetName===i.name)).tables;for(let t of e){const e=t.name+"[";for(let o of io(Vi(t.ref))){const n=Wt(o.col,o.row),s=i.cells[n];if(s&&s.content&&s.content.startsWith("=")){let i;for(;-1!==(i=s.content.indexOf(e));){let o=s.content.slice(i+e.length),r=o.indexOf("]");o.startsWith("[")&&(r=o.indexOf("]",r+1),r=o.indexOf("]",r+1)),o=o.slice(0,r);const a=qf(o,t,n);s.content=s.content.slice(0,i)+a+s.content.slice(e.length+i+r+1)}}}}}}(e.sheets,t.sheets)}function Gf(e,t,i,o){for(let n=t.left;n<=t.right;n++)for(let s=t.top;s<=t.bottom;s++){const t=Wt(n,s),r=i[t],a=(null==r?void 0:r.style)?{...o[r.style],...e}:e;let l=o.findIndex((e=>ct(e,a)));-1===l&&(l=o.length,o.push(a)),r?r.style=l:i[t]={style:l}}}function qf(e,t,i){const o=e.split(","),n=Vi(t.ref),s={...n};let r=!0;if(1===o.length){const e=t.cols.findIndex((e=>e.name===o[0]));s.left=s.right=e+n.left,t.headerRowCount&&(s.top+=t.headerRowCount),t.totalsRowCount&&(s.bottom-=1)}else{switch(o[0].slice(1,o[0].length-1)){case"#All":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=n.bottom;break;case"#Data":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=t.totalsRowCount?n.bottom+1:n.bottom;break;case"#This Row":s.top=s.bottom=$t(i).row;break;case"#Headers":s.top=s.bottom=n.top,t.headerRowCount||(r=!1);break;case"#Totals":s.top=s.bottom=n.bottom,t.totalsRowCount||(r=!1)}const e=o[1].slice(1,o[1].length-1),a=t.cols.findIndex((t=>t.name===e));s.left=s.right=a+n.left}return r?s.top!==s.bottom?Bi(s):Wt(s.left,s.top):K}function Zf(e,t,i){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:i}}function jf(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function Xf(e){return new mp(e.map((([e,t])=>`${e}="${jf(t)}"`)).join(" "))}function Yf(e,t="text/xml"){const i=(new DOMParser).parseFromString(e.toString(),t),o=i.querySelector("parsererror");if(o){const t=o.innerHTML,i=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),s=n.slice(Math.max(i-3,0),Math.min(i+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${s}`)}return i}function Kf(e,t){return Jf`
1398
+ />`,gp.defaultProps={topOffset:0},gp.props={topOffset:{type:Number,optional:!0}};const pp={ROW:ca,COL:la,CELL:aa};class mp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=N,this.HEADER_WIDTH=_,this.keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===rn.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===rn.empty?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()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():this.env.model.dispatch("CLEAN_CLIPBOARD_HIGHLIGHT")},"CTRL+A":()=>this.env.model.selection.loopSelection(),"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(),i=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,i,o.cell);if(this.env.model.getters.isSingleCellOrMerge(t,i)||this.env.model.getters.isEmpty(t,i)&&n.length<=1){const i=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",o=`=SUM(${i})`;this.props.onGridComposerCellFocused(o,{start:5,end:5+i.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,i)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),i=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,i)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,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},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,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"),"CTRL+K":()=>ia(this.env)}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=$n(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),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())),sp("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=rp(((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 So({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}focus(){var e;this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||null===(e=this.hiddenInput.el)||void 0===e||e.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}}get isAutofillVisible(){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:_,gridOffsetY:N})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getClientPositionKey(e){var t,i,o;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(i=e.position)||void 0===i?void 0:i.col}-${null===(o=e.position)||void 0===o?void 0:o.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{ctrlKey:i,shiftKey:o}){i&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),o?this.env.model.selection.setAnchorCorner(e,t):i?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,s=t;_g(this.env,((e,t,i)=>{i.preventDefault(),(e!==n&&-1!=e||t!==s&&-1!=t)&&(n=-1===e?n:e,s=-1===t?s:t,this.env.model.selection.setAnchorCorner(n,s))}),(()=>{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 i=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:i,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t}).type===rn.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),tg(e,this.env.model.selection),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 i=this.keyDownMapping[t];return i?(e.preventDefault(),e.stopPropagation(),void i()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:i,top:o}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(i)?n="COL":this.env.model.getters.getActiveRows().has(o)&&(n="ROW");const{x:s,y:r,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(n,s+a,r+l)}onCellRightClicked(e,t,{x:i,y:o}){const n=this.env.model.getters.getSelectedZones();let s="CELL";Ki(e,t,n[n.length-1])?this.env.model.getters.getActiveCols().has(e)?s="COL":this.env.model.getters.getActiveRows().has(t)&&(s="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(s,i,o)}toggleContextMenu(e,t,i){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:i},this.menuState.menuItems=pp[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const i=t.clipboardData;if(!i)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?xr(this.env):this.env.model.dispatch("COPY");const o=this.env.model.getters.getClipboardContent();for(const e in o)i.setData(e,o[e]);t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(an.PlainText)>-1){const e=t.getData(an.PlainText),i=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?Mr(this.env,i):Or(this.env,i,e)}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(s("Copy/Paste is not supported in this browser."))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}mp.template="o-spreadsheet-Grid",mp.components={GridComposer:qg,GridOverlay:Jg,GridPopover:ep,HeadersOverlay:np,Menu:Yn,Autofill:Fg,ClientTag:kg,Highlight:cp,Popover:qn,VerticalScrollBar:gp,HorizontalScrollBar:up,FilterIconsOverlay:Yg},mp.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class fp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const vp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],bp="000000",Sp={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Cp={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"},Ep="http://schemas.openxmlformats.org/drawingml/2006/main",wp="http://schemas.openxmlformats.org/drawingml/2006/chart",yp={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"},xp={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",image:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"},Ip="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Rp=.75,Tp=.1317,Ap=8.43,Mp=12.75,Op=30,Np=100,_p=164,Fp={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}]},Dp=["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"],kp="[Content_Types].xml";var Lp;!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"}(Lp||(Lp={}));class Pp{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,i){let o=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;i&&(o+=`Only ${i.join(", ")} are currently supported.`),this._conversionWarnings.has(o)||this._conversionWarnings.add(o)}}const Up=["thin"],Vp=["general","left","center","right"],zp=["Arial"],Bp=["solid"],Hp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],$p={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},Wp={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"},Gp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const qp={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},Zp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},jp={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"},Xp={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},Yp={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},Kp={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"},Qp={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},Jp={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},em={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"},tm={"image/avif":"avif","image/bmp":"bmp","image/gif":"gif","image/vnd.microsoft.icon":"ico","image/jpeg":"jpeg","image/png":"png","image/tiff":"tiff","image/webp":"webp"};function im(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=bp;else{if(!e.indexed)return;t=em[e.indexed]}var i;return t=6===(i=t).length?"#"+i+"FF":"#"+i.slice(2)+i.slice(0,2),e.tint&&(t=function(e,t){const i=At(e),o=Ot(i);t<0&&(o.l=o.l*(1+t));t>0&&(o.l=o.l*(1-t)+(100-100*(1-t)));return Tt(Mt(o))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function om(e,t){const i=e.split("/"),o=t.split("/");let n="",s=0;for(let e=0;e<i.length-1;e++)i[e]===o[e]?s++:n+="../";return n+=o.slice(s).join("/"),n}function nm(e,t=0){const i={};for(let o=0;o<e.length;o++)e[o]&&(i[o+t]=e[o]);return i}function sm(e){const t=[];for(let i of Object.keys(e).map(Number))t[i]=e[i];return t}function rm(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const am=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function lm(e,t,i){var o,n,s;if(0===e)return;let r=Qp[e]||(null===(o=t.find((t=>t.id===e)))||void 0===o?void 0:o.format);if(r)try{let e=r.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(n=e.match(/"/g))||void 0===n?void 0:n.length)||0;if(t/2+((null===(s=e.match(/\[/g))||void 0===s?void 0:s.length)||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return null!==e.match(am)}(e)&&(e=function(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,"mmm"),e=e.replace(/am\/pm|a\/m/g,"a"),e=e.replace(/hhhh/g,"hh"),e=e.replace(/\bh\b/g,"hh"),e}(e)),function(e){try{return pi(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}i.generateNotSupportedWarning(Lp.NumFmtIdNotSupported,r||`nmFmtId ${e}`)}function cm(e,t){const i=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(Lp.DiagonalBorderNotSupported)}(e,t);const i={top:hm(e.top,t),bottom:hm(e.bottom,t),left:hm(e.left,t),right:hm(e.right,t)};return Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e])),i}));return nm(i,1)}function hm(e,t){if(!e)return;!function(e,t){Up.includes(e.style)||t.generateNotSupportedWarning(Lp.BorderStyleNotSupported,e.style,Up)}(e,t);const i=Wp[e.style];return i?[i,im(e.color)]:void 0}function dm(e,t){return nm(e.styles.map((i=>um({fontStyle:e.fonts[i.fontId],fillStyle:e.fills[i.fillId],alignment:i.alignment},t))),1)}function um(e,t){var i,o,n,s,r,a,l,c,h,d,u,g;return function(e,t,i){e&&e.name&&!zp.includes(e.name)&&i.generateNotSupportedWarning(Lp.FontNotSupported,e.name,zp);t&&t.patternType&&!Bp.includes(t.patternType)&&i.generateNotSupportedWarning(Lp.FillStyleNotSupported,t.patternType,Bp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!Vp.includes(e)&&t.generateNotSupportedWarning(Lp.HorizontalAlignmentNotSupported,e,Vp)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(Lp.VerticalAlignmentNotSupported)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.vertical,t),{bold:null===(n=e.fontStyle)||void 0===n?void 0:n.bold,italic:null===(s=e.fontStyle)||void 0===s?void 0:s.italic,strikethrough:null===(r=e.fontStyle)||void 0===r?void 0:r.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)?Gp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?im(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):im(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:im(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:null===(g=e.fontStyle)||void 0===g?void 0:g.size}}function gm(e,t){const i=[];for(let o of e.styles){const n=lm(o.numFmtId,e.numFmts,t);n&&(i[o.numFmtId]=n)}return nm(i,1)}function pm(e,t,i){const o=[];let n=1;for(let r of e){if(0===r.cfRules.length)continue;bm(r,t,i);const e=r.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=mm(n++,r);t&&o.push(t);continue;case"iconSet":const c=fm(n++,r,i);c&&o.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=qp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=qp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(s=e.operator).slice(0,1).toUpperCase()+s.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&o.push({id:(n++).toString(),ranges:r.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:um({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},i)}})}}var s;return o}function mm(e,t){const i=t.cfRules[0].colorScale;if(!i||i.cfvos.length!==i.colors.length||i.cfvos.length<2||i.cfvos.length>3)return;const o=[];for(let e=0;e<i.cfvos.length;e++)o.push({color:(n=im(i.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:Zp[i.cfvos[e].type],value:i.cfvos[e].value});var n;const s=o[0],r=2===o.length?o[1]:o[2],a=3===o.length?o[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:s,midpoint:a,maximum:r}}}function fm(e,t,i){const o=t.cfRules[0].iconSet;if(!o)return;let n=o.cfvos,s=o.cfIcons;if(n.length<3||s&&s.length<3)return;n.length>3&&(n=[n[0],n[Math.floor(n.length/2)],n[n.length-1]]),s&&s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]);const r=[];for(let e=1;e<=2;e++){const t=Zp[n[e].type];if("value"===t)return;r.push({value:n[e].value||"",operator:n[e].gte?"ge":"gt",type:t})}let a={lower:s?vm(s[0].iconSet,s[0].iconId):vm(o.iconSet,0),middle:s?vm(s[1].iconSet,s[1].iconId):vm(o.iconSet,1),upper:s?vm(s[2].iconSet,s[2].iconId):vm(o.iconSet,2)};o.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(i.generateNotSupportedWarning(Lp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=yg.dots.good;break;case"middle":a[e]=yg.dots.neutral;break;case"lower":a[e]=yg.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:r[1],lowerInflectionPoint:r[0]}}}function vm(e,t){const i=jp[e];return i?0===t?yg[i].bad:1===t?yg[i].neutral:yg[i].good:""}function bm(e,t,i){if(e.cfRules.length>1&&i.generateNotSupportedWarning(Lp.MultipleRulesCfNotSupported),Hp.includes(e.cfRules[0].type)||i.generateNotSupportedWarning(Lp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const o=t[e.cfRules[0].dxfId];o.border&&i.generateNotSupportedWarning(Lp.CfFormatBorderNotSupported),o.alignment&&i.generateNotSupportedWarning(Lp.CfFormatAlignmentNotSupported),o.numFmt&&i.generateNotSupportedWarning(Lp.CfFormatNumFmtNotSupported)}}class Sm{constructor(e=new Em){this.scope=e,this.code=""}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new Cm(this.scope,this.code,e)}toString(){return wm(this.code)}}class Cm{constructor(e,t,i){this.scope=e,this.returnExpression=i,this.code=wm(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new Sm(this.scope);return t.append(`const ${e} = () => {`),t.append(this.code),t.append(`return ${this.returnExpression};`),t.append("}"),t.return(e)}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new Sm(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class Em{constructor(){this.nextId=1,this.declaredVariables=new Set}nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function wm(e){let t="",i=0;const o=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of o)e.startsWith("}")&&i--,t+="\t".repeat(i)+e+"\n",e.endsWith("{")&&i++;return t.trim()}const ym=Xu.content,xm=["%"],Im="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(xm);function Rm(e){const t=(e=vt(e)).split(""),i=[];for(;t.length;){let e=Lm(t)||Mm(t)||Nm(t)||Fm(t)||Tm(t)||Pm(t)||_m(t)||km(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Tm(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Am={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Mm(e){if(e[0]in Am){const t=e.shift();return{type:Am[t],value:t}}return null}function Om(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Nm(e){for(let t of Im)if(Om(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function _m(e){const t=rt(e).match(Yt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Fm(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const Dm=/\w|\.|!|\$/;function km(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Dm);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in ym)return{type:"FUNCTION",value:e};return e.match(Lt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function Lm(e){let t=0;for(;e[0]===he;)t++,e.shift();if(t)return{type:"SPACE",value:he.repeat(t)};for(;" "===e[0];)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Pm(e){return Om(e,K)?(e.splice(0,K.length),{type:"INVALID_REFERENCE",value:K}):null}const Um=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Vm=["-","+"],zm=["%"],Bm=["*","+","&"],Hm={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function $m(e){var t,i,o;const n=e.shift();if(!n)throw new h(le);switch(n.type){case"DEBUGGER":const r=qm(e,1e3);return r.debug=!0,r;case"NUMBER":return{type:"NUMBER",value:ni(n.value)};case"STRING":return{type:"STRING",value:Ne(n.value)};case"FUNCTION":const a=function(e){var t;Gm(e,"LEFT_PAREN",s("Missing opening parenthesis"));const i=e[0];if("RIGHT_PAREN"===(null==i?void 0:i.type))return Gm(e,"RIGHT_PAREN"),[];const o=[];o.push(Wm(e));for(;"RIGHT_PAREN"!==(null===(t=e[0])||void 0===t?void 0:t.type);)Gm(e,"COMMA",s("Wrong function call")),o.push(Wm(e));return Gm(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:n.value,args:a};case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(t=e[0])||void 0===t?void 0:t.value)&&"REFERENCE"===(null===(i=e[1])||void 0===i?void 0:i.type)){e.shift();const t=e.shift();return{type:"REFERENCE",value:`${n.value}:${null==t?void 0:t.value}`}}return{type:"REFERENCE",value:n.value};case"SYMBOL":if(["TRUE","FALSE"].includes(n.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===n.value.toUpperCase()};if(n.value&&Um.test(n.value)&&"LEFT_PAREN"===(null===(o=e[0])||void 0===o?void 0:o.type))throw new p(n.value);throw new h(s("Invalid formula"));case"LEFT_PAREN":const l=qm(e);return Gm(e,"RIGHT_PAREN",s("Missing closing parenthesis")),l;case"OPERATOR":const c=n.value;if(Vm.includes(c))return{type:"UNARY_OPERATION",value:c,operand:qm(e,Hm[c])};throw new h(s("Unexpected token: %s",n.value));default:throw new h(s("Unexpected token: %s",n.value))}}function Wm(e){const t=e[0];return"COMMA"===(null==t?void 0:t.type)||"RIGHT_PAREN"===(null==t?void 0:t.type)?{type:"EMPTY",value:""}:qm(e)}function Gm(e,t,i=le){const o=e.shift();if(!o||o.type!==t)throw new h(i)}function qm(e,t=0){var i;if(0===e.length)throw new h(le);let o=$m(e);for(;"OPERATOR"===(null===(i=e[0])||void 0===i?void 0:i.type)&&Hm[e[0].value]>t;){const t=e.shift().value;if(zm.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:qm(e,Hm[t])}}}return o}function Zm(e){return jm(Rm(e))}function jm(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=qm(e);if(e.length)throw new h(le);return t}function Xm(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Xm(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:Xm(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:Xm(e.right,t,i),left:Xm(e.left,t,i)};default:return e}}function Ym(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>Ym(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?Km(e)+e.value:e.value+Qm(e);case"BIN_OPERATION":return Km(e)+e.value+Qm(e)}}function Km(e){const t=e.value,i="left"in e?e.left:e.operand,o=i.value;return"BIN_OPERATION"===i.type&&Hm[o]<Hm[t]?`(${Ym(i)})`:Ym(i)}function Qm(e){const t=e.value,i="right"in e?e.right:e.operand,o=Hm[i.value],n=Hm[t];let s=!1;return"BIN_OPERATION"!==i.type?s=!1:o<n?s=!0:o!==n||Bm.includes(t)||(s=!0),s?`(${Ym(i)})`:Ym(i)}var Jm;!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"}(Jm||(Jm={}));const ef=(e,t=(()=>!0))=>[{goTo:e,guard:t}],tf=(e,t=(()=>!0))=>({goTo:e,guard:t}),of={[Jm.LeftRef]:{REFERENCE:ef(Jm.Separator),NUMBER:ef(Jm.FullRowSeparator),SYMBOL:[tf(Jm.FullColumnSeparator,(e=>Pt(e.value))),tf(Jm.FullRowSeparator,(e=>Ut(e.value)))]},[Jm.FullColumnSeparator]:{SPACE:ef(Jm.FullColumnSeparator),OPERATOR:ef(Jm.RightColumnRef,(e=>":"===e.value))},[Jm.FullRowSeparator]:{SPACE:ef(Jm.FullRowSeparator),OPERATOR:ef(Jm.RightRowRef,(e=>":"===e.value))},[Jm.Separator]:{SPACE:ef(Jm.Separator),OPERATOR:ef(Jm.RightRef,(e=>":"===e.value))},[Jm.RightRef]:{SPACE:ef(Jm.RightRef),NUMBER:ef(Jm.Found),REFERENCE:ef(Jm.Found,(e=>zt(e.value))),SYMBOL:ef(Jm.Found,(e=>Vt(e.value)))},[Jm.RightColumnRef]:{SPACE:ef(Jm.RightColumnRef),SYMBOL:ef(Jm.Found,(e=>Vt(e.value))),REFERENCE:ef(Jm.Found,(e=>zt(e.value)))},[Jm.RightRowRef]:{SPACE:ef(Jm.RightRowRef),NUMBER:ef(Jm.Found),REFERENCE:ef(Jm.Found,(e=>zt(e.value)))},[Jm.Found]:{}};function nf(e){var t;let i=0,o=of[Jm.LeftRef];const n=[];for(;void 0!==o;){const s=e[i++];if(!s)return null;const r=null===(t=o[s.type])||void 0===t?void 0:t.find((e=>e.guard(s))),a=r?r.goTo:void 0;switch(a){case void 0:return null;case Jm.Found:return n.push(s),e.splice(0,i),{type:"REFERENCE",value:rt(n.map((e=>e.value)))};default:o=of[a],n.push(s)}}return null}function sf(e){const t=Rm(e),i=[];for(;t.length;)i.push(nf(t)||t.shift());return i}const rf=Xu.content,af={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},lf={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},cf={};function hf(e){const t=sf(e),{dependencies:i,constantValues:o}=function(e){const t={numbers:[],strings:[]},i=[];for(const o of e)switch(o.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(o.value);break;case"STRING":const e=Ne(o.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=ni(o.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),n=function(e,t,i){return rt(e.map((e=>{switch(e.type){case"STRING":const o=Ne(e.value);return`|S${i.strings.indexOf(o)}|`;case"NUMBER":return`|N${i.numbers.indexOf(ni(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,o);if(!cf[n]){const r=jm([...t]),a=new Em;if("BIN_OPERATION"===r.type&&":"===r.value)throw new h(s("Invalid formula"));if("EMPTY"===r.type)throw new h(s("Invalid formula"));const l=g(r),c=new Sm;c.append(`// ${n}`),c.append(l),c.append(`return ${l.returnExpression};`);let d=new Function("deps","ref","range","ctx",c.toString());function u(e){const t=rf[e.value.toUpperCase()],i=e.args,o=i.length;if(o<t.minArgRequired)throw new h(s("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),o.toString()));if(o>t.maxArgPossible)throw new h(s("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),o.toString()));const n=t.nbrArgRepeating;if(n>1){const i=t.args.length-n;if((o-i)%n!=0)throw new h(s("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(),i.toString(),n.toString()))}let r=[];for(let n=0;n<o;n++){const o=t.getArgToFocus(n+1)-1;if(0<=o&&o<t.args.length){const a=i[n],l=t.args[o],c=l.type||[],d=c.includes("META"),u=l.lazy,p=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),m=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(m&&"REFERENCE"!==a.type)throw new h(s("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(n+1).toString(),a.type.toLowerCase()));const f=g(a,d,p,{functionName:e.value.toUpperCase(),paramIndex:n+1});r.push(u?f.wrapInClosure():f)}}return r}function g(e,t=!1,n=!1,r={}){const l=new Sm(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new h(s("Argument must be a reference to a cell or range."));switch(e.debug&&l.append("debugger;"),e.type){case"BOOLEAN":return l.return(`{ value: ${e.value} }`);case"NUMBER":return l.return(`{ value: this.constantValues.numbers[${o.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${o.strings.indexOf(e.value)}] }`);case"REFERENCE":const s=i.indexOf(e.value);return n?l.return(`range(deps[${s}])`):l.return(`ref(deps[${s}], ${t?"true":"false"}, "${r.functionName||af["="]}", ${r.paramIndex})`);case"FUNCALL":const a=u(e).map((e=>e.assignResultToVariable()));l.append(...a);const c=e.value.toUpperCase();return l.append(`ctx.__lastFnCalled = '${c}';`),l.return(`ctx['${c}'](${a.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=lf[e.value],i=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression})`)}case"BIN_OPERATION":{const t=af[e.value],i=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),o=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression}, ${o.returnExpression})`)}case"EMPTY":return l.return("undefined")}}cf[n]={execute:d}}return{execute:cf[n].execute,dependencies:i,constantValues:o,tokens:t}}function df(e){return function(e){let t=[],i="";return e.map(((e,o)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,o=Object.assign({},e,{start:t,end:t+i,length:i});return t=o.end,o}))}(sf(e))))}function uf(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function gf(e){return Math.round(Rp*e*100)/100}function pf(e){return Math.round(Tp*e*100)/100}function mf(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function ff(e,t){let i={};e.style&&(i=t.styles[e.style]);const o=function(e,t){if(e.format)return t.formats[e.format];if(e.isFormula){const t=Rm(e.content||""),i=Xu.content;if(!t.filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)))return e.computedFormat}return}(e,t),n={};if(e.border){const i=t.borders[e.border];n.left=mf(i.left),n.right=mf(i.right),n.bottom=mf(i.bottom),n.top=mf(i.top)}const s={font:{size:(null==i?void 0:i.fontSize)||q,color:{rgb:(null==i?void 0:i.textColor)?i.textColor:"000000"},family:2,name:"Arial"},fill:(null==i?void 0:i.fillColor)?{fgColor:{rgb:i.fillColor}}:{reservedAttribute:"none"},numFmt:o?{format:o,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:i.align}};return s.font.strike=!!(null==i?void 0:i.strikethrough)||void 0,s.font.underline=!!(null==i?void 0:i.underline)||void 0,s.font.bold=!!(null==i?void 0:i.bold)||void 0,s.font.italic=!!(null==i?void 0:i.italic)||void 0,s}function vf(e,t){const{id:i}=Sf(t.font,e.fonts),{id:o}=Sf(t.fill,e.fills),{id:n}=Sf(t.border,e.borders),s=function(e,t){if(!e)return 0;let i=Jp[e.format];if(!i){const{id:o}=Sf(e,t);i=o+_p}return i}(t.numFmt,e.numFmts),r={fontId:i,fillId:o,borderId:n,numFmtId:s,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=Sf(r,e.styles);return a}function bf(e,t,i){let o,n=e.find((e=>e.path===t));return n?(o=`rId${(n.rels.length+1).toString()}`,n.rels.push({...i,id:o})):(o="rId1",e.push({path:t,rels:[{...i,id:o}]})),o}function Sf(e,t){for(let[i,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(i,10),list:t};let i=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===i&&(t.push(e),i=t.length-1),{id:i,list:t}}const Cf=[];function Ef(e){const t=Cf.findIndex((t=>t===e));return-1===t?(Cf.push(e),Cf.length):t+1}const wf=[];function yf(e){const t=wf.findIndex((t=>t===e));return-1===t?(wf.push(e),wf.length):t+1}function xf(e){return Math.round(914400*e/96)}function If(e,t,i){let o,n,s=e;if(({xc:s,sheetName:o}=Bt(e)),o){const e=i.sheets.findIndex((e=>e.name===o));if(e<0)throw new Error("Unable to find a sheet with the name "+o);n=e}else n=Number(t);const r=Vi(s);return void 0===r.right&&(r.right=i.sheets[n].colNumber),void 0===r.bottom&&(r.bottom=i.sheets[n].rowNumber),(r.right-r.left+1)*(r.bottom-r.top+1)}function Rf(e){return Math.round(96*e/914400)}function Tf(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.cols.find((e=>n>=e.min&&n<=e.max));(null==e?void 0:e.width)?o+=e.width:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?o+=t.sheetFormat.defaultColWidth:o+=Ap}return o/Tp}function Af(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?o+=e.height:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?o+=t.sheetFormat.defaultRowHeight:o+=Mp}return o/Rp}function Mf(e){let t=1;return e.figures.map((i=>function(e,t,i){const o=Tf(e.anchors[0].col,i)+Rf(e.anchors[0].colOffset),n=Tf(e.anchors[1].col,i)+Rf(e.anchors[1].colOffset),s=Af(e.anchors[0].row,i)+Rf(e.anchors[0].rowOffset),r=Af(e.anchors[1].row,i)+Rf(e.anchors[1].rowOffset),a=n-o,l=r-s,c=Of(e.data);return c?{id:t,x:o,y:s,width:a,height:l,tag:"chart",data:Of(e.data)}:void 0}(i,(t++).toString(),e))).filter(ot)}function Of(e){var t;const i=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let o=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&o.reverse(),{dataSets:o,dataSetsHaveTitle:!1,labelRange:i,title:e.title||"",type:e.type,background:im({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1}}const Nf=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),_f=new RegExp(/SUBTOTAL\(([0-9]*),/g),Ff=new RegExp(Nt.source,"ig");function Df(e,t){const i=function(e){const t={};for(let i of e.rows)for(let e of i.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 o of e.rows.map((e=>e.cells)).flat())(null==o?void 0:o.formula)&&(o.formula.content=void 0===o.formula.sharedIndex||o.formula.content?"="+o.formula.content:"="+Lf(o.xc,i[o.formula.sharedIndex]),o.formula.content=kf(o.formula.content,t))}function kf(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(_f,((e,t)=>{const i=Kp[t];return i?i+"(":e}))).replace(Nf,((e,i,o,n)=>{var s;i=Number(i)-1,n=n.replace(/\$/g,"");const r=t.externalBooks[i].sheetNames.findIndex((e=>e===o));if(-1===r)return e;const a=null===(s=t.externalBooks[i].datasets.find((e=>e.sheetId===r)))||void 0===s?void 0:s.data;if(!a)return e;const l=a&&a[n];return(Number(l)?l:`"${l}"`)||e}))}function Lf(e,t){const i=Wt(t.refCellXc);let o,n=t.formula.slice();do{if(o=Ff.exec(n),o){const t=Wt(o[0].replace("$","")),s=Wt(e),r={colFixed:o[0].startsWith("$"),rowFixed:o[0].includes("$",1)},a={col:s.col-i.col,row:s.row-i.row},l={col:r.colFixed?t.col:t.col+a.col,row:r.rowFixed?t.row:t.row+a.row};n=n.slice(0,o.index)+Gt(l.col,l.row,r)+n.slice(o.index+o[0].length)}}while(o);return n}function Pf(e,t){return e.sheets.map((i=>{Df(i,e);const o=function(e){const t=[0,0];for(let i of e.rows)t[0]=Math.max(t[0],...i.cells.map((e=>Wt(e.xc).col))),t[1]=Math.max(t[1],i.index);return t[0]=Math.max(t[0],Op),t[1]=Math.max(t[1],Np),t}(i),n=i.sheetViews[0];return{id:i.sheetName,areGridLinesVisible:!n||n.showGridLines,name:i.sheetName,colNumber:o[0],rowNumber:o[1],cells:zf(i,e,o,t),merges:i.merges,cols:Uf(i,o[0]),rows:Vf(i,o[1]),conditionalFormats:pm(i.cfs,e.dxfs,t),figures:Mf(i),isVisible:i.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Uf(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?e.sheetFormat.defaultColWidth:Ap,o[s-1]={size:(n=r,n?Math.round(n/Tp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Vf(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?e.sheetFormat.defaultRowHeight:Mp,o[s-1]={size:(n=r,n?Math.round(n/Rp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function zf(e,t,i,o){const n={},s=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const r=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let i of e.rows)for(let e of i.cells)n[e.xc]={content:Bf(e,r,s,o),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 o of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=i[0];e++){const i=Gt(e-1,o.index-1);let s=n[i];s||(s={},n[i]=s),s.style=s.style?s.style:o.styleIndex+1,s.border=s.border?s.border:t.styles[o.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[o.styleIndex].numFmtId+1}for(let o of e.cols.filter((e=>e.styleIndex)))for(let e=o.min;e<=Math.min(o.max,i[0]);e++)for(let s=1;s<=i[1];s++){const i=Gt(e-1,s-1);let r=n[i];r||(r={},n[i]=r),r.style=r.style?r.style:o.styleIndex+1,r.border=r.border?r.border:t.styles[o.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[o.styleIndex].numFmtId+1}return n}function Bf(e,t,i,o){let n;switch(e.type){case"sharedString":n=i[parseInt(e.value,10)];break;case"boolean":n=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":n=e.value}return n&&t[e.xc]&&(n=function(e,t,i){const o=e.display||t;e.relTarget||e.location||i.generateNotSupportedWarning(Lp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:tt(Bt(e.location).sheetName);return Ke(o,n)}(t[e.xc],n,o)),e.formula&&(n=e.formula.content),n}const Hf={fillColor:"#000000",textColor:"#ffffff",bold:!0},$f={bold:!0},Wf=["thin","#000000FF"];function Gf(e,t){for(const i of t.sheets)for(const t of i.tables){const o=e.sheets.find((e=>e.name===i.sheetName));o&&t.autoFilter&&(o.filterTables||(o.filterTables=[]),o.filterTables.push({range:t.ref}))}!function(e,t){var i,o,n,s;const r=sm(e.styles),a=sm(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=zi(t.ref);for(let e=0;e<t.headerRowCount;e++)qf(Hf,{...h,bottom:h.top+e},c.cells,r);for(let e=0;e<t.totalsRowCount;e++)qf($f,{...h,top:h.bottom-e},c.cells,r);(null===(i=t.style)||void 0===i?void 0:i.showFirstColumn)&&qf($f,{...h,right:h.left},c.cells,r),(null===(o=t.style)||void 0===o?void 0:o.showLastColumn)&&qf($f,{...h,left:h.right},c.cells,r);for(let e=h.left;e<=h.right;e++)for(let i=h.top;i<=h.bottom;i++){const o=Gt(e,i),r=c.cells[o],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?Wf:void 0,right:e===h.right?Wf:void 0,top:i===h.top||(null===(s=t.style)||void 0===s?void 0:s.showRowStripes)||i>h.bottom-t.totalsRowCount?Wf:void 0,bottom:i===h.bottom?Wf:void 0},d=(null==r?void 0:r.border)?{...a[r.border],...l}:l;let u=a.findIndex((e=>ht(e,d)));-1===u&&(u=a.length,a.push(d)),r?r.border=u:c.cells[o]={border:u}}}e.styles=nm(r),e.borders=nm(a)}(e,t),function(e,t){for(let i of e){const e=t.find((e=>e.sheetName===i.name)).tables;for(let t of e){const e=t.name+"[";for(let o of oo(zi(t.ref))){const n=Gt(o.col,o.row),s=i.cells[n];if(s&&s.content&&s.content.startsWith("=")){let i;for(;-1!==(i=s.content.indexOf(e));){let o=s.content.slice(i+e.length),r=o.indexOf("]");o.startsWith("[")&&(r=o.indexOf("]",r+1),r=o.indexOf("]",r+1)),o=o.slice(0,r);const a=Zf(o,t,n);s.content=s.content.slice(0,i)+a+s.content.slice(e.length+i+r+1)}}}}}}(e.sheets,t.sheets)}function qf(e,t,i,o){for(let n=t.left;n<=t.right;n++)for(let s=t.top;s<=t.bottom;s++){const t=Gt(n,s),r=i[t],a=(null==r?void 0:r.style)?{...o[r.style],...e}:e;let l=o.findIndex((e=>ht(e,a)));-1===l&&(l=o.length,o.push(a)),r?r.style=l:i[t]={style:l}}}function Zf(e,t,i){const o=e.split(","),n=zi(t.ref),s={...n};let r=!0;if(1===o.length){const e=t.cols.findIndex((e=>e.name===o[0]));s.left=s.right=e+n.left,t.headerRowCount&&(s.top+=t.headerRowCount),t.totalsRowCount&&(s.bottom-=1)}else{switch(o[0].slice(1,o[0].length-1)){case"#All":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=n.bottom;break;case"#Data":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=t.totalsRowCount?n.bottom+1:n.bottom;break;case"#This Row":s.top=s.bottom=Wt(i).row;break;case"#Headers":s.top=s.bottom=n.top,t.headerRowCount||(r=!1);break;case"#Totals":s.top=s.bottom=n.bottom,t.totalsRowCount||(r=!1)}const e=o[1].slice(1,o[1].length-1),a=t.cols.findIndex((t=>t.name===e));s.left=s.right=a+n.left}return r?s.top!==s.bottom?Hi(s):Gt(s.left,s.top):K}function jf(e,t,i){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:i}}function Xf(e){return String(e).replace(/\&/g,"&amp;").replace(/\</g,"&lt;").replace(/\>/g,"&gt;").replace(/\"/g,"&quot;").replace(/\'/g,"&apos;")}function Yf(e){return new fp(e.map((([e,t])=>`${e}="${Xf(t)}"`)).join(" "))}function Kf(e,t="text/xml"){const i=(new DOMParser).parseFromString(e.toString(),t),o=i.querySelector("parsererror");if(o){const t=o.innerHTML,i=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),s=n.slice(Math.max(i-3,0),Math.min(i+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${s}`)}return i}function Qf(e,t){return ev`
1399
1399
  <Override ContentType="${t}" PartName="${e}" />
1400
- `}function Qf(e){return new mp(e.join("\n"))}function Jf(e,...t){let i=[e[0]];for(let o=0;o<t.length;o++){const n=t[o]instanceof mp?t[o]:jf(t[o]);i.push(n+e[o+1])}return new mp(st(i))}function ev(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function tv(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class iv{constructor(e){this.value=e}asString(){return sm(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class ov{constructor(e,t,i){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=i,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(it)}mapOnElements(e,t){var i;const o=[],n=this.currentFile;let s;if(e.children){const t=null===(i=this.querySelector(e.parent,e.query))||void 0===i?void 0:i.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,o}catchErrorOnElement(e,t){const i=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([i,e.message].join("\n"))}extractAttr(e,t,i){const o=e.attributes[t];o||this.handleMissingValue(e,`attribute "${t}"`,i);const n=(null==o?void 0:o.value)?o.value:null==i?void 0:i.default;return void 0===n?void 0:new iv(n)}extractTextContent(e,t){var i;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===(null===(i=null==e?void 0:e.attributes["xml:space"])||void 0===i?void 0:i.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=o?n:n.trim()),n?sm(n):null==t?void 0:t.default}extractChildAttr(e,t,i,o){var n;let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,o);const r=s?null===(n=this.extractAttr(s,i,o))||void 0===n?void 0:n.asString():null==o?void 0:o.default;return void 0!==r?new iv(r):void 0}extractChildTextContent(e,t,i){if(void 0!==(null==i?void 0:i.default)&&"string"!=typeof i.default)throw new Error("extractTextContent default value should be a string");let o=this.querySelector(e,t);return o||this.handleMissingValue(e,`child <${t}>`,i),o?this.extractTextContent(o,i):null==i?void 0:i.default}handleMissingValue(e,t,i){if(null==i?void 0:i.required){if(!(null==i?void 0:i.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 ${i.default}`)}}extractColor(e,t,i){var o,n,s,r,a;if(!e)return i?{rgb:i}:void 0;const l=null===(o=this.extractAttr(e,"theme"))||void 0===o?void 0:o.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===(n=this.extractAttr(e,"rgb"))||void 0===n?void 0:n.asString();return{rgb:c,auto:null===(s=this.extractAttr(e,"auto"))||void 0===s?void 0:s.asBool(),indexed:null===(r=this.extractAttr(e,"indexed"))||void 0===r?void 0:r.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 i=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!i||!i.file)throw new Error("Cannot find target file");return i}querySelector(e,t){return t=this.areNamespaceIgnored?ev(t):tv(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?ev(t):tv(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 nv extends ov{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:vp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:vp}).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 sv extends ov{constructor(e,t,i,o){super(e,t,i),this.theme=o}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 i,o,n,s,r,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===(i=this.extractAttr(e,"dxfId"))||void 0===i?void 0:i.asNum(),stopIfTrue:null===(o=this.extractAttr(e,"stopIfTrue"))||void 0===o?void 0:o.asBool(),aboveAverage:null===(n=this.extractAttr(e,"aboveAverage"))||void 0===n?void 0:n.asBool(),percent:null===(s=this.extractAttr(e,"percent"))||void 0===s?void 0:s.asBool(),bottom:null===(r=this.extractAttr(e,"bottom"))||void 0===r?void 0:r.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 i=this.querySelector(e,"colorScale");if(i)return{colors:this.mapOnElements({parent:i,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(i)}}extractCfIconSet(e){var t,i;const o=this.querySelector(e,"iconSet, x14:iconSet");if(o)return{iconSet:this.extractAttr(o,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(o,"showValue",{default:!0}).asBool(),percent:this.extractAttr(o,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(o,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(i=this.extractAttr(o,"custom"))||void 0===i?void 0:i.asBool(),cfvos:this.extractCFVos(o),cfIcons:this.extractCfIcons(o)}}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,i;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===(i=this.extractAttr(e,"val"))||void 0===i?void 0:i.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class rv extends ov{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!Xp[t])throw new Error(`Unsupported chart type ${t}`);const i=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),o=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:i,type:Xp[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:jp[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===o,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=ev(e.tagName);if(fp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class av extends ov{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==ev(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 i=this.querySelector(t,e);if(!i)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(i,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(i,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(i,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(i,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),i=this.getTargetXmlFile(this.relationships[t]),o=new rv(i,this.xlsxFileStructure,this.warningManager).extractChart();if(!o)throw new Error("Unable to extract chart definition");return o}}class lv extends ov{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 cv extends ov{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,i,o,n,s;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(i=this.extractAttr(e,"showFirstColumn"))||void 0===i?void 0:i.asBool(),showLastColumn:null===(o=this.extractAttr(e,"showLastColumn"))||void 0===o?void 0:o.asBool(),showRowStripes:null===(n=this.extractAttr(e,"showRowStripes"))||void 0===n?void 0:n.asBool(),showColumnStripes:null===(s=this.extractAttr(e,"showColumnStripes"))||void 0===s?void 0:s.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 hv extends ov{constructor(e,t,i,o){super(e,t,i),this.theme=o}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=im(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=im(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,i=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(!i)throw new Error("Cannot find corresponding workbook sheet");return i}extractConditionalFormats(){return new sv(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new av(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new cv(o,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 lv(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:Tp.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:Ap.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,i,o,n,s,r,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(i=this.extractAttr(e,"customWidth"))||void 0===i?void 0:i.asBool(),bestFit:null===(o=this.extractAttr(e,"bestFit"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),min:null===(s=this.extractAttr(e,"min",{required:!0}))||void 0===s?void 0:s.asNum(),max:null===(r=this.extractAttr(e,"max",{required:!0}))||void 0===r?void 0:r.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,i,o,n,s;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(i=this.extractAttr(e,"ht"))||void 0===i?void 0:i.asNum(),customHeight:null===(o=this.extractAttr(e,"customHeight"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),styleIndex:null===(s=this.extractAttr(e,"s"))||void 0===s?void 0:s.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,i,o;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(i=this.extractAttr(e,"s"))||void 0===i?void 0:i.asNum(),type:Hp[null===(o=this.extractAttr(e,"t",{default:"n"}))||void 0===o?void 0:o.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,i;const o=this.querySelector(e,"f");if(o)return{content:this.extractTextContent(o),sharedIndex:null===(t=this.extractAttr(o,"si"))||void 0===t?void 0:t.asNum(),ref:null===(i=this.extractAttr(o,"ref"))||void 0===i?void 0:i.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,i,o,n;const s=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(i=this.extractAttr(e,"ref",{required:!0}))||void 0===i?void 0:i.asString(),location:null===(o=this.extractAttr(e,"location"))||void 0===o?void 0:o.asString(),display:null===(n=this.extractAttr(e,"display"))||void 0===n?void 0:n.asString(),relTarget:s?this.relationships[s].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),i={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),o=this.extractTextContent(e,{required:!0});i[t]=o}const o=[];for(let e=0;e<Object.keys(i).length;e++)i[e]?o.push(i[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),o.push(""));return o}}class dv extends ov{constructor(e,t,i){super(e.styles,e,t),this.theme=i}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,i,o,n;const s=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),r=this.extractChildAttr(e,"sz","val",{default:q.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===(i=h.attributes.val)||void 0===i?void 0:i.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(o=u.attributes.val)||void 0===o?void 0:o.value),p=this.querySelector(e,"u")||void 0;return{name:s,size:r,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(n=p.attributes.val)||void 0===n?void 0:n.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const i=e.children[0];return"patternFill"===i.tagName?{patternType:null===(t=i.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(i,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(i,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(i,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,i;const o={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 o.diagonal&&(o.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),o.diagonalDown=null===(i=this.extractAttr(e,"diagonalDown"))||void 0===i?void 0:i.asBool()),o}extractSingleBorder(e,t,i){const o=this.querySelector(e,t);if(o&&o.attributes.style)return{style:this.extractAttr(o,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(o.children[0],i,"000000")}}extractAlignment(e){var t,i,o,n,s,r,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===(i=this.extractAttr(e,"wrapText"))||void 0===i?void 0:i.asBool(),indent:null===(o=this.extractAttr(e,"indent"))||void 0===o?void 0:o.asNum(),relativeIndent:null===(n=this.extractAttr(e,"relativeIndent"))||void 0===n?void 0:n.asNum(),justifyLastLine:null===(s=this.extractAttr(e,"justifyLastLine"))||void 0===s?void 0:s.asBool(),shrinkToFit:null===(r=this.extractAttr(e,"shrinkToFit"))||void 0===r?void 0:r.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"),i=this.querySelector(e,"fill"),o=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),s=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:i?this.extractFill(i):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:s?this.extractAlignment(s):void 0,border:o?this.extractBorder(o):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 uv extends ov{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})}))),i={};for(let e of t)i[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:i}}))}}function gv(e,t){const i=function(e,t){const i=t[Dp],o=i.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of o){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const i=[];for(let o of e){const e=pv(o,t);i.push({file:{fileName:o,xml:t[o]},rels:e?{fileName:e,xml:t[e]}:void 0})}return i}(i,t)}function pv(e,t){if(e===Dp)return"_rels/.rels";let i="";const o=e.split("/");for(let e=0;e<o.length-1;e++)i+=o[e]+"/";return i+="_rels/",i+=o[o.length-1]+".rels",t[i]||(i=void 0),i}class mv{constructor(e){this.warningManager=new Lp,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=Yf(new mp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new nv(e.theme,e,this.warningManager).getTheme():void 0,i=e.sharedStrings?new nv(e.sharedStrings,e,this.warningManager).getSharedStrings():[],o=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((i=>new hv(i,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new uv(t,e,this.warningManager).getExternalBook())),s=new dv(e,this.warningManager,t);return{fonts:s.getFonts(),fills:s.getFills(),borders:s.getBorders(),dxfs:s.getDxfs(),numFmts:s.getNumFormats(),styles:s.getStyles(),sheets:o,sharedStrings:i,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:gv(wp.sheet,this.xmls),workbook:gv(wp.workbook,this.xmls)[0],styles:gv(wp.styles,this.xmls)[0],sharedStrings:gv(wp.sharedStrings,this.xmls)[0],theme:gv(wp.themes,this.xmls)[0],charts:gv(wp.chart,this.xmls),figures:gv(wp.drawing,this.xmls),tables:gv(wp.table,this.xmls),pivots:gv(wp.pivot,this.xmls),externalLinks:gv(wp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(s("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Lf(e,this.warningManager),styles:hm(e,this.warningManager),formats:um(e,this.warningManager),borders:lm(e,this.warningManager),entities:{},revisionId:Q};return Wf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=dt(e.styles[t])})),t}}function fv(e){const t=nf(e);let i=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Ot.test(e.value)){const t=e.value.trim();return i.includes(t)||i.push(t),`${ae}${i.indexOf(t)}${ae}`}return e.value}))),dependencies:i}}const vv=12,bv="Sheet1";function Sv(e,t){if(!e)return xv();if(e["[Content_Types].xml"]){const i=new mv(e);if(e=i.convertXlsx(),t)for(let e of i.warningManager.warnings.sort())console.warn(e)}return"version"in(e=_e(e))&&e.version<vv&&(e=function(e){for(let t=Cv.findIndex((t=>t.from===e.version));t<Cv.length;t++)e=Cv[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,i=new Pi;for(const o of e.sheets||[])for(const e of o.figures||[])t.has(e.id)&&(e.id+=i.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(xv(),e,{version:vv}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(yv(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(yv(bv,"Sheet1"));return e}(e),e}(e),e}const Cv=[{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 i=t.cells[e];i.content&&i.content.startsWith("=")&&(i.formula=fv(i.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:i,...o}=t.figures[e].data,n=[];for(let e of i)if(e.labelCell){const t=Vi(e.dataRange),i=e.labelCell+":"+Wt(t.right,t.bottom);n.push(i)}else n.push(e.dataRange);o.dataSetsHaveTitle=Boolean(i[0].labelCell),o.dataSets=n,t.figures[e].data=o}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const i=[],o=new RegExp(re,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,s=e.replace(o,"_");let r=1,a=s;for(;i.includes(a);)a=`${s}${r}`,r++;n.name=a,i.push(a);const l=t=>{if(void 0===t)return t;let i=t.replace(e,a),o=t;for(;o!==i;)o=i,i=o.replace(e,a);return o};for(let e in n.cells){const t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of n.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),i=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:i}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const i of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[i])||void 0===t?void 0:t.type)&&(e.rule[i].value=l(e.rule[i].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 i=t.cells[e];if(i.formula){let{text:e,dependencies:t}=i.formula;for(let[i,o]of Object.entries(t)){const t=`\\${ae}${i}\\${ae}`;e=e.replace(new RegExp(t,"g"),o)}i.content=e,delete i.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let i of e.sheets||[])for(let e in i.cells||[]){const o=i.cells[e];o.format&&(o.format=nt(o.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 Ev(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const i=[],o=[],n=e=>{if("CREATE_SHEET"===e.type)i.push(e.sheetId);else if("sheetId"in e&&!i.includes(e.sheetId))return{...e,sheetId:bv};return e};for(const e of t)"REMOTE_REVISION"===e.type?o.push({...e,commands:e.commands.map(n)}):o.push(e);return o}(e,t),t=wv(t,"SORT_CELLS"),t=function(e,t){var i;const o=[],n={};for(const t of e.sheets||[])null===(i=t.figures)||void 0===i||i.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const i of e.commands){let e=i;switch(i.type){case"CREATE_CHART":n[i.id]=i.definition;break;case"UPDATE_CHART":if(!n[i.id]){console.log(`Fix chart definition: chart with id ${i.id} not found.`);continue}const t={...n[i.id],...i.definition};e={...i,definition:t},n[i.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=wv(t,"SET_DECIMAL")),t}function wv(e,t){const i=[];for(const o of e)"REMOTE_REVISION"===o.type?i.push({...o,commands:o.commands.filter((e=>e.type!==t))}):i.push(o);return i}function yv(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function xv(e="Sheet1"){return{version:vv,sheets:[yv(bv,e)],entities:{},styles:{},formats:{},borders:{},revisionId:Q,uniqueFigureIds:!0}}function Iv(e,t){return{...yv(e,t),charts:[],images:[]}}class Rv{constructor(e,t){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 i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const o=e.filter((e=>0!==e));if(o.length)return o}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Rv.getters=[];class Tv extends Rv{constructor({getters:e,stateObserver:t,range:i,dispatch:o,uuidGenerator:n}){super(t,o),this.range=i,i.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class Av extends Tv{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 i=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,i)}break;case"DELETE_SHEET":const i={...this.borders};delete i[e.sheetId],this.history.update("borders",i);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,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,i)}handleAddRows(e){let t,i;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,i)}getCellBorder({sheetId:e,col:t,row:i}){var o,n,s,r,a,l,c,h,d,u,g,p;const m={top:null===(s=null===(n=null===(o=this.borders[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.horizontal,bottom:null===(l=null===(a=null===(r=this.borders[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i+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[i])||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[i])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,i){const o=He(t+1,i);for(let n=0;n<this.getters.getNumberRows(e);n++){const s=this.getCellBorder({sheetId:e,col:t,row:n}),r=this.getCellBorder({sheetId:e,col:i,row:n});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,i,n,t)}}}ensureRowBorderContinuity(e,t,i){const o=He(t+1,i);for(let n=0;n<this.getters.getNumberCols(e);n++){const s=this.getCellBorder({sheetId:e,col:n,row:t}),r=this.getCellBorder({sheetId:e,col:n,row:i});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,n,i,t)}}}getCommonSides(e,t){const i={};for(let o of["top","bottom","left","right"])e[o]&&e[o]===t[o]&&(i[o]=e[o]);return i}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?He(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,i,{moveFirstLeftBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfColumn(e,t,i,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfColumn(e,n,i,"vertical"),this.moveBordersOfColumn(e,n,i,"horizontal")})))}shiftBordersVertically(e,t,i,{moveFirstTopBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfRow(e,t,i,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfRow(e,n,i,"horizontal"),this.moveBordersOfRow(e,n,i,"vertical")})))}moveBordersOfRow(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getColumnsWithBorders(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[r])||void 0===a?void 0:a[t+i])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o];this.history.update("borders",e,r,t+i,o,n?u:u||d),this.history.update("borders",e,r,t,o,void 0)}))}moveBordersOfColumn(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getRowsRange(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[t+i])||void 0===a?void 0:a[r])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[o];this.history.update("borders",e,t+i,r,o,n?u:u||d),this.history.update("borders",e,t,r,o,void 0)}))}setBorder(e,t,i,o,n=!0){var s,r,a,l,c,h,d,u,g,p,m,f,v,b,S,C;!n&&(null===(l=null===(a=null===(r=null===(s=this.borders)||void 0===s?void 0:s[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,i,"vertical",null==o?void 0:o.left),!n&&(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[i])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,i,"horizontal",null==o?void 0:o.top),!n&&(null===(f=null===(m=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===m?void 0:m[i])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,i,"vertical",null==o?void 0:o.right),!n&&(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[i+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,i+1,"horizontal",null==o?void 0:o.bottom)}clearBorders(e,t){for(let i of t){for(let t=i.top;t<=i.bottom;t++){this.history.update("borders",e,i.right+1,t,"vertical",void 0);for(let o=i.left;o<=i.right;o++)this.history.update("borders",e,o,t,void 0)}for(let t=i.left;t<=i.right;t++)this.history.update("borders",e,t,i.bottom+1,"horizontal",void 0)}}addBorder(e,t,i,o){this.setBorder(e,t,i,{...this.getCellBorder({sheetId:e,col:t,row:i}),...o})}setBorders(e,t,i){if("clear"===i)return this.clearBorders(e,t);for(let o of t){if("h"===i||"hv"===i||"all"===i)for(let t=o.top+1;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++)this.addBorder(e,i,t,{top:j});if("v"===i||"hv"===i||"all"===i)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left+1;i<=o.right;i++)this.addBorder(e,i,t,{left:j});if("left"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.left,t,{left:j});if("right"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.right+1,t,{left:j});if("top"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.top,{top:j});if("bottom"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.bottom+1,{top:j})}}addBordersToMerge(e,t){const{left:i,right:o,top:n,bottom:s}=t,r=this.getCellBorder({sheetId:e,col:i,row:n}),a=this.getCellBorder({sheetId:e,col:o,row:s});this.clearBorders(e,[t]),(null==r?void 0:r.top)&&this.setBorders(e,[{...t,bottom:n}],"top"),(null==r?void 0:r.left)&&this.setBorders(e,[{...t,right:i}],"left"),((null==a?void 0:a.bottom)||(null==r?void 0:r.bottom))&&this.setBorders(e,[{...t,top:s}],"bottom"),((null==a?void 0:a.right)||(null==r?void 0:r.right))&&this.setBorders(e,[{...t,left:o}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[i,o]of Object.entries(t.cells))if(null==o?void 0:o.border){const n=e.borders[o.border],{col:s,row:r}=$t(i);this.setBorder(t.id,s,r,n,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,Vi(e))}export(e){let t=0;const i={};function o(e){for(let[t,o]of Object.entries(i))if(Me(o)===Me(e))return parseInt(t,10);return i[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let i=0;i<t.rowNumber;i++){const n=this.getCellBorder({sheetId:t.id,col:e,row:i});if(n){const s=Wt(e,i),r=t.cells[s],a=o(n);r?r.border=a:t.cells[s]={border:a}}}e.borders=i}exportForExcel(e){this.export(e)}}Av.getters=["getCellBorder"];class Mv extends Tv{constructor(){super(...arguments),this.nextId=1,this.cells={}}adaptRanges(e,t){for(const i of Object.keys(this.cells))for(const o of Object.values(this.cells[i]||{}))if(o.isFormula)for(const n of o.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",i,o.id,"dependencies",o.dependencies.indexOf(n),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,i){for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:i})}clearFormatting(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:null,format:""})}handleAddColumnsRows(e,t){let i,o;"before"===e.position?(i=He(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=He(e.base+1,e.base+e.quantity+1),o=e.base),t(e.sheetId,o,i)}import(e){for(let t of e.sheets)for(let i in t.cells){const o=t.cells[i],{col:n,row:s}=$t(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(t.id,o,e.styles,e.formats);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cellId:i.id,col:n,row:s,sheetId:t.id})}}}export(e){const t={},i={};for(let o of e.sheets){const e={},n=Object.keys(this.cells[o.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const o of n){const n=this.getters.getCell(o);e[Wt(o.col,o.row)]={style:n.style?nt(n.style,t):void 0,format:n.format?nt(n.format,i):void 0,content:n.content||void 0}}o.cells=e}e.styles=t,e.formats=i}importCell(e,t,i,o){const n=t.style&&i[t.style]||void 0,s=t.format&&o[t.format]||void 0,r=this.getNextUid();return this.createCell(r,(null==t?void 0:t.content)||"",s,n,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const i=this.cells[t][e];if(i)return i}}buildFormulaContent(e,t,i){const o=i||[...t.dependencies];return st(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=o.shift();return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){var t;return(null===(t=this.getters.getCell(e))||void 0===t?void 0:t.style)||{}}zoneToXC(e,t,i=[{colFixed:!1,rowFixed:!1}]){const o=Wt((t=this.getters.expandZone(e,t)).left,t.top,i[0]),n=Wt(t.right,t.bottom,i.length>1?i[1]:i[0]),s=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),r=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=s.col===r.col&&s.row===r.row;return o==n||a?o:o+":"+n}setStyle(e,t,i){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){const o=this.getters.getCell({sheetId:e,col:t,row:n});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:i?{...null==o?void 0:o.style,...i}:void 0})}}copyColumnStyle(e,t,i){for(let o=0;o<this.getters.getNumberRows(e);o++){const n=this.getFormat(e,t,o);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,...n})}}copyRowStyle(e,t,i){for(let o=0;o<this.getters.getNumberCols(e);o++){const n=this.getFormat(e,o,t);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,...n})}}getFormat(e,t,i){const o={},n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.getters.getCell(n);return s&&(s.style&&(o.style=s.style),s.format&&(o.format=s.format)),o}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,i,o){const n=this.getters.getCell({sheetId:e,col:t,row:i}),s="content"in o||"formula"in o,r=s?ft(null==o?void 0:o.content):(null==n?void 0:n.content)||"";let a;a=void 0!==o.style?o.style||void 0:n?n.style:void 0;let l=("format"in o?o.format:n&&n.format)||xi(r);if((s&&!r&&!o.formula||!s&&(!n||""===n.content))&&!a&&!l)return void(n&&(this.history.update("cells",e,n.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:i,sheetId:e})));const c=(null==n?void 0:n.id)||this.getNextUid(),h=this.createCell(c,r,l,a,e);this.history.update("cells",e,h.id,h),this.dispatch("UPDATE_CELL_POSITION",{cellId:h.id,col:t,row:i,sheetId:e})}createCell(e,t,i,o,n){if(!t.startsWith("="))return this.createLiteralCell(e,t,i,o);try{return this.createFormulaCell(e,t,i,o,n)}catch(n){return this.createErrorFormula(e,t,i,o,n)}}createLiteralCell(e,t,i,o){return{id:e,content:t,style:o,format:i,isFormula:!1}}createFormulaCell(e,t,i,o,n){const s=cf(t);return s.dependencies.length?this.createFormulaCellWithDependencies(e,s,i,o,n):{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:s,dependencies:[]}}createFormulaCellWithDependencies(e,t,i,o,n){const s=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(n,e))),r=this.buildFormulaContent.bind(this);return{id:e,get content(){return r(n,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})},style:o,format:i,isFormula:!0,compiledFormula:t,dependencies:s}}createErrorFormula(e,t,i,o,n){return{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:{dependencies:[],tokens:Im(t),execute:function(){throw n}},dependencies:[]}}checkCellOutOfSheet(e,t,i){if(!this.getters.tryGetSheet(e))return 27;return Yi(t,i,this.getters.getSheetZone(e))?0:18}}Mv.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Ov extends Tv{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=ar.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i,o,n){const s=t.find((e=>e.match(o.type)));if(!s)throw new Error(`No builder for this chart: ${o.type}`);return s.createChart(o,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const i=ar.getAll().find((e=>e.match(t.type)));if(!i)throw new Error("Unknown chart type.");return i.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,i]of Object.entries(this.charts))this.history.update("charts",t,null==i?void 0:i.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 i=this.getters.getFigures(e.sheetId);for(const o of i)if("chart"===o.tag){const i=o.id.split(ee).pop(),n=`${e.sheetIdTo}${ee}${i}`,s=null===(t=this.charts[o.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:n,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.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 i=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!i)throw new Error("Chart not defined.");return i}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 i=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!i)throw new Error(`There is no chart with the given figureId: ${e}`);return i}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 i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();i&&(e.data=i,o.push(e))}else o.push(e)}i.figures=o}}exportForExcel(e){var t;for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e)if(i&&"chart"===i.tag){const e=null===(t=this.charts[i.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&o.push({...i,data:e})}i.charts=o}}addFigure(e,t,i={x:0,y:0},o={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const i=this.getters.getFigureSheetId(e);i&&this.history.update("charts",e,this.createChart(e,t,i))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?84:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:85}}function Nv(e){return""===e?NaN:Number(e)}Ov.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class _v extends Tv{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const i of this.cfRules[e])for(const o of i.ranges){const n=t(o);switch(n.changeType){case"REMOVE":let t=i.ranges.slice();t.splice(i.ranges.indexOf(o),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",t):this.removeConditionalFormatting(i.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",i.ranges.indexOf(o),n.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 i={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(i,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 i=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{i.add(e)}))})),Array.from(i)}getRulesByZone(e,t){const i=new Set;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,o).forEach((e=>{i.add(e.id)}))}return i}getRulesByCell(e,t,i){const o=[];for(let n of this.cfRules[e])for(let e of n.ranges)Yi(t,i,e.zone)&&o.push(n);return new Set(o.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 i={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return i}addConditionalFormatting(e,t){const i=this.cfRules[t].slice(),o=i.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);o>-1?i.splice(o,1,n):i.push(n),this.history.update("cfRules",t,i)}checkValidReordering(e,t,i){if(!this.cfRules[i])return 27;const o=this.cfRules[i].findIndex((t=>t.id===e));if(-1===o)return 71;const n="up"===t?o-1:o+1;return n<0||n>=this.cfRules[i].length?71: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 i=>{if(t.includes(i.operator)){const t=[],o=e=>void 0===e||""===e;return e>=1&&o(i.values[0])&&t.push(51),e>=2&&o(i.values[1])&&t.push(52),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 53;case"max":return 55;case"mid":return 54;case"upperInflectionPoint":return 56;case"lowerInflectionPoint":return 57}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{cf(e.value||"")}catch(e){switch(t){case"min":return 58;case"max":return 60;case"mid":return 59;case"upperInflectionPoint":return 61;case"lowerInflectionPoint":return 62}}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,i=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(i)?48:0}checkMinBiggerThanMax(e){const t=e.minimum.value,i=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&Nv(t)>=Nv(i)?47:0}checkMidBiggerThanMax(e){var t;const i=null===(t=e.midpoint)||void 0===t?void 0:t.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&Nv(i)>=Nv(o)?49:0}checkMinBiggerThanMid(e){var t;const i=e.minimum.value,o=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&&Nv(i)>=Nv(o)?50:0}removeConditionalFormatting(e,t){const i=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==i){const e=this.cfRules[t].slice();e.splice(i,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,i){const o=this.cfRules[i].findIndex((t=>t.id===e)),n="up"===t?o-1:o+1;if(!(n<0||n>=this.cfRules[i].length)&&-1!==o&&-1!==n){const e=[...this.cfRules[i]],t=e[o];e[o]=e[n],e[n]=t,this.history.update("cfRules",i,e)}}}_v.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Fv extends Tv{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:i,...o}=e,n=o;this.updateFigure(i,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[i,o]of Object.entries(t))switch(i){case"x":case"y":void 0!==o&&this.history.update("figures",e,t.id,i,Math.max(o,0));break;case"width":case"height":void 0!==o&&this.history.update("figures",e,t.id,i,o)}}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 i;return void 0===(null===(i=this.figures[e])||void 0===i?void 0:i[t])?70:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?82:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(it)}getFigure(e,t){var i;return null===(i=this.figures[e])||void 0===i?void 0:i[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var i;return void 0!==(null===(i=this.figures[t])||void 0===i?void 0:i[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 i=void 0;t.figures.push({...e,data:i})}}exportForExcel(e){this.export(e)}}Fv.getters=["getFigures","getFigure","getFigureSheetId"];class Dv{constructor(e){this.filters=[],this.zone=e;const t=new Pi;this.id=t.uuidv4();for(const i of He(e.left,e.right+1)){const e={...this.zone,left:i,right:i};this.filters.push(new kv(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 Dv(this.zone)}}class kv{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 Lv extends Tv{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!co(...e.target))return 81;const t=qi(...e.target),i=()=>this.getFilterTables(e.sheetId).some((e=>Xi(e.zone,t)))?78:0,o=()=>{const i=this.getters.getMergesInZone(e.sheetId,t);for(let e of i)if(Xi(t,e))return 80;return 0};return this.checkValidations(e,i,o);case"ADD_MERGE":for(let t of e.target)for(let i of this.getFilterTables(e.sheetId))if(Xi(i.zone,t))return 80}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":const i={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=_e(t);i[e.id]=e}this.history.update("tables",e.sheetIdTo,i);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=qi(...e.target),i=this.createFilterTable(t);this.history.update("tables",e.sheetId,i.id,i);break}case"REMOVE_FILTER_TABLE":{const t={};for(const i of this.getFilterTables(e.sheetId))e.target.every((e=>!Zi(e,i.zone)))&&(t[i.id]=i);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let i of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,i)&&this.extendTableDown(t,i);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(it):[]}getFilter(e){var t;return null===(t=this.getFilterTable(e))||void 0===t?void 0:t.filters.find((t=>t.col===e.col))}getFilterId(e){var t;return null===(t=this.getFilter(e))||void 0===t?void 0:t.id}getFilterTable({sheetId:e,col:t,row:i}){return this.getFilterTables(e).find((e=>Yi(t,i,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Ki(e.zone,t)))}doesZonesContainFilter(e,t){for(const i of t)for(const t of this.getFilterTables(e))if(Zi(i,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Hi(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o=[];for(const i of t.filters){const t=Hi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);o.push(new kv(i.id,t))}if(o.length<eo(i).numberOfCols){for(let e=i.left;e<=i.right;e++)o.find((t=>t.col===e))||o.push(new kv(this.uuidGenerator.uuidv4(),{...i,left:e,right:e}));o.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Gi(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(i){if(Bi(i)!==Bi(t.zone)){const o=[];for(const i of t.filters){const t=Gi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&o.push(new kv(i.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}else{const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i)}}}createFilterTable(e){return new Dv(e)}extendTableDown(e,t){const i={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",i);for(let i=0;i<t.filters.length;i++){const o=t.filters[i],n={...o.zoneWithHeaders,bottom:o.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",i,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:i,row:o},n){var s;if(!e)return;const r=n.zone;if(!(r.bottom+1===o&&i>=r.left&&i<=r.right))return!1;for(const e of He(r.left,r.right+1)){const i={sheetId:t,col:e,row:o};if(null===(s=this.getters.getCell(i))||void 0===s?void 0:s.content)return!1;if(this.getters.getFilter(i))return!1;if(this.getters.isInMerge(i))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const i=this.createFilterTable(Vi(e.range));this.history.update("tables",t.id,i.id,i)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:Bi(e.zone)})}exportForExcel(e){this.export(e)}}Lv.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Pv extends Tv{constructor(){super(...arguments),this.sizes={}}handle(e){var t,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),i={COL:t.COL.map((e=>({manualSize:void 0,computedSize:rt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:rt(e)})))};this.history.update("sizes",e.sheetId,i);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,_e(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const o={...this.sizes};delete o[e.sheetId],this.history.update("sizes",o);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);const i=Math.min(...e.elements);t=t.map(((t,o)=>"ROW"===e.dimension&&o>=i?{manualSize:t.manualSize,computedSize:rt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const i=lt(e.position,e.base),o=t[e.base],n=He(0,e.quantity).map((()=>({manualSize:o.manualSize,computedSize:rt(o.computedSize())})));t.splice(i,0,...n),t=t.map(((t,i)=>"ROW"===e.dimension&&i>e.base+e.quantity?{manualSize:t.manualSize,computedSize:rt((()=>this.getRowTallestCellSize(e.sheetId,i)))}: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 i=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:rt(i)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:rt(e.size||F)});break;case"UPDATE_CELL":const n=null===(i=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[e.row];if(n&&!n.manualSize){const{sheetId:t,row:i}=e;this.history.update("sizes",t,"ROW",i,"computedSize",rt((()=>this.getRowTallestCellSize(t,i))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let i of He(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,i);t!==this.getRowSize(e.sheetId,i)&&this.history.update("sizes",e.sheetId,"ROW",i,"computedSize",rt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,i){var o,n,s,r;return Math.round((null===(n=null===(o=this.sizes[e])||void 0===o?void 0:o[t][i])||void 0===n?void 0:n.manualSize)||(null===(r=null===(s=this.sizes[e])||void 0===s?void 0:s[t][i])||void 0===r?void 0:r.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,i;const o={COL:[],ROW:[]};for(let t of He(0,this.getters.getNumberCols(e)))o.COL.push(this.getHeaderSize(e,"COL",t));for(let n of He(0,this.getters.getNumberRows(e))){let s=null===(i=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[n].manualSize;if(!s){s=this.getRowTallestCellSize(e,n)}o.ROW.push(s)}return o}getDefaultHeaderSize(e){return"COL"===e?F:D}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return D;return function(e){return e&&e.content?Le(Be(e.style),e.isFormula?1:e.content.split(he).length)+2*z:D}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const i=this.getters.getRowCells(e,t);let o=0;for(let e=0;e<i.length;e++){const t=this.getters.getCellById(i[e]);if(!t)continue;const n=this.getters.getCellPosition(t.id),s=this.getCellHeight(n);s>o&&s>D&&(o=s)}return o<=D?D:o}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[i,o]of Object.entries(t.rows))o.size&&(e.ROW[i]=o.size);for(let[i,o]of Object.entries(t.cols))o.size&&(e.COL[i]=o.size);const i=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:i.COL.map(((t,i)=>({manualSize:e.COL[i],computedSize:rt(t)}))),ROW:i.ROW.map(((t,i)=>({manualSize:e.ROW[i],computedSize:rt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var i,o;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of He(0,this.getters.getNumberRows(n.id)))(t||(null===(i=this.sizes[n.id].ROW[e])||void 0===i?void 0:i.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of He(0,this.getters.getNumberCols(n.id)))(t||(null===(o=this.sizes[n.id].COL[e])||void 0===o?void 0:o.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Pv.getters=["getRowSize","getColSize"];class Uv extends Tv{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),i="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=i?66:Math.min(...e.elements)<0||Math.max(...e.elements)>i?86:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.checkElementsIncludeAllVisibleHeaders(e.sheetId,e.dimension,e.elements)?8:0:27}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,_e(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 i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],i=lt(e.position,e.base);t.splice(i,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)}}checkElementsIncludeAllVisibleHeaders(e,t,i){return ht(i,this.getAllVisibleHeaders(e,t))}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],i=this.hiddenHeaders[e].COL;for(let e=0;e<i.length;e++){i[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=[[]],i=this.hiddenHeaders[e].ROW;for(let e=0;e<i.length;e++){i[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}getAllVisibleHeaders(e,t){return He(0,this.hiddenHeaders[e][t].length).filter((i=>!this.hiddenHeaders[e][t][i]))}import(e){var t,i;for(let o of e.sheets){this.hiddenHeaders[o.id]={COL:[],ROW:[]};for(let e=0;e<o.rowNumber;e++)this.hiddenHeaders[o.id].ROW[e]=Boolean(null===(t=o.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<o.colNumber;e++)this.hiddenHeaders[o.id].COL[e]=Boolean(null===(i=o.cols[e])||void 0===i?void 0:i.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e=0;e<this.getters.getNumberRows(i.id);e++)(t||this.hiddenHeaders[i.id].ROW[e])&&(void 0===i.rows[e]&&(i.rows[e]={}),i.rows[e].isHidden=this.hiddenHeaders[i.id].ROW[e]);void 0===i.cols&&(i.cols={});for(let e=0;e<this.getters.getNumberCols(i.id);e++)(t||this.hiddenHeaders[i.id].COL[e])&&(void 0===i.cols[e]&&(i.cols[e]={}),i.cols[e].isHidden=this.hiddenHeaders[i.id].COL[e])}}}Uv.getters=["checkElementsIncludeAllVisibleHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class Vv extends Tv{constructor(e){super(e),this.images={},this.syncedImages=new Set,this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?28:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addFigure(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const i of t)if("image"===i.tag){const t=i.id.split(ee).pop(),o=`${e.sheetIdTo}${ee}${t}`,n=this.getImage(i.id);if(n){const t={width:i.width,height:i.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:o,position:{x:i.x,y:i.y},size:t,definition:_e(n)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){var e;const t=new Set(this.getAllImages().map((e=>e.path)));for(const i of this.syncedImages)t.has(i)||null===(e=this.fileStore)||void 0===e||e.delete(i)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addFigure(e,t,i,o){const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const i of e)this.history.update("images",t.id,i.id,i.data),this.syncedImages.add(i.data.path)}}export(e){var t;for(const i of e.sheets){const e=i.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=null===(t=this.images[i.id])||void 0===t?void 0:t[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),i=[];for(const t of e)if("image"===(null==t?void 0:t.tag)){const e=this.getImage(t.id);e&&i.push({...t,data:_e(e)})}t.images=i}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(it));return e}}Vv.getters=["getImage","getImagePath","getImageSize"];class zv extends Tv{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 i of Object.values(t).filter(it))this.addMerge(e.sheetIdTo,i.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 i=t?[t]:Object.keys(this.merges);for(const t of i)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(it)}getMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e],s=n?t in n&&(null===(o=n[t])||void 0===o?void 0:o[i]):void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){var i;const o=this.mergeCellMap[e];if(!o)return[];const n=new Set;for(const{col:e,row:s}of io(t)){const t=null===(i=o[e])||void 0===i?void 0:i[s];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(it)}doesIntersectMerge(e,t){return io(t).some((({col:t,row:i})=>void 0!==this.getMerge({sheetId:e,col:t,row:i})))}doesColumnsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(o.id,t,n,i,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(o.id,n,t,n,i))return!0;return!1}expandZone(e,t){let{left:i,right:o,top:n,bottom:s}=t,r={left:i,right:o,top:n,bottom:s};for(let t in this.merges[e]){const i=this.getMergeById(e,parseInt(t));i&&Xi(i,r)&&(r=qi(i,r))}return ji(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,i,o,n){const s=this.getMerge({sheetId:e,col:t,row:i}),r=this.getMerge({sheetId:e,col:o,row:n});return!(!s||!r)&&ji(s,r)}isInMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(o=n[t])||void 0===o?void 0:o[i]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:i}=this.getMerge(e);return{sheetId:e.sheetId,col:i,row:t}}isMergeHidden(e,t){const i=this.getters.getHiddenColsGroups(e),o=this.getters.getHiddenRowsGroups(e);for(let e of i)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of o)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const i=this.getMerge({sheetId:e,col:t.left,row:t.top});if(i)return ji(t,i);const{numberOfCols:o,numberOfRows:n}=eo(t);return 1===o&&1===n}isMergeDestructive(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=ke(o,0,this.getters.getNumberCols(e)-1),s=ke(s,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=s;t++)for(let s=i;s<=o;s++)if(s!==i||t!==n){const i=this.getters.getCell({sheetId:e,col:s,row:t});if(i&&""!==i.content)return!0}return!1}getMergeById(e,t){var i;const o=null===(i=this.merges[e])||void 0===i?void 0:i[t];return void 0!==o?Hv(t,o):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 i of e)if(t!==i&&Xi(t,i))return 65;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<i&&e.right>=i||e.top<o&&e.bottom>=o)return 75;return 0}checkMergedContentUpdate(e){const{col:t,row:i,content:o}=e;if(void 0===o)return 0;const{col:n,row:s}=this.getMainCellPosition(e);return n===t&&s===i?0:4}checkMergeExists(e){const{sheetId:t,target:i}=e;for(const e of i){const{left:i,top:o}=e,n=this.getMerge({sheetId:t,col:i,row:o});if(void 0===n||!ji(e,n))return 5}return 0}addMerge(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=ke(o,0,this.getters.getNumberCols(e)-1),s=ke(s,0,this.getters.getNumberRows(e)-1);if(Wt(i,n)===Wt(o,s))return;const r=this.getters.getCell({sheetId:e,col:i,row:n});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,Bi({left:i,top:n,right:o,bottom:s})));let l=new Set;for(let t=n;t<=s;t++)for(let s=i;s<=o;s++){s===i&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,style:r?r.style:null,content:""});const o=this.getMerge({sheetId:e,col:s,row:t});o&&l.add(o.id),this.history.update("mergeCellMap",e,s,t,a)}for(let t of l){const{top:i,bottom:o,left:n,right:s}=this.getMergeById(e,t);for(let t=i;t<=o;t++)for(let i=n;i<=s;i++){const o={sheetId:e,col:i,row:t},n=this.getMerge(o);n&&n.id===a||(this.history.update("mergeCellMap",e,i,t,void 0),this.dispatch("CLEAR_CELL",o))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:i,top:o,bottom:n,right:s}=t,r=this.getMerge({sheetId:e,col:i,row:o});if(void 0!==r&&ji(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=o;t<=n;t++)for(let o=i;o<=s;o++)this.history.update("mergeCellMap",e,o,t,void 0)}}applyRangeChangeOnSheet(e,t){const i=Object.entries(this.merges[e]||{});for(const[o,n]of i)if(n){const i=n.zone,s=t(n);switch(s.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,i);break;default:const{numberOfCols:t,numberOfRows:n}=eo(s.range.zone);1===t&&1===n?this.removeMerge(e,i):this.history.update("merges",e,parseInt(o,10),s.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:i,row:o}of io(t))this.history.update("mergeCellMap",e,i,o,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 i of t)this.addMerge(e,Vi(i))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Bv(e))}}exportForExcel(e){this.export(e)}}function Bv(e){return Object.entries(e).map((([e,t])=>t?Hv(parseInt(e,10),t):void 0)).filter(it).map((e=>Wt(e.left,e.top)+":"+Wt(e.right,e.bottom)))}function Hv(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}zv.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class $v{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",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const s=$e(n);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of s){const s=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=s&&s<=n.zone[i]){const e=Math.min(n.zone[i],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e)}else if(n.zone[t]>=s&&n.zone[i]<=l)a="REMOVE",r=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[i]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e),r=this.createAdaptedRange(r,o,"MOVE",-(n.zone[t]-s))}else s<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,o,a,-(l-s+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(n.zone[t]<=e.base&&e.base<n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),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 i=void 0,o=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:o,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!Ki(i.zone,t))return{changeType:"NONE"};const o=e.targetSheetId,n=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(i,"both","MOVE",[n,s]),a=e.sheetId!==o||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:o,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||zi(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,o){const n=oo(e.unboundedZone,t,i,o);return e.clone({zone:n})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,o){const n=e.map((e=>_i.fromRange(e,this.getters)));return n.map((e=>{if(!zi(e.zone))return e;const n=e.prefixSheet?e.sheetId:o,s={...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:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return e.clone({sheetId:n,zone:s}).orderZone()}))}getRangeFromSheetXC(e,t){if(!kt.test(t))return new _i({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,o=t,n=!1;t.includes("!")&&(({xc:o,sheetName:i}=zt(t)),i&&(n=!0));const s=Ui(o),r=_i.getRangeParts(o,s),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e;return new _i({prefixSheet:n,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize).orderZone()}getSelectionRangeString(e,t){const i=_i.fromRange(e,this.getters),o=this.getters.expandZone(i.sheetId,i.zone),n=i.clone({zone:{...o,bottom:i.isFullCol?void 0:o.bottom,right:i.isFullRow?void 0:o.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return K;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return K;if(e.zone.left<0||e.zone.top<0)return K;const i=_i.fromRange(e,this.getters);let o=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,n="";if(o&&(n=i.invalidSheetName?i.invalidSheetName:De(this.getters.getSheetName(i.sheetId))),o&&!n)return K;let s=this.getRangePartString(i,0);return i.parts&&2===i.parts.length&&(i.zone.top!==i.zone.bottom||i.zone.left!==i.zone.right||i.parts[0].rowFixed||i.parts[0].colFixed||i.parts[1].rowFixed||i.parts[1].colFixed)&&(s+=":",s+=this.getRangePartString(i,1)),`${o?n+"!":""}${s}`}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 _i(t,this.getters.getSheetSize)}getRangePartString(e,t){const i=e.parts&&e.parts[t].colFixed?"$":"",o=Bt(0===t?e.zone.left:e.zone.right),n=e.parts&&e.parts[t].rowFixed?"$":"",s=String(0===t?e.zone.top+1:e.zone.bottom+1);let r="";return r=e.isFullCol?0===t&&e.unboundedZone.hasHeader?i+o+n+s:i+o:e.isFullRow?0===t&&e.unboundedZone.hasHeader?i+o+n+s:n+s:i+o+n+s,r}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:K}}}$v.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Wv extends Tv{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":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 14}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>t?86:e.quantity<=0?87:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?86:this.checkElementsIncludeAllNonFrozenHeaders(e.sheetId,e.dimension,e.elements)?8:0}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.delta);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,i;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let o of e.sheets){const e=o.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:r}=this.getImportedSheetSize(o),a={id:o.id,name:e,numberOfCols:s,rows:Li(r),areGridLinesVisible:void 0===o.areGridLinesVisible||o.areGridLinesVisible,isVisible:o.isVisible,panes:{xSplit:(null===(t=o.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(i=o.panes)||void 0===i?void 0:i.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(it).map((e=>{const t=this.sheets[e],i={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)&&(i.panes=t.panes),i}))}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}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=Fe(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,i){return"COL"===t?i>=0&&i<this.getNumberCols(e):i>=0&&i<this.getNumberRows(e)}getRow(e,t){const i=this.getSheet(e).rows[t];if(!i)throw new Error(`Row ${i} not found.`);return i}getCell({sheetId:e,col:t,row:i}){var o;const n=this.tryGetSheet(e),s=null===(o=null==n?void 0:n.rows[i])||void 0===o?void 0:o.cells[t];if(void 0!==s)return this.getters.getCellById(s)}getColsZone(e,t,i){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:i}}getRowCells(e,t){var i;return Object.values(null===(i=this.getSheet(e).rows[t])||void 0===i?void 0:i.cells).filter(it)}getRowsZone(e,t,i){return{top:t,bottom:i,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 i=this.orderedSheetIds.map(this.getSheetName.bind(this));let o=`${e}${t}`;for(;i.includes(o);)o=`${e}${t}`,t++;return o}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols: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,i){const o={...this.getPaneDivisions(e)};"COL"===i?o.xSplit=t:"ROW"===i&&(o.ySplit=t),this.history.update("sheets",e,"panes",o)}checkElementsIncludeAllNonFrozenHeaders(e,t,i){const o=this.getters.getPaneDivisions(e),n="ROW"===t?o.ySplit:o.xSplit,s=this.getters.getNumberHeaders(e,t);if(!n)return!1;return ht(i,He(n,s))}isEmpty(e,t){return io(t).map((({col:t,row:i})=>this.getCell({sheetId:e,col:t,row:i}))).every((e=>!e||""===e.content))}updateCellPosition(e){const{sheetId:t,cellId:i,col:o,row:n}=e;i?this.setNewPosition(i,t,o,n):this.clearPosition(t,o,n)}setNewPosition(e,t,i,o){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:o,col:i,sheetId:t}),this.history.update("sheets",t,"rows",o,"cells",i,e)}clearPosition(e,t,i){var o;const n=null===(o=this.sheets[e])||void 0===o?void 0:o.rows[i].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",i,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){this.sheets[e].rows[o].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:o})}}createSheet(e,t,i,o,n){const s={id:e,name:t,numberOfCols:i,rows:Li(o),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},r=this.orderedSheetIds.slice();r.splice(n,0,s.id);const a=this.sheets;return this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},a,{[s.id]:s})),s}moveSheet(e,t){const i=this.orderedSheetIds.slice(),o=i.findIndex((t=>t===e)),n=i.splice(o,1);let s=this.findIndexOfTargetSheet(o,t);i.splice(s,0,n[0]),this.history.update("orderedSheetIds",i)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(s("There is not enough visible sheets"))}checkSheetName(e){const{orderedSheetIds:t,sheets:i}=this,o=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=i[e])||void 0===t?void 0:t.name.toLowerCase())===o}))?11:re.test(o)?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:74}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:74}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.top<e.quantity&&e.quantity<=i.bottom)return 65;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.left<e.quantity&&e.quantity<=i.right)return 65;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const i=e.name;this.history.update("sheets",e.id,"name",t.trim());const o=Object.assign({},this.sheetIdsMapName);o[t]=e.id,delete o[i],this.history.update("sheetIdsMapName",o)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const i=this.getSheet(e),o=this.getDuplicateSheetName(i.name),n=_e(i);n.id=t,n.name=o;for(let e=0;e<=n.numberOfCols;e++)for(let t=0;t<=n.rows.length;t++)n.rows[t]&&(n.rows[t].cells[e]=void 0);const s=this.orderedSheetIds.slice(),r=s.indexOf(e);s.splice(r+1,0,n.id),this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},this.sheets,{[n.id]:n}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:i}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:i,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[n.name]=n.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this)),o=s("Copy of %s",e);let n=o.toString();for(;i.includes(n);)n=`${o} (${t})`,t++;return n}deleteSheet(e){const t=e.name,i=Object.assign({},this.sheets);delete i[e.id],this.history.update("sheets",i);const o=this.orderedSheetIds.slice(),n=o.indexOf(e.id);o.splice(n,1),this.history.update("orderedSheetIds",o);const s=Object.assign({},this.sheetIdsMapName);delete s[t],this.history.update("sheetIdsMapName",s)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let i of t)this.moveCellOnColumnsDeletion(e,i);const i=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",i-t.length);const o=t.filter((t=>t<e.panes.xSplit)).length;o&&this.setPaneDivisions(e.id,e.panes.xSplit-o,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let i of $e(t))this.moveCellOnRowsDeletion(e,i[i.length-1],i[0]),i.map((t=>this.updateRowsStructureOnDeletion(t,e)));const i=t.filter((t=>t<e.panes.ySplit)).length;i&&this.setPaneDivisions(e.id,e.panes.ySplit-i,"ROW")}addColumns(e,t,i,o){const n="before"===i?t:t+1;this.moveCellsOnAddition(e,n,o,"columns");const s=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",s+o),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+o,"COL")}addRows(e,t,i,o){const n="before"===i?t:t+1;this.addEmptyRows(e,o),this.moveCellsOnAddition(e,n,o,"rows"),this.updateRowsStructureOnAddition(e,t,o),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+o,"ROW")}moveCellOnColumnsDeletion(e,t){for(let i=0;i<e.rows.length;i++){const o=e.rows[i];for(let n in o.cells){const s=Number(n),r=o.cells[n];r&&(s===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:i}),s>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:s-1,row:i}))}}}moveCellsOnAddition(e,t,i,o){const n=[];for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if("rows"!==o||s>=t)for(let a in r.cells){const l=Number(a),c=r.cells[a];c&&("rows"===o||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===o?i:0),row:s+("rows"===o?i:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,i){const o=i-t+1;for(let n=0;n<e.rows.length;n++){const s=e.rows[n];if(n>=t&&n<=i)for(let t in s.cells){const i=Number(t);s.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:i,row:n})}if(n>i)for(let t in s.cells){const i=Number(t),r=s.cells[t];r&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:i,row:n-o})}}}updateRowsStructureOnDeletion(e,t){const i=[],o=t.rows.map((e=>e.cells));for(let n in t.rows)Number(n)!==e&&i.push({cells:o.shift()});this.history.update("sheets",t.id,"rows",i)}updateRowsStructureOnAddition(e,t,i){const o=[],n=e.rows.map((e=>e.cells));e.rows.forEach((()=>o.push({cells:n.shift()}))),this.history.update("sheets",e.id,"rows",o)}addEmptyRows(e,t){const i=e.rows.slice();for(let e=0;e<t;e++)i.push({cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map($t);let i=e.rowNumber,o=e.colNumber;for(let{col:e,row:n}of t)i=Math.max(i,n+1),o=Math.max(o,e+1);return{rowNumber:i,colNumber:o}}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(zi))return 25;if(t.length&&"sheetId"in e){const i=this.getSheetZone(e.sheetId);return t.every((e=>Ki(e,i)))?0:18}return 0}}Wv.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions","checkElementsIncludeAllNonFrozenHeaders"];class Gv extends Rv{constructor({getters:e,stateObserver:t,dispatch:i,uiActions:o,selection:n}){super(t,i),this.getters=e,this.ui=o,this.selection=n}drawGrid(e,t){}}Gv.layers=[];class qv extends Gv{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 i=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(i),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:xt(255,0,0),colors:[]},{leadColor:xt(255,128,0),colors:[]},{leadColor:xt(128,128,0),colors:[]},{leadColor:xt(128,255,0),colors:[]},{leadColor:xt(0,255,0),colors:[]},{leadColor:xt(0,255,128),colors:[]},{leadColor:xt(0,255,255),colors:[]},{leadColor:xt(0,127,255),colors:[]},{leadColor:xt(0,0,255),colors:[]},{leadColor:xt(127,0,255),colors:[]},{leadColor:xt(128,0,128),colors:[]},{leadColor:xt(255,0,128),colors:[]}];for(const i of e.map(Tt)){let e=500,o=0;t.forEach(((t,n)=>{const s=(r=i,a=t.leadColor,Math.sqrt(Math.pow(r.r-a.r,2)+Math.pow(r.g-a.g,2)+Math.pow(r.b-a.b,2)));var r,a;e>s&&(e=s,o=n)})),t[o].colors.push(i)}return t.map((e=>e.colors.sort(((e,t)=>Mt(e).s-Mt(t).s)))).flat().map(Rt)}([...new Set([...new Set([...e,...this.customColors])].filter(wt).map(Et))]).filter((e=>!O.includes(e)))}getColorsFromCells(e){var t,i;const o=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&o.add(n.style.textColor),(null===(i=n.style)||void 0===i?void 0:i.fillColor)&&o.add(n.style.fillColor);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),i=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(i.push(t.style.textColor),i.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(i.push(Ct(t.minimum.color)),i.push(t.midpoint?Ct(t.midpoint.color):void 0),i.push(Ct(t.maximum.color)))}return i.filter(it)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let i=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&i.add(t),e.type){case"gauge":const t=e.sectionRule.colors;i.add(t.lowerColor),i.add(t.middleColor),i.add(t.upperColor);break;case"scorecard":const o=e;i.add(o.baselineColorDown),i.add(o.baselineColorUp)}}return[...i]}tryToAddColor(e){const t=Et(e);e&&!O.includes(t)&&this.customColors.add(t)}}qv.getters=["getCustomColors"];const Zv=ju.mapping;class jv extends Gv{constructor(e){super(e),this.isUpToDate=!1,this.evaluatedCells={},this.evalContext=e.custom,this.lazyEvaluation=e.lazyEvaluation}handle(e){switch(an.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(),this.isUpToDate=!0)}evaluateFormula(e,t=this.getters.getActiveSheetId()){const i=cf(e),o=this.getCompilationParameters((e=>this.getEvaluatedCell(this.getters.getCellPosition(e.id)))),n=[];for(let e of i.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return i.execute(n,...o).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell({sheetId:e,col:t,row:i}){var o,n,s;return void 0===this.getters.getCell({sheetId:e,col:t,row:i})?bn(""):(null===(s=null===(n=null===(o=this.evaluatedCells[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.call(n))||bn("")}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},i={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);i[e]=this.getEvaluatedCell(t)}return i}getColEvaluatedCells(e,t){var i;return Object.values((null===(i=this.evaluatedCells[e])||void 0===i?void 0:i[t])||[]).filter(it).map((e=>e()))}getEvaluatedCellsInZone(e,t){return io(t).map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i})))}setEvaluatedCell(e,t){const{col:i,row:o,sheetId:n}=this.getters.getCellPosition(e);this.evaluatedCells[n]||(this.evaluatedCells[n]={}),this.evaluatedCells[n][i]||(this.evaluatedCells[n][i]={}),this.evaluatedCells[n][i][o]=t,this.lazyEvaluation||this.evaluatedCells[n][i][o]()}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){this.evaluatedCells={};const e=new Set,t=e=>{var t,n;const s=e.id,{col:r,row:a,sheetId:l}=this.getters.getCellPosition(s),c=null===(n=null===(t=this.evaluatedCells[l])||void 0===t?void 0:t[r])||void 0===n?void 0:n[a];return c||rt((()=>{try{switch(e.isFormula){case!0:return o(e);case!1:return fn(e.content,e.format)}}catch(t){return i(t,e)}}))},i=(e,t)=>{e instanceof Error||(e=new Error(e));const i=(null==e?void 0:e.errorType)||a.GenericError,o=n[2].__lastFnCalled||"",s=new c(i,e.message.replace("[[FUNCTION_NAME]]",o),void 0!==e.logLevel?e.logLevel:l.error);return wn(t.content,s)},o=t=>{const i=t.id;if(e.has(i))throw new d;n[2].__originCellXC=()=>{const e=n[2].getters.getCellPosition(i);return Wt(e.col,e.row)},e.add(i);const o=t.compiledFormula.execute(t.dependencies,...n);if(e.delete(i),Array.isArray(o.value))throw new Error(s("This formula depends on invalid values"));return bn(o.value,t.format||o.format)},n=this.getCompilationParameters((e=>t(e)()));for(const e of this.getAllCells())this.setEvaluatedCell(e.id,t(e))}getCompilationParameters(e){const t=Object.assign(Object.create(Zv),this.evalContext,{getters:this.getters}),i=this.getters;const o=t=>{const i=e(t);if(i.type===sn.error)throw i.error;return i};return[function(e,t,n,r){if(t)return{value:Bi(e.zone)};if(!zi(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(r?s("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",n.toString(),r.toString()):s("Function %s expects its parameters to be single values or single cell references, not ranges.",n.toString()));if(e.invalidSheetName)throw new Error(s("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!i.tryGetSheet(e.sheetId))throw new Error(s("Invalid sheet name"));return t=i.getCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}),t&&""!==t.content?o(t):{value:null,format:null==t?void 0:t.format}}(e)},function(e){const n=e.sheetId;if(!zi(e.zone))throw new u;const s=i.getSheetZone(n),r=[],a=Zi(e.zone,s);if(!a)return r.push([]),r;for(let i=a.left;i<=a.right;i++){const n=[];for(let s=a.top;s<=a.bottom;s++){const r=t.getters.getCell({sheetId:e.sheetId,col:i,row:s});n.push(r?o(r):void 0)}r.push(n)}return r},t]}exportForExcel(e){for(let t of e.sheets)for(const e in t.cells){const i={sheetId:t.id,...$t(e)},o=this.getters.getCell(i);if(o){const n=t.cells[e],s=this.getEvaluatedCell(i);n.value=s.value,n.isFormula=o.isFormula&&!this.isBadExpression(o.content),o.format!==s.format&&(n.computedFormat=s.format)}}}isBadExpression(e){try{return cf(e),!1}catch(e){return!0}}}jv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getColEvaluatedCells","getEvaluatedCellsInZone"];class Xv extends Gv{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=ar.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i){const o=t.find((e=>e.match(i.type)));if(!o)throw new Error("No runtime builder for this chart.");return o.getChartRuntime(i,e)}}(this.getters)}handle(e){if(an.has(e.type)||ln.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 i=t.zone.left,o=t.zone.top,n=t.sheetId;return this.getters.getCellComputedStyle({sheetId:n,col:i,row:o}).fillColor||w}}Xv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class Yv extends Gv{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new Pi,this.rulePredicate={CellIsRule:(e,t)=>{if(e.type===sn.error)return!1;const i=t.values.map(vn);switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==i[0]&&e.value.toString().startsWith(i[0].toString());case"EndsWith":return""!==i[0]&&e.value.toString().endsWith(i[0].toString());case"Between":return e.value>=i[0]&&e.value<=i[1];case"NotBetween":return!(e.value>=i[0]&&e.value<=i[1]);case"ContainsText":return e.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(i[0].toString());case"GreaterThan":return e.value>i[0];case"GreaterThanOrEqual":return e.value>=i[0];case"LessThan":return e.value<i[0];case"LessThanOrEqual":return e.value<=i[0];case"NotEqual":return""!==i[0]&&e.value!==i[0];case"Equal":return""===i[0]||e.value===i[0];default:console.warn(s("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((ln.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 i=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(i,e.originCol,e.originRow);for(const t of o)this.adaptRules(i,t,[Wt(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){var t;const{sheetId:i,col:o,row:n}=e,s=this.getters.getCell(e),r=this.computedStyles[i],a=r&&(null===(t=r[o])||void 0===t?void 0:t[n]),l={...null==s?void 0:s.style,...a};return this.getters.getEvaluatedCell(e).link&&!l.textColor&&(l.textColor=I),this.getters.isFilterHeader(e)&&(l.bold=!0),l}getConditionalIcon({col:e,row:t}){var i;const o=this.getters.getActiveSheetId(),n=this.computedIcons[o];return n&&(null===(i=n[e])||void 0===i?void 0:i[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const i=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let n of o.ranges){const s=this.getters.getRangeFromSheetXC(t,n).zone;for(let n=s.top;n<=s.bottom;n++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let a=this.getters.getEvaluatedCell({sheetId:t,col:r,row:n});s&&s(a,o.rule)&&(i[r]||(i[r]=[]),i[r][n]=Object.assign((null===(e=i[r])||void 0===e?void 0:e[n])||{},o.rule.style))}}}}catch(e){}}parsePoint(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCellsInZone(o,this.getters.getRangeFromSheetXC(o,e).zone).filter((e=>e.type===sn.number)).map((e=>e.value));switch(t.type){case"value":return"max"===i?Math.max(...n):Math.min(...n);case"number":return Number(t.value);case"percentage":const e=Math.min(...n);return e+(Math.max(...n)-e)*Number(t.value)/100;case"percentile":return ni(n,Number(t.value)/100,!0);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return o instanceof Promise?null:o;default:return null}}applyIcon(e,t){const i=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===i||null===o||i>o)return;const n=this.getters.getActiveSheetId(),s=this.getters.getRangeFromSheetXC(n,e).zone,r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=s.top;e<=s.bottom;e++)for(let l=s.left;l<=s.right;l++){const s=this.getters.getEvaluatedCell({sheetId:n,col:l,row:e});if(s.type!==sn.number)continue;const c=this.computeIcon(s.value,o,t.upperInflectionPoint.operator,i,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,i,o,n,s){return"ge"===i&&e>=t||"gt"===i&&e>t?s[0]:"ge"===n&&e>=o||"gt"===n&&e>o?s[1]:s[2]}applyColorScale(e,t){var i;const o=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,s=this.parsePoint(e,t.maximum,"max");if(null===o||null===s||o>=s||n&&(o>=n||n>=s))return;const r=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(r,e).zone,l=this.computedStyles[r],c=[];t.midpoint&&n?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.midpoint.color)}),c.push({minValue:n,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(n,s,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,s,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.getEvaluatedCell({sheetId:r,col:t,row:e});if(a.type===sn.number){const r=ke(a.value,o,s);let h;h=2===c.length&&n?r<=n?this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(r,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(i=l[t])||void 0===i?void 0:i[e])||{},l[t][e].fillColor=Ct(h)}}}computeColorDiffUnits(e,t,i,o){const n=t-e;return[((i>>16)%256-(o>>16)%256)/n,((i>>8)%256-(o>>8)%256)/n,(i%256-o%256)/n]}colorCell(e,t,i,o){const[n,s,r]=o;return Math.round((i>>16)%256-n*(e-t))<<16|Math.round((i>>8)%256-s*(e-t))<<8|Math.round(i%256-r*(e-t))}adaptRules(e,t,i,o){if(0===i.length&&0===o.length)return;const n=this.getters.getConditionalFormats(e),s=n.findIndex((e=>e.id===t.id));let r=[];s>-1&&(r=n[s].ranges),r=r.concat(i);const a=Qi(r,o);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,i){const o=Wt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let s of n.ranges)if(Yi(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=n,r=[];if("CUT"===i&&r.push(Wt(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,s,[o],r);else{this.adaptRules(e.sheetId,s,[],r);const i=this.getCFToCopyTo(t.sheetId,s);this.adaptRules(t.sheetId,i,[o],[])}}}getCFToCopyTo(e,t){const i=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&ct(e.rule,t.rule)));return i||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}Yv.getters=["getConditionalIcon","getCellComputedStyle"];class Kv extends Gv{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 79;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":case"UNHIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const i of this.getters.getFilters(e.sheetIdTo)){const o=i.zoneWithHeaders;t[i.id]=this.getFilterValues({sheetId:e.sheetId,col:o.left,row:o.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){const{sheetId:t,col:i,row:o}=e;let n;for(let e of this.getters.getFilterTables(t)){const s=e.zone;if(Yi(i,o,s)){const e=this.intersectZoneWithViewport(t,s);n={top:o===e.top?X:void 0,bottom:o===e.bottom?X:void 0,left:i===e.left?X:void 0,right:i===e.right?X:void 0}}}const s=this.getters.getCellBorder(e),r={...n,...dt(s||{})};return ot(r)?null:r}getFilterHeaders(e){const t=[];for(let i of this.getters.getFilterTables(e)){const o=i.zone;if(!o)continue;const n=o.top;for(let i=o.left;i<=o.right;i++)this.getters.isColHidden(e,i)||this.getters.isRowHidden(e,n)||t.push({col:i,row:n})}return t}getFilterValues(e){const t=this.getters.getFilterId(e),i=e.sheetId;return t&&this.filterValues[i]&&this.filterValues[i][t]||[]}isFilterHeader({sheetId:e,col:t,row:i}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===i))}isFilterActive(e){var t,i;const o=this.getters.getFilterId(e),n=e.sheetId;return Boolean(o&&(null===(i=null===(t=this.filterValues[n])||void 0===t?void 0:t[o])||void 0===i?void 0:i.length))}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:i,sheetId:o}){const n=this.getters.getFilterId({sheetId:o,col:e,row:t});n&&(this.filterValues[o]||(this.filterValues[o]={}),this.filterValues[o][n]=i)}updateHiddenRows(){var e,t;const i=this.getters.getActiveSheetId(),o=this.getters.getFilters(i).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let s of o){if(this.getters.isRowHiddenByUser(i,s.zoneWithHeaders.top))continue;if(n.has(s.zoneWithHeaders.top))continue;const o=null===(t=null===(e=this.filterValues[i])||void 0===e?void 0:e[s.id])||void 0===t?void 0:t.map(ut);if(o&&s.filteredZone)for(let e=s.filteredZone.top;e<=s.filteredZone.bottom;e++){const t=this.getCellValueAsString(i,s.col,e);o.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,i){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const i of t.filterTables){const o=Vi(i.range),n=[],s=[];for(const i of He(0,eo(o).numberOfCols)){const r={sheetId:t.id,col:o.left+i,row:o.top},a=this.getFilterValues(r),l=this.getters.getFilter(r);if(!l)continue;const c=l.filteredZone?io(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));n.push({colId:i,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(i,d,s);s.push(u),t.cells[Wt(h.col,h.row)]={...t.cells[Wt(h.col,h.row)],content:u,value:u,isFormula:!1}}i.filters=n}}}getUniqueColNameForExcel(e,t,i){t||(t=`Column${e}`);let o=t,n=2;for(;i.includes(o);)o=t+String(n),n++;return o}}Kv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];class Qv{constructor(e,t,i,o,n,s){this.getters=e,this.sheetId=t,this.boundaries=i,this.viewportWidth=o.width,this.viewportHeight=o.height,this.offsetScrollbarX=s.x,this.offsetScrollbarY=s.y,this.canScrollVertically=n.canScrollVertically,this.canScrollHorizontally=n.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:i,size:o}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:s}=this.getters.getRowDimensions(this.sheetId,t),r=this.searchHeaderIndex("COL",i-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,r),l=this.searchHeaderIndex("ROW",n-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=i-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(F,Math.min(a,this.viewportWidth-o)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(D+5,Math.min(c,this.viewportHeight-s)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const i=this.getters.getMainCellPosition({sheetId:t,...e}),{col:o,row:n}=this.getters.getNextVisibleCellPosition(i);Yi(o,this.boundaries.top,this.boundaries)&&this.adjustPositionX(o),Yi(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{end:i}=this.getters.getColDimensions(t,e),o=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<i){let i=e;for(;this.getters.isColHidden(t,i)&&e<o;)i++;const n=this.getters.getColDimensions(t,i).end,s=this.searchHeaderIndex("COL",n-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left,!0);this.offsetX=this.getters.getColDimensions(t,s).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let i=e;for(;this.getters.isColHidden(t,i)&&e>0;)i--;this.offsetX=this.getters.getColDimensions(t,i).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId,{end:i}=this.getters.getRowDimensions(t,e),o=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<i){let i=e;for(;this.getters.isRowHidden(t,i)&&e<o;)i++;const n=this.getters.getRowDimensions(t,i).end,s=this.searchHeaderIndex("ROW",n-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top,!0);this.offsetY=this.getters.getRowDimensions(t,s).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let i=e;for(;this.getters.isRowHidden(t,i)&&e>0;)i--;this.offsetY=this.getters.getRowDimensions(t,i).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=Zi(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.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}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,i=0,o=!1){let n=0;const s=this.sheetId,r=this.getters.getNumberHeaders(s,e);for(let a=i;a<=r-1;a++){const i=o||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(s,e,a)&&!i&&(n+="COL"===e?this.getters.getColSize(s,a):this.getters.getRowSize(s,a),n>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.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!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.viewportWidth,this.left)),-1===this.left&&(this.left=this.boundaries.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.viewportHeight,this.top)),-1===this.top&&(this.top=this.boundaries.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 Jv extends Gv{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"AlterZone":break;case"ZonesSelected":let{col:t,row:i}=no(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const o=e.previousAnchor.zone,n=e.anchor.zone,{top:s,bottom:r,left:a,right:l}=this.getters.getActiveMainViewport();o.left===n.left&&o.right===n.right&&(t=a>t||t>l?a:t),o.top===n.top&&o.bottom===n.bottom&&(i=s>i||i>r?s:i)}const o=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(o)-1),i=Math.min(i,this.getters.getNumberRows(o)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:i})}}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:i}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(o,i).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(i);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"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}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 i of t)(null===(e=this.viewports[i])||void 0===e?void 0:e.bottomRight)||this.resetViewports(i)}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=>He(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=>He(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:i,ySplit:o}=this.getters.getPaneDivisions(e);let{width:n,height:s}=t.getMaxSize();return{x:this.getters.getColDimensions(e,i).start,y:this.getters.getRowDimensions(e,o).start,width:n,height:s}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:i}=this.getMainViewportRect(),o=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-o.viewportWidth+1),maxOffsetY:Math.max(0,i-o.viewportHeight+1)}}getColRowOffsetInViewport(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),s=this.getters.getSheetViewVisibleRows();if(i<t)return-this.getColRowOffsetInViewport(e,i,t);let r=0;const a="COL"===e?n:s;for(let n=t;n<i;n++)a.includes(n)&&(r+="COL"===e?this.getters.getColSize(o,n):this.getters.getRowSize(o,n));return r}isVisibleInViewport({sheetId:e,col:t,row:i}){return this.getSubViewports(e).some((e=>e.isVisible(t,i)))}getEdgeScrollCol(e,t,i){let o=!1,n=0,s=0;const{xSplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(o=!0,s=jt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=jt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=jt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getEdgeScrollRow(e,t,i){let o=!1,n=0,s=0;const{ySplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(o=!0,s=jt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=jt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=jt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),i=this.getSubViewports(t).map((t=>t.getRect(e))).filter(it);if(0===i.length)return{x:0,y:0,width:0,height:0};const o=Math.min(...i.map((e=>e.x))),n=Math.min(...i.map((e=>e.y))),s=Math.max(...i.map((e=>e.x+e.width)))-o,r=Math.max(...i.map((e=>e.y+e.height)))-n;return{x:o+this.gridOffsetX,y:n+this.gridOffsetY,width:s,height:r}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,i).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(it)}checkPositiveDimension(e){return e.width<0||e.height<0?68:0}checkValuesAreDifferent(e){const{height:t,width:i}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===i&&e.height===t?76:0}checkScrollingDirection({offsetX:e,offsetY:t}){const i=this.getMainInternalViewport(this.getters.getActiveSheetId());return!i.canScrollHorizontally&&e>0||!i.canScrollVertically&&t>0?69: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 i=this.getSubViewports(e);Object.values(i).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,i=0,o=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=i,this.gridOffsetY=o,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const i=this.getters.getActiveSheetId(),{maxOffsetX:o,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(i)).forEach((i=>i.setViewportOffset(ke(e,0,o),ke(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),i=t-this.sheetViewHeight;return e=Math.min(e,i),e=Math.max(e,0)}getViewportOffset(e){var t,i;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(i=this.viewports[e])||void 0===i?void 0:i.bottomRight.offsetScrollbarY)||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),s=this.getters.getColRowOffset("COL",0,t,e),r=this.getters.getColRowOffset("ROW",0,i,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:i&&t&&new Qv(this.getters,e,{left:0,right:t-1,top:0,bottom:i-1},{width:s,height:r},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:i&&new Qv(this.getters,e,{left:t,right:o-1,top:0,bottom:i-1},{width:this.sheetViewWidth-s,height:r},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Qv(this.getters,e,{left:0,right:t-1,top:i,bottom:n-1},{width:s,height:this.sheetViewHeight-r},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Qv(this.getters,e,{left:t,right:o-1,top:i,bottom:n-1},{width:this.sheetViewWidth-s,height:this.sheetViewHeight-r},{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:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:o}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(o.cell.col,o.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],i=this.getters.getFigures(e),{scrollX:o,scrollY:n}=this.getActiveSheetScrollInfo(),{x:s,y:r}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of i)e.x>=s&&(e.x+e.width<=s+o||e.x>=a+o+s)||e.y>=r&&(e.y+e.height<=r+n||e.y>=l+n+r)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,i).start;return{xRatio:o/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}Jv.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class eb{constructor(e,t,i){this.index=0,this.cells=e,this.getters=t,this.direction=i}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:i,tooltip:o}=xn.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:i,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class tb extends Gv{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:ke(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:ke(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:45;case"AUTOFILL_AUTO":const i=this.getters.getSelectedZone();return i.top===i.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(),i=this.autofillZone;switch(this.direction){case"down":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(Wt(o,e));const s=this.createGenerator(n);for(let t=i.top;t<=i.bottom;t++)this.computeNewCell(s,o,t,e)}break;case"up":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(Wt(o,e));const s=this.createGenerator(n);for(let t=i.bottom;t>=i.top;t--)this.computeNewCell(s,o,t,e)}break;case"left":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(Wt(e,o));const s=this.createGenerator(n);for(let t=i.right;t>=i.left;t--)this.computeNewCell(s,t,o,e)}break;case"right":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(Wt(e,o));const s=this.createGenerator(n);for(let t=i.left;t<=i.right;t++)this.computeNewCell(s,t,o,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 i=this.getters.getSelectedZone();if(Yi(e,t,i))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,i.top-1,i.left,i.right),this.steps=i.top-t;break;case"down":this.saveZone(i.bottom+1,t,i.left,i.right),this.steps=t-i.bottom;break;case"left":this.saveZone(i.top,i.bottom,e,i.left-1),this.steps=i.left-e;break;case"right":this.saveZone(i.top,i.bottom,i.right+1,e),this.steps=e-i.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let i=e.left,o=e.bottom;if(i>0){let e=this.getters.getEvaluatedCell({sheetId:t,col:i-1,row:o});for(;e.type!==sn.empty;)o+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:i-1,row:o})}if(o===e.bottom&&(i=e.right,i<=this.getters.getNumberCols(t))){let e=this.getters.getEvaluatedCell({sheetId:t,col:i+1,row:o});for(;e.type!==sn.empty;)o+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:i+1,row:o})}o!==e.bottom&&(this.select(e.left,o-1),this.autofill(!0))}computeNewCell(e,t,i,o){const{cellData:n,tooltip:s,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=s,o&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:i,content:a,style:l,border:c,format:h})}getRule(e,t){const i=In.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((i=>i.condition(e,t)));return i&&i.generateRule(e,t)}createGenerator(e){const t=[],i=[],o=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=$t(t),s=this.getters.getCell({sheetId:o,col:e,row:n});i.push({col:e,row:n,cell:s,sheetId:o})}const n=i.map((e=>e.cell));for(let e of i){let i={type:"COPY_MODIFIER"};if(e&&e.cell){i=this.getRule(e.cell,n)||i}const o=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:o},rule:i})}return new eb(t,this.getters,this.direction)}saveZone(e,t,i,o){this.autofillZone={top:e,bottom:t,left:i,right:o}}getDirection(e,t){const i=this.getters.getSelectedZone(),o={up:{number:i.top-t,value:"up"},down:{number:t-i.bottom,value:"down"},left:{number:i.left-e,value:"left"},right:{number:e-i.right,value:"right"}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const n=o.up.number>0?"up":"down",s=o.left.number>0?"left":"right";return Math.abs(o[n].number)>=Math.abs(o[s].number)?o[n].value:o[s].value}autoFillMerge(e,t,i,o){const n=this.getters.getActiveSheetId(),s={sheetId:n,col:i,row:o},r={sheetId:n,col:e,row:t};if(this.getters.isInMerge(s)&&!this.getters.isInMerge(r)){const e=this.getters.getMerge(s);e&&this.dispatch("REMOVE_MERGE",{sheetId:n,target:[e]})}const a=this.getters.getMerge(r);(null==a?void 0:a.topLeft.col)===e&&(null==a?void 0:a.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:n,target:[{top:o,bottom:o+a.bottom-a.top,left:i,right:i+a.right-a.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:i}=e,{x:o,y:n,width:s,height:r}=this.getters.getVisibleRect(this.autofillZone);s>0&&r>0&&(t.strokeStyle="black",t.lineWidth=i,t.setLineDash([3]),t.strokeRect(o,n,s,r),t.setLineDash([]))}}tb.layers=[5],tb.getters=["getAutofillTooltip"];class ib extends Gv{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:i}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,i.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,i){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,i):this.sumData(e,t)}sumData(e,t){const i=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,i).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return i.has("ROW")&&i.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,i){const{col:o,row:n}=Yi(i.col,i.row,t)?i:{col:t.left,row:t.top},s=this.findAdjacentData(e,o,n);return s?this.getters.isSingleCellOrMerge(e,t)||to(qi(s,t))?[{position:{col:o,row:n},zone:s}]:this.sumDimensions(e,qi(s,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,i){const o=this.getters.getSheet(e),n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.findSuitableZoneToSum(o,n.col,n.row);if(s)return this.getters.expandZone(e,s)}findSuitableZoneToSum(e,t,i){const o=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:i-1}),n=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:i});if(this.isNumber(n)&&!this.isNumber(o))return this.findHorizontalZone(e,t,i);const s=this.findVerticalZone(e,t,i);if(this.isZoneValid(s))return s;const r=this.findHorizontalZone(e,t,i);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,i){const o={top:0,bottom:i-1,left:t,right:t},n=this.reduceZoneStart(e,o,o.bottom);return{...o,top:n}}findHorizontalZone(e,t,i){const o={top:i,bottom:i,left:0,right:t-1},n=this.reduceZoneStart(e,o,o.right);return{...o,left:n}}reduceZoneStart(e,t,i){const o=this.getters.getEvaluatedCellsInZone(e.id,t),n=He(i,-1,-1),s=n.filter((e=>o[e]&&!o[e].isAutoSummable)),r=Math.max(...s),a=$e(n.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return e.type===sn.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y))}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 i=new Set;return to(t)?(i.add(1===eo(t).numberOfCols?"COL":"ROW"),i):(this.lastColIsEmpty(e,t)&&i.add("ROW"),this.lastRowIsEmpty(e,t)&&i.add("COL"),0===i.size&&i.add("COL"),i)}sumDimensions(e,t,i){return[...i.has("COL")?this.sumColumns(t,e):[],...i.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:i}=e;return{position:{col:i,row:t},zone:{...e,top:t,right:i-1}}}sumColumns(e,t){const i=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,i.bottom-1)},io(i).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const i=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,i.right-1)},io(i).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const i of t){const{col:t,row:o}=i.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,i.zone)})`})}}nextEmptyRow(e,t){let i=t.bottom+1;const{left:o,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:i,top:i,left:o,right:n});)i++;return{...t,top:i,bottom:i}}nextEmptyCol(e,t){let i=t.right+1;const{top:o,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:i,right:i,top:o,bottom:n});)i++;return{...t,left:i,right:i}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}ib.getters=["getAutomaticSums"];class ob extends Gv{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{ss.get(e.popoverType)}catch(e){return 72}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,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){var i,o;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=null===(o=(i=ss.get(this.persistentPopover.type)).onOpen)||void 0===o?void 0:o.call(i,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:n,col:e,row:t}))return{isOpen:!1};const s=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}),r=ss.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,s,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==r?void 0:r.isOpen)?{...r,anchorRect:this.computePopoverAnchorRect(s)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const i=this.getters.getActiveSheetId(),o=this.getters.getMerge({sheetId:i,col:e,row:t});return o?this.getters.getVisibleRect(o):this.getters.getVisibleRect(ro({col:e,row:t}))}}ob.getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];var nb;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(nb||(nb={}));class sb extends Gv{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch="",this.isSearchDirty=!1}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(nb.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(nb.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"UNDO":case"REDO":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":this.isSearchDirty=!0;break;case"ACTIVATE_SHEET":this.refreshSearch()}}finalize(){this.isSearchDirty&&(this.refreshSearch(),this.isSearchDirty=!1)}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(nb.current)}updateRegex(){let e=Ne(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),i=[];if(this.toSearch)for(const o of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(o.id),s=this.getters.isColHidden(e,t),r=this.getters.isRowHidden(e,n);if(!s&&!r&&(o&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:n})))){const e={col:t,row:n,selected:!1};i.push(e)}}return i.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 i;i=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,i=(i%t.length+t.length)%t.length,this.selectedMatchIndex=i,this.selection.selectCell(t[i].col,t[i].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}}replaceMatch(e,t){if(!this.currentSearchRegex)return;const i=this.getters.getActiveSheetId(),o=this.getters.getCell({sheetId:i,...e}),{col:n,row:s}=e;if((null==o?void 0:o.isFormula)&&!this.searchOptions.searchFormulas)return;const r=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),a=this.getSearchableString({sheetId:i,col:n,row:s}).replace(r,t);this.dispatch("UPDATE_CELL",{sheetId:i,col:n,row:s,content:a})}replace(e){if(null===this.selectedMatchIndex)return;const t=this.searchMatches[this.selectedMatchIndex];this.replaceMatch(t,e),this.selectNextCell(nb.next)}replaceAll(e){const t=this.searchMatches.length;for(let i=0;i<t;i++)this.replaceMatch(this.searchMatches[i],e)}getSearchableString(e){const t=this.getters.getCell(e);return this.searchOptions.searchFormulas&&(null==t?void 0:t.isFormula)?t.content:this.getters.getEvaluatedCell(e).formattedValue}drawGrid(e){const{ctx:t}=e,i=this.getters.getActiveSheetId();for(const e of this.searchMatches){const o=this.getters.getMerge({sheetId:i,col:e.col,row:e.row}),n=o?o.left:e.col,s=o?o.right:e.col,r=o?o.top:e.row,a=o?o.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:r,left:n,right:s,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)))}}}sb.layers=[3],sb.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class rb extends Gv{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,i){return"COL"===t?this.isColHidden(e,i):this.isRowHidden(e,i)}getNextVisibleCellPosition({sheetId:e,col:t,row:i}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",i,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,i,o){if(i<=o)for(let n=i;n<=o;n++)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n;if(i>o)for(let n=i;n>=o;n--)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n}findLastVisibleColRowIndex(e,t,{last:i,first:o}){return He(i,o,-1).find((i=>!this.isHeaderHidden(e,t,i)))||o}findFirstVisibleColRowIndex(e,t){const i=this.getters.getNumberHeaders(e,t);for(let o=0;o<i;o++){if("COL"===t&&!this.isColHidden(e,o))return o;if("ROW"===t&&!this.isRowHidden(e,o))return o}}exportForExcel(e){for(const t of e.sheets)for(const[e,i]of Object.entries(t.rows)){const o=this.isRowHidden(t.id,Number(e));i.isHidden=o}}}rb.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class ab extends Gv{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{numberOfRows:t,numberOfCols:i}=eo(e.zone),o=t*i==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:o}}))}drawGrid(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;const s=this.getHighlights();for(let e of s.filter(((e,t)=>s.findIndex((t=>ji(t.zone,e.zone)&&t.sheetId===o))===t))){const{x:i,y:o,width:s,height:r}=this.getters.getVisibleRect(e.zone);s>0&&r>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,s-n,r-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,s-2*n,r-2*n))}}}ab.layers=[1],ab.getters=["getHighlights"];class lb extends Gv{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleCols()),o=this.getters.getColRowOffsetInViewport("COL",i,t),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleRows()),o=this.getters.getColRowOffsetInViewport("ROW",i,t),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,i){let o=this.getters.getColRowOffsetInViewport(e,t,i);return this.getters.isDashboard()||(o+="ROW"===e?N:_),o}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(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:i}=e,{width:o,height:n}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,o+m,n+m);const s=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),r=s?.1*i:0;if(s)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=i,t.strokeRect(e.x+r,e.y+r,e.width-2*r,e.height-2*r)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let i=e.style;i.fillColor&&"#ffffff"!==i.fillColor&&(t.fillStyle=i.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),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())}}drawOverflowingCellBackground(e){var t,i;const{ctx:o,thinLineWidth:n}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const s=e.content.align||"left";let r,a;const l=e.y+n/2,c=e.height-n,h=Math.min((null===(t=e.clipRect)||void 0===t?void 0:t.width)||1/0,e.content.width);"left"===s?(r=e.x+n/2,a=h-2*n):"right"===s?(r=e.x+e.width-n/2,a=2*n-h):(r=((null===(i=e.clipRect)||void 0===i?void 0:i.x)||e.x+e.width/2-e.content.width/2)+n/2,a=h-2*n),o.fillStyle="#ffffff",o.fillRect(r,l,a,c)}}drawBorders(e){const{ctx:t,thinLineWidth:i}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:n,width:s,height:r}=e;t.left&&o(t.left,i,n,i,n+r),t.top&&o(t.top,i,n,i+s,n),t.right&&o(t.right,i+s,n,i+s,n+r),t.bottom&&o(t.bottom,i,n+r,i+s,n+r)}}function o([e,o],n,s,r,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*i,t.beginPath(),t.moveTo(n,s),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:i}=e;let o;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},s=e.content.align||"left",r=ze(n);r!==o&&(o=r,t.font=r),t.fillStyle=n.textColor||"#000";let a=e.x;if(a+="left"===s?V+(e.image?e.image.size+U:0):"right"===s?e.width-V-(e.isFilterHeader?20:0):e.width/2,t.textAlign=s,e.clipRect){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.clipRect;t.rect(i,o,n,s),t.clip()}const l=Be(n),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let o of e.content.textLines){if(t.fillText(o,Math.round(a),Math.round(h)),n.strikethrough||n.underline){const e=Pe(t,o,n);let r=a;"right"===s?r-=e:"center"===s&&(r-=e/2),n.strikethrough&&t.fillRect(r,h+l/2,e,2.6*i),n.underline&&t.fillRect(r,h+l+1,e,1.3*i)}h+=V+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const i=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.image.clipIcon;t.rect(i,o,n,s),t.clip()}const o=e.image.size,n=this.computeTextYCoordinate(e,o);t.drawImage(i,e.x+U,n,o,o),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,i=1){const o=e.y+1,n=Le(t,i),s=e.height>n+2*V,r=e.verticalAlign||"middle";if(s){if("middle"===r)return o+(e.height-n)/2;if("bottom"===r)return o+e.height-n-V}return o+V}drawHeaders(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getSheetViewVisibleCols(),n=o[0],s=o[o.length-1],r=this.getters.getSheetViewVisibleRows(),a=r[0],l=r[r.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let i of e)for(let e of He(i.left,i.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let i of e)for(let e of He(i.top,i.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${Z}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333";for(let e=n;e<=s;e++){const i={left:e,right:e,top:0,bottom:f-1},{x:o,width:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=E.has(e),a=u.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(o,0,n,N)}for(let e=a;e<=l;e++){const i={top:e,bottom:e,left:0,right:m-1},{y:o,height:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=w.has(e),a=g.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(0,o,_,n)}t.beginPath(),t.moveTo(_,0),t.lineTo(_,h),t.moveTo(0,N),t.lineTo(c,N),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of o){const i=this.getters.getColSize(p,e),o=Bt(e);t.fillStyle=E.has(e)?"#fff":C;let s=this.getHeaderOffset("COL",n,e);t.fillText(o,s+i/2,13),t.moveTo(s+i,0),t.lineTo(s+i,N)}for(const e of r){const i=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let o=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,o+i/2),t.moveTo(0,o+i),t.lineTo(_,o+i)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.isDashboard()?0:_,r=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#BCBCBC",t.beginPath(),o&&(t.moveTo(s+o,0),t.lineTo(s+o,r)),n&&(t.moveTo(0,r+n),t.lineTo(s,r+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.getSheetViewVisibleCols(),r=s[0],a=s[s.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:r,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:_,u=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#DADFE8",t.beginPath(),o&&(t.moveTo(d+o,u),t.lineTo(d+o,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}findNextEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n<t;){const e={sheetId:o,col:n+1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==sn.empty||this.getters.isInMerge(e)||(null==s?void 0:s.left))return n;n++}return n}findPreviousEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n>t;){const e={sheetId:o,col:n-1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==sn.empty||this.getters.isInMerge(e)||(null==s?void 0:s.right))return n;n--}return n}computeCellAlignment(e,t){const i=this.getters.getCell(e);if((null==i?void 0:i.isFormula)&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),n=this.getters.getEvaluatedCell(e);return t&&n.type===sn.number?"center"!==o?"left":o:o||n.defaultAlign}createZoneBox(e,t,i){const{left:o,right:n}=i,s=t.left,r=t.top,a={sheetId:e,col:s,row:r},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===sn.empty)return f;const v=this.getters.getConditionalIcon(a),b=Be(f.style),S=v?U+b:0;v&&(f.image={type:"icon",size:b,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:Eg[v].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",y="wrap"!==w||h?void 0:g-2*V,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+V))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===sn.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||b>p;if(v||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,i;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,i=s):(e=this.findNextEmptyCol(s,n,r),i=this.findPreviousEmptyCol(s,o,r),f.isOverflow=!0),T){case"left":{const i=ro({col:e,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(qi(t,i));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"right":{const e=ro({col:i,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(qi(t,e));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"center":{const o={...t,left:i,right:e},{x:n,y:s,height:r,width:a}=this.getters.getVisibleRect(o),l=R/2,c=f.x+f.width/2;if(n+a<c+l||n>c-l||b>r||x.length>1){const e=n>c-l?n:c-l,t=n+a-e;f.clipRect={x:e,y:s,width:t,height:r}}break}}}else("clip"===w||"wrap"===w||x.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),i=t[0],o=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),s={left:i,right:o,top:n[0],bottom:n[n.length-1]},r=this.getters.getActiveSheetId();for(const i of n)for(const o of t){const t={sheetId:r,col:o,row:i};this.getters.isInMerge(t)||e.push(this.createZoneBox(r,ro(t),s))}for(const t of this.getters.getMerges(r))if(!this.getters.isMergeHidden(r,t)&&Xi(t,s)){const i=this.createZoneBox(r,t,s),o=this.getters.getCellBorder({sheetId:r,col:t.right,row:t.bottom});i.border={...i.border,bottom:o?o.bottom:void 0,right:o?o.right:void 0},i.isMerge=!0,e.push(i)}return e}}lb.layers=[0,7],lb.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];class cb extends Gv{constructor(e,t,i){if(i&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=i,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 30;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 30}return 0}handleEvent(e){const t=Bi(e.anchor.zone),i=this.activeSheet,o=this.getters.getActiveSheetId(),n=this.getters.getSheetName(o);this.add([o===i?t:`${De(n)}!${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 i=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,i)}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:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),o=this.getters.expandZone(e.sheetIdTo,ro({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}}}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],xc:t}}insertNewRange(e,t){const i=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:i+t+1,color:St[(i+t)%St.length]}))))}setRange(e,t){const[,...i]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,i),i.length&&this.focus(e+i.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const i=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return i.map((e=>{const{sheetName:i}=zt(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:i&&this.getters.getSheetIdByName(i)||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:i}=zt(t),o=this.getters.getSheetIdByName(i),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(o===n||void 0===o&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}cb.layers=[1],cb.getters=[];class hb extends Gv{get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e,this.inputs={},this.focusedInputId=null}allowDispatch(e){var t,i;if("FOCUS_RANGE"===e.type){const o=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(i=this.currentInput)||void 0===i?void 0:i.focusedRangeIndex)===o)return 29}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":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:ro({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}break;case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id],i=t.ranges.find((t=>t.id===e.rangeId)),o=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(o,(null==i?void 0:i.xc)||"A1").zone;this.selection.capture(t,{cell:{col:n.left,row:n.top},zone:n},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,i)=>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===i}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:i}=zt(e);return null!==t.match(kt)&&(!i||void 0!==this.getters.getSheetIdByName(i))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,i=!1){if(this.inputs[e]=new cb(this.config,t,i),0===t.length){const t=this.inputs[e],i={zone:ro({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,i,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}hb.layers=[1],hb.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class db{constructor(){this.subscriptions={}}on(e,t,i){if(!i)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:i})}trigger(e,t){const i=this.subscriptions[e]||[];for(let e=0,o=i.length;e<o;e++){const o=i[e];o.callback.call(o.owner,t)}}off(e,t){const i=this.subscriptions[e];i&&(this.subscriptions[e]=i.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function ub(e,t){return{...e,definition:Sr(e.definition,t)}}function gb(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let i=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)i>t&&i--}if("ADD_COLUMNS_ROWS"===t.type){i=i>("before"===t.position?t.base-1:t.base)?i+t.quantity:i}return i>0?{...e,quantity:i}:void 0}Qu.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],ub),Qu.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],ub),Qu.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const i=t.sheetId;if(e.targetSheetId===i||e.sheetId===i)return;return e})),Qu.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),Qu.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var i;if(e.name===t.name)return{...e,name:(null===(i=e.name)||void 0===i?void 0:i.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),Qu.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const i=[];for(const o of e.target)for(const e of t.target)Xi(o,e)||i.push({...o});if(i.length)return{...e,target:i};return})),Qu.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],gb),Qu.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],gb),Qu.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const i of e.target)for(const e of t.target)if(Xi(e,i))return;return e}));const pb=[{match:function(e){return"sheetId"in e},fn:vb},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const i=vb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;const o=[];for(const i of e.target){const e=ls(i,t);e&&o.push(e)}if(!o.length)return"IGNORE_COMMAND";return{...e,target:o}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const i=vb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const i="COL"===t.dimension?"col":"row";let o=e[i];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[i]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const i of t.target){if(!(e.col===i.left&&e.row===i.top)&&Yi(e.col,e.row,i))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 i=vb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const i="ADD_COLUMNS_ROWS"===e.type,o=i?"base":"elements";let n=i?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const i=t.elements.sort(((e,t)=>t-e));for(let t of i)e>t&&e--;return e})).filter(it)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((i=>i>e?i+t.quantity:i))}if(n.length){let t=n;return i&&(t=n[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const i=[],o="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)i.push({...n,_zone:n._zone});else{const e=ls(n._zone,t);e&&o!==n._sheetId&&i.push({...n,_zone:e})}if(!i.length)return"IGNORE_COMMAND";return{...e,ranges:i}}}];function mb(e,t){const i=Qu.getTransformation(e.type,t.type);return i?i(e,t):function(e,t){for(const{match:i,fn:o}of pb)if(i(e)){const i=o(e,t);if("SKIP_TRANSFORMATION"===i)continue;if("IGNORE_COMMAND"===i)return;e=i}return e}(e,t)}function fb(e,t){let i=[...e];for(const e of t)i=i.map((t=>mb(t,e))).filter(it);return i}function vb(e,t){const i="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===i?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class bb{constructor(e,t,i,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...i],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Sb extends Error{}class Cb extends db{constructor(e,t,i=Q){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=i,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Pi,this.debouncedMove=function(e,t,i){let o;return function(){const n=this,s=arguments,r=i&&!o;clearTimeout(o),o=setTimeout((function(){o=null,i||e.apply(n,s)}),t),r&&e.apply(n,s)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const i=new bb(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.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;for(const t of e)this.onMessageReceived(t);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 Sb("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(it))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const i=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==i?void 0:i.col)===e.col&&i.row===e.row&&i.sheetId===e.sheetId)return;const o=i?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:o,version:1,client:{...n,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{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":const{clientId:t,commands:i}=e,o=new bb(e.nextRevisionId,t,i);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:fb(i,t)})}break;case"SNAPSHOT_CREATED":{const t=new bb(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}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Eb=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class wb extends Gv{constructor(){super(...arguments),this.availableColors=new Set(Eb),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(Eb));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 Sb)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const i of this.getters.getConnectedClients())if(i.id!==this.getters.getClient().id&&i.position&&i.position.sheetId===e&&this.isPositionValid(i.position)){const e=i.position;this.colors[i.id]||(this.colors[i.id]=this.chooseNewColor());const o=this.colors[i.id];t.push({...i,position:e,color:o})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:s}=e.position,r=this.getters.expandZone(o,{top:n,bottom:n,left:s,right:s}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*i,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 ${q+1}px ${Z}`}}}wb.getters=["getClientsToDisplay"],wb.layers=[6];class yb extends Gv{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Yi(e.col,e.row,e.zone))throw new Error(s("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;return io(t).some((({col:t,row:i})=>!this.getters.isInMerge({sheetId:e,col:t,row:i})))?63:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const i=this.getters.getMerges(e).filter((e=>Xi(e,t))),o=eo(i[0]);let[n,s]=[o.numberOfCols,o.numberOfRows];return i.every((e=>{let[t,i]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&i===s}))?0:63}expand(e,t){const{left:i,right:o,top:n,bottom:s}=this.getters.expandZone(e,t);return{left:Math.max(0,i),right:Math.min(this.getters.getNumberCols(e)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,s)}}checkExpandedValues(e,t){const i=this.expand(e,t);let o;if(this.getters.doesIntersectMerge(e,i)){const{left:t,right:n,top:s,bottom:r}=i;for(let i=t;i<=n;i++)for(let t=s;t<=r;t++){const{col:n,row:s}=this.getters.getMainCellPosition({sheetId:e,col:i,row:t});if(o=this.getters.getEvaluatedCell({sheetId:e,col:n,row:s}),o.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,i))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let i,{top:o,bottom:n,left:s,right:r}=t,a=!1;for(;!a;)a=!0,o>0&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:o-1,bottom:o-1}),i&&(a=!1,o--)),s>0&&(i=this.checkExpandedValues(e,{left:s-1,right:s-1,top:o-1,bottom:n+1}),i&&(a=!1,s--)),r<this.getters.getNumberCols(e)-1&&(i=this.checkExpandedValues(e,{left:r+1,right:r+1,top:o-1,bottom:n+1}),i&&(a=!1,r++)),n<this.getters.getNumberRows(e)-1&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:n+1,bottom:n+1}),i&&(a=!1,n++));return{left:s,right:r,top:o,bottom:n}}hasHeader(e,t){if(1===t[0].length)return!1;let i=t.map((t=>t.map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).type))));return i[0][0]===sn.empty&&(i=i.slice(1)),!i.some((e=>e[0]===sn.empty))&&!!i.some((e=>e[1]!==sn.empty&&e[0]!==e[1]))}sortZone(e,t,i,o,n){const[s,r]=this.mainCellsSteps(e,i);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},i),c=this.mainCells(e,i);!n.sortHeaders&&this.hasHeader(e,c)&&(l.top+=r),c=this.mainCells(e,l);const h=function(e,t,i){const o=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let n=o.filter((e=>e.type===sn.empty)),s=o.filter((e=>e.type!==sn.empty));i&&(s.push(...n.map((e=>({...e,type:sn.number,value:0})))),n=[]);const r="descending"===t?-1:1;return s.sort(((e,t)=>{let i=Er.indexOf(e.type)-Er.indexOf(t.type);return 0===i&&(i=e.type===sn.text||e.type===sn.error?e.value.localeCompare(t.value):e.value-t.value),r*i})).concat(n)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),o,Boolean(n.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++)for(let t=0;t<g;t++){let{col:i,row:o,sheetId:n}=c[e][d[t]];const a=this.getters.getCell({sheetId:n,col:i,row:o});let h=l.left+e*s,u=l.top+t*r,g={sheetId:n,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,i=this.getters.createAdaptedRanges(a.dependencies,0,t,n);e=this.getters.buildFormulaContent(n,a,i)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const i=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[i?i.right-i.left+1:1,i?i.bottom-i.top+1:1]}mainCells(e,t){const[i,o]=this.mainCellsSteps(e,t),n=[],s=He(t.left,t.right+1,i),r=He(t.top,t.bottom+1,o);for(const t of s){const i=[];n.push(i);for(const o of r)i.push({sheetId:e,col:t,row:o})}return n}}yb.getters=["getContiguousZone"];class xb extends Gv{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}xb.getters=["shouldShowFormulas"];class Ib extends Gv{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 i=this.getColMaxWidth(e.sheetId,t);0!==i&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:i,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){const t=this.getCellText(e),i=this.getters.getCellComputedStyle(e),o=t.split(he);let n=Math.max(...o.map((e=>this.getTextWidth(e,i))));this.getters.getConditionalIcon(e)&&(n+=function(e){return Be(e)+2*U}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(n+=20),n>0&&(n+=2*B,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,n)}return n}getTextWidth(e,t){return Pe(this.ctx,e,t)}getCellText(e,t=!1){const i=this.getters.getCell(e);return t&&(null==i?void 0:i.isFormula)?i.content:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const i=this.getters.getCellStyle(e),o=this.getters.getCellText(e,this.getters.shouldShowFormulas()),n=[];for(const e of o.split("\n")){const o=e.split(" ");if(!t){n.push(e);continue}let s="",r=t;for(let e of o){const o=this.splitWordToSpecificWidth(this.ctx,e,t,i),a=o.pop(),l=Pe(this.ctx,a,i);if(o.length)""!==s&&(n.push(s),s="",r=t),o.forEach((e=>{n.push(e)})),s=a,r=t-l;else{const e=""===s?a:" "+a,o=Pe(this.ctx,e,i);o<=r?(s+=e,r-=o):(n.push(s),s=a,r=t-l)}}""!==s&&n.push(s)}return n}getColDimensions(e,t){const i=this.getColRowOffset("COL",0,t,e),o=this.getters.getColSize(e,t);return{start:i,size:o,end:i+(this.getters.isColHidden(e,t)?0:o)}}getRowDimensions(e,t){const i=this.getColRowOffset("ROW",0,t,e),o=this.getters.getRowSize(e,t);return{start:i,size:o,end:i+(this.getters.isRowHidden(e,t)?0:o)}}getColRowOffset(e,t,i,o=this.getters.getActiveSheetId()){if(i<t)return-this.getColRowOffset(e,i,t);let n=0;for(let s=t;s<i;s++)this.getters.isHeaderHidden(o,e,s)||(n+="COL"===e?this.getters.getColSize(o,s):this.getters.getRowSize(o,s));return n}getColMaxWidth(e,t){const i=io(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...i)}splitWordToSpecificWidth(e,t,i,o){if(Pe(e,t,o)<=i)return[t];const n=[];let s="";for(let r of t){Pe(e,s+r,o)>i?(n.push(s),s=r):s+=r}return n.push(s),n}}Ib.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];class Rb{constructor(e,t,i,o){this.getters=t,this.dispatch=i,this.selection=o,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,i,o){const n=this.getters.getActiveSheetId(),s=t+o-this.getters.getNumberRows(n);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(n)-1,sheetId:n,quantity:s,position:"after"});const r=e+i-this.getters.getNumberCols(n);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(n)-1,sheetId:n,quantity:r,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Tb extends Rb{constructor(e,t,i,o,n){if(super(t,i,o,n),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const s=new Set(e.map((e=>e.left))),r=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===s.size&&1===r.size?function(e){return e.reduce(((e,t)=>{const i=e.length;for(let o=0;o<i;o++)if(Xi(e[o],t))return e[o]=qi(e[o],t),e;return e[i]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>io(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=i.getActiveSheetId();for(let e of u){let t=[];for(let o of d){const n={col:o,row:e,sheetId:p};t.push({cell:i.getCell(n),style:i.getCellComputedStyle(n),evaluatedCell:i.getEvaluatedCell(n),border:i.getCellBorder(n)||void 0,position:n})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const i of He(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:i,row:e.zone.top}));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const i=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 o=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(i,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(i,e[0])||o*n!=1))return 2;const{xSplit:s,ySplit:r}=this.getters.getPaneDivisions(i);for(const t of this.getPasteZones(e))if(t.left<s&&t.right>=s||t.top<r&&t.bottom>=r)return 75;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const i=this.cells.length,o=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(o,i,n,e)}pasteFromCopy(e,t){if(1===e.length){const i=this.cells.length,o=this.cells[0].length,n=this.pastedZones(e,o,i);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const i of e)for(let e=i.left;e<=i.right;e++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,o,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const i=e[0];this.pasteZone(i.left,i.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:i.left,row:i.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.sheetId,target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,i){const o=e[0],n=Math.max(1,Math.floor((o.right+1-o.left)/t)),s=Math.max(1,Math.floor((o.bottom+1-o.top)/i)),r=[];for(let e=0;e<n;e++)for(let n=0;n<s;n++){const s=o.top+n*i,a=o.left+e*t;r.push({left:a,top:s,bottom:s+i-1,right:a+t-1})}return r}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const i=[],o=t.length,n=t[0].length,s=e[e.length-1],r=s.left,a=s.top,l=Math.max(1,Math.floor((s.right+1-r)/n)),c=Math.max(1,Math.floor((s.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)i.push({left:r,top:a,right:r-1+e*n,bottom:a-1+t*o});return i}selectPastedZone(e,t,i,o){const n=o[0],s=n.left,r=n.top;if(t>1||e>1||i){const n=this.pastedZones(o,e,t),a=i?n[0]:qi(...n);this.selection.selectZone({cell:{col:s,row:r},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,i){const o=this.cells.length,n=this.cells[0].length,s="onlyValue"!==(null==i?void 0:i.pasteOption)&&(null==i?void 0:i.shouldPasteCF),r=this.getters.getActiveSheetId();this.addMissingDimensions(n,o,e,t);for(let a=0;a<o;a++){const o=this.cells[a];for(let l=0;l<n;l++){const n=o[l],c={col:e+l,row:t+a,sheetId:r};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,i),s&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,i,o){const{sheetId:n,col:s,row:r}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==(null==o?void 0:o.pasteOption)){const i=this.getters.getCellBorder(t),o=e.border,a={top:(null==i?void 0:i.top)||(null==o?void 0:o.top),bottom:(null==i?void 0:i.bottom)||(null==o?void 0:o.bottom),left:(null==i?void 0:i.left)||(null==o?void 0:o.left),right:(null==i?void 0:i.right)||(null==o?void 0:o.right)};this.dispatch("SET_BORDER",{sheetId:n,col:s,row:r,border:a})}if(e.cell){if("onlyFormat"===(null==o?void 0:o.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===(null==o?void 0:o.pasteOption)){const i=gi(e.evaluatedCell.value);return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===i){const t=s-e.position.col,o=r-e.position.row;a=this.getUpdatedContent(n,e.cell,t,o,i)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,i,o,n){const s=this.getters.createAdaptedRanges(t.dependencies,i,o,e);return this.getters.buildFormulaContent(e,t,s)}pasteMergeIfExist(e,t){let{sheetId:i,col:o,row:n}=e;const{col:s,row:r}=this.getters.getMainCellPosition(e);if(s===o&&r===n){const s=this.getters.getMerge(e);if(!s)return;({sheetId:i,col:o,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:i,force:!0,target:[{left:o,top:n,right:o+s.right-s.left,bottom:n+s.bottom-s.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),i=e[0],o=this.zones[0],n=[i.left-o.left,i.top-o.top];for(const e of this.copiedTables){const i=oo(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[i]});for(const o of He(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:i.left+o,row:i.top,values:e.filtersValues[o]})}}getClipboardContent(){return{[rn.PlainText]:this.getPlainTextContent(),[rn.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.position,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1==this.cells.length&&1==this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const i of t){e+=`<td style="${bo(fo(i.style))}">`+jf(this.getters.getCellText(i.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let i of this.zones){if("COL"===t&&e<=i.right)return!0;if("ROW"===t&&e<=i.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:i}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*i;for(const e of this.zones){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);n>0&&s>0&&t.strokeRect(i,o,n,s)}}}}class Ab{constructor(e,t,i){this.operation=e,this.getters=t,this.dispatch=i,this.sheetId=t.getActiveSheetId();const o=t.getSelectedFigureId();if(!o)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,o);if(!n)throw new Error(`No figure for the given id: ${o}`);switch(this.copiedFigure={...n},n.tag){case"chart":this.copiedFigureContent=new Mb(i,t,this.sheetId,o);break;case"image":this.copiedFigureContent=new Ob(i,t,this.sheetId,o);break;default:throw new Error(`Unknow tag '${n.tag}' for the given figure id: ${o}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?73:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),i={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},o={height:this.copiedFigure.height,width:this.copiedFigure.width},n=(new Pi).uuidv4();this.copiedFigureContent.paste(t,n,i,o),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return{[rn.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Mb{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getChart(o);if(!n)throw new Error(`No chart for the given id: ${o}`);this.copiedChart=n.copyInSheetId(i)}paste(e,t,i,o){const n=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:i,size:o,definition:n.getDefinition()})}}class Ob{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getImage(o);this.copiedImage=_e(n)}paste(e,t,i,o){const n=_e(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:i,size:o,definition:n})}}class Nb extends Rb{constructor(e,t,i,o){super("COPY",t,i,o),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId(),o=this.getPasteZone(e);return this.getters.doesIntersectMerge(i,o)?2:0}paste(e){const t=this.values,i=this.getPasteZone(e),{left:o,top:n}=i,{numberOfCols:s,numberOfRows:r}=eo(i),a=this.getters.getActiveSheetId();this.addMissingDimensions(s,r,o,n);for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)this.dispatch("UPDATE_CELL",{row:n+e,col:o+i,content:t[e][i],sheetId:a});const l={left:o,top:n,right:o+s-1,bottom:n+r-1};this.selection.selectZone({cell:{col:o,row:n},zone:l})}getClipboardContent(){return{[rn.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,i=Math.max(...this.values.map((e=>e.length))),{left:o,top:n}=e[0];return{top:n,left:o,bottom:n+t-1,right:o+i-1}}}class _b extends Gv{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:i});case"PASTE_FROM_OS_CLIPBOARD":return new Nb(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}}return 0}handle(e){var t,i;switch(e.type){case"COPY":case"CUT":const o=this.getters.getSelectedZones();this.state=this.getClipboardState(o,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const n=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!zi(t[0])){for(const{col:t,row:i}of io(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:i,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(i);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===(i=this.state)||void 0===i?void 0:i.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 Nb(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:dn(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||{[rn.PlainText]:"\t"}}getClipboardTextContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent()[rn.PlainText])||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o;return o="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(i)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o,n;return"COL"===t?(o={...e,right:this.getters.getNumberCols(i)-1},n={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:this.getters.getNumberRows(i)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1}),{cut:[o],paste:[n]}}getClipboardStateForCopyCells(e,t){return new Tb(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new Ab(t,this.getters,this.dispatch):new Tb(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}function Fb(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=zt(e.value),[o,n]=t.split(":"),s=i?`${De(i)}!`:"",r=Db(o),a=n?`:${Db(n)}`:"";return{...e,value:s+r+a}}function Db(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=kb(e,"colrow");break;case"colrow":e=kb(e,"row");break;case"row":e=kb(e,"col");break;case"col":e=kb(e,"none")}return e}function kb(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}_b.layers=[2],_b.getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];const Lb=s("The cell you are trying to edit has been deleted.");class Pb extends Gv{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=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.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":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):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),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:o}=zt(e.value),n=o||this.getters.getSheetName(this.sheetId),s=this.getters.getActiveSheetId();if(this.getters.getSheetName(s)!==n)return!1;const r=this.getters.getRangeFromSheetXC(s,i);return ji(this.getters.expandZone(s,r.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const o=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(o,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(n),this.previousRef=n,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 t=this.getters.getActivePosition(),{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),n=this.getters.expandZone(e.sheetIdTo,ro({col:i,row:o}));this.selection.resetAnchor(this,{cell:{col:i,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:Lb}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}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((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Fb).map((e=>e.value)).join(""),o=this.currentContent,n=e[0].start,s=e[e.length-1].end,r=o.slice(0,n)+i+o.slice(s),a=r.length-o.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:r,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}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:Lb});const{top:t,left:i}=Wi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,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:Lb});const{top:t,left:i}=Wi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=$i({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=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=ro({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 i;const o=this.getters.getActiveCell();e&&(null===(i=o.format)||void 0===i?void 0:i.includes("%"))&&ti(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:n,row:s,sheetId:r}=this.getters.getActivePosition();this.col=n,this.sheetId=r,this.row=s,this.initialContent=this.getComposerContent({sheetId:r,col:n,row:s}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=ro({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let i=this.currentContent;if(!(this.initialContent!==i))return;if(i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCell({sheetId:o,col:this.col,row:this.row});if(i.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&&(i+=st(new Array(o).fill(")")))}else n.link&&(i=Ye(i,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:i})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});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})}getComposerContent(e){const t=this.getters.getCell(e);if(null==t?void 0:t.isFormula)return t.content;const{format:i,value:o,type:n,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(n){case sn.text:case sn.empty:return o;case sn.boolean:return s;case sn.error:return(null==t?void 0:t.content)||"";case sn.number:return i&&Si(i)?s:this.numberComposerContent(o,i)}}numberComposerContent(e,t){return(null==t?void 0:t.includes("%"))?100*e+"%":function(e){const{integerDigits:t,decimalDigits:i}=fi(e,20);return i?`${t}.${i}`:t}(e)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?hf(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:s("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),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,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 i=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${De(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let i=[...t];1===t.length&&lo(e.zone)>1?i.push({...t[0]}):2===t.length&&1===lo(e.zone)&&i.pop();const o=e.clone({parts:i});return this.getters.getSelectionRangeString(o,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:o,end:o}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const o=new Set(Object.values(i));let n=0;const s=()=>{for(;o.has(n);)n++;return o.add(n),n};for(const e of t){const t=e in i?i[e]:s();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return St[t%St.length]};return this.getReferencedRanges().map((i=>{const o=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(o),sheetId:i.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 i=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type)||ym.includes(o.value);){if("SPACE"!==o.type||i<1)return!1;i--,o=this.currentTokens[i]}for(i=t+1,o=this.currentTokens[i];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;i++,o=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Pb.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];const Ub=[{name:s("Sum"),types:[sn.number],compute:e=>dl.compute([e])},{name:s("Avg"),types:[sn.number],compute:e=>wl.compute([e])},{name:s("Min"),types:[sn.number],compute:e=>Vl.compute([e])},{name:s("Max"),types:[sn.number],compute:e=>kl.compute([e])},{name:s("Count"),types:[sn.number,sn.text,sn.boolean,sn.error],compute:e=>Ol.compute([e])},{name:s("Count Numbers"),types:[sn.number,sn.text,sn.boolean,sn.error],compute:e=>Ml.compute([e])}];class Vb extends Gv{constructor(e){super(e),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=e.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 i=[];switch(e.mode){case"overrideSelection":i=[t.zone];break;case"updateAnchor":i=[...this.gridSelection.zones];const o=i.findIndex((t=>ji(t,e.previousAnchor.zone)));o>=0&&(i[o]=t.zone);break;case"newAnchor":i=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,i),this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor));const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:o,row:n}),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:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(i,o),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:_e(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor));else{const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,i)}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:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}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 n=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of n)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:_e(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:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:i})}const s=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(s,e))),this.gridSelection.anchor.zone=this.getters.expandZone(s,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor))}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}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 i=t.left;i<=t.right;i++)e.add(i);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let i of this.gridSelection.zones)if(0===i.left&&i.right===this.getters.getNumberCols(t)-1)for(let t=i.top;t<=i.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return _e(this.gridSelection.zones)}getSelectedZone(){return _e(this.gridSelection.anchor.zone)}getSelection(){return _e(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>e.type!==sn.empty)));let t=new Set,i=[];for(let o of e)t.add(o.type),i.push(o.value);let o={};for(let e of Ub){let n;e.types.some((e=>t.has(e)))&&(n=e.compute(i)),o[e.name]=n}return o}getAggregate(){let e=0,t=0;const i=this.getters.getActiveSheetId(),o=this.gridSelection.zones.map(io).flat();for(const{col:n,row:s}of o){const o=this.getters.getEvaluatedCell({sheetId:i,col:n,row:s});o.type===sn.number&&(t++,e+=o.value)}return t<2?null:gi(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>ji(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 i=[];const o="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[o]+1},((t,i)=>e[o]+i));i=i.concat(t)}return[...new Set(i)].sort()}setSelectionMixin(e,t){const{anchor:i,zones:o}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=i,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,i)=>t===i.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(o)}selectCell(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.expandZone(i,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:o,cell:{col:e,row:t}},[o])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),i=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[i]})}onColumnsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Wi(i,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Wi(n,"left",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onRowsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Wi(i,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Wi(n,"top",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onAddElements(e){const t=$i(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(i,[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 i="COL"===e.dimension,o=e.elements[0],n=e.elements[t-1],s=e.base<o,r=s&&i?t:0,a=s&&!i?t:0,l=[{left:i?o+r:0,right:i?n+r:this.getters.getNumberCols(e.sheetId)-1,top:i?0:o+a,bottom:i?this.getters.getNumberRows(e.sheetId)-1:n+a}],c=new Tb(l,"CUT",this.getters,this.dispatch,this.selection),h=[{left:i?e.base:0,right:i?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:i?0:e.base,bottom:i?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}];c.paste(h,{selectTarget:!0});const d=s?e.elements.map((e=>e+t)):e.elements;let u=e.base;for(const t of d){const i="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:i,elements:[u]}),u+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:d})}isMoveElementAllowed(e){const t="COL"===e.dimension,i=e.elements[0],o=e.elements[e.elements.length-1],n=e.sheetId,s=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return s(n,i-1,i)||s(n,o,o+1)||s(n,e.base-1,e.base)?2:0}clipSelection(e,t){const i=this.getters.getNumberCols(e)-1,o=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:ke(e.left,0,i),right:ke(e.right,0,i),top:ke(e.top,0,o),bottom:ke(e.bottom,0,o)}))),anchor:{cell:{col:ke(t.anchor.cell.col,0,i),row:ke(t.anchor.cell.row,0,o)},zone:{left:ke(t.anchor.zone.left,0,i),right:ke(t.anchor.zone.right,0,i),top:ke(t.anchor.zone.top,0,o),bottom:ke(t.anchor.zone.bottom,0,o)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*i;for(const e of o){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(i,o,n,s),t.globalCompositeOperation="source-over",t.strokeRect(i,o,n,s)}t.globalCompositeOperation="source-over";const s=this.getActivePosition();let r;t.strokeStyle=E,t.lineWidth=3*i,r=this.getters.isInMerge(s)?this.getters.getMerge(s):ro(s);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);c>0&&h>0&&t.strokeRect(a,l,c,h)}}Vb.layers=[6],Vb.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","getElementsFromSelection"];const zb=(new yo).add("sheet",Wv).add("header visibility",Uv).add("filters",Lv).add("cell",Mv).add("merge",zv).add("headerSize",Pv).add("borders",Av).add("conditional formatting",_v).add("figures",Fv).add("chart",Ov).add("image",Vv),Bb=(new yo).add("ui_sheet",Ib).add("header_visibility_ui",rb).add("ui_options",xb).add("selectionInputManager",hb).add("highlight",ab).add("grid renderer",lb).add("autofill",tb).add("find_and_replace",sb).add("sort",yb).add("automatic_sum",ib).add("format",class extends Gv{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,i){for(const o of t)for(const t of io(o)){const o=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==o){const n=Ri(o,i);this.dispatch("SET_FORMATTING",{sheetId:e,target:[ro(t)],format:n})}}}getCellNumberFormat(e){var t;for(const i of[e]){const e=this.getters.getEvaluatedCell(i);if(e.type===sn.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y)))return e.format||yi(e.value)}}}).add("cell_popovers",ob).add("selection_multiuser",wb),Hb=(new yo).add("selection",Vb).add("clipboard",_b).add("edition",Pb),$b=(new yo).add("evaluation",jv).add("evaluation_filter",Kv).add("evaluation_chart",Xv).add("evaluation_cf",Yv).add("viewport",Jv).add("custom_colors",qv),Wb=new yo;Wb.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,action:(e,t)=>Oo(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Gb{constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const i=document.createElement("input");i.setAttribute("type","file"),i.setAttribute("accept","image/*"),i.addEventListener("change",(async()=>{null===i.files||1!=i.files.length?t():e(i.files[0])})),i.click()}))}getImageSize(e){return new Promise(((t,i)=>{const o=new Image;o.src=e,o.addEventListener("load",(()=>{const e={width:o.width,height:o.height};t(e)})),o.addEventListener("error",i)}))}}const qb=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];po`
1400
+ `}function Jf(e){return new fp(e.join("\n"))}function ev(e,...t){let i=[e[0]];for(let o=0;o<t.length;o++){const n=t[o]instanceof fp?t[o]:Xf(t[o]);i.push(n+e[o+1])}return new fp(rt(i))}function tv(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function iv(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class ov{constructor(e){this.value=e}asString(){return rm(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class nv{constructor(e,t,i){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=i,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(ot)}mapOnElements(e,t){var i;const o=[],n=this.currentFile;let s;if(e.children){const t=null===(i=this.querySelector(e.parent,e.query))||void 0===i?void 0:i.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,o}catchErrorOnElement(e,t){const i=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([i,e.message].join("\n"))}extractAttr(e,t,i){const o=e.attributes[t];o||this.handleMissingValue(e,`attribute "${t}"`,i);const n=(null==o?void 0:o.value)?o.value:null==i?void 0:i.default;return void 0===n?void 0:new ov(n)}extractTextContent(e,t){var i;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===(null===(i=null==e?void 0:e.attributes["xml:space"])||void 0===i?void 0:i.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=o?n:n.trim()),n?rm(n):null==t?void 0:t.default}extractChildAttr(e,t,i,o){var n;let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,o);const r=s?null===(n=this.extractAttr(s,i,o))||void 0===n?void 0:n.asString():null==o?void 0:o.default;return void 0!==r?new ov(r):void 0}extractChildTextContent(e,t,i){if(void 0!==(null==i?void 0:i.default)&&"string"!=typeof i.default)throw new Error("extractTextContent default value should be a string");let o=this.querySelector(e,t);return o||this.handleMissingValue(e,`child <${t}>`,i),o?this.extractTextContent(o,i):null==i?void 0:i.default}handleMissingValue(e,t,i){if(null==i?void 0:i.required){if(!(null==i?void 0:i.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 ${i.default}`)}}extractColor(e,t,i){var o,n,s,r,a;if(!e)return i?{rgb:i}:void 0;const l=null===(o=this.extractAttr(e,"theme"))||void 0===o?void 0:o.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===(n=this.extractAttr(e,"rgb"))||void 0===n?void 0:n.asString();return{rgb:c,auto:null===(s=this.extractAttr(e,"auto"))||void 0===s?void 0:s.asBool(),indexed:null===(r=this.extractAttr(e,"indexed"))||void 0===r?void 0:r.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 i=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!i||!i.file)throw new Error("Cannot find target file");return i}querySelector(e,t){return t=this.areNamespaceIgnored?tv(t):iv(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?tv(t):iv(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 sv extends nv{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:bp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:bp}).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 rv extends nv{constructor(e,t,i,o){super(e,t,i),this.theme=o}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 i,o,n,s,r,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===(i=this.extractAttr(e,"dxfId"))||void 0===i?void 0:i.asNum(),stopIfTrue:null===(o=this.extractAttr(e,"stopIfTrue"))||void 0===o?void 0:o.asBool(),aboveAverage:null===(n=this.extractAttr(e,"aboveAverage"))||void 0===n?void 0:n.asBool(),percent:null===(s=this.extractAttr(e,"percent"))||void 0===s?void 0:s.asBool(),bottom:null===(r=this.extractAttr(e,"bottom"))||void 0===r?void 0:r.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 i=this.querySelector(e,"colorScale");if(i)return{colors:this.mapOnElements({parent:i,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(i)}}extractCfIconSet(e){var t,i;const o=this.querySelector(e,"iconSet, x14:iconSet");if(o)return{iconSet:this.extractAttr(o,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(o,"showValue",{default:!0}).asBool(),percent:this.extractAttr(o,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(o,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(i=this.extractAttr(o,"custom"))||void 0===i?void 0:i.asBool(),cfvos:this.extractCFVos(o),cfIcons:this.extractCfIcons(o)}}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,i;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===(i=this.extractAttr(e,"val"))||void 0===i?void 0:i.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class av extends nv{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!Yp[t])throw new Error(`Unsupported chart type ${t}`);const i=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),o=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:i,type:Yp[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:Xp[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===o,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=tv(e.tagName);if(vp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class lv extends nv{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==tv(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 i=this.querySelector(t,e);if(!i)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(i,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(i,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(i,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(i,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),i=this.getTargetXmlFile(this.relationships[t]),o=new av(i,this.xlsxFileStructure,this.warningManager).extractChart();if(!o)throw new Error("Unable to extract chart definition");return o}}class cv extends nv{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 hv extends nv{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,i,o,n,s;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(i=this.extractAttr(e,"showFirstColumn"))||void 0===i?void 0:i.asBool(),showLastColumn:null===(o=this.extractAttr(e,"showLastColumn"))||void 0===o?void 0:o.asBool(),showRowStripes:null===(n=this.extractAttr(e,"showRowStripes"))||void 0===n?void 0:n.asBool(),showColumnStripes:null===(s=this.extractAttr(e,"showColumnStripes"))||void 0===s?void 0:s.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 dv extends nv{constructor(e,t,i,o){super(e,t,i),this.theme=o}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=om(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=om(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,i=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(!i)throw new Error("Cannot find corresponding workbook sheet");return i}extractConditionalFormats(){return new rv(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new lv(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new hv(o,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 cv(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:Ap.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:Mp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,i,o,n,s,r,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(i=this.extractAttr(e,"customWidth"))||void 0===i?void 0:i.asBool(),bestFit:null===(o=this.extractAttr(e,"bestFit"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),min:null===(s=this.extractAttr(e,"min",{required:!0}))||void 0===s?void 0:s.asNum(),max:null===(r=this.extractAttr(e,"max",{required:!0}))||void 0===r?void 0:r.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,i,o,n,s;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(i=this.extractAttr(e,"ht"))||void 0===i?void 0:i.asNum(),customHeight:null===(o=this.extractAttr(e,"customHeight"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),styleIndex:null===(s=this.extractAttr(e,"s"))||void 0===s?void 0:s.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,i,o;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(i=this.extractAttr(e,"s"))||void 0===i?void 0:i.asNum(),type:$p[null===(o=this.extractAttr(e,"t",{default:"n"}))||void 0===o?void 0:o.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,i;const o=this.querySelector(e,"f");if(o)return{content:this.extractTextContent(o),sharedIndex:null===(t=this.extractAttr(o,"si"))||void 0===t?void 0:t.asNum(),ref:null===(i=this.extractAttr(o,"ref"))||void 0===i?void 0:i.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,i,o,n;const s=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(i=this.extractAttr(e,"ref",{required:!0}))||void 0===i?void 0:i.asString(),location:null===(o=this.extractAttr(e,"location"))||void 0===o?void 0:o.asString(),display:null===(n=this.extractAttr(e,"display"))||void 0===n?void 0:n.asString(),relTarget:s?this.relationships[s].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),i={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),o=this.extractTextContent(e,{required:!0});i[t]=o}const o=[];for(let e=0;e<Object.keys(i).length;e++)i[e]?o.push(i[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),o.push(""));return o}}class uv extends nv{constructor(e,t,i){super(e.styles,e,t),this.theme=i}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,i,o,n;const s=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),r=this.extractChildAttr(e,"sz","val",{default:q.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===(i=h.attributes.val)||void 0===i?void 0:i.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(o=u.attributes.val)||void 0===o?void 0:o.value),p=this.querySelector(e,"u")||void 0;return{name:s,size:r,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(n=p.attributes.val)||void 0===n?void 0:n.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const i=e.children[0];return"patternFill"===i.tagName?{patternType:null===(t=i.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(i,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(i,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(i,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,i;const o={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 o.diagonal&&(o.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),o.diagonalDown=null===(i=this.extractAttr(e,"diagonalDown"))||void 0===i?void 0:i.asBool()),o}extractSingleBorder(e,t,i){const o=this.querySelector(e,t);if(o&&o.attributes.style)return{style:this.extractAttr(o,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(o.children[0],i,"000000")}}extractAlignment(e){var t,i,o,n,s,r,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===(i=this.extractAttr(e,"wrapText"))||void 0===i?void 0:i.asBool(),indent:null===(o=this.extractAttr(e,"indent"))||void 0===o?void 0:o.asNum(),relativeIndent:null===(n=this.extractAttr(e,"relativeIndent"))||void 0===n?void 0:n.asNum(),justifyLastLine:null===(s=this.extractAttr(e,"justifyLastLine"))||void 0===s?void 0:s.asBool(),shrinkToFit:null===(r=this.extractAttr(e,"shrinkToFit"))||void 0===r?void 0:r.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"),i=this.querySelector(e,"fill"),o=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),s=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:i?this.extractFill(i):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:s?this.extractAlignment(s):void 0,border:o?this.extractBorder(o):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 gv extends nv{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})}))),i={};for(let e of t)i[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:i}}))}}function pv(e,t){const i=function(e,t){const i=t[kp],o=i.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of o){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const i=[];for(let o of e){const e=mv(o,t);i.push({file:{fileName:o,xml:t[o]},rels:e?{fileName:e,xml:t[e]}:void 0})}return i}(i,t)}function mv(e,t){if(e===kp)return"_rels/.rels";let i="";const o=e.split("/");for(let e=0;e<o.length-1;e++)i+=o[e]+"/";return i+="_rels/",i+=o[o.length-1]+".rels",t[i]||(i=void 0),i}class fv{constructor(e){this.warningManager=new Pp,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=Kf(new fp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new sv(e.theme,e,this.warningManager).getTheme():void 0,i=e.sharedStrings?new sv(e.sharedStrings,e,this.warningManager).getSharedStrings():[],o=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((i=>new dv(i,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new gv(t,e,this.warningManager).getExternalBook())),s=new uv(e,this.warningManager,t);return{fonts:s.getFonts(),fills:s.getFills(),borders:s.getBorders(),dxfs:s.getDxfs(),numFmts:s.getNumFormats(),styles:s.getStyles(),sheets:o,sharedStrings:i,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:pv(yp.sheet,this.xmls),workbook:pv(yp.workbook,this.xmls)[0],styles:pv(yp.styles,this.xmls)[0],sharedStrings:pv(yp.sharedStrings,this.xmls)[0],theme:pv(yp.themes,this.xmls)[0],charts:pv(yp.chart,this.xmls),figures:pv(yp.drawing,this.xmls),tables:pv(yp.table,this.xmls),pivots:pv(yp.pivot,this.xmls),externalLinks:pv(yp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(s("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Pf(e,this.warningManager),styles:dm(e,this.warningManager),formats:gm(e,this.warningManager),borders:cm(e,this.warningManager),entities:{},revisionId:Q};return Gf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=ut(e.styles[t])})),t}}function vv(e){const t=sf(e);let i=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Nt.test(e.value)){const t=e.value.trim();return i.includes(t)||i.push(t),`${ae}${i.indexOf(t)}${ae}`}return e.value}))),dependencies:i}}const bv=12,Sv="Sheet1";function Cv(e,t){if(!e)return Iv();if(e["[Content_Types].xml"]){const i=new fv(e);if(e=i.convertXlsx(),t)for(let e of i.warningManager.warnings.sort())console.warn(e)}return"version"in(e=Fe(e))&&e.version<bv&&(e=function(e){for(let t=Ev.findIndex((t=>t.from===e.version));t<Ev.length;t++)e=Ev[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,i=new Ui;for(const o of e.sheets||[])for(const e of o.figures||[])t.has(e.id)&&(e.id+=i.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Iv(),e,{version:bv}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(xv(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(xv(Sv,"Sheet1"));return e}(e),e}(e),e}const Ev=[{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 i=t.cells[e];i.content&&i.content.startsWith("=")&&(i.formula=vv(i.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:i,...o}=t.figures[e].data,n=[];for(let e of i)if(e.labelCell){const t=zi(e.dataRange),i=e.labelCell+":"+Gt(t.right,t.bottom);n.push(i)}else n.push(e.dataRange);o.dataSetsHaveTitle=Boolean(i[0].labelCell),o.dataSets=n,t.figures[e].data=o}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const i=[],o=new RegExp(re,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,s=e.replace(o,"_");let r=1,a=s;for(;i.includes(a);)a=`${s}${r}`,r++;n.name=a,i.push(a);const l=t=>{if(void 0===t)return t;let i=t.replace(e,a),o=t;for(;o!==i;)o=i,i=o.replace(e,a);return o};for(let e in n.cells){const t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of n.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),i=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:i}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const i of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[i])||void 0===t?void 0:t.type)&&(e.rule[i].value=l(e.rule[i].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 i=t.cells[e];if(i.formula){let{text:e,dependencies:t}=i.formula;for(let[i,o]of Object.entries(t)){const t=`\\${ae}${i}\\${ae}`;e=e.replace(new RegExp(t,"g"),o)}i.content=e,delete i.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let i of e.sheets||[])for(let e in i.cells||[]){const o=i.cells[e];o.format&&(o.format=st(o.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 wv(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const i=[],o=[],n=e=>{if("CREATE_SHEET"===e.type)i.push(e.sheetId);else if("sheetId"in e&&!i.includes(e.sheetId))return{...e,sheetId:Sv};return e};for(const e of t)"REMOTE_REVISION"===e.type?o.push({...e,commands:e.commands.map(n)}):o.push(e);return o}(e,t),t=yv(t,"SORT_CELLS"),t=function(e,t){var i;const o=[],n={};for(const t of e.sheets||[])null===(i=t.figures)||void 0===i||i.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const i of e.commands){let e=i;switch(i.type){case"CREATE_CHART":n[i.id]=i.definition;break;case"UPDATE_CHART":if(!n[i.id]){console.log(`Fix chart definition: chart with id ${i.id} not found.`);continue}const t={...n[i.id],...i.definition};e={...i,definition:t},n[i.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=yv(t,"SET_DECIMAL")),t}function yv(e,t){const i=[];for(const o of e)"REMOTE_REVISION"===o.type?i.push({...o,commands:o.commands.filter((e=>e.type!==t))}):i.push(o);return i}function xv(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Iv(e="Sheet1"){return{version:bv,sheets:[xv(Sv,e)],entities:{},styles:{},formats:{},borders:{},revisionId:Q,uniqueFigureIds:!0}}function Rv(e,t){return{...xv(e,t),charts:[],images:[]}}class Tv{constructor(e,t){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 i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const o=e.filter((e=>0!==e));if(o.length)return o}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Tv.getters=[];class Av extends Tv{constructor({getters:e,stateObserver:t,range:i,dispatch:o,uuidGenerator:n}){super(t,o),this.range=i,i.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class Mv extends Av{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 i=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,i)}break;case"DELETE_SHEET":const i={...this.borders};delete i[e.sheetId],this.history.update("borders",i);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,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,i)}handleAddRows(e){let t,i;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,i)}getCellBorder({sheetId:e,col:t,row:i}){var o,n,s,r,a,l,c,h,d,u,g,p;const m={top:null===(s=null===(n=null===(o=this.borders[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.horizontal,bottom:null===(l=null===(a=null===(r=this.borders[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i+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[i])||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[i])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,i){const o=$e(t+1,i);for(let n=0;n<this.getters.getNumberRows(e);n++){const s=this.getCellBorder({sheetId:e,col:t,row:n}),r=this.getCellBorder({sheetId:e,col:i,row:n});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,i,n,t)}}}ensureRowBorderContinuity(e,t,i){const o=$e(t+1,i);for(let n=0;n<this.getters.getNumberCols(e);n++){const s=this.getCellBorder({sheetId:e,col:n,row:t}),r=this.getCellBorder({sheetId:e,col:n,row:i});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,n,i,t)}}}getCommonSides(e,t){const i={};for(let o of["top","bottom","left","right"])e[o]&&e[o]===t[o]&&(i[o]=e[o]);return i}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?$e(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,i,{moveFirstLeftBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfColumn(e,t,i,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfColumn(e,n,i,"vertical"),this.moveBordersOfColumn(e,n,i,"horizontal")})))}shiftBordersVertically(e,t,i,{moveFirstTopBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfRow(e,t,i,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfRow(e,n,i,"horizontal"),this.moveBordersOfRow(e,n,i,"vertical")})))}moveBordersOfRow(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getColumnsWithBorders(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[r])||void 0===a?void 0:a[t+i])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o];this.history.update("borders",e,r,t+i,o,n?u:u||d),this.history.update("borders",e,r,t,o,void 0)}))}moveBordersOfColumn(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getRowsRange(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[t+i])||void 0===a?void 0:a[r])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[o];this.history.update("borders",e,t+i,r,o,n?u:u||d),this.history.update("borders",e,t,r,o,void 0)}))}setBorder(e,t,i,o,n=!0){var s,r,a,l,c,h,d,u,g,p,m,f,v,b,S,C;!n&&(null===(l=null===(a=null===(r=null===(s=this.borders)||void 0===s?void 0:s[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,i,"vertical",null==o?void 0:o.left),!n&&(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[i])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,i,"horizontal",null==o?void 0:o.top),!n&&(null===(f=null===(m=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===m?void 0:m[i])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,i,"vertical",null==o?void 0:o.right),!n&&(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[i+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,i+1,"horizontal",null==o?void 0:o.bottom)}clearBorders(e,t){for(let i of t){for(let t=i.top;t<=i.bottom;t++){this.history.update("borders",e,i.right+1,t,"vertical",void 0);for(let o=i.left;o<=i.right;o++)this.history.update("borders",e,o,t,void 0)}for(let t=i.left;t<=i.right;t++)this.history.update("borders",e,t,i.bottom+1,"horizontal",void 0)}}addBorder(e,t,i,o){this.setBorder(e,t,i,{...this.getCellBorder({sheetId:e,col:t,row:i}),...o})}setBorders(e,t,i){if("clear"===i)return this.clearBorders(e,t);for(let o of t){if("h"===i||"hv"===i||"all"===i)for(let t=o.top+1;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++)this.addBorder(e,i,t,{top:j});if("v"===i||"hv"===i||"all"===i)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left+1;i<=o.right;i++)this.addBorder(e,i,t,{left:j});if("left"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.left,t,{left:j});if("right"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.right+1,t,{left:j});if("top"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.top,{top:j});if("bottom"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.bottom+1,{top:j})}}addBordersToMerge(e,t){const{left:i,right:o,top:n,bottom:s}=t,r=this.getCellBorder({sheetId:e,col:i,row:n}),a=this.getCellBorder({sheetId:e,col:o,row:s});this.clearBorders(e,[t]),(null==r?void 0:r.top)&&this.setBorders(e,[{...t,bottom:n}],"top"),(null==r?void 0:r.left)&&this.setBorders(e,[{...t,right:i}],"left"),((null==a?void 0:a.bottom)||(null==r?void 0:r.bottom))&&this.setBorders(e,[{...t,top:s}],"bottom"),((null==a?void 0:a.right)||(null==r?void 0:r.right))&&this.setBorders(e,[{...t,left:o}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[i,o]of Object.entries(t.cells))if(null==o?void 0:o.border){const n=e.borders[o.border],{col:s,row:r}=Wt(i);this.setBorder(t.id,s,r,n,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,zi(e))}export(e){let t=0;const i={};function o(e){for(let[t,o]of Object.entries(i))if(Oe(o)===Oe(e))return parseInt(t,10);return i[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let i=0;i<t.rowNumber;i++){const n=this.getCellBorder({sheetId:t.id,col:e,row:i});if(n){const s=Gt(e,i),r=t.cells[s],a=o(n);r?r.border=a:t.cells[s]={border:a}}}e.borders=i}exportForExcel(e){this.export(e)}}Mv.getters=["getCellBorder"];class Ov extends Av{constructor(){super(...arguments),this.nextId=1,this.cells={}}adaptRanges(e,t){for(const i of Object.keys(this.cells))for(const o of Object.values(this.cells[i]||{}))if(o.isFormula)for(const n of o.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",i,o.id,"dependencies",o.dependencies.indexOf(n),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,i){for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:i})}clearFormatting(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:null,format:""})}handleAddColumnsRows(e,t){let i,o;"before"===e.position?(i=$e(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=$e(e.base+1,e.base+e.quantity+1),o=e.base),t(e.sheetId,o,i)}import(e){for(let t of e.sheets)for(let i in t.cells){const o=t.cells[i],{col:n,row:s}=Wt(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(t.id,o,e.styles,e.formats);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cellId:i.id,col:n,row:s,sheetId:t.id})}}}export(e){const t={},i={};for(let o of e.sheets){const e={},n=Object.keys(this.cells[o.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const o of n){const n=this.getters.getCell(o);e[Gt(o.col,o.row)]={style:n.style?st(n.style,t):void 0,format:n.format?st(n.format,i):void 0,content:n.content||void 0}}o.cells=e}e.styles=t,e.formats=i}importCell(e,t,i,o){const n=t.style&&i[t.style]||void 0,s=t.format&&o[t.format]||void 0,r=this.getNextUid();return this.createCell(r,(null==t?void 0:t.content)||"",s,n,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){for(const t in this.cells){const i=this.cells[t][e];if(i)return i}}buildFormulaContent(e,t,i){const o=i||t.dependencies;let n=0;return rt(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=o[n++];return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){var t;return(null===(t=this.getters.getCell(e))||void 0===t?void 0:t.style)||{}}zoneToXC(e,t,i=[{colFixed:!1,rowFixed:!1}]){const o=Gt((t=this.getters.expandZone(e,t)).left,t.top,i[0]),n=Gt(t.right,t.bottom,i.length>1?i[1]:i[0]),s=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),r=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=s.col===r.col&&s.row===r.row;return o==n||a?o:o+":"+n}setStyle(e,t,i){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){const o=this.getters.getCell({sheetId:e,col:t,row:n});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:i?{...null==o?void 0:o.style,...i}:void 0})}}copyColumnStyle(e,t,i){for(let o=0;o<this.getters.getNumberRows(e);o++){const n=this.getFormat(e,t,o);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,...n})}}copyRowStyle(e,t,i){for(let o=0;o<this.getters.getNumberCols(e);o++){const n=this.getFormat(e,o,t);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,...n})}}getFormat(e,t,i){const o={},n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.getters.getCell(n);return s&&(s.style&&(o.style=s.style),s.format&&(o.format=s.format)),o}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,i,o){const n=this.getters.getCell({sheetId:e,col:t,row:i}),s="content"in o||"formula"in o,r=s?vt(null==o?void 0:o.content):(null==n?void 0:n.content)||"";let a;a=void 0!==o.style?o.style||void 0:n?n.style:void 0;let l=("format"in o?o.format:n&&n.format)||Ii(r);if((s&&!r&&!o.formula||!s&&(!n||""===n.content))&&!a&&!l)return void(n&&(this.history.update("cells",e,n.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:i,sheetId:e})));const c=(null==n?void 0:n.id)||this.getNextUid(),h=this.createCell(c,r,l,a,e);this.history.update("cells",e,h.id,h),this.dispatch("UPDATE_CELL_POSITION",{cellId:h.id,col:t,row:i,sheetId:e})}createCell(e,t,i,o,n){if(!t.startsWith("="))return this.createLiteralCell(e,t,i,o);try{return this.createFormulaCell(e,t,i,o,n)}catch(n){return this.createErrorFormula(e,t,i,o,n)}}createLiteralCell(e,t,i,o){return{id:e,content:t,style:o,format:i,isFormula:!1}}createFormulaCell(e,t,i,o,n){const s=hf(t);return s.dependencies.length?this.createFormulaCellWithDependencies(e,s,i,o,n):{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:s,dependencies:[]}}createFormulaCellWithDependencies(e,t,i,o,n){const s=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(n,e))),r=this.buildFormulaContent.bind(this);return{id:e,get content(){return r(n,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})},style:o,format:i,isFormula:!0,compiledFormula:t,dependencies:s}}createErrorFormula(e,t,i,o,n){return{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:{dependencies:[],tokens:Rm(t),execute:function(){throw n}},dependencies:[]}}checkCellOutOfSheet(e,t,i){if(!this.getters.tryGetSheet(e))return 27;return Ki(t,i,this.getters.getSheetZone(e))?0:18}}Ov.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Nv extends Av{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=lr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i,o,n){const s=t.find((e=>e.match(o.type)));if(!s)throw new Error(`No builder for this chart: ${o.type}`);return s.createChart(o,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const i=lr.getAll().find((e=>e.match(t.type)));if(!i)throw new Error("Unknown chart type.");return i.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,i]of Object.entries(this.charts))this.history.update("charts",t,null==i?void 0:i.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 i=this.getters.getFigures(e.sheetId);for(const o of i)if("chart"===o.tag){const i=o.id.split(ee).pop(),n=`${e.sheetIdTo}${ee}${i}`,s=null===(t=this.charts[o.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:n,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.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 i=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!i)throw new Error("Chart not defined.");return i}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 i=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!i)throw new Error(`There is no chart with the given figureId: ${e}`);return i}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 i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();i&&(e.data=i,o.push(e))}else o.push(e)}i.figures=o}}exportForExcel(e){var t;for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e)if(i&&"chart"===i.tag){const e=null===(t=this.charts[i.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&o.push({...i,data:e})}i.charts=o}}addFigure(e,t,i={x:0,y:0},o={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const i=this.getters.getFigureSheetId(e);i&&this.history.update("charts",e,this.createChart(e,t,i))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?84:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:85}}function _v(e){return""===e?NaN:Number(e)}Nv.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class Fv extends Av{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const i of this.cfRules[e])for(const o of i.ranges){const n=t(o);switch(n.changeType){case"REMOVE":let t=i.ranges.slice();t.splice(i.ranges.indexOf(o),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",t):this.removeConditionalFormatting(i.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",i.ranges.indexOf(o),n.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 i={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(i,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 i=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{i.add(e)}))})),Array.from(i)}getRulesByZone(e,t){const i=new Set;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,o).forEach((e=>{i.add(e.id)}))}return i}getRulesByCell(e,t,i){const o=[];for(let n of this.cfRules[e])for(let e of n.ranges)Ki(t,i,e.zone)&&o.push(n);return new Set(o.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 i={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return i}addConditionalFormatting(e,t){const i=this.cfRules[t].slice(),o=i.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);o>-1?i.splice(o,1,n):i.push(n),this.history.update("cfRules",t,i)}checkValidReordering(e,t,i){if(!this.cfRules[i])return 27;const o=this.cfRules[i].findIndex((t=>t.id===e));if(-1===o)return 71;const n="up"===t?o-1:o+1;return n<0||n>=this.cfRules[i].length?71: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 i=>{if(t.includes(i.operator)){const t=[],o=e=>void 0===e||""===e;return e>=1&&o(i.values[0])&&t.push(51),e>=2&&o(i.values[1])&&t.push(52),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 53;case"max":return 55;case"mid":return 54;case"upperInflectionPoint":return 56;case"lowerInflectionPoint":return 57}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{hf(e.value||"")}catch(e){switch(t){case"min":return 58;case"max":return 60;case"mid":return 59;case"upperInflectionPoint":return 61;case"lowerInflectionPoint":return 62}}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,i=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(i)?48:0}checkMinBiggerThanMax(e){const t=e.minimum.value,i=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&_v(t)>=_v(i)?47:0}checkMidBiggerThanMax(e){var t;const i=null===(t=e.midpoint)||void 0===t?void 0:t.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&_v(i)>=_v(o)?49:0}checkMinBiggerThanMid(e){var t;const i=e.minimum.value,o=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&&_v(i)>=_v(o)?50:0}removeConditionalFormatting(e,t){const i=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==i){const e=this.cfRules[t].slice();e.splice(i,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,i){const o=this.cfRules[i].findIndex((t=>t.id===e)),n="up"===t?o-1:o+1;if(!(n<0||n>=this.cfRules[i].length)&&-1!==o&&-1!==n){const e=[...this.cfRules[i]],t=e[o];e[o]=e[n],e[n]=t,this.history.update("cfRules",i,e)}}}Fv.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Dv extends Av{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:i,...o}=e,n=o;this.updateFigure(i,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[i,o]of Object.entries(t))switch(i){case"x":case"y":void 0!==o&&this.history.update("figures",e,t.id,i,Math.max(o,0));break;case"width":case"height":void 0!==o&&this.history.update("figures",e,t.id,i,o)}}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 i;return void 0===(null===(i=this.figures[e])||void 0===i?void 0:i[t])?70:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?82:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(ot)}getFigure(e,t){var i;return null===(i=this.figures[e])||void 0===i?void 0:i[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var i;return void 0!==(null===(i=this.figures[t])||void 0===i?void 0:i[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 i=void 0;t.figures.push({...e,data:i})}}exportForExcel(e){this.export(e)}}Dv.getters=["getFigures","getFigure","getFigureSheetId"];class kv{constructor(e){this.filters=[],this.zone=e;const t=new Ui;this.id=t.uuidv4();for(const i of $e(e.left,e.right+1)){const e={...this.zone,left:i,right:i};this.filters.push(new Lv(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 kv(this.zone)}}class Lv{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 Pv extends Av{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!ho(...e.target))return 81;const t=Zi(...e.target),i=()=>this.getFilterTables(e.sheetId).some((e=>Yi(e.zone,t)))?78:0,o=()=>{const i=this.getters.getMergesInZone(e.sheetId,t);for(let e of i)if(Yi(t,e))return 80;return 0};return this.checkValidations(e,i,o);case"ADD_MERGE":for(let t of e.target)for(let i of this.getFilterTables(e.sheetId))if(Yi(i.zone,t))return 80}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":const i={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=Fe(t);i[e.id]=e}this.history.update("tables",e.sheetIdTo,i);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=Zi(...e.target),i=this.createFilterTable(t);this.history.update("tables",e.sheetId,i.id,i);break}case"REMOVE_FILTER_TABLE":{const t={};for(const i of this.getFilterTables(e.sheetId))e.target.every((e=>!ji(e,i.zone)))&&(t[i.id]=i);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let i of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,i)&&this.extendTableDown(t,i);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(ot):[]}getFilter(e){var t;return null===(t=this.getFilterTable(e))||void 0===t?void 0:t.filters.find((t=>t.col===e.col))}getFilterId(e){var t;return null===(t=this.getFilter(e))||void 0===t?void 0:t.id}getFilterTable({sheetId:e,col:t,row:i}){return this.getFilterTables(e).find((e=>Ki(t,i,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Qi(e.zone,t)))}doesZonesContainFilter(e,t){for(const i of t)for(const t of this.getFilterTables(e))if(ji(i,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=$i(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o=[];for(const i of t.filters){const t=$i(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);o.push(new Lv(i.id,t))}if(o.length<to(i).numberOfCols){for(let e=i.left;e<=i.right;e++)o.find((t=>t.col===e))||o.push(new Lv(this.uuidGenerator.uuidv4(),{...i,left:e,right:e}));o.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=qi(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(i){if(Hi(i)!==Hi(t.zone)){const o=[];for(const i of t.filters){const t=qi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&o.push(new Lv(i.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}else{const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i)}}}createFilterTable(e){return new kv(e)}extendTableDown(e,t){const i={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",i);for(let i=0;i<t.filters.length;i++){const o=t.filters[i],n={...o.zoneWithHeaders,bottom:o.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",i,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:i,row:o},n){var s;if(!e)return;const r=n.zone;if(!(r.bottom+1===o&&i>=r.left&&i<=r.right))return!1;for(const e of $e(r.left,r.right+1)){const i={sheetId:t,col:e,row:o};if(null===(s=this.getters.getCell(i))||void 0===s?void 0:s.content)return!1;if(this.getters.getFilter(i))return!1;if(this.getters.isInMerge(i))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const i=this.createFilterTable(zi(e.range));this.history.update("tables",t.id,i.id,i)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:Hi(e.zone)})}exportForExcel(e){this.export(e)}}Pv.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Uv extends Av{constructor(){super(...arguments),this.sizes={}}handle(e){var t,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),i={COL:t.COL.map((e=>({manualSize:void 0,computedSize:at(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:at(e)})))};this.history.update("sizes",e.sheetId,i);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,Fe(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const o={...this.sizes};delete o[e.sheetId],this.history.update("sizes",o);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);const i=Math.min(...e.elements);t=t.map(((t,o)=>"ROW"===e.dimension&&o>=i?{manualSize:t.manualSize,computedSize:at((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const i=ct(e.position,e.base),o=t[e.base],n=$e(0,e.quantity).map((()=>({manualSize:o.manualSize,computedSize:at(o.computedSize())})));t.splice(i,0,...n),t=t.map(((t,i)=>"ROW"===e.dimension&&i>e.base+e.quantity?{manualSize:t.manualSize,computedSize:at((()=>this.getRowTallestCellSize(e.sheetId,i)))}: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 i=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:at(i)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:at(e.size||F)});break;case"UPDATE_CELL":const n=null===(i=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[e.row];if(n&&!n.manualSize){const{sheetId:t,row:i}=e;this.history.update("sizes",t,"ROW",i,"computedSize",at((()=>this.getRowTallestCellSize(t,i))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let i of $e(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,i);t!==this.getRowSize(e.sheetId,i)&&this.history.update("sizes",e.sheetId,"ROW",i,"computedSize",at(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,i){var o,n,s,r;return Math.round((null===(n=null===(o=this.sizes[e])||void 0===o?void 0:o[t][i])||void 0===n?void 0:n.manualSize)||(null===(r=null===(s=this.sizes[e])||void 0===s?void 0:s[t][i])||void 0===r?void 0:r.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,i;const o={COL:[],ROW:[]};for(let t of $e(0,this.getters.getNumberCols(e)))o.COL.push(this.getHeaderSize(e,"COL",t));for(let n of $e(0,this.getters.getNumberRows(e))){let s=null===(i=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[n].manualSize;if(!s){s=this.getRowTallestCellSize(e,n)}o.ROW.push(s)}return o}getDefaultHeaderSize(e){return"COL"===e?F:D}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return D;return function(e){return e&&e.content?Pe(He(e.style),e.isFormula?1:e.content.split(he).length)+2*z:D}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const i=this.getters.getRowCells(e,t);let o=0;for(let e=0;e<i.length;e++){const t=this.getters.getCellById(i[e]);if(!t)continue;const n=this.getters.getCellPosition(t.id),s=this.getCellHeight(n);s>o&&s>D&&(o=s)}return o<=D?D:o}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[i,o]of Object.entries(t.rows))o.size&&(e.ROW[i]=o.size);for(let[i,o]of Object.entries(t.cols))o.size&&(e.COL[i]=o.size);const i=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:i.COL.map(((t,i)=>({manualSize:e.COL[i],computedSize:at(t)}))),ROW:i.ROW.map(((t,i)=>({manualSize:e.ROW[i],computedSize:at(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var i,o;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of $e(0,this.getters.getNumberRows(n.id)))(t||(null===(i=this.sizes[n.id].ROW[e])||void 0===i?void 0:i.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of $e(0,this.getters.getNumberCols(n.id)))(t||(null===(o=this.sizes[n.id].COL[e])||void 0===o?void 0:o.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Uv.getters=["getRowSize","getColSize"];class Vv extends Av{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),i="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=i?66:Math.min(...e.elements)<0||Math.max(...e.elements)>i?86:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.checkElementsIncludeAllVisibleHeaders(e.sheetId,e.dimension,e.elements)?8:0:27}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,Fe(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 i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],i=ct(e.position,e.base);t.splice(i,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)}}checkElementsIncludeAllVisibleHeaders(e,t,i){return dt(i,this.getAllVisibleHeaders(e,t))}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],i=this.hiddenHeaders[e].COL;for(let e=0;e<i.length;e++){i[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=[[]],i=this.hiddenHeaders[e].ROW;for(let e=0;e<i.length;e++){i[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}getAllVisibleHeaders(e,t){return $e(0,this.hiddenHeaders[e][t].length).filter((i=>!this.hiddenHeaders[e][t][i]))}import(e){var t,i;for(let o of e.sheets){this.hiddenHeaders[o.id]={COL:[],ROW:[]};for(let e=0;e<o.rowNumber;e++)this.hiddenHeaders[o.id].ROW[e]=Boolean(null===(t=o.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<o.colNumber;e++)this.hiddenHeaders[o.id].COL[e]=Boolean(null===(i=o.cols[e])||void 0===i?void 0:i.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e=0;e<this.getters.getNumberRows(i.id);e++)(t||this.hiddenHeaders[i.id].ROW[e])&&(void 0===i.rows[e]&&(i.rows[e]={}),i.rows[e].isHidden=this.hiddenHeaders[i.id].ROW[e]);void 0===i.cols&&(i.cols={});for(let e=0;e<this.getters.getNumberCols(i.id);e++)(t||this.hiddenHeaders[i.id].COL[e])&&(void 0===i.cols[e]&&(i.cols[e]={}),i.cols[e].isHidden=this.hiddenHeaders[i.id].COL[e])}}}Vv.getters=["checkElementsIncludeAllVisibleHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class zv extends Av{constructor(e){super(e),this.images={},this.syncedImages=new Set,this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?28:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addFigure(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const i of t)if("image"===i.tag){const t=i.id.split(ee).pop(),o=`${e.sheetIdTo}${ee}${t}`,n=this.getImage(i.id);if(n){const t={width:i.width,height:i.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:o,position:{x:i.x,y:i.y},size:t,definition:Fe(n)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){var e;const t=new Set(this.getAllImages().map((e=>e.path)));for(const i of this.syncedImages)t.has(i)||null===(e=this.fileStore)||void 0===e||e.delete(i)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addFigure(e,t,i,o){const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const i of e)this.history.update("images",t.id,i.id,i.data),this.syncedImages.add(i.data.path)}}export(e){var t;for(const i of e.sheets){const e=i.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=null===(t=this.images[i.id])||void 0===t?void 0:t[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),i=[];for(const t of e)if("image"===(null==t?void 0:t.tag)){const e=this.getImage(t.id);e&&i.push({...t,data:Fe(e)})}t.images=i}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(ot));return e}}zv.getters=["getImage","getImagePath","getImageSize"];class Bv extends Av{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 i of Object.values(t).filter(ot))this.addMerge(e.sheetIdTo,i.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 i=t?[t]:Object.keys(this.merges);for(const t of i)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(ot)}getMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e],s=n?t in n&&(null===(o=n[t])||void 0===o?void 0:o[i]):void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){var i;const o=this.mergeCellMap[e];if(!o)return[];const n=new Set;for(const{col:e,row:s}of oo(t)){const t=null===(i=o[e])||void 0===i?void 0:i[s];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(ot)}doesIntersectMerge(e,t){return oo(t).some((({col:t,row:i})=>void 0!==this.getMerge({sheetId:e,col:t,row:i})))}doesColumnsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(o.id,t,n,i,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(o.id,n,t,n,i))return!0;return!1}expandZone(e,t){let{left:i,right:o,top:n,bottom:s}=t,r={left:i,right:o,top:n,bottom:s};for(let t in this.merges[e]){const i=this.getMergeById(e,parseInt(t));i&&Yi(i,r)&&(r=Zi(i,r))}return Xi(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,i,o,n){const s=this.getMerge({sheetId:e,col:t,row:i}),r=this.getMerge({sheetId:e,col:o,row:n});return!(!s||!r)&&Xi(s,r)}isInMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(o=n[t])||void 0===o?void 0:o[i]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:i}=this.getMerge(e);return{sheetId:e.sheetId,col:i,row:t}}isMergeHidden(e,t){const i=this.getters.getHiddenColsGroups(e),o=this.getters.getHiddenRowsGroups(e);for(let e of i)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of o)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const i=this.getMerge({sheetId:e,col:t.left,row:t.top});if(i)return Xi(t,i);const{numberOfCols:o,numberOfRows:n}=to(t);return 1===o&&1===n}isMergeDestructive(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=Le(o,0,this.getters.getNumberCols(e)-1),s=Le(s,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=s;t++)for(let s=i;s<=o;s++)if(s!==i||t!==n){const i=this.getters.getCell({sheetId:e,col:s,row:t});if(i&&""!==i.content)return!0}return!1}getMergeById(e,t){var i;const o=null===(i=this.merges[e])||void 0===i?void 0:i[t];return void 0!==o?$v(t,o):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 i of e)if(t!==i&&Yi(t,i))return 65;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<i&&e.right>=i||e.top<o&&e.bottom>=o)return 75;return 0}checkMergedContentUpdate(e){const{col:t,row:i,content:o}=e;if(void 0===o)return 0;const{col:n,row:s}=this.getMainCellPosition(e);return n===t&&s===i?0:4}checkMergeExists(e){const{sheetId:t,target:i}=e;for(const e of i){const{left:i,top:o}=e,n=this.getMerge({sheetId:t,col:i,row:o});if(void 0===n||!Xi(e,n))return 5}return 0}addMerge(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=Le(o,0,this.getters.getNumberCols(e)-1),s=Le(s,0,this.getters.getNumberRows(e)-1);if(Gt(i,n)===Gt(o,s))return;const r=this.getters.getCell({sheetId:e,col:i,row:n});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,Hi({left:i,top:n,right:o,bottom:s})));let l=new Set;for(let t=n;t<=s;t++)for(let s=i;s<=o;s++){s===i&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,style:r?r.style:null,content:""});const o=this.getMerge({sheetId:e,col:s,row:t});o&&l.add(o.id),this.history.update("mergeCellMap",e,s,t,a)}for(let t of l){const{top:i,bottom:o,left:n,right:s}=this.getMergeById(e,t);for(let t=i;t<=o;t++)for(let i=n;i<=s;i++){const o={sheetId:e,col:i,row:t},n=this.getMerge(o);n&&n.id===a||(this.history.update("mergeCellMap",e,i,t,void 0),this.dispatch("CLEAR_CELL",o))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:i,top:o,bottom:n,right:s}=t,r=this.getMerge({sheetId:e,col:i,row:o});if(void 0!==r&&Xi(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=o;t<=n;t++)for(let o=i;o<=s;o++)this.history.update("mergeCellMap",e,o,t,void 0)}}applyRangeChangeOnSheet(e,t){const i=Object.entries(this.merges[e]||{});for(const[o,n]of i)if(n){const i=n.zone,s=t(n);switch(s.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,i);break;default:const{numberOfCols:t,numberOfRows:n}=to(s.range.zone);1===t&&1===n?this.removeMerge(e,i):this.history.update("merges",e,parseInt(o,10),s.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:i,row:o}of oo(t))this.history.update("mergeCellMap",e,i,o,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 i of t)this.addMerge(e,zi(i))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Hv(e))}}exportForExcel(e){this.export(e)}}function Hv(e){return Object.entries(e).map((([e,t])=>t?$v(parseInt(e,10),t):void 0)).filter(ot).map((e=>Gt(e.left,e.top)+":"+Gt(e.right,e.bottom)))}function $v(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Bv.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class Wv{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",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const s=We(n);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of s){const s=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=s&&s<=n.zone[i]){const e=Math.min(n.zone[i],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e)}else if(n.zone[t]>=s&&n.zone[i]<=l)a="REMOVE",r=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[i]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e),r=this.createAdaptedRange(r,o,"MOVE",-(n.zone[t]-s))}else s<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,o,a,-(l-s+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(n.zone[t]<=e.base&&e.base<n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),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 i=void 0,o=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:o,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!Qi(i.zone,t))return{changeType:"NONE"};const o=e.targetSheetId,n=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(i,"both","MOVE",[n,s]),a=e.sheetId!==o||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:o,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||Bi(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,o){const n=no(e.unboundedZone,t,i,o);return e.clone({zone:n})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,o){const n=e.map((e=>Fi.fromRange(e,this.getters)));return n.map((e=>{if(!Bi(e.zone))return e;const n=e.prefixSheet?e.sheetId:o,s={...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:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return e.clone({sheetId:n,zone:s}).orderZone()}))}getRangeFromSheetXC(e,t){if(!Lt.test(t))return new Fi({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,o=t,n=!1;t.includes("!")&&(({xc:o,sheetName:i}=Bt(t)),i&&(n=!0));const s=Vi(o),r=Fi.getRangeParts(o,s),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e;return new Fi({prefixSheet:n,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize).orderZone()}getSelectionRangeString(e,t){const i=Fi.fromRange(e,this.getters),o=this.getters.expandZone(i.sheetId,i.zone),n=i.clone({zone:{...o,bottom:i.isFullCol?void 0:o.bottom,right:i.isFullRow?void 0:o.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return K;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return K;if(e.zone.left<0||e.zone.top<0)return K;const i=Fi.fromRange(e,this.getters);let o=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,n="";if(o&&(n=i.invalidSheetName?i.invalidSheetName:ke(this.getters.getSheetName(i.sheetId))),o&&!n)return K;let s=this.getRangePartString(i,0);return i.parts&&2===i.parts.length&&(i.zone.top!==i.zone.bottom||i.zone.left!==i.zone.right||i.parts[0].rowFixed||i.parts[0].colFixed||i.parts[1].rowFixed||i.parts[1].colFixed)&&(s+=":",s+=this.getRangePartString(i,1)),`${o?n+"!":""}${s}`}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 Fi(t,this.getters.getSheetSize)}getRangePartString(e,t){const i=e.parts&&e.parts[t].colFixed?"$":"",o=Ht(0===t?e.zone.left:e.zone.right),n=e.parts&&e.parts[t].rowFixed?"$":"",s=String(0===t?e.zone.top+1:e.zone.bottom+1);let r="";return r=e.isFullCol?0===t&&e.unboundedZone.hasHeader?i+o+n+s:i+o:e.isFullRow?0===t&&e.unboundedZone.hasHeader?i+o+n+s:n+s:i+o+n+s,r}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:K}}}Wv.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Gv extends Av{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":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 14}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>t?86:e.quantity<=0?87:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?86:this.checkElementsIncludeAllNonFrozenHeaders(e.sheetId,e.dimension,e.elements)?8:0}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.delta);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,i;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let o of e.sheets){const e=o.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:r}=this.getImportedSheetSize(o),a={id:o.id,name:e,numberOfCols:s,rows:Pi(r),areGridLinesVisible:void 0===o.areGridLinesVisible||o.areGridLinesVisible,isVisible:o.isVisible,panes:{xSplit:(null===(t=o.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(i=o.panes)||void 0===i?void 0:i.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(ot).map((e=>{const t=this.sheets[e],i={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)&&(i.panes=t.panes),i}))}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}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=De(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,i){return"COL"===t?i>=0&&i<this.getNumberCols(e):i>=0&&i<this.getNumberRows(e)}getRow(e,t){const i=this.getSheet(e).rows[t];if(!i)throw new Error(`Row ${i} not found.`);return i}getCell({sheetId:e,col:t,row:i}){var o;const n=this.tryGetSheet(e),s=null===(o=null==n?void 0:n.rows[i])||void 0===o?void 0:o.cells[t];if(void 0!==s)return this.getters.getCellById(s)}getColsZone(e,t,i){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:i}}getRowCells(e,t){var i;return Object.values(null===(i=this.getSheet(e).rows[t])||void 0===i?void 0:i.cells).filter(ot)}getRowsZone(e,t,i){return{top:t,bottom:i,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 i=this.orderedSheetIds.map(this.getSheetName.bind(this));let o=`${e}${t}`;for(;i.includes(o);)o=`${e}${t}`,t++;return o}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols: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,i){const o={...this.getPaneDivisions(e)};"COL"===i?o.xSplit=t:"ROW"===i&&(o.ySplit=t),this.history.update("sheets",e,"panes",o)}checkElementsIncludeAllNonFrozenHeaders(e,t,i){const o=this.getters.getPaneDivisions(e),n="ROW"===t?o.ySplit:o.xSplit,s=this.getters.getNumberHeaders(e,t);if(!n)return!1;return dt(i,$e(n,s))}isEmpty(e,t){return oo(t).map((({col:t,row:i})=>this.getCell({sheetId:e,col:t,row:i}))).every((e=>!e||""===e.content))}updateCellPosition(e){const{sheetId:t,cellId:i,col:o,row:n}=e;i?this.setNewPosition(i,t,o,n):this.clearPosition(t,o,n)}setNewPosition(e,t,i,o){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:o,col:i,sheetId:t}),this.history.update("sheets",t,"rows",o,"cells",i,e)}clearPosition(e,t,i){var o;const n=null===(o=this.sheets[e])||void 0===o?void 0:o.rows[i].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",i,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){this.sheets[e].rows[o].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:o})}}createSheet(e,t,i,o,n){const s={id:e,name:t,numberOfCols:i,rows:Pi(o),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},r=this.orderedSheetIds.slice();r.splice(n,0,s.id);const a=this.sheets;return this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},a,{[s.id]:s})),s}moveSheet(e,t){const i=this.orderedSheetIds.slice(),o=i.findIndex((t=>t===e)),n=i.splice(o,1);let s=this.findIndexOfTargetSheet(o,t);i.splice(s,0,n[0]),this.history.update("orderedSheetIds",i)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(s("There is not enough visible sheets"))}checkSheetName(e){const{orderedSheetIds:t,sheets:i}=this,o=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=i[e])||void 0===t?void 0:t.name.toLowerCase())===o}))?11:re.test(o)?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:74}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:74}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.top<e.quantity&&e.quantity<=i.bottom)return 65;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.left<e.quantity&&e.quantity<=i.right)return 65;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const i=e.name;this.history.update("sheets",e.id,"name",t.trim());const o=Object.assign({},this.sheetIdsMapName);o[t]=e.id,delete o[i],this.history.update("sheetIdsMapName",o)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const i=this.getSheet(e),o=this.getDuplicateSheetName(i.name),n=Fe(i);n.id=t,n.name=o;for(let e=0;e<=n.numberOfCols;e++)for(let t=0;t<=n.rows.length;t++)n.rows[t]&&(n.rows[t].cells[e]=void 0);const s=this.orderedSheetIds.slice(),r=s.indexOf(e);s.splice(r+1,0,n.id),this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},this.sheets,{[n.id]:n}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:i}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:i,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[n.name]=n.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this)),o=s("Copy of %s",e);let n=o.toString();for(;i.includes(n);)n=`${o} (${t})`,t++;return n}deleteSheet(e){const t=e.name,i=Object.assign({},this.sheets);delete i[e.id],this.history.update("sheets",i);const o=this.orderedSheetIds.slice(),n=o.indexOf(e.id);o.splice(n,1),this.history.update("orderedSheetIds",o);const s=Object.assign({},this.sheetIdsMapName);delete s[t],this.history.update("sheetIdsMapName",s)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let i of t)this.moveCellOnColumnsDeletion(e,i);const i=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",i-t.length);const o=t.filter((t=>t<e.panes.xSplit)).length;o&&this.setPaneDivisions(e.id,e.panes.xSplit-o,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let i of We(t))this.moveCellOnRowsDeletion(e,i[i.length-1],i[0]),i.map((t=>this.updateRowsStructureOnDeletion(t,e)));const i=t.filter((t=>t<e.panes.ySplit)).length;i&&this.setPaneDivisions(e.id,e.panes.ySplit-i,"ROW")}addColumns(e,t,i,o){const n="before"===i?t:t+1;this.moveCellsOnAddition(e,n,o,"columns");const s=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",s+o),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+o,"COL")}addRows(e,t,i,o){const n="before"===i?t:t+1;this.addEmptyRows(e,o),this.moveCellsOnAddition(e,n,o,"rows"),this.updateRowsStructureOnAddition(e,t,o),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+o,"ROW")}moveCellOnColumnsDeletion(e,t){for(let i=0;i<e.rows.length;i++){const o=e.rows[i];for(let n in o.cells){const s=Number(n),r=o.cells[n];r&&(s===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:i}),s>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:s-1,row:i}))}}}moveCellsOnAddition(e,t,i,o){const n=[];for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if("rows"!==o||s>=t)for(let a in r.cells){const l=Number(a),c=r.cells[a];c&&("rows"===o||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===o?i:0),row:s+("rows"===o?i:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,i){const o=i-t+1;for(let n=0;n<e.rows.length;n++){const s=e.rows[n];if(n>=t&&n<=i)for(let t in s.cells){const i=Number(t);s.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:i,row:n})}if(n>i)for(let t in s.cells){const i=Number(t),r=s.cells[t];r&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:i,row:n-o})}}}updateRowsStructureOnDeletion(e,t){const i=[],o=t.rows.map((e=>e.cells));for(let n in t.rows)Number(n)!==e&&i.push({cells:o.shift()});this.history.update("sheets",t.id,"rows",i)}updateRowsStructureOnAddition(e,t,i){const o=[],n=e.rows.map((e=>e.cells));e.rows.forEach((()=>o.push({cells:n.shift()}))),this.history.update("sheets",e.id,"rows",o)}addEmptyRows(e,t){const i=e.rows.slice();for(let e=0;e<t;e++)i.push({cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Wt);let i=e.rowNumber,o=e.colNumber;for(let{col:e,row:n}of t)i=Math.max(i,n+1),o=Math.max(o,e+1);return{rowNumber:i,colNumber:o}}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(Bi))return 25;if(t.length&&"sheetId"in e){const i=this.getSheetZone(e.sheetId);return t.every((e=>Qi(e,i)))?0:18}return 0}}Gv.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions","checkElementsIncludeAllNonFrozenHeaders"];class qv extends Tv{constructor({getters:e,stateObserver:t,dispatch:i,uiActions:o,selection:n}){super(t,i),this.getters=e,this.ui=o,this.selection=n}drawGrid(e,t){}}qv.layers=[];class Zv extends qv{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 i=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(i),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:It(255,0,0),colors:[]},{leadColor:It(255,128,0),colors:[]},{leadColor:It(128,128,0),colors:[]},{leadColor:It(128,255,0),colors:[]},{leadColor:It(0,255,0),colors:[]},{leadColor:It(0,255,128),colors:[]},{leadColor:It(0,255,255),colors:[]},{leadColor:It(0,127,255),colors:[]},{leadColor:It(0,0,255),colors:[]},{leadColor:It(127,0,255),colors:[]},{leadColor:It(128,0,128),colors:[]},{leadColor:It(255,0,128),colors:[]}];for(const i of e.map(At)){let e=500,o=0;t.forEach(((t,n)=>{const s=(r=i,a=t.leadColor,Math.sqrt(Math.pow(r.r-a.r,2)+Math.pow(r.g-a.g,2)+Math.pow(r.b-a.b,2)));var r,a;e>s&&(e=s,o=n)})),t[o].colors.push(i)}return t.map((e=>e.colors.sort(((e,t)=>Ot(e).s-Ot(t).s)))).flat().map(Tt)}([...new Set([...new Set([...e,...this.customColors])].filter(yt).map(wt))]).filter((e=>!O.includes(e)))}getColorsFromCells(e){var t,i;const o=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&o.add(n.style.textColor),(null===(i=n.style)||void 0===i?void 0:i.fillColor)&&o.add(n.style.fillColor);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),i=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(i.push(t.style.textColor),i.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(i.push(Et(t.minimum.color)),i.push(t.midpoint?Et(t.midpoint.color):void 0),i.push(Et(t.maximum.color)))}return i.filter(ot)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let i=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&i.add(t),e.type){case"gauge":const t=e.sectionRule.colors;i.add(t.lowerColor),i.add(t.middleColor),i.add(t.upperColor);break;case"scorecard":const o=e;i.add(o.baselineColorDown),i.add(o.baselineColorUp)}}return[...i]}tryToAddColor(e){const t=wt(e);e&&!O.includes(t)&&this.customColors.add(t)}}Zv.getters=["getCustomColors"];const jv=Xu.mapping;class Xv extends qv{constructor(e){super(e),this.isUpToDate=!1,this.evaluatedCells={},this.evalContext=e.custom,this.lazyEvaluation=e.lazyEvaluation}handle(e){switch(ln.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(),this.isUpToDate=!0)}evaluateFormula(e,t=this.getters.getActiveSheetId()){const i=hf(e),o=this.getCompilationParameters((e=>this.getEvaluatedCell(this.getters.getCellPosition(e.id)))),n=[];for(let e of i.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return i.execute(n,...o).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell({sheetId:e,col:t,row:i}){var o,n,s;return void 0===this.getters.getCell({sheetId:e,col:t,row:i})?Sn(""):(null===(s=null===(n=null===(o=this.evaluatedCells[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.call(n))||Sn("")}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},i={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);i[e]=this.getEvaluatedCell(t)}return i}getColEvaluatedCells(e,t){var i;return Object.values((null===(i=this.evaluatedCells[e])||void 0===i?void 0:i[t])||[]).filter(ot).map((e=>e()))}getEvaluatedCellsInZone(e,t){return oo(t).map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i})))}setEvaluatedCell(e,t){const{col:i,row:o,sheetId:n}=this.getters.getCellPosition(e);this.evaluatedCells[n]||(this.evaluatedCells[n]={}),this.evaluatedCells[n][i]||(this.evaluatedCells[n][i]={}),this.evaluatedCells[n][i][o]=t,this.lazyEvaluation||this.evaluatedCells[n][i][o]()}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){this.evaluatedCells={};const e=new Set,t=e=>{var t,n;const s=e.id,{col:r,row:a,sheetId:l}=this.getters.getCellPosition(s),c=null===(n=null===(t=this.evaluatedCells[l])||void 0===t?void 0:t[r])||void 0===n?void 0:n[a];return c||at((()=>{try{switch(e.isFormula){case!0:return o(e);case!1:return vn(e.content,e.format)}}catch(t){return i(t,e)}}))},i=(e,t)=>{e instanceof Error||(e=new Error(e));const i=(null==e?void 0:e.errorType)||a.GenericError,o=n[2].__lastFnCalled||"",s=new c(i,e.message.replace("[[FUNCTION_NAME]]",o),void 0!==e.logLevel?e.logLevel:l.error);return yn(t.content,s)},o=t=>{const i=t.id;if(e.has(i))throw new d;n[2].__originCellXC=()=>{const e=n[2].getters.getCellPosition(i);return Gt(e.col,e.row)},e.add(i);const o=t.compiledFormula.execute(t.dependencies,...n);if(e.delete(i),Array.isArray(o.value))throw new Error(s("This formula depends on invalid values"));return Sn(o.value,t.format||o.format)},n=this.getCompilationParameters((e=>t(e)()));for(const e of this.getAllCells())this.setEvaluatedCell(e.id,t(e))}getCompilationParameters(e){const t=Object.assign(Object.create(jv),this.evalContext,{getters:this.getters}),i=this.getters;const o=t=>{const i=e(t);if(i.type===rn.error)throw i.error;return i};return[function(e,t,n,r){if(t)return{value:Hi(e.zone)};if(!Bi(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(r?s("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",n.toString(),r.toString()):s("Function %s expects its parameters to be single values or single cell references, not ranges.",n.toString()));if(e.invalidSheetName)throw new Error(s("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!i.tryGetSheet(e.sheetId))throw new Error(s("Invalid sheet name"));return t=i.getCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}),t&&""!==t.content?o(t):{value:null,format:null==t?void 0:t.format}}(e)},function(e){const n=e.sheetId;if(!Bi(e.zone))throw new u;const s=i.getSheetZone(n),r=[],a=ji(e.zone,s);if(!a)return r.push([]),r;for(let i=a.left;i<=a.right;i++){const n=[];for(let s=a.top;s<=a.bottom;s++){const r=t.getters.getCell({sheetId:e.sheetId,col:i,row:s});n.push(r?o(r):void 0)}r.push(n)}return r},t]}exportForExcel(e){for(let t of e.sheets)for(const e in t.cells){const i={sheetId:t.id,...Wt(e)},o=this.getters.getCell(i);if(o){const n=t.cells[e],s=this.getEvaluatedCell(i);n.value=s.value,n.isFormula=o.isFormula&&!this.isBadExpression(o.content),o.format!==s.format&&(n.computedFormat=s.format)}}}isBadExpression(e){try{return hf(e),!1}catch(e){return!0}}}Xv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getColEvaluatedCells","getEvaluatedCellsInZone"];class Yv extends qv{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=lr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i){const o=t.find((e=>e.match(i.type)));if(!o)throw new Error("No runtime builder for this chart.");return o.getChartRuntime(i,e)}}(this.getters)}handle(e){if(ln.has(e.type)||cn.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 i=t.zone.left,o=t.zone.top,n=t.sheetId;return this.getters.getCellComputedStyle({sheetId:n,col:i,row:o}).fillColor||w}}Yv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class Kv extends qv{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new Ui,this.rulePredicate={CellIsRule:(e,t)=>{if(e.type===rn.error)return!1;const i=t.values.map(bn);switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==i[0]&&e.value.toString().startsWith(i[0].toString());case"EndsWith":return""!==i[0]&&e.value.toString().endsWith(i[0].toString());case"Between":return e.value>=i[0]&&e.value<=i[1];case"NotBetween":return!(e.value>=i[0]&&e.value<=i[1]);case"ContainsText":return e.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(i[0].toString());case"GreaterThan":return e.value>i[0];case"GreaterThanOrEqual":return e.value>=i[0];case"LessThan":return e.value<i[0];case"LessThanOrEqual":return e.value<=i[0];case"NotEqual":return""!==i[0]&&e.value!==i[0];case"Equal":return""===i[0]||e.value===i[0];default:console.warn(s("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((cn.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 i=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(i,e.originCol,e.originRow);for(const t of o)this.adaptRules(i,t,[Gt(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){var t;const{sheetId:i,col:o,row:n}=e,s=this.getters.getCell(e),r=this.computedStyles[i],a=r&&(null===(t=r[o])||void 0===t?void 0:t[n]),l={...null==s?void 0:s.style,...a};return this.getters.getEvaluatedCell(e).link&&!l.textColor&&(l.textColor=I),this.getters.isFilterHeader(e)&&(l.bold=!0),l}getConditionalIcon({col:e,row:t}){var i;const o=this.getters.getActiveSheetId(),n=this.computedIcons[o];return n&&(null===(i=n[e])||void 0===i?void 0:i[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const i=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let n of o.ranges){const s=this.getters.getRangeFromSheetXC(t,n).zone;for(let n=s.top;n<=s.bottom;n++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let a=this.getters.getEvaluatedCell({sheetId:t,col:r,row:n});s&&s(a,o.rule)&&(i[r]||(i[r]=[]),i[r][n]=Object.assign((null===(e=i[r])||void 0===e?void 0:e[n])||{},o.rule.style))}}}}catch(e){}}parsePoint(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCellsInZone(o,this.getters.getRangeFromSheetXC(o,e).zone).filter((e=>e.type===rn.number)).map((e=>e.value));switch(t.type){case"value":return"max"===i?Math.max(...n):Math.min(...n);case"number":return Number(t.value);case"percentage":const e=Math.min(...n);return e+(Math.max(...n)-e)*Number(t.value)/100;case"percentile":return si(n,Number(t.value)/100,!0);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return o instanceof Promise?null:o;default:return null}}applyIcon(e,t){const i=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===i||null===o||i>o)return;const n=this.getters.getActiveSheetId(),s=this.getters.getRangeFromSheetXC(n,e).zone,r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=s.top;e<=s.bottom;e++)for(let l=s.left;l<=s.right;l++){const s=this.getters.getEvaluatedCell({sheetId:n,col:l,row:e});if(s.type!==rn.number)continue;const c=this.computeIcon(s.value,o,t.upperInflectionPoint.operator,i,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,i,o,n,s){return"ge"===i&&e>=t||"gt"===i&&e>t?s[0]:"ge"===n&&e>=o||"gt"===n&&e>o?s[1]:s[2]}applyColorScale(e,t){var i;const o=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,s=this.parsePoint(e,t.maximum,"max");if(null===o||null===s||o>=s||n&&(o>=n||n>=s))return;const r=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(r,e).zone,l=this.computedStyles[r],c=[];t.midpoint&&n?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.midpoint.color)}),c.push({minValue:n,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(n,s,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,s,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.getEvaluatedCell({sheetId:r,col:t,row:e});if(a.type===rn.number){const r=Le(a.value,o,s);let h;h=2===c.length&&n?r<=n?this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(r,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(i=l[t])||void 0===i?void 0:i[e])||{},l[t][e].fillColor=Et(h)}}}computeColorDiffUnits(e,t,i,o){const n=t-e;return[((i>>16)%256-(o>>16)%256)/n,((i>>8)%256-(o>>8)%256)/n,(i%256-o%256)/n]}colorCell(e,t,i,o){const[n,s,r]=o;return Math.round((i>>16)%256-n*(e-t))<<16|Math.round((i>>8)%256-s*(e-t))<<8|Math.round(i%256-r*(e-t))}adaptRules(e,t,i,o){if(0===i.length&&0===o.length)return;const n=this.getters.getConditionalFormats(e),s=n.findIndex((e=>e.id===t.id));let r=[];s>-1&&(r=n[s].ranges),r=r.concat(i);const a=Ji(r,o);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,i){const o=Gt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let s of n.ranges)if(Ki(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=n,r=[];if("CUT"===i&&r.push(Gt(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,s,[o],r);else{this.adaptRules(e.sheetId,s,[],r);const i=this.getCFToCopyTo(t.sheetId,s);this.adaptRules(t.sheetId,i,[o],[])}}}getCFToCopyTo(e,t){const i=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&ht(e.rule,t.rule)));return i||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}Kv.getters=["getConditionalIcon","getCellComputedStyle"];class Qv extends qv{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 79;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":case"UNHIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const i of this.getters.getFilters(e.sheetIdTo)){const o=i.zoneWithHeaders;t[i.id]=this.getFilterValues({sheetId:e.sheetId,col:o.left,row:o.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){const{sheetId:t,col:i,row:o}=e;let n;for(let e of this.getters.getFilterTables(t)){const s=e.zone;if(Ki(i,o,s)){const e=this.intersectZoneWithViewport(t,s);n={top:o===e.top?X:void 0,bottom:o===e.bottom?X:void 0,left:i===e.left?X:void 0,right:i===e.right?X:void 0}}}const s=this.getters.getCellBorder(e),r={...n,...ut(s||{})};return nt(r)?null:r}getFilterHeaders(e){const t=[];for(let i of this.getters.getFilterTables(e)){const o=i.zone;if(!o)continue;const n=o.top;for(let i=o.left;i<=o.right;i++)this.getters.isColHidden(e,i)||this.getters.isRowHidden(e,n)||t.push({col:i,row:n})}return t}getFilterValues(e){const t=this.getters.getFilterId(e),i=e.sheetId;return t&&this.filterValues[i]&&this.filterValues[i][t]||[]}isFilterHeader({sheetId:e,col:t,row:i}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===i))}isFilterActive(e){var t,i;const o=this.getters.getFilterId(e),n=e.sheetId;return Boolean(o&&(null===(i=null===(t=this.filterValues[n])||void 0===t?void 0:t[o])||void 0===i?void 0:i.length))}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:i,sheetId:o}){const n=this.getters.getFilterId({sheetId:o,col:e,row:t});n&&(this.filterValues[o]||(this.filterValues[o]={}),this.filterValues[o][n]=i)}updateHiddenRows(){var e,t;const i=this.getters.getActiveSheetId(),o=this.getters.getFilters(i).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let s of o){if(this.getters.isRowHiddenByUser(i,s.zoneWithHeaders.top))continue;if(n.has(s.zoneWithHeaders.top))continue;const o=null===(t=null===(e=this.filterValues[i])||void 0===e?void 0:e[s.id])||void 0===t?void 0:t.map(gt);if(o&&s.filteredZone)for(let e=s.filteredZone.top;e<=s.filteredZone.bottom;e++){const t=this.getCellValueAsString(i,s.col,e);o.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,i){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const i of t.filterTables){const o=zi(i.range),n=[],s=[];for(const i of $e(0,to(o).numberOfCols)){const r={sheetId:t.id,col:o.left+i,row:o.top},a=this.getFilterValues(r),l=this.getters.getFilter(r);if(!l)continue;const c=l.filteredZone?oo(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));n.push({colId:i,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(i,d,s);s.push(u),t.cells[Gt(h.col,h.row)]={...t.cells[Gt(h.col,h.row)],content:u,value:u,isFormula:!1}}i.filters=n}}}getUniqueColNameForExcel(e,t,i){t||(t=`Column${e}`);let o=t,n=2;for(;i.includes(o);)o=t+String(n),n++;return o}}Qv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];class Jv{constructor(e,t,i,o,n,s){this.getters=e,this.sheetId=t,this.boundaries=i,this.viewportWidth=o.width,this.viewportHeight=o.height,this.offsetScrollbarX=s.x,this.offsetScrollbarY=s.y,this.canScrollVertically=n.canScrollVertically,this.canScrollHorizontally=n.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:i,size:o}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:s}=this.getters.getRowDimensions(this.sheetId,t),r=this.searchHeaderIndex("COL",i-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,r),l=this.searchHeaderIndex("ROW",n-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=i-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(F,Math.min(a,this.viewportWidth-o)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(D+5,Math.min(c,this.viewportHeight-s)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const i=this.getters.getMainCellPosition({sheetId:t,...e}),{col:o,row:n}=this.getters.getNextVisibleCellPosition(i);Ki(o,this.boundaries.top,this.boundaries)&&this.adjustPositionX(o),Ki(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{end:i}=this.getters.getColDimensions(t,e),o=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<i){let i=e;for(;this.getters.isColHidden(t,i)&&e<o;)i++;const n=this.getters.getColDimensions(t,i).end,s=this.searchHeaderIndex("COL",n-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left,!0);this.offsetX=this.getters.getColDimensions(t,s).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let i=e;for(;this.getters.isColHidden(t,i)&&e>0;)i--;this.offsetX=this.getters.getColDimensions(t,i).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId,{end:i}=this.getters.getRowDimensions(t,e),o=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<i){let i=e;for(;this.getters.isRowHidden(t,i)&&e<o;)i++;const n=this.getters.getRowDimensions(t,i).end,s=this.searchHeaderIndex("ROW",n-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top,!0);this.offsetY=this.getters.getRowDimensions(t,s).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let i=e;for(;this.getters.isRowHidden(t,i)&&e>0;)i--;this.offsetY=this.getters.getRowDimensions(t,i).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=ji(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.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}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,i=0,o=!1){let n=0;const s=this.sheetId,r=this.getters.getNumberHeaders(s,e);for(let a=i;a<=r-1;a++){const i=o||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(s,e,a)&&!i&&(n+="COL"===e?this.getters.getColSize(s,a):this.getters.getRowSize(s,a),n>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.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!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.viewportWidth,this.left)),-1===this.left&&(this.left=this.boundaries.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.viewportHeight,this.top)),-1===this.top&&(this.top=this.boundaries.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 eb extends qv{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"AlterZone":break;case"ZonesSelected":let{col:t,row:i}=so(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const o=e.previousAnchor.zone,n=e.anchor.zone,{top:s,bottom:r,left:a,right:l}=this.getters.getActiveMainViewport();o.left===n.left&&o.right===n.right&&(t=a>t||t>l?a:t),o.top===n.top&&o.bottom===n.bottom&&(i=s>i||i>r?s:i)}const o=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(o)-1),i=Math.min(i,this.getters.getNumberRows(o)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:i})}}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:i}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(o,i).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(i);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"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}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 i of t)(null===(e=this.viewports[i])||void 0===e?void 0:e.bottomRight)||this.resetViewports(i)}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=>$e(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=>$e(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:i,ySplit:o}=this.getters.getPaneDivisions(e);let{width:n,height:s}=t.getMaxSize();return{x:this.getters.getColDimensions(e,i).start,y:this.getters.getRowDimensions(e,o).start,width:n,height:s}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:i}=this.getMainViewportRect(),o=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-o.viewportWidth+1),maxOffsetY:Math.max(0,i-o.viewportHeight+1)}}getColRowOffsetInViewport(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),s=this.getters.getSheetViewVisibleRows();if(i<t)return-this.getColRowOffsetInViewport(e,i,t);let r=0;const a="COL"===e?n:s;for(let n=t;n<i;n++)a.includes(n)&&(r+="COL"===e?this.getters.getColSize(o,n):this.getters.getRowSize(o,n));return r}isVisibleInViewport({sheetId:e,col:t,row:i}){return this.getSubViewports(e).some((e=>e.isVisible(t,i)))}getEdgeScrollCol(e,t,i){let o=!1,n=0,s=0;const{xSplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(o=!0,s=Xt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=Xt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=Xt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getEdgeScrollRow(e,t,i){let o=!1,n=0,s=0;const{ySplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(o=!0,s=Xt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=Xt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=Xt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),i=this.getSubViewports(t).map((t=>t.getRect(e))).filter(ot);if(0===i.length)return{x:0,y:0,width:0,height:0};const o=Math.min(...i.map((e=>e.x))),n=Math.min(...i.map((e=>e.y))),s=Math.max(...i.map((e=>e.x+e.width)))-o,r=Math.max(...i.map((e=>e.y+e.height)))-n;return{x:o+this.gridOffsetX,y:n+this.gridOffsetY,width:s,height:r}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,i).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(ot)}checkPositiveDimension(e){return e.width<0||e.height<0?68:0}checkValuesAreDifferent(e){const{height:t,width:i}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===i&&e.height===t?76:0}checkScrollingDirection({offsetX:e,offsetY:t}){const i=this.getMainInternalViewport(this.getters.getActiveSheetId());return!i.canScrollHorizontally&&e>0||!i.canScrollVertically&&t>0?69: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 i=this.getSubViewports(e);Object.values(i).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,i=0,o=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=i,this.gridOffsetY=o,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const i=this.getters.getActiveSheetId(),{maxOffsetX:o,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(i)).forEach((i=>i.setViewportOffset(Le(e,0,o),Le(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),i=t-this.sheetViewHeight;return e=Math.min(e,i),e=Math.max(e,0)}getViewportOffset(e){var t,i;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(i=this.viewports[e])||void 0===i?void 0:i.bottomRight.offsetScrollbarY)||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),s=this.getters.getColRowOffset("COL",0,t,e),r=this.getters.getColRowOffset("ROW",0,i,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:i&&t&&new Jv(this.getters,e,{left:0,right:t-1,top:0,bottom:i-1},{width:s,height:r},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:i&&new Jv(this.getters,e,{left:t,right:o-1,top:0,bottom:i-1},{width:this.sheetViewWidth-s,height:r},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Jv(this.getters,e,{left:0,right:t-1,top:i,bottom:n-1},{width:s,height:this.sheetViewHeight-r},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Jv(this.getters,e,{left:t,right:o-1,top:i,bottom:n-1},{width:this.sheetViewWidth-s,height:this.sheetViewHeight-r},{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:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:o}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(o.cell.col,o.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],i=this.getters.getFigures(e),{scrollX:o,scrollY:n}=this.getActiveSheetScrollInfo(),{x:s,y:r}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of i)e.x>=s&&(e.x+e.width<=s+o||e.x>=a+o+s)||e.y>=r&&(e.y+e.height<=r+n||e.y>=l+n+r)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,i).start;return{xRatio:o/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}eb.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class tb{constructor(e,t,i){this.index=0,this.cells=e,this.getters=t,this.direction=i}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:i,tooltip:o}=In.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:i,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class ib extends qv{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:Le(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:Le(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:45;case"AUTOFILL_AUTO":const i=this.getters.getSelectedZone();return i.top===i.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(),i=this.autofillZone;switch(this.direction){case"down":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(Gt(o,e));const s=this.createGenerator(n);for(let t=i.top;t<=i.bottom;t++)this.computeNewCell(s,o,t,e)}break;case"up":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(Gt(o,e));const s=this.createGenerator(n);for(let t=i.bottom;t>=i.top;t--)this.computeNewCell(s,o,t,e)}break;case"left":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(Gt(e,o));const s=this.createGenerator(n);for(let t=i.right;t>=i.left;t--)this.computeNewCell(s,t,o,e)}break;case"right":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(Gt(e,o));const s=this.createGenerator(n);for(let t=i.left;t<=i.right;t++)this.computeNewCell(s,t,o,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 i=this.getters.getSelectedZone();if(Ki(e,t,i))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,i.top-1,i.left,i.right),this.steps=i.top-t;break;case"down":this.saveZone(i.bottom+1,t,i.left,i.right),this.steps=t-i.bottom;break;case"left":this.saveZone(i.top,i.bottom,e,i.left-1),this.steps=i.left-e;break;case"right":this.saveZone(i.top,i.bottom,i.right+1,e),this.steps=e-i.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let i=e.left,o=e.bottom;if(i>0){let e=this.getters.getEvaluatedCell({sheetId:t,col:i-1,row:o});for(;e.type!==rn.empty;)o+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:i-1,row:o})}if(o===e.bottom&&(i=e.right,i<=this.getters.getNumberCols(t))){let e=this.getters.getEvaluatedCell({sheetId:t,col:i+1,row:o});for(;e.type!==rn.empty;)o+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:i+1,row:o})}o!==e.bottom&&(this.select(e.left,o-1),this.autofill(!0))}computeNewCell(e,t,i,o){const{cellData:n,tooltip:s,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=s,o&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:i,content:a,style:l,border:c,format:h})}getRule(e,t){const i=Rn.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((i=>i.condition(e,t)));return i&&i.generateRule(e,t)}createGenerator(e){const t=[],i=[],o=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=Wt(t),s=this.getters.getCell({sheetId:o,col:e,row:n});i.push({col:e,row:n,cell:s,sheetId:o})}const n=i.map((e=>e.cell));for(let e of i){let i={type:"COPY_MODIFIER"};if(e&&e.cell){i=this.getRule(e.cell,n)||i}const o=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:o},rule:i})}return new tb(t,this.getters,this.direction)}saveZone(e,t,i,o){this.autofillZone={top:e,bottom:t,left:i,right:o}}getDirection(e,t){const i=this.getters.getSelectedZone(),o={up:{number:i.top-t,value:"up"},down:{number:t-i.bottom,value:"down"},left:{number:i.left-e,value:"left"},right:{number:e-i.right,value:"right"}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const n=o.up.number>0?"up":"down",s=o.left.number>0?"left":"right";return Math.abs(o[n].number)>=Math.abs(o[s].number)?o[n].value:o[s].value}autoFillMerge(e,t,i,o){const n=this.getters.getActiveSheetId(),s={sheetId:n,col:i,row:o},r={sheetId:n,col:e,row:t};if(this.getters.isInMerge(s)&&!this.getters.isInMerge(r)){const e=this.getters.getMerge(s);e&&this.dispatch("REMOVE_MERGE",{sheetId:n,target:[e]})}const a=this.getters.getMerge(r);(null==a?void 0:a.topLeft.col)===e&&(null==a?void 0:a.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:n,target:[{top:o,bottom:o+a.bottom-a.top,left:i,right:i+a.right-a.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:i}=e,{x:o,y:n,width:s,height:r}=this.getters.getVisibleRect(this.autofillZone);s>0&&r>0&&(t.strokeStyle="black",t.lineWidth=i,t.setLineDash([3]),t.strokeRect(o,n,s,r),t.setLineDash([]))}}ib.layers=[5],ib.getters=["getAutofillTooltip"];class ob extends qv{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:i}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,i.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,i){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,i):this.sumData(e,t)}sumData(e,t){const i=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,i).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return i.has("ROW")&&i.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,i){const{col:o,row:n}=Ki(i.col,i.row,t)?i:{col:t.left,row:t.top},s=this.findAdjacentData(e,o,n);return s?this.getters.isSingleCellOrMerge(e,t)||io(Zi(s,t))?[{position:{col:o,row:n},zone:s}]:this.sumDimensions(e,Zi(s,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,i){const o=this.getters.getSheet(e),n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.findSuitableZoneToSum(o,n.col,n.row);if(s)return this.getters.expandZone(e,s)}findSuitableZoneToSum(e,t,i){const o=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:i-1}),n=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:i});if(this.isNumber(n)&&!this.isNumber(o))return this.findHorizontalZone(e,t,i);const s=this.findVerticalZone(e,t,i);if(this.isZoneValid(s))return s;const r=this.findHorizontalZone(e,t,i);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,i){const o={top:0,bottom:i-1,left:t,right:t},n=this.reduceZoneStart(e,o,o.bottom);return{...o,top:n}}findHorizontalZone(e,t,i){const o={top:i,bottom:i,left:0,right:t-1},n=this.reduceZoneStart(e,o,o.right);return{...o,left:n}}reduceZoneStart(e,t,i){const o=this.getters.getEvaluatedCellsInZone(e.id,t),n=$e(i,-1,-1),s=n.filter((e=>o[e]&&!o[e].isAutoSummable)),r=Math.max(...s),a=We(n.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return e.type===rn.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y))}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 i=new Set;return io(t)?(i.add(1===to(t).numberOfCols?"COL":"ROW"),i):(this.lastColIsEmpty(e,t)&&i.add("ROW"),this.lastRowIsEmpty(e,t)&&i.add("COL"),0===i.size&&i.add("COL"),i)}sumDimensions(e,t,i){return[...i.has("COL")?this.sumColumns(t,e):[],...i.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:i}=e;return{position:{col:i,row:t},zone:{...e,top:t,right:i-1}}}sumColumns(e,t){const i=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,i.bottom-1)},oo(i).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const i=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,i.right-1)},oo(i).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const i of t){const{col:t,row:o}=i.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,i.zone)})`})}}nextEmptyRow(e,t){let i=t.bottom+1;const{left:o,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:i,top:i,left:o,right:n});)i++;return{...t,top:i,bottom:i}}nextEmptyCol(e,t){let i=t.right+1;const{top:o,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:i,right:i,top:o,bottom:n});)i++;return{...t,left:i,right:i}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}ob.getters=["getAutomaticSums"];class nb extends qv{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{rs.get(e.popoverType)}catch(e){return 72}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,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){var i,o;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=null===(o=(i=rs.get(this.persistentPopover.type)).onOpen)||void 0===o?void 0:o.call(i,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:n,col:e,row:t}))return{isOpen:!1};const s=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}),r=rs.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,s,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==r?void 0:r.isOpen)?{...r,anchorRect:this.computePopoverAnchorRect(s)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const i=this.getters.getActiveSheetId(),o=this.getters.getMerge({sheetId:i,col:e,row:t});return o?this.getters.getVisibleRect(o):this.getters.getVisibleRect(ao({col:e,row:t}))}}nb.getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];var sb;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(sb||(sb={}));class rb extends qv{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch="",this.isSearchDirty=!1}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(sb.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(sb.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"UNDO":case"REDO":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":this.isSearchDirty=!0;break;case"ACTIVATE_SHEET":this.refreshSearch()}}finalize(){this.isSearchDirty&&(this.refreshSearch(),this.isSearchDirty=!1)}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(sb.current)}updateRegex(){let e=_e(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),i=[];if(this.toSearch)for(const o of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(o.id),s=this.getters.isColHidden(e,t),r=this.getters.isRowHidden(e,n);if(!s&&!r&&(o&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:n})))){const e={col:t,row:n,selected:!1};i.push(e)}}return i.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 i;i=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,i=(i%t.length+t.length)%t.length,this.selectedMatchIndex=i,this.selection.selectCell(t[i].col,t[i].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}}replaceMatch(e,t){if(!this.currentSearchRegex)return;const i=this.getters.getActiveSheetId(),o=this.getters.getCell({sheetId:i,...e}),{col:n,row:s}=e;if((null==o?void 0:o.isFormula)&&!this.searchOptions.searchFormulas)return;const r=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),a=this.getSearchableString({sheetId:i,col:n,row:s}).replace(r,t);this.dispatch("UPDATE_CELL",{sheetId:i,col:n,row:s,content:a})}replace(e){if(null===this.selectedMatchIndex)return;const t=this.searchMatches[this.selectedMatchIndex];this.replaceMatch(t,e),this.selectNextCell(sb.next)}replaceAll(e){const t=this.searchMatches.length;for(let i=0;i<t;i++)this.replaceMatch(this.searchMatches[i],e)}getSearchableString(e){const t=this.getters.getCell(e);return this.searchOptions.searchFormulas&&(null==t?void 0:t.isFormula)?t.content:this.getters.getEvaluatedCell(e).formattedValue}drawGrid(e){const{ctx:t}=e,i=this.getters.getActiveSheetId();for(const e of this.searchMatches){const o=this.getters.getMerge({sheetId:i,col:e.col,row:e.row}),n=o?o.left:e.col,s=o?o.right:e.col,r=o?o.top:e.row,a=o?o.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:r,left:n,right:s,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)))}}}rb.layers=[3],rb.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class ab extends qv{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,i){return"COL"===t?this.isColHidden(e,i):this.isRowHidden(e,i)}getNextVisibleCellPosition({sheetId:e,col:t,row:i}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",i,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,i,o){if(i<=o)for(let n=i;n<=o;n++)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n;if(i>o)for(let n=i;n>=o;n--)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n}findLastVisibleColRowIndex(e,t,{last:i,first:o}){return $e(i,o,-1).find((i=>!this.isHeaderHidden(e,t,i)))||o}findFirstVisibleColRowIndex(e,t){const i=this.getters.getNumberHeaders(e,t);for(let o=0;o<i;o++){if("COL"===t&&!this.isColHidden(e,o))return o;if("ROW"===t&&!this.isRowHidden(e,o))return o}}exportForExcel(e){for(const t of e.sheets)for(const[e,i]of Object.entries(t.rows)){const o=this.isRowHidden(t.id,Number(e));i.isHidden=o}}}ab.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class lb extends qv{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{numberOfRows:t,numberOfCols:i}=to(e.zone),o=t*i==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:o}}))}drawGrid(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;const s=this.getHighlights();for(let e of s.filter(((e,t)=>s.findIndex((t=>Xi(t.zone,e.zone)&&t.sheetId===o))===t))){const{x:i,y:o,width:s,height:r}=this.getters.getVisibleRect(e.zone);s>0&&r>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,s-n,r-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,s-2*n,r-2*n))}}}lb.layers=[1],lb.getters=["getHighlights"];class cb extends qv{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleCols()),o=this.getters.getColRowOffsetInViewport("COL",i,t),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleRows()),o=this.getters.getColRowOffsetInViewport("ROW",i,t),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,i){let o=this.getters.getColRowOffsetInViewport(e,t,i);return this.getters.isDashboard()||(o+="ROW"===e?N:_),o}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(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:i}=e,{width:o,height:n}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,o+m,n+m);const s=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),r=s?.1*i:0;if(s)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=i,t.strokeRect(e.x+r,e.y+r,e.width-2*r,e.height-2*r)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let i=e.style;i.fillColor&&"#ffffff"!==i.fillColor&&(t.fillStyle=i.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),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())}}drawOverflowingCellBackground(e){var t,i;const{ctx:o,thinLineWidth:n}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const s=e.content.align||"left";let r,a;const l=e.y+n/2,c=e.height-n,h=Math.min((null===(t=e.clipRect)||void 0===t?void 0:t.width)||1/0,e.content.width);"left"===s?(r=e.x+n/2,a=h-2*n):"right"===s?(r=e.x+e.width-n/2,a=2*n-h):(r=((null===(i=e.clipRect)||void 0===i?void 0:i.x)||e.x+e.width/2-e.content.width/2)+n/2,a=h-2*n),o.fillStyle="#ffffff",o.fillRect(r,l,a,c)}}drawBorders(e){const{ctx:t,thinLineWidth:i}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:n,width:s,height:r}=e;t.left&&o(t.left,i,n,i,n+r),t.top&&o(t.top,i,n,i+s,n),t.right&&o(t.right,i+s,n,i+s,n+r),t.bottom&&o(t.bottom,i,n+r,i+s,n+r)}}function o([e,o],n,s,r,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*i,t.beginPath(),t.moveTo(n,s),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:i}=e;let o;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},s=e.content.align||"left",r=Be(n);r!==o&&(o=r,t.font=r),t.fillStyle=n.textColor||"#000";let a=e.x;if(a+="left"===s?V+(e.image?e.image.size+U:0):"right"===s?e.width-V-(e.isFilterHeader?20:0):e.width/2,t.textAlign=s,e.clipRect){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.clipRect;t.rect(i,o,n,s),t.clip()}const l=He(n),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let o of e.content.textLines){if(t.fillText(o,Math.round(a),Math.round(h)),n.strikethrough||n.underline){const e=Ue(t,o,n);let r=a;"right"===s?r-=e:"center"===s&&(r-=e/2),n.strikethrough&&t.fillRect(r,h+l/2,e,2.6*i),n.underline&&t.fillRect(r,h+l+1,e,1.3*i)}h+=V+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const i=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.image.clipIcon;t.rect(i,o,n,s),t.clip()}const o=e.image.size,n=this.computeTextYCoordinate(e,o);t.drawImage(i,e.x+U,n,o,o),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,i=1){const o=e.y+1,n=Pe(t,i),s=e.height>n+2*V,r=e.verticalAlign||"middle";if(s){if("middle"===r)return o+(e.height-n)/2;if("bottom"===r)return o+e.height-n-V}return o+V}drawHeaders(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getSheetViewVisibleCols(),n=o[0],s=o[o.length-1],r=this.getters.getSheetViewVisibleRows(),a=r[0],l=r[r.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let i of e)for(let e of $e(i.left,i.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let i of e)for(let e of $e(i.top,i.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${Z}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333";for(let e=n;e<=s;e++){const i={left:e,right:e,top:0,bottom:f-1},{x:o,width:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=E.has(e),a=u.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(o,0,n,N)}for(let e=a;e<=l;e++){const i={top:e,bottom:e,left:0,right:m-1},{y:o,height:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=w.has(e),a=g.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(0,o,_,n)}t.beginPath(),t.moveTo(_,0),t.lineTo(_,h),t.moveTo(0,N),t.lineTo(c,N),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of o){const i=this.getters.getColSize(p,e),o=Ht(e);t.fillStyle=E.has(e)?"#fff":C;let s=this.getHeaderOffset("COL",n,e);t.fillText(o,s+i/2,13),t.moveTo(s+i,0),t.lineTo(s+i,N)}for(const e of r){const i=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let o=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,o+i/2),t.moveTo(0,o+i),t.lineTo(_,o+i)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.isDashboard()?0:_,r=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#BCBCBC",t.beginPath(),o&&(t.moveTo(s+o,0),t.lineTo(s+o,r)),n&&(t.moveTo(0,r+n),t.lineTo(s,r+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.getSheetViewVisibleCols(),r=s[0],a=s[s.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:r,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:_,u=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#DADFE8",t.beginPath(),o&&(t.moveTo(d+o,u),t.lineTo(d+o,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}findNextEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n<t;){const e={sheetId:o,col:n+1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==rn.empty||this.getters.isInMerge(e)||(null==s?void 0:s.left))return n;n++}return n}findPreviousEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n>t;){const e={sheetId:o,col:n-1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==rn.empty||this.getters.isInMerge(e)||(null==s?void 0:s.right))return n;n--}return n}computeCellAlignment(e,t){const i=this.getters.getCell(e);if((null==i?void 0:i.isFormula)&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),n=this.getters.getEvaluatedCell(e);return t&&n.type===rn.number?"center"!==o?"left":o:o||n.defaultAlign}createZoneBox(e,t,i){const{left:o,right:n}=i,s=t.left,r=t.top,a={sheetId:e,col:s,row:r},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===rn.empty)return f;const v=this.getters.getConditionalIcon(a),b=He(f.style),S=v?U+b:0;v&&(f.image={type:"icon",size:b,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:wg[v].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",y="wrap"!==w||h?void 0:g-2*V,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+V))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===rn.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||b>p;if(v||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,i;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,i=s):(e=this.findNextEmptyCol(s,n,r),i=this.findPreviousEmptyCol(s,o,r),f.isOverflow=!0),T){case"left":{const i=ao({col:e,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(Zi(t,i));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"right":{const e=ao({col:i,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(Zi(t,e));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"center":{const o={...t,left:i,right:e},{x:n,y:s,height:r,width:a}=this.getters.getVisibleRect(o),l=R/2,c=f.x+f.width/2;if(n+a<c+l||n>c-l||b>r||x.length>1){const e=n>c-l?n:c-l,t=n+a-e;f.clipRect={x:e,y:s,width:t,height:r}}break}}}else("clip"===w||"wrap"===w||x.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),i=t[0],o=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),s={left:i,right:o,top:n[0],bottom:n[n.length-1]},r=this.getters.getActiveSheetId();for(const i of n)for(const o of t){const t={sheetId:r,col:o,row:i};this.getters.isInMerge(t)||e.push(this.createZoneBox(r,ao(t),s))}for(const t of this.getters.getMerges(r))if(!this.getters.isMergeHidden(r,t)&&Yi(t,s)){const i=this.createZoneBox(r,t,s),o=this.getters.getCellBorder({sheetId:r,col:t.right,row:t.bottom});i.border={...i.border,bottom:o?o.bottom:void 0,right:o?o.right:void 0},i.isMerge=!0,e.push(i)}return e}}cb.layers=[0,7],cb.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];class hb extends qv{constructor(e,t,i){if(i&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=i,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 30;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 30}return 0}handleEvent(e){const t=Hi(e.anchor.zone),i=this.activeSheet,o=this.getters.getActiveSheetId(),n=this.getters.getSheetName(o);this.add([o===i?t:`${ke(n)}!${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 i=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,i)}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:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),o=this.getters.expandZone(e.sheetIdTo,ao({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}}}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],xc:t}}insertNewRange(e,t){const i=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:i+t+1,color:Ct[(i+t)%Ct.length]}))))}setRange(e,t){const[,...i]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,i),i.length&&this.focus(e+i.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const i=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return i.map((e=>{const{sheetName:i}=Bt(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:i&&this.getters.getSheetIdByName(i)||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:i}=Bt(t),o=this.getters.getSheetIdByName(i),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(o===n||void 0===o&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}hb.layers=[1],hb.getters=[];class db extends qv{get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e,this.inputs={},this.focusedInputId=null}allowDispatch(e){var t,i;if("FOCUS_RANGE"===e.type){const o=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(i=this.currentInput)||void 0===i?void 0:i.focusedRangeIndex)===o)return 29}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":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:ao({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}break;case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id],i=t.ranges.find((t=>t.id===e.rangeId)),o=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(o,(null==i?void 0:i.xc)||"A1").zone;this.selection.capture(t,{cell:{col:n.left,row:n.top},zone:n},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,i)=>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===i}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:i}=Bt(e);return null!==t.match(Lt)&&(!i||void 0!==this.getters.getSheetIdByName(i))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,i=!1){if(this.inputs[e]=new hb(this.config,t,i),0===t.length){const t=this.inputs[e],i={zone:ao({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,i,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}db.layers=[1],db.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class ub{constructor(){this.subscriptions={}}on(e,t,i){if(!i)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:i})}trigger(e,t){const i=this.subscriptions[e]||[];for(let e=0,o=i.length;e<o;e++){const o=i[e];o.callback.call(o.owner,t)}}off(e,t){const i=this.subscriptions[e];i&&(this.subscriptions[e]=i.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function gb(e,t){return{...e,definition:Cr(e.definition,t)}}function pb(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let i=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)i>t&&i--}if("ADD_COLUMNS_ROWS"===t.type){i=i>("before"===t.position?t.base-1:t.base)?i+t.quantity:i}return i>0?{...e,quantity:i}:void 0}Ju.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],gb),Ju.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],gb),Ju.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const i=t.sheetId;if(e.targetSheetId===i||e.sheetId===i)return;return e})),Ju.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),Ju.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var i;if(e.name===t.name)return{...e,name:(null===(i=e.name)||void 0===i?void 0:i.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),Ju.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const i=[];for(const o of e.target)for(const e of t.target)Yi(o,e)||i.push({...o});if(i.length)return{...e,target:i};return})),Ju.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],pb),Ju.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],pb),Ju.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const i of e.target)for(const e of t.target)if(Yi(e,i))return;return e}));const mb=[{match:function(e){return"sheetId"in e},fn:bb},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const i=bb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;const o=[];for(const i of e.target){const e=cs(i,t);e&&o.push(e)}if(!o.length)return"IGNORE_COMMAND";return{...e,target:o}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const i=bb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const i="COL"===t.dimension?"col":"row";let o=e[i];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[i]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const i of t.target){if(!(e.col===i.left&&e.row===i.top)&&Ki(e.col,e.row,i))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 i=bb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const i="ADD_COLUMNS_ROWS"===e.type,o=i?"base":"elements";let n=i?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const i=t.elements.sort(((e,t)=>t-e));for(let t of i)e>t&&e--;return e})).filter(ot)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((i=>i>e?i+t.quantity:i))}if(n.length){let t=n;return i&&(t=n[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const i=[],o="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)i.push({...n,_zone:n._zone});else{const e=cs(n._zone,t);e&&o!==n._sheetId&&i.push({...n,_zone:e})}if(!i.length)return"IGNORE_COMMAND";return{...e,ranges:i}}}];function fb(e,t){const i=Ju.getTransformation(e.type,t.type);return i?i(e,t):function(e,t){for(const{match:i,fn:o}of mb)if(i(e)){const i=o(e,t);if("SKIP_TRANSFORMATION"===i)continue;if("IGNORE_COMMAND"===i)return;e=i}return e}(e,t)}function vb(e,t){let i=[...e];for(const e of t)i=i.map((t=>fb(t,e))).filter(ot);return i}function bb(e,t){const i="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===i?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class Sb{constructor(e,t,i,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...i],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Cb extends Error{}class Eb extends ub{constructor(e,t,i=Q){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=i,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Ui,this.debouncedMove=function(e,t,i){let o;return function(){const n=this,s=arguments,r=i&&!o;clearTimeout(o),o=setTimeout((function(){o=null,i||e.apply(n,s)}),t),r&&e.apply(n,s)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const i=new Sb(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.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;for(const t of e)this.onMessageReceived(t);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 Cb("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(ot))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const i=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==i?void 0:i.col)===e.col&&i.row===e.row&&i.sheetId===e.sheetId)return;const o=i?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:o,version:1,client:{...n,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{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":const{clientId:t,commands:i}=e,o=new Sb(e.nextRevisionId,t,i);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:vb(i,t)})}break;case"SNAPSHOT_CREATED":{const t=new Sb(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}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const wb=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class yb extends qv{constructor(){super(...arguments),this.availableColors=new Set(wb),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(wb));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 Cb)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const i of this.getters.getConnectedClients())if(i.id!==this.getters.getClient().id&&i.position&&i.position.sheetId===e&&this.isPositionValid(i.position)){const e=i.position;this.colors[i.id]||(this.colors[i.id]=this.chooseNewColor());const o=this.colors[i.id];t.push({...i,position:e,color:o})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:s}=e.position,r=this.getters.expandZone(o,{top:n,bottom:n,left:s,right:s}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*i,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 ${q+1}px ${Z}`}}}yb.getters=["getClientsToDisplay"],yb.layers=[6];class xb extends qv{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Ki(e.col,e.row,e.zone))throw new Error(s("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;return oo(t).some((({col:t,row:i})=>!this.getters.isInMerge({sheetId:e,col:t,row:i})))?63:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const i=this.getters.getMerges(e).filter((e=>Yi(e,t))),o=to(i[0]);let[n,s]=[o.numberOfCols,o.numberOfRows];return i.every((e=>{let[t,i]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&i===s}))?0:63}expand(e,t){const{left:i,right:o,top:n,bottom:s}=this.getters.expandZone(e,t);return{left:Math.max(0,i),right:Math.min(this.getters.getNumberCols(e)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,s)}}checkExpandedValues(e,t){const i=this.expand(e,t);let o;if(this.getters.doesIntersectMerge(e,i)){const{left:t,right:n,top:s,bottom:r}=i;for(let i=t;i<=n;i++)for(let t=s;t<=r;t++){const{col:n,row:s}=this.getters.getMainCellPosition({sheetId:e,col:i,row:t});if(o=this.getters.getEvaluatedCell({sheetId:e,col:n,row:s}),o.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,i))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let i,{top:o,bottom:n,left:s,right:r}=t,a=!1;for(;!a;)a=!0,o>0&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:o-1,bottom:o-1}),i&&(a=!1,o--)),s>0&&(i=this.checkExpandedValues(e,{left:s-1,right:s-1,top:o-1,bottom:n+1}),i&&(a=!1,s--)),r<this.getters.getNumberCols(e)-1&&(i=this.checkExpandedValues(e,{left:r+1,right:r+1,top:o-1,bottom:n+1}),i&&(a=!1,r++)),n<this.getters.getNumberRows(e)-1&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:n+1,bottom:n+1}),i&&(a=!1,n++));return{left:s,right:r,top:o,bottom:n}}hasHeader(e,t){if(1===t[0].length)return!1;let i=t.map((t=>t.map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).type))));return i[0][0]===rn.empty&&(i=i.slice(1)),!i.some((e=>e[0]===rn.empty))&&!!i.some((e=>e[1]!==rn.empty&&e[0]!==e[1]))}sortZone(e,t,i,o,n){const[s,r]=this.mainCellsSteps(e,i);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},i),c=this.mainCells(e,i);!n.sortHeaders&&this.hasHeader(e,c)&&(l.top+=r),c=this.mainCells(e,l);const h=function(e,t,i){const o=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let n=o.filter((e=>e.type===rn.empty)),s=o.filter((e=>e.type!==rn.empty));i&&(s.push(...n.map((e=>({...e,type:rn.number,value:0})))),n=[]);const r="descending"===t?-1:1;return s.sort(((e,t)=>{let i=wr.indexOf(e.type)-wr.indexOf(t.type);return 0===i&&(i=e.type===rn.text||e.type===rn.error?e.value.localeCompare(t.value):e.value-t.value),r*i})).concat(n)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),o,Boolean(n.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++)for(let t=0;t<g;t++){let{col:i,row:o,sheetId:n}=c[e][d[t]];const a=this.getters.getCell({sheetId:n,col:i,row:o});let h=l.left+e*s,u=l.top+t*r,g={sheetId:n,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,i=this.getters.createAdaptedRanges(a.dependencies,0,t,n);e=this.getters.buildFormulaContent(n,a,i)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const i=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[i?i.right-i.left+1:1,i?i.bottom-i.top+1:1]}mainCells(e,t){const[i,o]=this.mainCellsSteps(e,t),n=[],s=$e(t.left,t.right+1,i),r=$e(t.top,t.bottom+1,o);for(const t of s){const i=[];n.push(i);for(const o of r)i.push({sheetId:e,col:t,row:o})}return n}}xb.getters=["getContiguousZone"];class Ib extends qv{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Ib.getters=["shouldShowFormulas"];class Rb extends qv{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 i=this.getColMaxWidth(e.sheetId,t);0!==i&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:i,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){const t=this.getCellText(e),i=this.getters.getCellComputedStyle(e),o=t.split(he);let n=Math.max(...o.map((e=>this.getTextWidth(e,i))));this.getters.getConditionalIcon(e)&&(n+=function(e){return He(e)+2*U}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(n+=20),n>0&&(n+=2*B,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,n)}return n}getTextWidth(e,t){return Ue(this.ctx,e,t)}getCellText(e,t=!1){const i=this.getters.getCell(e);return t&&(null==i?void 0:i.isFormula)?i.content:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const i=this.getters.getCellStyle(e),o=this.getters.getCellText(e,this.getters.shouldShowFormulas()),n=[];for(const e of o.split("\n")){const o=e.split(" ");if(!t){n.push(e);continue}let s="",r=t;for(let e of o){const o=this.splitWordToSpecificWidth(this.ctx,e,t,i),a=o.pop(),l=Ue(this.ctx,a,i);if(o.length)""!==s&&(n.push(s),s="",r=t),o.forEach((e=>{n.push(e)})),s=a,r=t-l;else{const e=""===s?a:" "+a,o=Ue(this.ctx,e,i);o<=r?(s+=e,r-=o):(n.push(s),s=a,r=t-l)}}""!==s&&n.push(s)}return n}getColDimensions(e,t){const i=this.getColRowOffset("COL",0,t,e),o=this.getters.getColSize(e,t);return{start:i,size:o,end:i+(this.getters.isColHidden(e,t)?0:o)}}getRowDimensions(e,t){const i=this.getColRowOffset("ROW",0,t,e),o=this.getters.getRowSize(e,t);return{start:i,size:o,end:i+(this.getters.isRowHidden(e,t)?0:o)}}getColRowOffset(e,t,i,o=this.getters.getActiveSheetId()){if(i<t)return-this.getColRowOffset(e,i,t);let n=0;for(let s=t;s<i;s++)this.getters.isHeaderHidden(o,e,s)||(n+="COL"===e?this.getters.getColSize(o,s):this.getters.getRowSize(o,s));return n}getColMaxWidth(e,t){const i=oo(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...i)}splitWordToSpecificWidth(e,t,i,o){if(Ue(e,t,o)<=i)return[t];const n=[];let s="";for(let r of t){Ue(e,s+r,o)>i?(n.push(s),s=r):s+=r}return n.push(s),n}}Rb.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];class Tb{constructor(e,t,i,o){this.getters=t,this.dispatch=i,this.selection=o,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,i,o){const n=this.getters.getActiveSheetId(),s=t+o-this.getters.getNumberRows(n);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(n)-1,sheetId:n,quantity:s,position:"after"});const r=e+i-this.getters.getNumberCols(n);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(n)-1,sheetId:n,quantity:r,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Ab extends Tb{constructor(e,t,i,o,n){if(super(t,i,o,n),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const s=new Set(e.map((e=>e.left))),r=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===s.size&&1===r.size?function(e){return e.reduce(((e,t)=>{const i=e.length;for(let o=0;o<i;o++)if(Yi(e[o],t))return e[o]=Zi(e[o],t),e;return e[i]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>oo(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=i.getActiveSheetId();for(let e of u){let t=[];for(let o of d){const n={col:o,row:e,sheetId:p};t.push({cell:i.getCell(n),style:i.getCellComputedStyle(n),evaluatedCell:i.getEvaluatedCell(n),border:i.getCellBorder(n)||void 0,position:n})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const i of $e(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:i,row:e.zone.top}));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const i=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 o=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(i,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(i,e[0])||o*n!=1))return 2;const{xSplit:s,ySplit:r}=this.getters.getPaneDivisions(i);for(const t of this.getPasteZones(e))if(t.left<s&&t.right>=s||t.top<r&&t.bottom>=r)return 75;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const i=this.cells.length,o=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(o,i,n,e)}pasteFromCopy(e,t){if(1===e.length){const i=this.cells.length,o=this.cells[0].length,n=this.pastedZones(e,o,i);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const i of e)for(let e=i.left;e<=i.right;e++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,o,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const i=e[0];this.pasteZone(i.left,i.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:i.left,row:i.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.sheetId,target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,i){const o=e[0],n=Math.max(1,Math.floor((o.right+1-o.left)/t)),s=Math.max(1,Math.floor((o.bottom+1-o.top)/i)),r=[];for(let e=0;e<n;e++)for(let n=0;n<s;n++){const s=o.top+n*i,a=o.left+e*t;r.push({left:a,top:s,bottom:s+i-1,right:a+t-1})}return r}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const i=[],o=t.length,n=t[0].length,s=e[e.length-1],r=s.left,a=s.top,l=Math.max(1,Math.floor((s.right+1-r)/n)),c=Math.max(1,Math.floor((s.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)i.push({left:r,top:a,right:r-1+e*n,bottom:a-1+t*o});return i}selectPastedZone(e,t,i,o){const n=o[0],s=n.left,r=n.top;if(t>1||e>1||i){const n=this.pastedZones(o,e,t),a=i?n[0]:Zi(...n);this.selection.selectZone({cell:{col:s,row:r},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,i){const o=this.cells.length,n=this.cells[0].length,s="onlyValue"!==(null==i?void 0:i.pasteOption)&&(null==i?void 0:i.shouldPasteCF),r=this.getters.getActiveSheetId();this.addMissingDimensions(n,o,e,t);for(let a=0;a<o;a++){const o=this.cells[a];for(let l=0;l<n;l++){const n=o[l],c={col:e+l,row:t+a,sheetId:r};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,i),s&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,i,o){const{sheetId:n,col:s,row:r}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==(null==o?void 0:o.pasteOption)){const i=this.getters.getCellBorder(t),o=e.border,a={top:(null==i?void 0:i.top)||(null==o?void 0:o.top),bottom:(null==i?void 0:i.bottom)||(null==o?void 0:o.bottom),left:(null==i?void 0:i.left)||(null==o?void 0:o.left),right:(null==i?void 0:i.right)||(null==o?void 0:o.right)};this.dispatch("SET_BORDER",{sheetId:n,col:s,row:r,border:a})}if(e.cell){if("onlyFormat"===(null==o?void 0:o.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===(null==o?void 0:o.pasteOption)){const i=pi(e.evaluatedCell.value);return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===i){const t=s-e.position.col,o=r-e.position.row;a=this.getUpdatedContent(n,e.cell,t,o,i)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,i,o,n){const s=this.getters.createAdaptedRanges(t.dependencies,i,o,e);return this.getters.buildFormulaContent(e,t,s)}pasteMergeIfExist(e,t){let{sheetId:i,col:o,row:n}=e;const{col:s,row:r}=this.getters.getMainCellPosition(e);if(s===o&&r===n){const s=this.getters.getMerge(e);if(!s)return;({sheetId:i,col:o,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:i,force:!0,target:[{left:o,top:n,right:o+s.right-s.left,bottom:n+s.bottom-s.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),i=e[0],o=this.zones[0],n=[i.left-o.left,i.top-o.top];for(const e of this.copiedTables){const i=no(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[i]});for(const o of $e(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:i.left+o,row:i.top,values:e.filtersValues[o]})}}getClipboardContent(){return{[an.PlainText]:this.getPlainTextContent(),[an.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.position,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1==this.cells.length&&1==this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const i of t){e+=`<td style="${So(vo(i.style))}">`+Xf(this.getters.getCellText(i.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let i of this.zones){if("COL"===t&&e<=i.right)return!0;if("ROW"===t&&e<=i.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:i}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*i;for(const e of this.zones){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);n>0&&s>0&&t.strokeRect(i,o,n,s)}}}}class Mb{constructor(e,t,i){this.operation=e,this.getters=t,this.dispatch=i,this.sheetId=t.getActiveSheetId();const o=t.getSelectedFigureId();if(!o)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,o);if(!n)throw new Error(`No figure for the given id: ${o}`);switch(this.copiedFigure={...n},n.tag){case"chart":this.copiedFigureContent=new Ob(i,t,this.sheetId,o);break;case"image":this.copiedFigureContent=new Nb(i,t,this.sheetId,o);break;default:throw new Error(`Unknow tag '${n.tag}' for the given figure id: ${o}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?73:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),i={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},o={height:this.copiedFigure.height,width:this.copiedFigure.width},n=(new Ui).uuidv4();this.copiedFigureContent.paste(t,n,i,o),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return{[an.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Ob{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getChart(o);if(!n)throw new Error(`No chart for the given id: ${o}`);this.copiedChart=n.copyInSheetId(i)}paste(e,t,i,o){const n=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:i,size:o,definition:n.getDefinition()})}}class Nb{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getImage(o);this.copiedImage=Fe(n)}paste(e,t,i,o){const n=Fe(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:i,size:o,definition:n})}}class _b extends Tb{constructor(e,t,i,o){super("COPY",t,i,o),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId(),o=this.getPasteZone(e);return this.getters.doesIntersectMerge(i,o)?2:0}paste(e){const t=this.values,i=this.getPasteZone(e),{left:o,top:n}=i,{numberOfCols:s,numberOfRows:r}=to(i),a=this.getters.getActiveSheetId();this.addMissingDimensions(s,r,o,n);for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)this.dispatch("UPDATE_CELL",{row:n+e,col:o+i,content:t[e][i],sheetId:a});const l={left:o,top:n,right:o+s-1,bottom:n+r-1};this.selection.selectZone({cell:{col:o,row:n},zone:l})}getClipboardContent(){return{[an.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,i=Math.max(...this.values.map((e=>e.length))),{left:o,top:n}=e[0];return{top:n,left:o,bottom:n+t-1,right:o+i-1}}}class Fb extends qv{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:i});case"PASTE_FROM_OS_CLIPBOARD":return new _b(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}}return 0}handle(e){var t,i;switch(e.type){case"COPY":case"CUT":const o=this.getters.getSelectedZones();this.state=this.getClipboardState(o,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const n=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Bi(t[0])){for(const{col:t,row:i}of oo(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:i,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(i);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===(i=this.state)||void 0===i?void 0:i.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 _b(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:un(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||{[an.PlainText]:"\t"}}getClipboardTextContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent()[an.PlainText])||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o;return o="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(i)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o,n;return"COL"===t?(o={...e,right:this.getters.getNumberCols(i)-1},n={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:this.getters.getNumberRows(i)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1}),{cut:[o],paste:[n]}}getClipboardStateForCopyCells(e,t){return new Ab(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new Mb(t,this.getters,this.dispatch):new Ab(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}function Db(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=Bt(e.value),[o,n]=t.split(":"),s=i?`${ke(i)}!`:"",r=kb(o),a=n?`:${kb(n)}`:"";return{...e,value:s+r+a}}function kb(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=Lb(e,"colrow");break;case"colrow":e=Lb(e,"row");break;case"row":e=Lb(e,"col");break;case"col":e=Lb(e,"none")}return e}function Lb(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}Fb.layers=[2],Fb.getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];const Pb=s("The cell you are trying to edit has been deleted.");class Ub extends qv{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=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.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":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):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),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:o}=Bt(e.value),n=o||this.getters.getSheetName(this.sheetId),s=this.getters.getActiveSheetId();if(this.getters.getSheetName(s)!==n)return!1;const r=this.getters.getRangeFromSheetXC(s,i);return Xi(this.getters.expandZone(s,r.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const o=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(o,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(n),this.previousRef=n,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 t=this.getters.getActivePosition(),{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),n=this.getters.expandZone(e.sheetIdTo,ao({col:i,row:o}));this.selection.resetAnchor(this,{cell:{col:i,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:Pb}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}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((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Db).map((e=>e.value)).join(""),o=this.currentContent,n=e[0].start,s=e[e.length-1].end,r=o.slice(0,n)+i+o.slice(s),a=r.length-o.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:r,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}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:Pb});const{top:t,left:i}=Gi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,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:Pb});const{top:t,left:i}=Gi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Wi({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=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=ao({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 i;const o=this.getters.getActiveCell();e&&(null===(i=o.format)||void 0===i?void 0:i.includes("%"))&&ii(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:n,row:s,sheetId:r}=this.getters.getActivePosition();this.col=n,this.sheetId=r,this.row=s,this.initialContent=this.getComposerContent({sheetId:r,col:n,row:s}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=ao({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let i=this.currentContent;if(!(this.initialContent!==i))return;if(i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCell({sheetId:o,col:this.col,row:this.row});if(i.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&&(i+=rt(new Array(o).fill(")")))}else n.link&&(i=Ke(i,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:i})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});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})}getComposerContent(e){const t=this.getters.getCell(e);if(null==t?void 0:t.isFormula)return t.content;const{format:i,value:o,type:n,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(n){case rn.text:case rn.empty:return o;case rn.boolean:return s;case rn.error:return(null==t?void 0:t.content)||"";case rn.number:return i&&Ci(i)?s:this.numberComposerContent(o,i)}}numberComposerContent(e,t){return(null==t?void 0:t.includes("%"))?100*e+"%":function(e){const{integerDigits:t,decimalDigits:i}=vi(e,20);return i?`${t}.${i}`:t}(e)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?df(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:s("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),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,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 i=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${ke(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let i=[...t];1===t.length&&co(e.zone)>1?i.push({...t[0]}):2===t.length&&1===co(e.zone)&&i.pop();const o=e.clone({parts:i});return this.getters.getSelectionRangeString(o,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:o,end:o}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const o=new Set(Object.values(i));let n=0;const s=()=>{for(;o.has(n);)n++;return o.add(n),n};for(const e of t){const t=e in i?i[e]:s();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return Ct[t%Ct.length]};return this.getReferencedRanges().map((i=>{const o=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(o),sheetId:i.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 i=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type)||xm.includes(o.value);){if("SPACE"!==o.type||i<1)return!1;i--,o=this.currentTokens[i]}for(i=t+1,o=this.currentTokens[i];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;i++,o=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Ub.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];const Vb=[{name:s("Sum"),types:[rn.number],compute:e=>ul.compute([e])},{name:s("Avg"),types:[rn.number],compute:e=>yl.compute([e])},{name:s("Min"),types:[rn.number],compute:e=>zl.compute([e])},{name:s("Max"),types:[rn.number],compute:e=>Ll.compute([e])},{name:s("Count"),types:[rn.number,rn.text,rn.boolean,rn.error],compute:e=>Nl.compute([e])},{name:s("Count Numbers"),types:[rn.number,rn.text,rn.boolean,rn.error],compute:e=>Ol.compute([e])}];class zb extends qv{constructor(e){super(e),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=e.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 i=[];switch(e.mode){case"overrideSelection":i=[t.zone];break;case"updateAnchor":i=[...this.gridSelection.zones];const o=i.findIndex((t=>Xi(t,e.previousAnchor.zone)));o>=0&&(i[o]=t.zone);break;case"newAnchor":i=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,i),this.selection.resetDefaultAnchor(this,Fe(this.gridSelection.anchor));const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:o,row:n}),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:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(i,o),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:Fe(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Fe(this.gridSelection.anchor));else{const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,i)}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:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}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 n=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of n)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:Fe(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:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:i})}const s=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(s,e))),this.gridSelection.anchor.zone=this.getters.expandZone(s,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,Fe(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}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 i=t.left;i<=t.right;i++)e.add(i);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let i of this.gridSelection.zones)if(0===i.left&&i.right===this.getters.getNumberCols(t)-1)for(let t=i.top;t<=i.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Fe(this.gridSelection.zones)}getSelectedZone(){return Fe(this.gridSelection.anchor.zone)}getSelection(){return Fe(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=new Set(this.gridSelection.zones.map((e=>this.getters.getEvaluatedCellsInZone(this.getters.getActiveSheetId(),e))).flat().filter((e=>e.type!==rn.empty)));let t=new Set,i=[];for(let o of e)t.add(o.type),i.push(o.value);let o={};for(let e of Vb){let n;e.types.some((e=>t.has(e)))&&(n=e.compute(i)),o[e.name]=n}return o}getAggregate(){let e=0,t=0;const i=this.getters.getActiveSheetId(),o=this.gridSelection.zones.map(oo).flat();for(const{col:n,row:s}of o){const o=this.getters.getEvaluatedCell({sheetId:i,col:n,row:s});o.type===rn.number&&(t++,e+=o.value)}return t<2?null:pi(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Xi(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 i=[];const o="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[o]+1},((t,i)=>e[o]+i));i=i.concat(t)}return[...new Set(i)].sort()}setSelectionMixin(e,t){const{anchor:i,zones:o}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=i,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,i)=>t===i.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(o)}selectCell(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.expandZone(i,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:o,cell:{col:e,row:t}},[o])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),i=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[i]})}onColumnsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Gi(i,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Gi(n,"left",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onRowsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=Gi(i,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Gi(n,"top",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onAddElements(e){const t=Wi(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(i,[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 i="COL"===e.dimension,o=e.elements[0],n=e.elements[t-1],s=e.base<o,r=s&&i?t:0,a=s&&!i?t:0,l=[{left:i?o+r:0,right:i?n+r:this.getters.getNumberCols(e.sheetId)-1,top:i?0:o+a,bottom:i?this.getters.getNumberRows(e.sheetId)-1:n+a}],c=new Ab(l,"CUT",this.getters,this.dispatch,this.selection),h=[{left:i?e.base:0,right:i?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:i?0:e.base,bottom:i?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}];c.paste(h,{selectTarget:!0});const d=s?e.elements.map((e=>e+t)):e.elements;let u=e.base;for(const t of d){const i="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:i,elements:[u]}),u+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:d})}isMoveElementAllowed(e){const t="COL"===e.dimension,i=e.elements[0],o=e.elements[e.elements.length-1],n=e.sheetId,s=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return s(n,i-1,i)||s(n,o,o+1)||s(n,e.base-1,e.base)?2:0}clipSelection(e,t){const i=this.getters.getNumberCols(e)-1,o=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:Le(e.left,0,i),right:Le(e.right,0,i),top:Le(e.top,0,o),bottom:Le(e.bottom,0,o)}))),anchor:{cell:{col:Le(t.anchor.cell.col,0,i),row:Le(t.anchor.cell.row,0,o)},zone:{left:Le(t.anchor.zone.left,0,i),right:Le(t.anchor.zone.right,0,i),top:Le(t.anchor.zone.top,0,o),bottom:Le(t.anchor.zone.bottom,0,o)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*i;for(const e of o){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(i,o,n,s),t.globalCompositeOperation="source-over",t.strokeRect(i,o,n,s)}t.globalCompositeOperation="source-over";const s=this.getActivePosition();let r;t.strokeStyle=E,t.lineWidth=3*i,r=this.getters.isInMerge(s)?this.getters.getMerge(s):ao(s);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);c>0&&h>0&&t.strokeRect(a,l,c,h)}}zb.layers=[6],zb.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","getElementsFromSelection","isGridSelectionActive"];const Bb=(new xo).add("sheet",Gv).add("header visibility",Vv).add("filters",Pv).add("cell",Ov).add("merge",Bv).add("headerSize",Uv).add("borders",Mv).add("conditional formatting",Fv).add("figures",Dv).add("chart",Nv).add("image",zv),Hb=(new xo).add("ui_sheet",Rb).add("header_visibility_ui",ab).add("ui_options",Ib).add("selectionInputManager",db).add("highlight",lb).add("grid renderer",cb).add("autofill",ib).add("find_and_replace",rb).add("sort",xb).add("automatic_sum",ob).add("format",class extends qv{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,i){for(const o of t)for(const t of oo(o)){const o=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==o){const n=Ti(o,i);this.dispatch("SET_FORMATTING",{sheetId:e,target:[ao(t)],format:n})}}}getCellNumberFormat(e){var t;for(const i of[e]){const e=this.getters.getEvaluatedCell(i);if(e.type===rn.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y)))return e.format||xi(e.value)}}}).add("cell_popovers",nb).add("selection_multiuser",yb),$b=(new xo).add("selection",zb).add("clipboard",Fb).add("edition",Ub),Wb=(new xo).add("evaluation",Xv).add("evaluation_filter",Qv).add("evaluation_chart",Yv).add("evaluation_cf",Kv).add("viewport",eb).add("custom_colors",Zv),Gb=new xo;Gb.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,action:(e,t)=>No(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class qb{constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const i=document.createElement("input");i.setAttribute("type","file"),i.setAttribute("accept","image/*"),i.addEventListener("change",(async()=>{null===i.files||1!=i.files.length?t():e(i.files[0])})),i.click()}))}getImageSize(e){return new Promise(((t,i)=>{const o=new Image;o.src=e,o.addEventListener("load",(()=>{const e={width:o.width,height:o.height};t(e)})),o.addEventListener("error",i)}))}}const Zb=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];mo`
1401
1401
  .o-ripple {
1402
1402
  z-index: 1;
1403
1403
  }
1404
- `;class Zb extends t.Component{constructor(){super(...arguments),this.rippleRef=t.useRef("ripple")}setup(){let e;t.onMounted((()=>{const t=this.rippleRef.el;t&&t.animate&&(e=t.animate(qb,{duration:this.props.duration,easing:"ease-out"}),e.addEventListener("finish",this.props.onAnimationEnd))})),t.onWillUnmount((()=>{null==e||e.removeEventListener("finish",this.props.onAnimationEnd)}))}get rippleStyle(){const{x:e,y:t,width:i,height:o}=this.props;return bo({transform:"scale(0)",left:e,top:t,"margin-left":`${-i/2+(this.props.offsetX||0)}px`,"margin-top":`${-o/2+(this.props.offsetY||0)}px`,width:`${i}px`,height:`${o}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}Zb.template="o-spreadsheet-RippleEffect",Zb.props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};class jb extends t.Component{constructor(){super(...arguments),this.childContainer=t.useRef("childContainer"),this.state=t.useState({ripples:[]}),this.currentId=1}onClick(e){if(!this.props.enabled)return;if(!this.childContainer.el)return;const t=this.getRippleChildRectInfo(),{x:i,y:o,width:n,height:s}=t,r=Math.max(n,s),a={x:e.clientX-i,y:e.clientY-o,width:this.props.width||2.85*r,height:this.props.height||2.85*r};this.state.ripples.push({rippleRect:a,id:this.currentId++})}getRippleStyle(){const e=this.childContainer.el;if(!e||1!==e.childElementCount||!e.firstElementChild)return"";const t=this.getRippleChildRectInfo();return bo({top:t.marginTop+"px",left:t.marginLeft+"px",width:t.width+"px",height:t.height+"px"})}getRippleChildRectInfo(){const e=this.childContainer.el;if(!e)throw new Error("No child container element found");if(1!==e.childElementCount||!e.firstElementChild){return{...Vn(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,i=function(e){const t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}(t);return{...Vn(t),marginLeft:i.left,marginTop:i.top}}removeRipple(e){const t=this.state.ripples.findIndex((t=>t.id===e));-1!==t&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){var t;const i=null===(t=this.state.ripples.find((t=>t.id===e)))||void 0===t?void 0:t.rippleRect;if(!i)throw new Error("Cannot find a ripple with the id "+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?"50%":i.x+"px",y:this.props.ignoreClickPosition?"50%":i.y+"px",width:i.width,height:i.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}jb.template="o-spreadsheet-Ripple",jb.components={RippleEffect:Zb},jb.defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""},jb.props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}},po`
1404
+ `;class jb extends t.Component{constructor(){super(...arguments),this.rippleRef=t.useRef("ripple")}setup(){let e;t.onMounted((()=>{const t=this.rippleRef.el;t&&t.animate&&(e=t.animate(Zb,{duration:this.props.duration,easing:"ease-out"}),e.addEventListener("finish",this.props.onAnimationEnd))})),t.onWillUnmount((()=>{null==e||e.removeEventListener("finish",this.props.onAnimationEnd)}))}get rippleStyle(){const{x:e,y:t,width:i,height:o}=this.props;return So({transform:"scale(0)",left:e,top:t,"margin-left":`${-i/2+(this.props.offsetX||0)}px`,"margin-top":`${-o/2+(this.props.offsetY||0)}px`,width:`${i}px`,height:`${o}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}jb.template="o-spreadsheet-RippleEffect",jb.props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};class Xb extends t.Component{constructor(){super(...arguments),this.childContainer=t.useRef("childContainer"),this.state=t.useState({ripples:[]}),this.currentId=1}onClick(e){if(!this.props.enabled)return;if(!this.childContainer.el)return;const t=this.getRippleChildRectInfo(),{x:i,y:o,width:n,height:s}=t,r=Math.max(n,s),a={x:e.clientX-i,y:e.clientY-o,width:this.props.width||2.85*r,height:this.props.height||2.85*r};this.state.ripples.push({rippleRect:a,id:this.currentId++})}getRippleStyle(){const e=this.childContainer.el;if(!e||1!==e.childElementCount||!e.firstElementChild)return"";const t=this.getRippleChildRectInfo();return So({top:t.marginTop+"px",left:t.marginLeft+"px",width:t.width+"px",height:t.height+"px"})}getRippleChildRectInfo(){const e=this.childContainer.el;if(!e)throw new Error("No child container element found");if(1!==e.childElementCount||!e.firstElementChild){return{...zn(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,i=function(e){const t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}(t);return{...zn(t),marginLeft:i.left,marginTop:i.top}}removeRipple(e){const t=this.state.ripples.findIndex((t=>t.id===e));-1!==t&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){var t;const i=null===(t=this.state.ripples.find((t=>t.id===e)))||void 0===t?void 0:t.rippleRect;if(!i)throw new Error("Cannot find a ripple with the id "+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?"50%":i.x+"px",y:this.props.ignoreClickPosition?"50%":i.y+"px",width:i.width,height:i.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}Xb.template="o-spreadsheet-Ripple",Xb.components={RippleEffect:jb},Xb.defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""},Xb.props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}},mo`
1405
1405
  .o-sheet {
1406
1406
  color: #666;
1407
1407
  padding: 0 15px;
@@ -1442,7 +1442,7 @@
1442
1442
  }
1443
1443
  }
1444
1444
  }
1445
- `;class Xb extends t.Component{constructor(){super(...arguments),this.state=t.useState({isEditing:!1}),this.sheetDivRef=t.useRef("sheetDiv"),this.sheetNameRef=t.useRef("sheetNameSpan"),this.editionState="initializing"}setup(){t.onMounted((()=>{this.isSheetActive&&this.scrollToSheet()})),t.onPatched((()=>{this.sheetNameRef.el&&this.state.isEditing&&"initializing"===this.editionState&&(this.editionState="editing",this.focusInputAndSelectContent())}))}focusInputAndSelectContent(){var e;if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();const t=window.getSelection();t&&this.sheetNameRef.el.firstChild&&t.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,(null===(e=this.sheetNameRef.el.textContent)||void 0===e?void 0:e.length)||0)}scrollToSheet(){var e,t;null===(t=null===(e=this.sheetDivRef.el)||void 0===e?void 0:e.scrollIntoView)||void 0===t||t.call(e)}onFocusOut(){this.state.isEditing&&"initializing"!==this.editionState&&this.stopEdition()}onMouseDown(e){this.activateSheet(),this.props.onMouseDown(e)}activateSheet(){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.startEdition()}onKeyDown(e){this.state.isEditing&&("Enter"===e.key&&(e.preventDefault(),this.stopEdition()),"Escape"===e.key&&this.cancelEdition())}onClickSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState="initializing"}stopEdition(){var e;if(!this.state.isEditing)return;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur();const t=this.getInputContent()||"";!function(e,t,i,o){const n=e.model.getters.getSheetName(t);if(null===i||i===n)return;const r=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:i});r.reasons.includes(10)?e.raiseError(s("The sheet name cannot be empty."),o):r.reasons.includes(11)?e.raiseError(s("A sheet with the name %s already exists. Please select another name.",i),o):r.reasons.includes(13)&&e.raiseError(s("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",se.join(" ")),o)}(this.env,this.props.sheetId,t,(()=>this.startEdition()))}cancelEdition(){var e;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){var e;return null===(e=this.sheetNameRef.el)||void 0===e?void 0:e.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}get contextMenuRegistry(){return function(e){const t=new ts;return t.add("delete",{name:s("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(s("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:s("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}}).add("rename",{name:s("Rename"),sequence:30,action:()=>e.renameSheetCallback()}).add("move_right",{name:s("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getVisibleSheetIds();return i.indexOf(t)!==i.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:1})}).add("move_left",{name:s("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(),delta:-1})}).add("hide_sheet",{name:s("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}),t}({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}}Xb.template="o-spreadsheet-BottomBarSheet",Xb.components={Ripple:jb},Xb.defaultProps={onMouseDown:()=>{},style:""},Xb.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},po`
1445
+ `;class Yb extends t.Component{constructor(){super(...arguments),this.state=t.useState({isEditing:!1}),this.sheetDivRef=t.useRef("sheetDiv"),this.sheetNameRef=t.useRef("sheetNameSpan"),this.editionState="initializing"}setup(){t.onMounted((()=>{this.isSheetActive&&this.scrollToSheet()})),t.onPatched((()=>{this.sheetNameRef.el&&this.state.isEditing&&"initializing"===this.editionState&&(this.editionState="editing",this.focusInputAndSelectContent())}))}focusInputAndSelectContent(){var e;if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();const t=window.getSelection();t&&this.sheetNameRef.el.firstChild&&t.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,(null===(e=this.sheetNameRef.el.textContent)||void 0===e?void 0:e.length)||0)}scrollToSheet(){var e,t;null===(t=null===(e=this.sheetDivRef.el)||void 0===e?void 0:e.scrollIntoView)||void 0===t||t.call(e)}onFocusOut(){this.state.isEditing&&"initializing"!==this.editionState&&this.stopEdition()}onMouseDown(e){this.activateSheet(),this.props.onMouseDown(e)}activateSheet(){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.startEdition()}onKeyDown(e){this.state.isEditing&&("Enter"===e.key&&(e.preventDefault(),this.stopEdition()),"Escape"===e.key&&this.cancelEdition())}onClickSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState="initializing"}stopEdition(){var e;if(!this.state.isEditing)return;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur();const t=this.getInputContent()||"";!function(e,t,i,o){const n=e.model.getters.getSheetName(t);if(null===i||i===n)return;const r=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:i});r.reasons.includes(10)?e.raiseError(s("The sheet name cannot be empty."),o):r.reasons.includes(11)?e.raiseError(s("A sheet with the name %s already exists. Please select another name.",i),o):r.reasons.includes(13)&&e.raiseError(s("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",se.join(" ")),o)}(this.env,this.props.sheetId,t,(()=>this.startEdition()))}cancelEdition(){var e;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){var e;return null===(e=this.sheetNameRef.el)||void 0===e?void 0:e.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}get contextMenuRegistry(){return function(e){const t=new is;return t.add("delete",{name:s("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(s("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:s("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}}).add("rename",{name:s("Rename"),sequence:30,action:()=>e.renameSheetCallback()}).add("move_right",{name:s("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getVisibleSheetIds();return i.indexOf(t)!==i.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:1})}).add("move_left",{name:s("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(),delta:-1})}).add("hide_sheet",{name:s("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}),t}({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}}Yb.template="o-spreadsheet-BottomBarSheet",Yb.components={Ripple:Xb},Yb.defaultProps={onMouseDown:()=>{},style:""},Yb.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},mo`
1446
1446
  .o-selection-statistic {
1447
1447
  margin-right: 20px;
1448
1448
  padding: 4px 4px 4px 8px;
@@ -1452,7 +1452,7 @@
1452
1452
  background-color: rgba(0, 0, 0, 0.08) !important;
1453
1453
  }
1454
1454
  }
1455
- `;class Yb extends t.Component{constructor(){super(...arguments),this.selectedStatisticFn="",this.statisticFnResults={}}setup(){this.statisticFnResults=this.env.model.getters.getStatisticFnResults(),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getStatisticFnResults();ct(e,this.statisticFnResults)||this.props.closeContextMenu(),this.statisticFnResults=e}))}getSelectedStatistic(){if(!Object.values(this.statisticFnResults).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(this.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn,this.statisticFnResults[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new ts;let i=0;for(let[e,o]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,o),sequence:i,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),i++;const o=e.currentTarget,{top:n,left:s,width:r}=o.getBoundingClientRect();this.props.openContextMenu(s+r,n,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?gi(t):"__")}}Yb.template="o-spreadsheet-BottomBarStatisic",Yb.components={Ripple:jb},Yb.props={openContextMenu:Function,closeContextMenu:Function};class Kb{constructor(e){this.edgeScrollOffset=0,this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.containerEl=e.containerEl,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.mouseX,this.currentMousePosition=e.mouseX,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size,Og(this.onMouseMove.bind(this),this.onMouseUp.bind(this))}onMouseMove(e){if(0!==e.button)return void this.onCancel();const t=e.clientX;t<this.containerRect.left||t>this.containerRect.right?this.startEdgeScroll(t<this.containerRect.left?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.edgeScrollOffset))}moveDraggedItemToPosition(e){this.currentMousePosition=e;const t=this.getHoveredItemIndex(e,this.items),i=this.items.findIndex((e=>e.id===this.draggedItemId)),o=this.items[i];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:o.position,end:o.position+o.size})&&(this.deadZone=void 0),i===t)return void this.onChange(this.getItemsPositions());const n=Math.min(i,t),s=Math.max(i,t),r=Math.sign(t-i);let a=0;for(let e=n;e<=s;e++)e!==i&&(this.items[e].position-=r*o.size,a+=this.items[e].size);o.position+=r*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=r>0?{start:e,end:o.position}:{start:o.position+o.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel();const t=this.items.findIndex((e=>e.id===this.draggedItemId));this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll()}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let i=this.currentMousePosition+t;i<this.minPosition?i=this.minPosition:i>this.maxPosition&&(i=this.maxPosition),this.edgeScrollOffset+=i-this.currentMousePosition,this.moveDraggedItemToPosition(i),this.containerEl.scrollLeft+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let i=this.currentMousePosition-this.initialMousePosition;i=Math.max(this.minPosition-t.positionAtStart,i),i=Math.min(this.maxPosition-t.positionAtStart-t.size,i),e[t.id]=i}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}po`
1455
+ `;class Kb extends t.Component{constructor(){super(...arguments),this.selectedStatisticFn="",this.statisticFnResults={}}setup(){this.statisticFnResults=this.env.model.getters.getStatisticFnResults(),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getStatisticFnResults();ht(e,this.statisticFnResults)||this.props.closeContextMenu(),this.statisticFnResults=e}))}getSelectedStatistic(){if(!Object.values(this.statisticFnResults).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(this.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn,this.statisticFnResults[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new is;let i=0;for(let[e,o]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,o),sequence:i,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),i++;const o=e.currentTarget,{top:n,left:s,width:r}=o.getBoundingClientRect();this.props.openContextMenu(s+r,n,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?pi(t):"__")}}Kb.template="o-spreadsheet-BottomBarStatisic",Kb.components={Ripple:Xb},Kb.props={openContextMenu:Function,closeContextMenu:Function};class Qb{constructor(e){this.edgeScrollOffset=0,this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.containerEl=e.containerEl,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.mouseX,this.currentMousePosition=e.mouseX,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size,Ng(this.onMouseMove.bind(this),this.onMouseUp.bind(this))}onMouseMove(e){if(0!==e.button)return void this.onCancel();const t=e.clientX;t<this.containerRect.left||t>this.containerRect.right?this.startEdgeScroll(t<this.containerRect.left?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.edgeScrollOffset))}moveDraggedItemToPosition(e){this.currentMousePosition=e;const t=this.getHoveredItemIndex(e,this.items),i=this.items.findIndex((e=>e.id===this.draggedItemId)),o=this.items[i];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:o.position,end:o.position+o.size})&&(this.deadZone=void 0),i===t)return void this.onChange(this.getItemsPositions());const n=Math.min(i,t),s=Math.max(i,t),r=Math.sign(t-i);let a=0;for(let e=n;e<=s;e++)e!==i&&(this.items[e].position-=r*o.size,a+=this.items[e].size);o.position+=r*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=r>0?{start:e,end:o.position}:{start:o.position+o.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel();const t=this.items.findIndex((e=>e.id===this.draggedItemId));this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll()}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let i=this.currentMousePosition+t;i<this.minPosition?i=this.minPosition:i>this.maxPosition&&(i=this.maxPosition),this.edgeScrollOffset+=i-this.currentMousePosition,this.moveDraggedItemToPosition(i),this.containerEl.scrollLeft+=t}),5))}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex((t=>t.position+t.size>=e))}getItemsPositions(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let i=this.currentMousePosition-this.initialMousePosition;i=Math.max(this.minPosition-t.positionAtStart,i),i=Math.min(this.maxPosition-t.positionAtStart-t.size,i),e[t.id]=i}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}mo`
1456
1456
  .o-spreadsheet-bottom-bar {
1457
1457
  background-color: ${f};
1458
1458
  padding-left: ${_}px;
@@ -1501,12 +1501,12 @@
1501
1501
  }
1502
1502
  }
1503
1503
  }
1504
- `;class Qb extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.sheetListRef=t.useRef("sheetList"),this.targetScroll=void 0,this.state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1}),this.menuMaxHeight=250,this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.sheetState=t.useState({sheetList:this.getVisibleSheets(),isDnd:!1,sheetDndPositions:void 0})}setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();this.sheetState.isDnd&&!ct(this.sheetState.sheetList,e)&&this.stopDragging(),this.sheetState.sheetList=e})),t.onWillUnmount((()=>{var e;null===(e=this.dndHelper)||void 0===e||e.destroy()}))}isDragged(e){var t;return this.sheetState.isDnd&&(null===(t=this.dndHelper)||void 0===t?void 0:t.draggedItemId)===e}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+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:i,name:n}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}getSheets(){return this.sheetState.sheetList}clickListSheets(e){const t=new ts,i=this.env.model.getters.getActiveSheetId();let o=0;for(const e of this.env.model.getters.getSheetIds()){const n=this.env.model.getters.getSheet(e);t.add(e,{name:n.name,sequence:o,isReadonlyAllowed:!0,textColor:n.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:e})}}),o++}const n=e.currentTarget,{left:s}=n.getBoundingClientRect(),r=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(s,r,"listSheets",t)}openContextMenu(e,t,i,o){this.menuState.isOpen=!0,this.menuState.menuId=i,this.menuState.menuItems=o.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,i){const o=i.currentTarget,{top:n,left:s}=o.getBoundingClientRect();i.closedMenuId!==e?this.openContextMenu(s,n,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button)return;this.closeMenu();const i=t.clientX;document.body.style.cursor="move";const o=this.getVisibleSheets(),n=this.getSheetItemRects(),s=o.map(((e,t)=>({id:e.id,size:n[t].width,position:n[t].x})));this.dndHelper=new Kb({draggedItemId:e,mouseX:i,items:s,containerEl:this.sheetListRef.el,onChange:e=>{this.sheetState.isDnd=!0,this.sheetState.sheetDndPositions=e},onCancel:()=>this.stopDragging(),onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const i=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==i&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:i}),this.stopDragging()}getSheetStyle(e){var t;const i={};return this.sheetState.isDnd&&(i.position="relative",i.left=((null===(t=this.sheetState.sheetDndPositions)||void 0===t?void 0:t[e])||0)+"px",i.transition="left 0.5s",i.cursor="move"),this.isDragged(e)&&(i.transition="left 0s",i["z-index"]="1000"),bo(i)}stopDragging(){document.body.style.cursor="",this.sheetState.sheetList=this.getVisibleSheets(),this.sheetState.isDnd=!1,this.sheetState.sheetDndPositions=void 0,this.dndHelper=void 0}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}getSheetClasses(e){let t="";return this.isDragged(e)&&(t+="dragged "),this.sheetState.isDnd&&(t+="dragging "),t}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}Qb.template="o-spreadsheet-BottomBar",Qb.components={Menu:Xn,Ripple:jb,BottomBarSheet:Xb,BottomBarStatistic:Yb},Qb.props={onClick:Function},po`
1504
+ `;class Jb extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.sheetListRef=t.useRef("sheetList"),this.targetScroll=void 0,this.state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1}),this.menuMaxHeight=250,this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.sheetState=t.useState({sheetList:this.getVisibleSheets(),isDnd:!1,sheetDndPositions:void 0})}setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();this.sheetState.isDnd&&!ht(this.sheetState.sheetList,e)&&this.stopDragging(),this.sheetState.sheetList=e})),t.onWillUnmount((()=>{var e;null===(e=this.dndHelper)||void 0===e||e.destroy()}))}isDragged(e){var t;return this.sheetState.isDnd&&(null===(t=this.dndHelper)||void 0===t?void 0:t.draggedItemId)===e}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+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:i,name:n}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}getSheets(){return this.sheetState.sheetList}clickListSheets(e){const t=new is,i=this.env.model.getters.getActiveSheetId();let o=0;for(const e of this.env.model.getters.getSheetIds()){const n=this.env.model.getters.getSheet(e);t.add(e,{name:n.name,sequence:o,isReadonlyAllowed:!0,textColor:n.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:e})}}),o++}const n=e.currentTarget,{left:s}=n.getBoundingClientRect(),r=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(s,r,"listSheets",t)}openContextMenu(e,t,i,o){this.menuState.isOpen=!0,this.menuState.menuId=i,this.menuState.menuItems=o.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,i){const o=i.currentTarget,{top:n,left:s}=o.getBoundingClientRect();i.closedMenuId!==e?this.openContextMenu(s,n,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button)return;this.closeMenu();const i=t.clientX;document.body.style.cursor="move";const o=this.getVisibleSheets(),n=this.getSheetItemRects(),s=o.map(((e,t)=>({id:e.id,size:n[t].width,position:n[t].x})));this.dndHelper=new Qb({draggedItemId:e,mouseX:i,items:s,containerEl:this.sheetListRef.el,onChange:e=>{this.sheetState.isDnd=!0,this.sheetState.sheetDndPositions=e},onCancel:()=>this.stopDragging(),onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const i=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==i&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:i}),this.stopDragging()}getSheetStyle(e){var t;const i={};return this.sheetState.isDnd&&(i.position="relative",i.left=((null===(t=this.sheetState.sheetDndPositions)||void 0===t?void 0:t[e])||0)+"px",i.transition="left 0.5s",i.cursor="move"),this.isDragged(e)&&(i.transition="left 0s",i["z-index"]="1000"),So(i)}stopDragging(){document.body.style.cursor="",this.sheetState.sheetList=this.getVisibleSheets(),this.sheetState.isDnd=!1,this.sheetState.sheetDndPositions=void 0,this.dndHelper=void 0}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}getSheetClasses(e){let t="";return this.isDragged(e)&&(t+="dragged "),this.sheetState.isDnd&&(t+="dragging "),t}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}Jb.template="o-spreadsheet-BottomBar",Jb.components={Menu:Yn,Ripple:Xb,BottomBarSheet:Yb,BottomBarStatistic:Kb},Jb.props={onClick:Function},mo`
1505
1505
  .o-dashboard-clickable-cell {
1506
1506
  position: absolute;
1507
1507
  cursor: pointer;
1508
1508
  }
1509
- `;let Jb=1;class eS extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=Hn(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),np("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=sp(((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:i}=this.env.model.getters.getColDimensions(e,t);return bo({"max-width":`${i}px`})}get gridOverlayDimensions(){return bo({height:"100%",width:"100%"})}getCellClickableStyle(e){return bo({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const i of this.env.model.getters.getSheetViewVisibleCols())for(const o of this.env.model.getters.getSheetViewVisibleRows()){const n={sheetId:t,col:i,row:o},s=this.getClickableAction(n);if(!s)continue;let r;r=this.env.model.getters.isInMerge(n)?this.env.model.getters.getMerge(n):ro({col:i,row:o});const a=this.env.model.getters.getVisibleRect(r);e.push({coordinates:a,position:{col:i,row:o},action:s,tKey:`${Jb}-${i}-${o}`})}return Jb++,e}getClickableAction(e){for(const t of Wb.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{position:t,action:i}=e;i({...t,sheetId:this.env.model.getters.getActiveSheetId()},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:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}eS.template="o-spreadsheet-SpreadsheetDashboard",eS.components={GridOverlay:Qg,GridPopover:Jg,Popover:Gn,VerticalScrollBar:up,HorizontalScrollBar:dp,FilterIconsOverlay:Xg},eS.props={},po`
1509
+ `;let eS=1;class tS extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=$n(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),sp("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=rp(((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:i}=this.env.model.getters.getColDimensions(e,t);return So({"max-width":`${i}px`})}get gridOverlayDimensions(){return So({height:"100%",width:"100%"})}getCellClickableStyle(e){return So({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const i of this.env.model.getters.getSheetViewVisibleCols())for(const o of this.env.model.getters.getSheetViewVisibleRows()){const n={sheetId:t,col:i,row:o},s=this.getClickableAction(n);if(!s)continue;let r;r=this.env.model.getters.isInMerge(n)?this.env.model.getters.getMerge(n):ao({col:i,row:o});const a=this.env.model.getters.getVisibleRect(r);e.push({coordinates:a,position:{col:i,row:o},action:s,tKey:`${eS}-${i}-${o}`})}return eS++,e}getClickableAction(e){for(const t of Gb.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{position:t,action:i}=e;i({...t,sheetId:this.env.model.getters.getActiveSheetId()},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:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}tS.template="o-spreadsheet-SpreadsheetDashboard",tS.components={GridOverlay:Jg,GridPopover:ep,Popover:qn,VerticalScrollBar:gp,HorizontalScrollBar:up,FilterIconsOverlay:Yg},tS.props={},mo`
1510
1510
  .o-sidePanel {
1511
1511
  display: flex;
1512
1512
  flex-direction: column;
@@ -1675,14 +1675,14 @@
1675
1675
  }
1676
1676
  }
1677
1677
  }
1678
- `;class tS extends t.Component{setup(){this.state=t.useState({panel:Tg.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=Tg.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}tS.template="o-spreadsheet-SidePanel",tS.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function};const iS={MergeIsDestructive:s("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:s("You can't merge cells inside of an existing filter.")};po`
1678
+ `;class iS extends t.Component{setup(){this.state=t.useState({panel:Ag.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=Ag.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}iS.template="o-spreadsheet-SidePanel",iS.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function};const oS={MergeIsDestructive:s("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:s("You can't merge cells inside of an existing filter.")};mo`
1679
1679
  .o-topbar-composer {
1680
1680
  height: fit-content;
1681
1681
  margin-top: -1px;
1682
1682
  border: 1px solid;
1683
1683
  z-index: ${ce.TopBarComposer};
1684
1684
  }
1685
- `;class oS extends t.Component{get composerStyle(){const e={padding:"5px 0px 5px 8px","max-height":"100px","line-height":"24px"};return e.height="inactive"===this.props.focus?"34px":"fit-content",bo(e)}get containerStyle(){return"inactive"===this.props.focus?bo({"border-color":M,"border-right":"none"}):bo({"border-color":E})}}oS.template="o-spreadsheet-TopBarComposer",oS.components={Composer:$g},oS.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},po`
1685
+ `;class nS extends t.Component{get composerStyle(){const e={padding:"5px 0px 5px 8px","max-height":"100px","line-height":"24px"};return e.height="inactive"===this.props.focus?"34px":"fit-content",So(e)}get containerStyle(){return"inactive"===this.props.focus?So({"border-color":M,"border-right":"none"}):So({"border-color":E})}}nS.template="o-spreadsheet-TopBarComposer",nS.components={Composer:Wg},nS.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},mo`
1686
1686
  .o-font-size-editor {
1687
1687
  height: calc(100% - 4px);
1688
1688
  input.o-font-size {
@@ -1697,7 +1697,7 @@
1697
1697
  -webkit-appearance: none;
1698
1698
  }
1699
1699
  }
1700
- `;class nS extends t.Component{constructor(){super(...arguments),this.fontSizes=de,this.dropdown=t.useState({isOpen:!1}),this.inputRef=t.useRef("inputFontSize"),this.rootEditorRef=t.useRef("FontSizeEditor")}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0})}onExternalClick(e){Pn(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||q}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=ke(Math.floor(parseFloat(e)),1,400);Fr(this.env,{fontSize:t}),this.closeFontList()}setSizeFromInput(e){this.setSize(e.target.value)}setSizeFromList(e){this.setSize(e)}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if("Enter"===e.key||"Escape"===e.key){this.closeFontList();const t=e.target;"Escape"===e.key&&(t.value=`${this.currentFontSize}`),this.props.onToggle()}}}nS.template="o-spreadsheet-FontSizeEditor",nS.components={},nS.props={onToggle:Function,dropdownStyle:String,class:String};const sS=[{name:"automatic",text:As.Automatic},{name:"number",text:As.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:As.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:As.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:As.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:As.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:As.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:As.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:As.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],rS=[{name:"custom_currency",text:As.CustomCurrency,sidePanel:"CustomCurrency"}],aS="#4a4f59";po`
1700
+ `;class sS extends t.Component{constructor(){super(...arguments),this.fontSizes=de,this.dropdown=t.useState({isOpen:!1}),this.inputRef=t.useRef("inputFontSize"),this.rootEditorRef=t.useRef("FontSizeEditor")}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0})}onExternalClick(e){Un(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||q}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=Le(Math.floor(parseFloat(e)),1,400);Dr(this.env,{fontSize:t}),this.closeFontList()}setSizeFromInput(e){this.setSize(e.target.value)}setSizeFromList(e){this.setSize(e)}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if("Enter"===e.key||"Escape"===e.key){this.closeFontList();const t=e.target;"Escape"===e.key&&(t.value=`${this.currentFontSize}`),this.props.onToggle()}}}sS.template="o-spreadsheet-FontSizeEditor",sS.components={},sS.props={onToggle:Function,dropdownStyle:String,class:String};const rS=[{name:"automatic",text:Ms.Automatic},{name:"number",text:Ms.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:Ms.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:Ms.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:Ms.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:Ms.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:Ms.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:Ms.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:Ms.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],aS=[{name:"custom_currency",text:Ms.CustomCurrency,sidePanel:"CustomCurrency"}],lS="#4a4f59";mo`
1701
1701
  .o-spreadsheet-topbar {
1702
1702
  background-color: white;
1703
1703
  line-height: 1.2;
@@ -1707,7 +1707,7 @@
1707
1707
  line-height: 1.2;
1708
1708
  user-select: none;
1709
1709
  font-weight: 500;
1710
- color: ${aS};
1710
+ color: ${lS};
1711
1711
 
1712
1712
  .o-topbar-top {
1713
1713
  border-bottom: 1px solid ${M};
@@ -1774,7 +1774,7 @@
1774
1774
  svg path,
1775
1775
  polygon,
1776
1776
  rect {
1777
- fill: ${aS};
1777
+ fill: ${lS};
1778
1778
  }
1779
1779
  }
1780
1780
 
@@ -1899,7 +1899,7 @@
1899
1899
  }
1900
1900
  }
1901
1901
  }
1902
- `;class lS extends t.Component{constructor(){super(...arguments),this.commonFormats=sS,this.customFormats=rS,this.currentFormatName="automatic",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=[]}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onExternalClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return Ag.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}toggleStyle(e){Fr(this.env,{[e]:!this.style[e]})}toggleFormat(e){const t=sS.find((t=>t.name===e)),i=t&&t.value||"";_r(this.env,i)}toggleHorizontalAlign(e){Fr(this.env,{align:e}),this.onClick()}toggleVerticalAlign(e){Fr(this.env,{verticalAlign:e}),this.onClick()}toggleTextWrapping(e){Fr(this.env,{wrapping:e}),this.onClick()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const i=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=i?"":e,this.openedEl=i?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen?this.closeMenus():this.openMenu(e,t)}openMenu(e,t){const{left:i,top:o,height:n}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:i,y:o+n},this.state.menuState.menuItems=e.children(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(),{col:t,row:i,sheetId:o}=this.env.model.getters.getActivePosition();this.inMerge=!1;const{top:n,left:s,right:r,bottom:a}=this.env.model.getters.getSelectedZone(),{xSplit:l,ySplit:c}=this.env.model.getters.getPaneDivisions(o);if(this.cannotMerge=e.length>1||n===a&&s===r||s<l&&l<=r||n<c&&c<=a,!this.cannotMerge){const n=this.env.model.getters.expandZone(o,ro({col:t,row:i}));this.inMerge=ji(e[0],n)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const h=this.env.model.getters.getActiveCell();if(h.format){const e=this.commonFormats.find((e=>e.value===h.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||h.defaultAlign,this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=Yu.getMenuItems()}getMenuName(e){return e.name(this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],i=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:i,target:t}):function(e,t,i){const o=e.model.dispatch("ADD_MERGE",{sheetId:t,target:i});o.isCancelledBecause(80)?e.raiseError(iS.MergeInFilter):o.isCancelledBecause(3)&&e.askConfirmation(iS.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:i,force:!0})}))}(this.env,i,t)}setColor(e,t){Fr(this.env,{[e]:t}),this.onClick()}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e}),this.onClick()}setFormat(e,t){t?this.openCustomFormatSidePanel(e):this.toggleFormat(e),this.onClick()}openCustomFormatSidePanel(e){const t=rS.find((t=>t.name===e)),i=t&&t.sidePanel||"";this.env.openSidePanel(i)}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()})}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!co(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;this.env.model.selection.selectTableAroundSelection();const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();Ir(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}lS.template="o-spreadsheet-TopBar",lS.components={ColorPickerWidget:cg,Menu:Xn,TopBarComposer:oS,FontSizeEditor:nS},lS.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class cS{constructor(e){this.clipboard=e}async write(e){var t;try{null===(t=this.clipboard)||void 0===t||t.write(this.getClipboardItems(e))}catch(e){}}async writeText(e){var t;try{null===(t=this.clipboard)||void 0===t||t.writeText(e)}catch(e){}}async readText(){let e;try{e=await navigator.permissions.query({name:"clipboard-read"})}catch(e){}try{return{status:"ok",content:await this.clipboard.readText()}}catch(t){return{status:"denied"===(null==e?void 0:e.state)?"permissionDenied":"notImplemented"}}}getClipboardItems(e){return[new ClipboardItem({[rn.PlainText]:this.getBlob(e,rn.PlainText),[rn.Html]:this.getBlob(e,rn.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}po`
1902
+ `;class cS extends t.Component{constructor(){super(...arguments),this.commonFormats=rS,this.customFormats=aS,this.currentFormatName="automatic",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=[]}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onExternalClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return Mg.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}toggleStyle(e){Dr(this.env,{[e]:!this.style[e]})}toggleFormat(e){const t=rS.find((t=>t.name===e)),i=t&&t.value||"";Fr(this.env,i)}toggleHorizontalAlign(e){Dr(this.env,{align:e}),this.onClick()}toggleVerticalAlign(e){Dr(this.env,{verticalAlign:e}),this.onClick()}toggleTextWrapping(e){Dr(this.env,{wrapping:e}),this.onClick()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const i=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=i?"":e,this.openedEl=i?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen?this.closeMenus():this.openMenu(e,t)}openMenu(e,t){const{left:i,top:o,height:n}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:i,y:o+n},this.state.menuState.menuItems=e.children(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(),{col:t,row:i,sheetId:o}=this.env.model.getters.getActivePosition();this.inMerge=!1;const{top:n,left:s,right:r,bottom:a}=this.env.model.getters.getSelectedZone(),{xSplit:l,ySplit:c}=this.env.model.getters.getPaneDivisions(o);if(this.cannotMerge=e.length>1||n===a&&s===r||s<l&&l<=r||n<c&&c<=a,!this.cannotMerge){const n=this.env.model.getters.expandZone(o,ao({col:t,row:i}));this.inMerge=Xi(e[0],n)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const h=this.env.model.getters.getActiveCell();if(h.format){const e=this.commonFormats.find((e=>e.value===h.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||h.defaultAlign,this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=Ku.getMenuItems()}getMenuName(e){return e.name(this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],i=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:i,target:t}):function(e,t,i){const o=e.model.dispatch("ADD_MERGE",{sheetId:t,target:i});o.isCancelledBecause(80)?e.raiseError(oS.MergeInFilter):o.isCancelledBecause(3)&&e.askConfirmation(oS.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:i,force:!0})}))}(this.env,i,t)}setColor(e,t){Dr(this.env,{[e]:t}),this.onClick()}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e}),this.onClick()}setFormat(e,t){t?this.openCustomFormatSidePanel(e):this.toggleFormat(e),this.onClick()}openCustomFormatSidePanel(e){const t=aS.find((t=>t.name===e)),i=t&&t.sidePanel||"";this.env.openSidePanel(i)}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()})}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!ho(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;this.env.model.selection.selectTableAroundSelection();const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();Rr(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}cS.template="o-spreadsheet-TopBar",cS.components={ColorPickerWidget:hg,Menu:Yn,TopBarComposer:nS,FontSizeEditor:sS},cS.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class hS{constructor(e){this.clipboard=e}async write(e){var t;try{null===(t=this.clipboard)||void 0===t||t.write(this.getClipboardItems(e))}catch(e){}}async writeText(e){var t;try{null===(t=this.clipboard)||void 0===t||t.writeText(e)}catch(e){}}async readText(){let e;try{e=await navigator.permissions.query({name:"clipboard-read"})}catch(e){}try{return{status:"ok",content:await this.clipboard.readText()}}catch(t){return{status:"denied"===(null==e?void 0:e.state)?"permissionDenied":"notImplemented"}}}getClipboardItems(e){return[new ClipboardItem({[an.PlainText]:this.getBlob(e,an.PlainText),[an.Html]:this.getBlob(e,an.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}mo`
1903
1903
  .o-spreadsheet {
1904
1904
  position: relative;
1905
1905
  display: grid;
@@ -1943,7 +1943,7 @@
1943
1943
  height: ${15}px;
1944
1944
  vertical-align: sub;
1945
1945
  }
1946
- `,po`
1946
+ `,mo`
1947
1947
  .o-grid {
1948
1948
  position: relative;
1949
1949
  overflow: hidden;
@@ -1972,23 +1972,23 @@
1972
1972
  outline: none;
1973
1973
  }
1974
1974
  }
1975
- `;class hS extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){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",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new Gb(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:hS._t,clipboard:this.env.clipboard||new cS(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e)}),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:s("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()}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}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}}hS.template="o-spreadsheet-Spreadsheet",hS.components={TopBar:lS,Grid:pp,BottomBar:Qb,SidePanel:tS,SpreadsheetDashboard:eS},hS._t=e=>e,hS.props={model:Object};class dS{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 uS(e){return vr.get(e.type)(e)}function gS(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class pS{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 i of this.operations){if(i.id===e)return e;if(i.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 i=this.buildTransformation.with(e.data),{before:o,operation:n,after:s}=this.locateOperation(t);this.operations=[...o,n,e,...s.map((e=>e.transformed(i)))]}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 pS(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:i}=this.locateOperation(e);this.operations=t.concat([i])}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 mS{constructor(e,t){this.id=e,this.data=t}transformed(e){return new fS(this.id,rt((()=>e(this.data))))}}class fS{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new fS(this.id,this.lazyData.map(e))}}class vS{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new vS(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new vS(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new vS(function*(e,t){let i=!0;for(const o of e)i||(yield o),o.operation.id===t&&(i=!1)}(this.operations,e))}}class bS{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 vS(We(this._execution(e),this._execution(e)))}revertedExecution(e){return new vS(We(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const o=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);o&&this.branchingOperationIds.set(n,o),this.insertBranchAfter(e,n),this.transform(n,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const o=this.buildTransformation.without(i.data),n=t.fork(i.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(o);const s=this.nextBranch(n);s&&this.rebaseUp(s)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const o=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(o&&n)if(e.getFirstOperationAmong(i,o)===o){const s=this.addToNextBranch(e,n,o,t,i);this.updateNextWith(n,s,i)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,i,o,n){let s=o;return n===i?(s=this.getTransformedOperation(e,i,o),t.prepend(s)):t.contains(n)?(s=this.getTransformedOperation(e,i,o),t.insert(s,n)):t.append(o),s}getTransformedOperation(e,t,i){const o=e.getOperation(t),n=this.buildTransformation.without(o.data);return i.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:o,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!o||!n)return;const s=this.buildTransformation.with(n.data),r=e.fork(i);r.transform(s),o.cutAfter(i),o.appendBranch(r);const a=t.transformed(s);this.insertPrevious(o,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{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 i=!!t;const o=e.getOperations();for(let n=o.length-1;n>=0;n--){const s=o[n];s.id===t&&(i=!1),i||(yield{operation:s,branch:e,isCancelled:!this.shouldExecute(e,s)})}const n=this.previousBranch(e);yield*n?this._revertedExecution(n):[]}*_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 SS{constructor(e,t,i,o,n){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=o,this.buildTransformation=n,this.HEAD_BRANCH=new pS(this.buildTransformation),this.tree=new bS(n,this.HEAD_BRANCH);const s=new mS(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,s),this.HEAD_OPERATION=s}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new mS(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,i),this.HEAD_BRANCH=o,this.HEAD_OPERATION=i}insert(e,t,i){const o=new mS(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,i),this.fastForward()}undo(e,t,i){const{branch:o,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}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:i,isCancelled:o}of e)o||this.revertOperation(i.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:i,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function CS(e,t,i){return new SS(e,(e=>{const o=e.commands.slice(),{changes:n}=t((()=>{for(const e of o)i(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){ES(t.changes[e],"before")}}([e])),(e=>new bb(e,"empty",[],[])),{with:e=>t=>new bb(t.id,t.clientId,fb(t.commands,e.commands)),without:e=>t=>new bb(t.id,t.clientId,fb(t.commands,e.commands.map(uS).flat()))})}function ES(e,t){let i=e.root,o=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===i[o]){const n=e.path[t+1];i[o]=gS(n)}i=i[o]}void 0===e[t]?delete i[o]:i[o]=e[t]}class wS 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 yS{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 i,o,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&this.mainSubscription.owner!==e&&(null===(n=(o=this.mainSubscription.callbacks).release)||void 0===n||n.call(o)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.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 xS{constructor(e){this.getters=e,this.stream=new yS,this.anchor={cell:{col:0,row:0},zone:ro({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}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){return this.modifyAnchor(e,"overrideSelection","ZonesSelected")}modifyAnchor(e,t,i){const o=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(o,e.zone)},this.processEvent({type:i,anchor:e,mode:t})}selectCell(e,t){const i=ro({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new un(83);const{col:i,row:o}=this.getNextAvailablePosition(e,t);return this.selectCell(i,o)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:o,row:n}=this.anchor.cell,s={left:Math.min(o,e),top:Math.min(n,t),right:Math.max(o,e),bottom:Math.max(n,t)},r={zone:this.getters.expandZone(i,s),cell:{col:o,row:n}};return this.processEvent({type:"AlterZone",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:i,col:e,row:t}));const o=this.getters.expandZone(i,ro({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:o,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new un(83);const i=this.getters.getActiveSheetId(),o=this.anchor,{col:n,row:s}=o.cell,{left:r,right:a,top:l,bottom:c}=o.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return un.Success;let g=o.zone;const p=e=>{e=so(e);const{left:t,right:o,top:n,bottom:s}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(i)-1,s)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(v-1),f);g=r+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?so(g):g,g&&!ji(g,o.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:s}}})}g=p(qi({top:s,bottom:s,left:n,right:n},so({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:n,row:s}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberRows(i)-1;let n={left:e,right:e,top:0,bottom:o};const s=this.getters.findFirstVisibleColRowIndex(i,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=s;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=qi(n,{left:r,right:r,top:s,bottom:o})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberCols(i)-1;let n={top:e,bottom:e,left:0,right:o};const s=this.getters.findFirstVisibleColRowIndex(i,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=s,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=qi(n,{left:s,right:o,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(ji(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:ro(t.cell)},"updateAnchor","AlterZone");const i=this.expandZoneToTable(t.zone);return ct(i,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:i},"updateAnchor","AlterZone")}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor","AlterZone")}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:_e(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new un(i):(this.anchor=t.anchor,this.stream.send(t),un.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!Yi(t.col,t.row,i))return 16;const{left:o,right:n,top:s,bottom:r}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",o,n);return void 0===this.getters.findVisibleHeader(a,"ROW",s,r)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(n("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:o}=this.anchor.cell,n=this.deltaToTarget({col:i,row:o},e,t);return{col:this.getNextAvailableCol(n[0],i,o),row:this.getNextAvailableRow(n[1],i,o)}}getNextAvailableCol(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(o,t,i,e,i)))}getNextAvailableRow(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,n,(e=>this.getters.isInSameMerge(o,t,i,t,e)))}getNextAvailableHeader(e,t,i,o,n){const s=this.getters.getActiveSheetId();if(0===e)return i;const r=Math.sign(e);let a=i+e;for(;n(a);)a+=r;for(;this.getters.isHeaderHidden(s,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(s,t)-1?this.getters.isHeaderHidden(s,t,i)?this.getNextAvailableHeader(-r,t,i,o,n):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:o,top:n,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",i,o)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",n,s)||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const o=this.anchor.zone;switch(e){case"down":case"up":i=i===o.top?o.bottom:o.top;break;case"left":case"right":t=t===o.right?o.left:o.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const o=this.getters.getActiveSheet();let n=e;const s=this.getNextCellPosition(e,t,i);let r=this.isCellEmpty(n,o.id)||this.isCellEmpty(s,o.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,i);if(n.col===e.col&&n.row===e.row)break;const s=this.isCellEmpty(e,o.id);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){n=e;break}n=e}return"cols"===t?n.col:n.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const o=this.getters.getMainCellPosition({sheetId:i,col:e,row:t});return this.getters.getEvaluatedCell(o).type===sn.empty}getNextCellPosition(e,t,i){const o="cols"===t?"col":"row",n={...e},s="cols"===t?this.getNextAvailableCol(i,n.col,n.row):this.getNextAvailableRow(i,n.col,n.row);return n[o]=s,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of He(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 He(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};let i=!1,o=e;do{i=!1;const e=t(o);ji(o,e)||(i=!0,o=e)}while(i);return o}}class IS{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(),[i,...o]=e;let n=i,s=o[o.length-1];for(let e=0;e<=o.length-2;e++){const t=o[e];if(void 0===n[t]){const i=o[e+1];n[t]=gS(i)}n=n[t]}n[s]!==t&&(this.changes.push({root:i,path:o,before:n[s],after:t}),void 0===t?delete n[s]:n[s]=t)}}const RS=17781237,TS=88853993;function AS(e,t,i){const o=[["xmlns:r",xp],["xmlns:a",Cp],["xmlns:c",Ep]],n=MS({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=Jf``;e.data.title&&(s=Jf`
1975
+ `;class dS extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){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",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new qb(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:dS._t,clipboard:this.env.clipboard||new hS(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e)}),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:s("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()}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}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}}dS.template="o-spreadsheet-Spreadsheet",dS.components={TopBar:cS,Grid:mp,BottomBar:Jb,SidePanel:iS,SpreadsheetDashboard:tS},dS._t=e=>e,dS.props={model:Object};class uS{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 gS(e){return br.get(e.type)(e)}function pS(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class mS{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 i of this.operations){if(i.id===e)return e;if(i.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 i=this.buildTransformation.with(e.data),{before:o,operation:n,after:s}=this.locateOperation(t);this.operations=[...o,n,e,...s.map((e=>e.transformed(i)))]}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 mS(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:i}=this.locateOperation(e);this.operations=t.concat([i])}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 fS{constructor(e,t){this.id=e,this.data=t}transformed(e){return new vS(this.id,at((()=>e(this.data))))}}class vS{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new vS(this.id,this.lazyData.map(e))}}class bS{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new bS(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new bS(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new bS(function*(e,t){let i=!0;for(const o of e)i||(yield o),o.operation.id===t&&(i=!1)}(this.operations,e))}}class SS{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 bS(Ge(this._execution(e),this._execution(e)))}revertedExecution(e){return new bS(Ge(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const o=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);o&&this.branchingOperationIds.set(n,o),this.insertBranchAfter(e,n),this.transform(n,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const o=this.buildTransformation.without(i.data),n=t.fork(i.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(o);const s=this.nextBranch(n);s&&this.rebaseUp(s)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const o=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(o&&n)if(e.getFirstOperationAmong(i,o)===o){const s=this.addToNextBranch(e,n,o,t,i);this.updateNextWith(n,s,i)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,i,o,n){let s=o;return n===i?(s=this.getTransformedOperation(e,i,o),t.prepend(s)):t.contains(n)?(s=this.getTransformedOperation(e,i,o),t.insert(s,n)):t.append(o),s}getTransformedOperation(e,t,i){const o=e.getOperation(t),n=this.buildTransformation.without(o.data);return i.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:o,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!o||!n)return;const s=this.buildTransformation.with(n.data),r=e.fork(i);r.transform(s),o.cutAfter(i),o.appendBranch(r);const a=t.transformed(s);this.insertPrevious(o,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{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 i=!!t;const o=e.getOperations();for(let n=o.length-1;n>=0;n--){const s=o[n];s.id===t&&(i=!1),i||(yield{operation:s,branch:e,isCancelled:!this.shouldExecute(e,s)})}const n=this.previousBranch(e);yield*n?this._revertedExecution(n):[]}*_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 CS{constructor(e,t,i,o,n){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=o,this.buildTransformation=n,this.HEAD_BRANCH=new mS(this.buildTransformation),this.tree=new SS(n,this.HEAD_BRANCH);const s=new fS(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,s),this.HEAD_OPERATION=s}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new fS(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,i),this.HEAD_BRANCH=o,this.HEAD_OPERATION=i}insert(e,t,i){const o=new fS(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,i),this.fastForward()}undo(e,t,i){const{branch:o,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}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:i,isCancelled:o}of e)o||this.revertOperation(i.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:i,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function ES(e,t,i){return new CS(e,(e=>{const o=e.commands.slice(),{changes:n}=t((()=>{for(const e of o)i(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){wS(t.changes[e],"before")}}([e])),(e=>new Sb(e,"empty",[],[])),{with:e=>t=>new Sb(t.id,t.clientId,vb(t.commands,e.commands)),without:e=>t=>new Sb(t.id,t.clientId,vb(t.commands,e.commands.map(gS).flat()))})}function wS(e,t){let i=e.root,o=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===i[o]){const n=e.path[t+1];i[o]=pS(n)}i=i[o]}void 0===e[t]?delete i[o]:i[o]=e[t]}class yS 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 xS{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 i,o,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&this.mainSubscription.owner!==e&&(null===(n=(o=this.mainSubscription.callbacks).release)||void 0===n||n.call(o)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.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 IS{constructor(e){this.getters=e,this.stream=new xS,this.anchor={cell:{col:0,row:0},zone:ao({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}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){return this.modifyAnchor(e,"overrideSelection","ZonesSelected")}modifyAnchor(e,t,i){const o=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(o,e.zone)},this.processEvent({type:i,anchor:e,mode:t})}selectCell(e,t){const i=ao({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new gn(83);const{col:i,row:o}=this.getNextAvailablePosition(e,t);return this.selectCell(i,o)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:o,row:n}=this.anchor.cell,s={left:Math.min(o,e),top:Math.min(n,t),right:Math.max(o,e),bottom:Math.max(n,t)},r={zone:this.getters.expandZone(i,s),cell:{col:o,row:n}};return this.processEvent({type:"AlterZone",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:i,col:e,row:t}));const o=this.getters.expandZone(i,ao({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:o,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new gn(83);const i=this.getters.getActiveSheetId(),o=this.anchor,{col:n,row:s}=o.cell,{left:r,right:a,top:l,bottom:c}=o.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return gn.Success;let g=o.zone;const p=e=>{e=ro(e);const{left:t,right:o,top:n,bottom:s}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(i)-1,s)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(v-1),f);g=r+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?ro(g):g,g&&!Xi(g,o.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:s}}})}g=p(Zi({top:s,bottom:s,left:n,right:n},ro({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:n,row:s}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberRows(i)-1;let n={left:e,right:e,top:0,bottom:o};const s=this.getters.findFirstVisibleColRowIndex(i,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=s;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=Zi(n,{left:r,right:r,top:s,bottom:o})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberCols(i)-1;let n={top:e,bottom:e,left:0,right:o};const s=this.getters.findFirstVisibleColRowIndex(i,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=s,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=Zi(n,{left:s,right:o,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(Xi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:ao(t.cell)},"updateAnchor","AlterZone");const i=this.expandZoneToTable(t.zone);return ht(i,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:i},"updateAnchor","AlterZone")}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor","AlterZone")}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}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:Fe(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new gn(i):(this.anchor=t.anchor,this.stream.send(t),gn.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!Ki(t.col,t.row,i))return 16;const{left:o,right:n,top:s,bottom:r}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",o,n);return void 0===this.getters.findVisibleHeader(a,"ROW",s,r)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(n("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:o}=this.anchor.cell,n=this.deltaToTarget({col:i,row:o},e,t);return{col:this.getNextAvailableCol(n[0],i,o),row:this.getNextAvailableRow(n[1],i,o)}}getNextAvailableCol(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(o,t,i,e,i)))}getNextAvailableRow(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,n,(e=>this.getters.isInSameMerge(o,t,i,t,e)))}getNextAvailableHeader(e,t,i,o,n){const s=this.getters.getActiveSheetId();if(0===e)return i;const r=Math.sign(e);let a=i+e;for(;n(a);)a+=r;for(;this.getters.isHeaderHidden(s,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(s,t)-1?this.getters.isHeaderHidden(s,t,i)?this.getNextAvailableHeader(-r,t,i,o,n):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:o,top:n,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",i,o)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",n,s)||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const o=this.anchor.zone;switch(e){case"down":case"up":i=i===o.top?o.bottom:o.top;break;case"left":case"right":t=t===o.right?o.left:o.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const o=this.getters.getActiveSheet();let n=e;const s=this.getNextCellPosition(e,t,i);let r=this.isCellEmpty(n,o.id)||this.isCellEmpty(s,o.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,i);if(n.col===e.col&&n.row===e.row)break;const s=this.isCellEmpty(e,o.id);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){n=e;break}n=e}return"cols"===t?n.col:n.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const o=this.getters.getMainCellPosition({sheetId:i,col:e,row:t});return this.getters.getEvaluatedCell(o).type===rn.empty}getNextCellPosition(e,t,i){const o="cols"===t?"col":"row",n={...e},s="cols"===t?this.getNextAvailableCol(i,n.col,n.row):this.getNextAvailableRow(i,n.col,n.row);return n[o]=s,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of $e(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 $e(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};let i=!1,o=e;do{i=!1;const e=t(o);Xi(o,e)||(i=!0,o=e)}while(i);return o}}class RS{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(),[i,...o]=e;let n=i,s=o[o.length-1];for(let e=0;e<=o.length-2;e++){const t=o[e];if(void 0===n[t]){const i=o[e+1];n[t]=pS(i)}n=n[t]}n[s]!==t&&(this.changes.push({root:i,path:o,before:n[s],after:t}),void 0===t?delete n[s]:n[s]=t)}}const TS=17781237,AS=88853993;function MS(e,t,i){const o=[["xmlns:r",Ip],["xmlns:a",Ep],["xmlns:c",wp]],n=OS({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=ev``;e.data.title&&(s=ev`
1976
1976
  <c:title>
1977
- ${NS(e.data.title,e.data.fontColor)}
1977
+ ${_S(e.data.title,e.data.fontColor)}
1978
1978
  <c:overlay val="0" />
1979
1979
  </c:title>
1980
- `);let r=Jf``;switch(e.data.type){case"bar":r=function(e){const t=new bs,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=rs(t.next()),r=MS({backgroundColor:s,line:{color:s}});i.push(Jf`
1980
+ `);let r=ev``;switch(e.data.type){case"bar":r=function(e){const t=new Ss,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=as(t.next()),r=OS({backgroundColor:s,line:{color:s}});i.push(ev`
1981
1981
  <c:ser>
1982
1982
  <c:idx val="${o}"/>
1983
1983
  <c:order val="${o}"/>
1984
- ${n.label?Jf`<c:tx>${kS(n.label)}</c:tx>`:""}
1984
+ ${n.label?ev`<c:tx>${LS(n.label)}</c:tx>`:""}
1985
1985
  ${r}
1986
- ${e.labelRange?Jf`<c:cat>${kS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1986
+ ${e.labelRange?ev`<c:cat>${LS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
1987
1987
  <c:val> <!-- x-coordinate values -->
1988
- ${LS(n.range)}
1988
+ ${PS(n.range)}
1989
1989
  </c:val>
1990
1990
  </c:ser>
1991
- `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",s=e.stacked?100:-20;return Jf`
1991
+ `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",s=e.stacked?100:-20;return ev`
1992
1992
  <c:barChart>
1993
1993
  <c:barDir val="col"/>
1994
1994
  <c:grouping val="${n}"/>
@@ -1996,13 +1996,13 @@
1996
1996
  <c:gapWidth val="70"/>
1997
1997
  <!-- each data marker in the series does not have a different color -->
1998
1998
  <c:varyColors val="0"/>
1999
- ${Qf(i)}
2000
- <c:axId val="${RS}" />
1999
+ ${Jf(i)}
2001
2000
  <c:axId val="${TS}" />
2001
+ <c:axId val="${AS}" />
2002
2002
  </c:barChart>
2003
- ${DS("b","c:catAx",RS,TS,{fontColor:e.fontColor})}
2004
- ${DS(o,"c:valAx",TS,RS,{fontColor:e.fontColor})}
2005
- `}(e.data);break;case"line":r=function(e){const t=new bs,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=MS({line:{width:2.5,style:"solid",color:rs(t.next())}});i.push(Jf`
2003
+ ${kS("b","c:catAx",TS,AS,{fontColor:e.fontColor})}
2004
+ ${kS(o,"c:valAx",AS,TS,{fontColor:e.fontColor})}
2005
+ `}(e.data);break;case"line":r=function(e){const t=new Ss,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=OS({line:{width:2.5,style:"solid",color:as(t.next())}});i.push(ev`
2006
2006
  <c:ser>
2007
2007
  <c:idx val="${o}"/>
2008
2008
  <c:order val="${o}"/>
@@ -2011,50 +2011,50 @@
2011
2011
  <c:symbol val="circle" />
2012
2012
  <c:size val="5"/>
2013
2013
  </c:marker>
2014
- ${n.label?Jf`<c:tx>${kS(n.label)}</c:tx>`:""}
2014
+ ${n.label?ev`<c:tx>${LS(n.label)}</c:tx>`:""}
2015
2015
  ${s}
2016
- ${e.labelRange?Jf`<c:cat>${kS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2016
+ ${e.labelRange?ev`<c:cat>${LS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
2017
2017
  <c:val> <!-- x-coordinate values -->
2018
- ${LS(n.range)}
2018
+ ${PS(n.range)}
2019
2019
  </c:val>
2020
2020
  </c:ser>
2021
- `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return Jf`
2021
+ `)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return ev`
2022
2022
  <c:lineChart>
2023
2023
  <c:grouping val="${n}"/>
2024
2024
  <!-- each data marker in the series does not have a different color -->
2025
2025
  <c:varyColors val="0"/>
2026
- ${Qf(i)}
2027
- <c:axId val="${RS}" />
2026
+ ${Jf(i)}
2028
2027
  <c:axId val="${TS}" />
2028
+ <c:axId val="${AS}" />
2029
2029
  </c:lineChart>
2030
- ${DS("b","c:catAx",RS,TS,{fontColor:e.fontColor})}
2031
- ${DS(o,"c:valAx",TS,RS,{fontColor:e.fontColor})}
2032
- `}(e.data);break;case"pie":r=function(e,t,i,{holeSize:o}={holeSize:50}){const n=new bs,s=Math.max(...e.dataSets.map((e=>xf(e.range,t,i)))),r=He(0,s).map((()=>rs(n.next()))),a=[];for(const[o,n]of Object.entries(e.dataSets).reverse()){const s=xf(n.range,t,i),l=[];for(const e of He(0,s)){const t=MS({backgroundColor:r[e],line:{color:"FFFFFF",width:1.5}});l.push(Jf`
2030
+ ${kS("b","c:catAx",TS,AS,{fontColor:e.fontColor})}
2031
+ ${kS(o,"c:valAx",AS,TS,{fontColor:e.fontColor})}
2032
+ `}(e.data);break;case"pie":r=function(e,t,i,{holeSize:o}={holeSize:50}){const n=new Ss,s=Math.max(...e.dataSets.map((e=>If(e.range,t,i)))),r=$e(0,s).map((()=>as(n.next()))),a=[];for(const[o,n]of Object.entries(e.dataSets).reverse()){const s=If(n.range,t,i),l=[];for(const e of $e(0,s)){const t=OS({backgroundColor:r[e],line:{color:"FFFFFF",width:1.5}});l.push(ev`
2033
2033
  <c:dPt>
2034
2034
  <c:idx val="${e}"/>
2035
2035
  ${t}
2036
2036
  </c:dPt>
2037
- `)}a.push(Jf`
2037
+ `)}a.push(ev`
2038
2038
  <c:ser>
2039
2039
  <c:idx val="${o}"/>
2040
2040
  <c:order val="${o}"/>
2041
- ${n.label?Jf`<c:tx>${kS(n.label)}</c:tx>`:""}
2042
- ${Qf(l)}
2043
- ${FS({showLeaderLines:!0})}
2044
- ${e.labelRange?Jf`<c:cat>${kS(e.labelRange)}</c:cat>`:""}
2041
+ ${n.label?ev`<c:tx>${LS(n.label)}</c:tx>`:""}
2042
+ ${Jf(l)}
2043
+ ${DS({showLeaderLines:!0})}
2044
+ ${e.labelRange?ev`<c:cat>${LS(e.labelRange)}</c:cat>`:""}
2045
2045
  <c:val>
2046
- ${LS(n.range)}
2046
+ ${PS(n.range)}
2047
2047
  </c:val>
2048
2048
  </c:ser>
2049
- `)}return Jf`
2049
+ `)}return ev`
2050
2050
  <c:doughnutChart>
2051
2051
  <c:varyColors val="1" />
2052
2052
  <c:holeSize val="${o}" />
2053
- ${FS()}
2054
- ${Qf(a)}
2053
+ ${DS()}
2054
+ ${Jf(a)}
2055
2055
  </c:doughnutChart>
2056
- `}(e.data,t,i,{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=Jf`
2057
- <c:chartSpace ${Xf(o)}>
2056
+ `}(e.data,t,i,{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=ev`
2057
+ <c:chartSpace ${Yf(o)}>
2058
2058
  <c:roundedCorners val="0" />
2059
2059
  <!-- <manualLayout/> to manually position the chart in the figure container -->
2060
2060
  ${n}
@@ -2065,32 +2065,32 @@
2065
2065
  <!-- how the chart element is placed on the chart -->
2066
2066
  <c:layout />
2067
2067
  ${r}
2068
- ${MS({backgroundColor:e.data.backgroundColor})}
2068
+ ${OS({backgroundColor:e.data.backgroundColor})}
2069
2069
  </c:plotArea>
2070
- ${function(e,t){return Jf`
2070
+ ${function(e,t){return ev`
2071
2071
  <c:legend>
2072
2072
  <c:legendPos val="${e}"/>
2073
2073
  <c:overlay val="0"/>
2074
- ${_S(10,t)}
2074
+ ${FS(10,t)}
2075
2075
  </c:legend>
2076
2076
  `}(a,l)}
2077
2077
  </c:chart>
2078
2078
  </c:chartSpace>
2079
- `;return Yf(c)}function MS(e){return Jf`
2079
+ `;return Kf(c)}function OS(e){return ev`
2080
2080
  <c:spPr>
2081
- ${e.backgroundColor?OS(e.backgroundColor):""}
2082
- ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",yf(e.width)]);const i=e.style?Jf`<a:prstDash val="${e.style}"/>`:"";return Jf`
2083
- <a:ln ${Xf(t)}>
2084
- ${OS(e.color)}
2081
+ ${e.backgroundColor?NS(e.backgroundColor):""}
2082
+ ${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",xf(e.width)]);const i=e.style?ev`<a:prstDash val="${e.style}"/>`:"";return ev`
2083
+ <a:ln ${Yf(t)}>
2084
+ ${NS(e.color)}
2085
2085
  ${i}
2086
2086
  </a:ln>
2087
2087
  `}(e.line):""}
2088
2088
  </c:spPr>
2089
- `}function OS(e){return Jf`
2089
+ `}function NS(e){return ev`
2090
2090
  <a:solidFill>
2091
2091
  <a:srgbClr val="${e}"/>
2092
2092
  </a:solidFill>
2093
- `}function NS(e,t="000000",i=22){return Jf`
2093
+ `}function _S(e,t="000000",i=22){return ev`
2094
2094
  <c:tx>
2095
2095
  <c:rich>
2096
2096
  <a:bodyPr />
@@ -2098,7 +2098,7 @@
2098
2098
  <a:p>
2099
2099
  <a:pPr lvl="0">
2100
2100
  <a:defRPr b="0">
2101
- ${OS(t)}
2101
+ ${NS(t)}
2102
2102
  <a:latin typeface="+mn-lt"/>
2103
2103
  </a:defRPr>
2104
2104
  </a:pPr>
@@ -2109,20 +2109,20 @@
2109
2109
  </a:p>
2110
2110
  </c:rich>
2111
2111
  </c:tx>
2112
- `}function _S(e=12,t="000000",i=!1,o=!1){return Jf`
2112
+ `}function FS(e=12,t="000000",i=!1,o=!1){return ev`
2113
2113
  <c:txPr>
2114
2114
  <a:bodyPr/>
2115
2115
  <a:lstStyle/>
2116
2116
  <a:p>
2117
2117
  <a:pPr lvl="0">
2118
- <a:defRPr ${Xf([["b",i?"1":"0"],["i",o?"1":"0"],["sz",100*e]])}>
2119
- ${OS(t)}
2118
+ <a:defRPr ${Yf([["b",i?"1":"0"],["i",o?"1":"0"],["sz",100*e]])}>
2119
+ ${NS(t)}
2120
2120
  <a:latin typeface="+mn-lt"/>
2121
2121
  </a:defRPr>
2122
2122
  </a:pPr>
2123
2123
  </a:p>
2124
2124
  </c:txPr>
2125
- `}function FS({showLeaderLines:e}={showLeaderLines:!1}){return Jf`
2125
+ `}function DS({showLeaderLines:e}={showLeaderLines:!1}){return ev`
2126
2126
  <dLbls>
2127
2127
  <c:showLegendKey val="0"/>
2128
2128
  <c:showVal val="0"/>
@@ -2132,7 +2132,7 @@
2132
2132
  <c:showBubbleSize val="0"/>
2133
2133
  <c:showLeaderLines val="${e?"1":"0"}"/>
2134
2134
  </dLbls>
2135
- `}function DS(e,t,i,o,{fontColor:n}){return Jf`
2135
+ `}function kS(e,t,i,o,{fontColor:n}){return ev`
2136
2136
  <${t}>
2137
2137
  <c:axId val="${i}"/>
2138
2138
  <c:crossAx val="${o}"/> <!-- reference to the other axe of the chart -->
@@ -2141,62 +2141,62 @@
2141
2141
  <c:orientation val="minMax" />
2142
2142
  </c:scaling>
2143
2143
  <c:axPos val="${e}" />
2144
- ${function(e="B7B7B7"){return Jf`
2144
+ ${function(e="B7B7B7"){return ev`
2145
2145
  <c:majorGridlines>
2146
- ${MS({line:{color:e}})}
2146
+ ${OS({line:{color:e}})}
2147
2147
  </c:majorGridlines>
2148
2148
  `}()}
2149
2149
  <c:majorTickMark val="out" />
2150
2150
  <c:minorTickMark val="none" />
2151
2151
  <c:numFmt formatCode="General" sourceLinked="1" />
2152
2152
  <c:title>
2153
- ${NS("")}
2153
+ ${_S("")}
2154
2154
  </c:title>
2155
- ${_S(10,n)}
2155
+ ${FS(10,n)}
2156
2156
  </${t}>
2157
2157
  <!-- <tickLblPos/> omitted -->
2158
- `}function kS(e){return Jf`
2158
+ `}function LS(e){return ev`
2159
2159
  <c:strRef>
2160
2160
  <c:f>${e}</c:f>
2161
2161
  </c:strRef>
2162
- `}function LS(e){return Jf`
2162
+ `}function PS(e){return ev`
2163
2163
  <c:numRef>
2164
2164
  <c:f>${e}</c:f>
2165
2165
  <c:numCache />
2166
2166
  </c:numRef>
2167
- `}function PS(e){const t=e.content,i=ju.content,o=[];let n=Jf``;if(Im(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported))){let i=Jf``;const s=VS(t);return e.value===a.CircularDependency&&(o.push(["t","str"]),i=Jf`<v>${e.value}</v>`),n=Jf`
2167
+ `}function US(e){const t=e.content,i=Xu.content,o=[];let n=ev``;if(Rm(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported))){let i=ev``;const s=zS(t);return e.value===a.CircularDependency&&(o.push(["t","str"]),i=ev`<v>${e.value}</v>`),n=ev`
2168
2168
  <f>
2169
2169
  ${s}
2170
2170
  </f>
2171
2171
  ${i}
2172
- `,{attrs:o,node:n}}{const t=e.value,i=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);return o.push(["t",i]),n=Jf`<v>${t}</v>`,{attrs:o,node:n}}}function US(e,t,i=!1){let o=e;const n=[];if(!i&&["TRUE","FALSE"].includes(o.trim()))o="TRUE"===o?"1":"0",n.push(["t","b"]);else if(i||!ti(o)){const{id:i}=bf(e,t);o=i.toString(),n.push(["t","s"])}return{attrs:n,node:Jf`<v>${o}</v>`}}function VS(e){let t;"="===e[0]&&(e=e.slice(1));try{t=qm(e)}catch(t){return e}return t=jm(t,"STRING",zS),t=jm(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),i=e.args,o=_p[t];if(o){const n=ju.content[t].args.filter((e=>!e.optional)),s=n.length-e.args.length;if(s)for(let t=e.args.length;t<n.length;t++){const e=o[t-s];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:Fp.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?Xm(t):e}function zS(e){const t=e.value.replace(new RegExp('"',"g"),""),i=Ce(t);if(i){let o=[];return(t.match(ve)||t.match(be))&&o.push("yyyy-mm-dd"),t.match(Se)&&o.push("hh:mm:ss"),{...e,value:gi(i.value,o.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function BS(e,t){const i=[];for(const o of t)switch(o.rule.type){case"CellIsRule":i.push(HS(o,o.rule,e));break;case"ColorScaleRule":i.push($S(o,o.rule));break;case"IconSetRule":i.push(WS(o,o.rule));break;default:console.warn(`Conditional formatting ${o.rule.type} not implemented`)}return i}function HS(e,t,i){const o=GS(e),n=df(t.operator);o.push(...function(e){const t=df(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",n]);const s=function(e,t){const i=e[0].split(":")[0],o=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${o[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${o[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${o[0]}"))="${o[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${o[0]}"))="${o[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[o[0]];case"Between":case"NotBetween":return[o[0],o[1]]}}(e.ranges,t).map((e=>Jf`<formula>${e}</formula>`)),r={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&&(r.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=bf(r,i);return o.push(["dxfId",a]),Jf`
2172
+ `,{attrs:o,node:n}}{const t=e.value,i=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);return o.push(["t",i]),n=ev`<v>${t}</v>`,{attrs:o,node:n}}}function VS(e,t,i=!1){let o=e;const n=[];if(!i&&["TRUE","FALSE"].includes(o.trim()))o="TRUE"===o?"1":"0",n.push(["t","b"]);else if(i||!ii(o)){const{id:i}=Sf(e,t);o=i.toString(),n.push(["t","s"])}return{attrs:n,node:ev`<v>${o}</v>`}}function zS(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Zm(e)}catch(t){return e}return t=Xm(t,"STRING",BS),t=Xm(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),i=e.args,o=Fp[t];if(o){const n=Xu.content[t].args.filter((e=>!e.optional)),s=n.length-e.args.length;if(s)for(let t=e.args.length;t<n.length;t++){const e=o[t-s];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:Dp.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?Ym(t):e}function BS(e){const t=e.value.replace(new RegExp('"',"g"),""),i=Ee(t);if(i){let o=[];return(t.match(ve)||t.match(be))&&o.push("yyyy-mm-dd"),t.match(Se)&&o.push("hh:mm:ss"),{...e,value:pi(i.value,o.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function HS(e,t){const i=[];for(const o of t)switch(o.rule.type){case"CellIsRule":i.push($S(o,o.rule,e));break;case"ColorScaleRule":i.push(WS(o,o.rule));break;case"IconSetRule":i.push(GS(o,o.rule));break;default:console.warn(`Conditional formatting ${o.rule.type} not implemented`)}return i}function $S(e,t,i){const o=qS(e),n=uf(t.operator);o.push(...function(e){const t=uf(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",n]);const s=function(e,t){const i=e[0].split(":")[0],o=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${o[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${o[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${o[0]}"))="${o[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${o[0]}"))="${o[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[o[0]];case"Between":case"NotBetween":return[o[0],o[1]]}}(e.ranges,t).map((e=>ev`<formula>${e}</formula>`)),r={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&&(r.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=Sf(r,i);return o.push(["dxfId",a]),ev`
2173
2173
  <conditionalFormatting sqref="${e.ranges.join(" ")}">
2174
- <cfRule ${Xf(o)}>
2175
- ${Qf(s)}
2174
+ <cfRule ${Yf(o)}>
2175
+ ${Jf(s)}
2176
2176
  </cfRule>
2177
2177
  </conditionalFormatting>
2178
- `}function $S(e,t){const i=GS(e);i.push(["type","colorScale"]);const o=[];for(const n of e.ranges){const e=[],s=[];let r=!0;for(let i of["minimum","midpoint","maximum"]){const o=t[i];o&&("formula"!==o.type?(e.push(ZS(o,i)),s.push([["rgb",rs(Ct(o.color))]])):r=!1)}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>Jf`<cfvo ${Xf(e)}/>`)),l=s.map((e=>Jf`<color ${Xf(e)}/>`));o.push(Jf`
2178
+ `}function WS(e,t){const i=qS(e);i.push(["type","colorScale"]);const o=[];for(const n of e.ranges){const e=[],s=[];let r=!0;for(let i of["minimum","midpoint","maximum"]){const o=t[i];o&&("formula"!==o.type?(e.push(jS(o,i)),s.push([["rgb",as(Et(o.color))]])):r=!1)}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>ev`<cfvo ${Yf(e)}/>`)),l=s.map((e=>ev`<color ${Yf(e)}/>`));o.push(ev`
2179
2179
  <conditionalFormatting sqref="${n}">
2180
- <cfRule ${Xf(i)}>
2180
+ <cfRule ${Yf(i)}>
2181
2181
  <colorScale>
2182
- ${Qf(a)}
2183
- ${Qf(l)}
2182
+ ${Jf(a)}
2183
+ ${Jf(l)}
2184
2184
  </colorScale>
2185
2185
  </cfRule>
2186
2186
  </conditionalFormatting>
2187
- `)}return Qf(o)}function WS(e,t){const i=GS(e);i.push(["type","iconSet"]);const o=[];for(const n of e.ranges){const e=[[["type","percent"],["val",0]]];let s=!0;for(let i of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[i].type){s=!1;continue}const o=t[i];e.push([...ZS(o,i),["gte","ge"===o.operator?"1":"0"]])}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const r=e.map((e=>Jf`<cfvo ${Xf(e)} />`));o.push(Jf`
2187
+ `)}return Jf(o)}function GS(e,t){const i=qS(e);i.push(["type","iconSet"]);const o=[];for(const n of e.ranges){const e=[[["type","percent"],["val",0]]];let s=!0;for(let i of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[i].type){s=!1;continue}const o=t[i];e.push([...jS(o,i),["gte","ge"===o.operator?"1":"0"]])}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const r=e.map((e=>ev`<cfvo ${Yf(e)} />`));o.push(ev`
2188
2188
  <conditionalFormatting sqref="${n}">
2189
- <cfRule ${Xf(i)}>
2190
- <iconSet iconSet="${qS(t.icons)}">
2191
- ${Qf(r)}
2189
+ <cfRule ${Yf(i)}>
2190
+ <iconSet iconSet="${ZS(t.icons)}">
2191
+ ${Jf(r)}
2192
2192
  </iconSet>
2193
2193
  </cfRule>
2194
2194
  </conditionalFormatting>
2195
- `)}return Qf(o)}function GS(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function qS(e){return bp[Object.keys(bp).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function ZS(e,t){const i=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),o=[["type",i]];if("min"!==i&&"max"!==i){let t=e.value;if("formula"===i)try{t=VS(e.value)}catch(i){t=e.value}o.push(["val",t])}return o}function jS(e,t,i){const o=[["xmlns:xdr",Sp.drawing],["xmlns:r",xp],["xmlns:a",Cp],["xmlns:c",Ep]],n=[];for(const[o,s]of Object.entries(i))switch(null==s?void 0:s.tag){case"chart":n.push(KS(s,t,e[o]));break;case"image":n.push(QS(s,t,e[o]))}return Yf(Jf`
2196
- <xdr:wsDr ${Xf(o)}>
2197
- ${Qf(n)}
2195
+ `)}return Jf(o)}function qS(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function ZS(e){return Sp[Object.keys(Sp).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function jS(e,t){const i=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),o=[["type",i]];if("min"!==i&&"max"!==i){let t=e.value;if("formula"===i)try{t=zS(e.value)}catch(i){t=e.value}o.push(["val",t])}return o}function XS(e,t,i){const o=[["xmlns:xdr",Cp.drawing],["xmlns:r",Ip],["xmlns:a",Ep],["xmlns:c",wp]],n=[];for(const[o,s]of Object.entries(i))switch(null==s?void 0:s.tag){case"chart":n.push(QS(s,t,e[o]));break;case"image":n.push(JS(s,t,e[o]))}return Kf(ev`
2196
+ <xdr:wsDr ${Yf(o)}>
2197
+ ${Jf(n)}
2198
2198
  </xdr:wsDr>
2199
- `)}function XS(e,t){const{x:i,y:o,height:n,width:s}=e,r=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=YS(r,i),{index:h,offset:d}=YS(r,i+s),{index:u,offset:g}=YS(a,o),{index:p,offset:m}=YS(a,o+n);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function YS(e,t){let i=0;for(const[o,n]of Object.entries(e)){if(i<=t&&t<i+n.size)return{index:parseInt(o),offset:yf(t-i+W)};i+=n.size}return{index:e.length-1,offset:yf(t-i+W)}}function KS(e,t,i){const{from:o,to:n}=XS(e,t),s=Cf(e.id),r=[["id",s],["name",`Chart ${s}`],["title","Chart"]];return Jf`
2199
+ `)}function YS(e,t){const{x:i,y:o,height:n,width:s}=e,r=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=KS(r,i),{index:h,offset:d}=KS(r,i+s),{index:u,offset:g}=KS(a,o),{index:p,offset:m}=KS(a,o+n);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function KS(e,t){let i=0;for(const[o,n]of Object.entries(e)){if(i<=t&&t<i+n.size)return{index:parseInt(o),offset:xf(t-i+W)};i+=n.size}return{index:e.length-1,offset:xf(t-i+W)}}function QS(e,t,i){const{from:o,to:n}=YS(e,t),s=Ef(e.id),r=[["id",s],["name",`Chart ${s}`],["title","Chart"]];return ev`
2200
2200
  <xdr:twoCellAnchor>
2201
2201
  <xdr:from>
2202
2202
  <xdr:col>${o.col}</xdr:col>
@@ -2212,7 +2212,7 @@
2212
2212
  </xdr:to>
2213
2213
  <xdr:graphicFrame>
2214
2214
  <xdr:nvGraphicFramePr>
2215
- <xdr:cNvPr ${Xf(r)} />
2215
+ <xdr:cNvPr ${Yf(r)} />
2216
2216
  <xdr:cNvGraphicFramePr />
2217
2217
  </xdr:nvGraphicFramePr>
2218
2218
  <xdr:xfrm>
@@ -2220,14 +2220,14 @@
2220
2220
  <a:ext cx="0" cy="0"/>
2221
2221
  </xdr:xfrm>
2222
2222
  <a:graphic>
2223
- <a:graphicData uri="${Ep}">
2223
+ <a:graphicData uri="${wp}">
2224
2224
  <c:chart r:id="${i}" />
2225
2225
  </a:graphicData>
2226
2226
  </a:graphic>
2227
2227
  </xdr:graphicFrame>
2228
2228
  <xdr:clientData fLocksWithSheet="0"/>
2229
2229
  </xdr:twoCellAnchor>
2230
- `}function QS(e,t,i){const{from:o,to:n}=XS(e,t),s=wf(e.id),r=[["id",s],["name",`Image ${s}`],["title","Image"]];return Jf`
2230
+ `}function JS(e,t,i){const{from:o,to:n}=YS(e,t),s=yf(e.id),r=[["id",s],["name",`Image ${s}`],["title","Image"]];return ev`
2231
2231
  <xdr:twoCellAnchor editAs="oneCell">
2232
2232
  <xdr:from>
2233
2233
  <xdr:col>${o.col}</xdr:col>
@@ -2243,7 +2243,7 @@
2243
2243
  </xdr:to>
2244
2244
  <xdr:pic>
2245
2245
  <xdr:nvPicPr>
2246
- <xdr:cNvPr ${Xf(r)}/>
2246
+ <xdr:cNvPr ${Yf(r)}/>
2247
2247
  <xdr:cNvPicPr preferRelativeResize="0"/>
2248
2248
  </xdr:nvPicPr>
2249
2249
  <xdr:blipFill>
@@ -2261,69 +2261,69 @@
2261
2261
  </xdr:pic>
2262
2262
  <xdr:clientData fLocksWithSheet="0"/>
2263
2263
  </xdr:twoCellAnchor>
2264
- `}function JS(e){return ot(e)?Jf``:Jf`
2264
+ `}function eC(e){return nt(e)?ev``:ev`
2265
2265
  <font>
2266
- ${e.bold?Jf`<b />`:""}
2267
- ${e.italic?Jf`<i />`:""}
2268
- ${e.underline?Jf`<u />`:""}
2269
- ${e.strike?Jf`<strike />`:""}
2270
- ${e.size?Jf`<sz val="${e.size}" />`:""}
2271
- ${e.color&&e.color.rgb?Jf`<color rgb="${rs(e.color.rgb)}" />`:""}
2272
- ${e.name?Jf`<name val="${e.name}" />`:""}
2266
+ ${e.bold?ev`<b />`:""}
2267
+ ${e.italic?ev`<i />`:""}
2268
+ ${e.underline?ev`<u />`:""}
2269
+ ${e.strike?ev`<strike />`:""}
2270
+ ${e.size?ev`<sz val="${e.size}" />`:""}
2271
+ ${e.color&&e.color.rgb?ev`<color rgb="${as(e.color.rgb)}" />`:""}
2272
+ ${e.name?ev`<name val="${e.name}" />`:""}
2273
2273
  </font>
2274
- `}function eC(e){return e?Xf([["style",e.style],["color",rs(e.color.rgb)]]):Jf``}const tC=Jf`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function iC(e,t,i){const o=Jf`
2275
- <table ${Xf([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",Sp.table],["xmlns:xr",Sp.revision],["xmlns:xr3",Sp.revision3],["xmlns:mc",Sp.markupCompatibility]])}>
2276
- ${function(e){const t=[["ref",e.range]];return Jf`
2277
- <autoFilter ${Xf(t)}>
2278
- ${Qf(function(e){const t=[];for(const i of e.filters){const e=Jf`
2279
- <filterColumn ${Xf([["colId",i.colId]])}>
2280
- ${oC(i)}
2274
+ `}function tC(e){return e?Yf([["style",e.style],["color",as(e.color.rgb)]]):ev``}const iC=ev`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function oC(e,t,i){const o=ev`
2275
+ <table ${Yf([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",Cp.table],["xmlns:xr",Cp.revision],["xmlns:xr3",Cp.revision3],["xmlns:mc",Cp.markupCompatibility]])}>
2276
+ ${function(e){const t=[["ref",e.range]];return ev`
2277
+ <autoFilter ${Yf(t)}>
2278
+ ${Jf(function(e){const t=[];for(const i of e.filters){const e=ev`
2279
+ <filterColumn ${Yf([["colId",i.colId]])}>
2280
+ ${nC(i)}
2281
2281
  </filterColumn>
2282
2282
  `;t.push(e)}return t}(e))}
2283
2283
  </autoFilter>
2284
2284
  `}(e)}
2285
- ${function(e,t){var i;const o=Vi(e.range),n=[];for(const e of He(0,eo(o).numberOfCols)){const s=Wt(o.left+e,o.top),r=[["id",e+1],["name",(null===(i=t.cells[s])||void 0===i?void 0:i.content)||`col${e}`]];n.push(Jf`<tableColumn ${Xf(r)}/>`)}return Jf`
2286
- <tableColumns ${Xf([["count",n.length]])}>
2287
- ${Qf(n)}
2285
+ ${function(e,t){var i;const o=zi(e.range),n=[];for(const e of $e(0,to(o).numberOfCols)){const s=Gt(o.left+e,o.top),r=[["id",e+1],["name",(null===(i=t.cells[s])||void 0===i?void 0:i.content)||`col${e}`]];n.push(ev`<tableColumn ${Yf(r)}/>`)}return ev`
2286
+ <tableColumns ${Yf([["count",n.length]])}>
2287
+ ${Jf(n)}
2288
2288
  </tableColumns>
2289
2289
  `}(e,i)}
2290
- ${tC}
2290
+ ${iC}
2291
2291
  </table>
2292
- `;return Yf(o)}function oC(e){const t=e.displayedValues.map((e=>Jf`<filter ${Xf([["val",e]])}/>`));return Jf`
2293
- <filters ${Xf(e.displayBlanks?[["blank",1]]:[])}>
2294
- ${Qf(t)}
2292
+ `;return Kf(o)}function nC(e){const t=e.displayedValues.map((e=>ev`<filter ${Yf([["val",e]])}/>`));return ev`
2293
+ <filters ${Yf(e.displayBlanks?[["blank",1]]:[])}>
2294
+ ${Jf(t)}
2295
2295
  </filters>
2296
- `}function nC(e){if(!Object.values(e).length)return Jf``;const t=[];for(let[i,o]of Object.entries(e)){const e=[["min",parseInt(i)+1],["max",parseInt(i)+1],["width",gf(o.size||F)],["customWidth",1],["hidden",o.isHidden?1:0]];t.push(Jf`
2297
- <col ${Xf(e)}/>
2298
- `)}return Jf`
2296
+ `}function sC(e){if(!Object.values(e).length)return ev``;const t=[];for(let[i,o]of Object.entries(e)){const e=[["min",parseInt(i)+1],["max",parseInt(i)+1],["width",pf(o.size||F)],["customWidth",1],["hidden",o.isHidden?1:0]];t.push(ev`
2297
+ <col ${Yf(e)}/>
2298
+ `)}return ev`
2299
2299
  <cols>
2300
- ${Qf(t)}
2300
+ ${Jf(t)}
2301
2301
  </cols>
2302
- `}function sC(e,t,i){const o=[];for(let n=0;n<i.rowNumber;n++){const s=[["r",n+1]],r=i.rows[n]||{};s.push(["ht",uf(r.size||D)],["customHeight",1],["hidden",r.isHidden?1:0]);const a=[];for(let o=0;o<i.colNumber;o++){const s=Wt(o,n),r=i.cells[s];if(r){const l=[["r",s]],c=ff(e,mf(r,t));l.push(["s",c]);let h=[],d=Jf``;if(r.isFormula)({attrs:h,node:d}=PS(r));else if(r.content&&je(r.content)){const{label:t}=Ke(r.content);({attrs:h,node:d}=US(t,e.sharedStrings))}else if(r.content&&""!==r.content){const t=rC(o,n,i);({attrs:h,node:d}=US(r.content,e.sharedStrings,t))}l.push(...h),a.push(Jf`
2303
- <c ${Xf(l)}>
2302
+ `}function rC(e,t,i){const o=[];for(let n=0;n<i.rowNumber;n++){const s=[["r",n+1]],r=i.rows[n]||{};s.push(["ht",gf(r.size||D)],["customHeight",1],["hidden",r.isHidden?1:0]);const a=[];for(let o=0;o<i.colNumber;o++){const s=Gt(o,n),r=i.cells[s];if(r){const l=[["r",s]],c=vf(e,ff(r,t));l.push(["s",c]);let h=[],d=ev``;if(r.isFormula)({attrs:h,node:d}=US(r));else if(r.content&&Xe(r.content)){const{label:t}=Qe(r.content);({attrs:h,node:d}=VS(t,e.sharedStrings))}else if(r.content&&""!==r.content){const t=aC(o,n,i);({attrs:h,node:d}=VS(r.content,e.sharedStrings,t))}l.push(...h),a.push(ev`
2303
+ <c ${Yf(l)}>
2304
2304
  ${d}
2305
2305
  </c>
2306
- `)}}(a.length||r.size!==D||r.isHidden)&&o.push(Jf`
2307
- <row ${Xf(s)}>
2308
- ${Qf(a)}
2306
+ `)}}(a.length||r.size!==D||r.isHidden)&&o.push(ev`
2307
+ <row ${Yf(s)}>
2308
+ ${Jf(a)}
2309
2309
  </row>
2310
- `)}return Jf`
2310
+ `)}return ev`
2311
2311
  <sheetData>
2312
- ${Qf(o)}
2312
+ ${Jf(o)}
2313
2313
  </sheetData>
2314
- `}function rC(e,t,i){return i.filterTables.some((i=>{const o=Vi(i.range),n={...o,bottom:o.top};return Yi(e,t,n)}))}function aC(e,t,i){var o;const n=t.sheets[i].cells,s=[];for(const r in n){const a=null===(o=n[r])||void 0===o?void 0:o.content;if(a&&je(a)){const{label:o,url:n}=Ke(a);if(Je(n)){const e=tt(n),i=t.sheets.find((t=>t.id===e)),a=i?`${i.name}!A1`:K;s.push(Jf`
2314
+ `}function aC(e,t,i){return i.filterTables.some((i=>{const o=zi(i.range),n={...o,bottom:o.top};return Ki(e,t,n)}))}function lC(e,t,i){var o;const n=t.sheets[i].cells,s=[];for(const r in n){const a=null===(o=n[r])||void 0===o?void 0:o.content;if(a&&Xe(a)){const{label:o,url:n}=Qe(a);if(et(n)){const e=it(n),i=t.sheets.find((t=>t.id===e)),a=i?`${i.name}!A1`:K;s.push(ev`
2315
2315
  <hyperlink display="${o}" location="${a}" ref="${r}"/>
2316
- `)}else{const t=vf(e.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:xo(n),type:yp.hyperlink,targetMode:"External"});s.push(Jf`
2316
+ `)}else{const t=bf(e.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:Io(n),type:xp.hyperlink,targetMode:"External"});s.push(ev`
2317
2317
  <hyperlink r:id="${t}" ref="${r}"/>
2318
- `)}}}return s.length?Jf`
2318
+ `)}}}return s.length?ev`
2319
2319
  <hyperlinks>
2320
- ${Qf(s)}
2320
+ ${Jf(s)}
2321
2321
  </hyperlinks>
2322
- `:Jf``}function lC(e){if(e.length){const t=e.map((e=>Jf`<mergeCell ref="${e}" />`));return Jf`
2322
+ `:ev``}function cC(e){if(e.length){const t=e.map((e=>ev`<mergeCell ref="${e}" />`));return ev`
2323
2323
  <mergeCells count="${e.length}">
2324
- ${Qf(t)}
2324
+ ${Jf(t)}
2325
2325
  </mergeCells>
2326
- `}return Jf``}function cC(e){const t=e.panes;let i=Jf``;if(t&&(t.xSplit||t.ySplit)){const e=Wt(t.xSplit,t.ySplit),o=t.xSplit?Jf`xSplit="${t.xSplit}"`:"",n=t.ySplit?Jf`ySplit="${t.ySplit}"`:"",s=t.xSplit?Jf`<selection pane="topRight"/>`:"",r=t.ySplit?Jf`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?Jf`<selection pane="bottomRight"/>`:"";i=Jf`
2326
+ `}return ev``}function hC(e){const t=e.panes;let i=ev``;if(t&&(t.xSplit||t.ySplit)){const e=Gt(t.xSplit,t.ySplit),o=t.xSplit?ev`xSplit="${t.xSplit}"`:"",n=t.ySplit?ev`ySplit="${t.ySplit}"`:"",s=t.xSplit?ev`<selection pane="topRight"/>`:"",r=t.ySplit?ev`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?ev`<selection pane="bottomRight"/>`:"";i=ev`
2327
2327
  <pane
2328
2328
  ${o}
2329
2329
  ${n}
@@ -2333,126 +2333,126 @@
2333
2333
  ${s}
2334
2334
  ${r}
2335
2335
  ${a}
2336
- `}return Jf`
2336
+ `}return ev`
2337
2337
  <sheetViews>
2338
2338
  <sheetView showGridLines="${e.areGridLinesVisible?1:0}" workbookViewId="0">
2339
2339
  ${i}
2340
2340
  </sheetView>
2341
2341
  </sheetViews>
2342
- `}function hC(e){const t=[],i={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:q,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const i=[["xmlns",Sp.workbook],["xmlns:r",xp]],o=[];for(const[i,n]of Object.entries(e.sheets)){const e=[["state",n.isVisible?"visible":"hidden"],["name",n.name],["sheetId",parseInt(i)+1],["r:id",`rId${parseInt(i)+1}`]];o.push(Jf`
2343
- <sheet ${Xf(e)} />
2344
- `),vf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:yp.sheet,target:`worksheets/sheet${i}.xml`})}return Zf(Yf(Jf`
2345
- <workbook ${Xf(i)}>
2342
+ `}function dC(e){const t=[],i={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:q,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const i=[["xmlns",Cp.workbook],["xmlns:r",Ip]],o=[];for(const[i,n]of Object.entries(e.sheets)){const e=[["state",n.isVisible?"visible":"hidden"],["name",n.name],["sheetId",parseInt(i)+1],["r:id",`rId${parseInt(i)+1}`]];o.push(ev`
2343
+ <sheet ${Yf(e)} />
2344
+ `),bf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:xp.sheet,target:`worksheets/sheet${i}.xml`})}return jf(Kf(ev`
2345
+ <workbook ${Yf(i)}>
2346
2346
  <sheets>
2347
- ${Qf(o)}
2347
+ ${Jf(o)}
2348
2348
  </sheets>
2349
2349
  </workbook>
2350
- `),"xl/workbook.xml","workbook")}(e,i)),t.push(...function(e,t){const i=[];let o=1;for(const[n,s]of Object.entries(e.sheets)){const r=[["xmlns",Sp.worksheet],["xmlns:r",xp]],a=[["defaultRowHeight",uf(D)],["defaultColWidth",gf(F)]],l=dC(s,n,o,t,i);o+=s.filterTables.length;let c=Jf``;const h=[];for(const o of s.charts){const s=Cf(o.id),r=vf(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../charts/chart${s}.xml`,type:yp.chart});h.push(r),i.push(Zf(AS(o,n,e),`xl/charts/chart${s}.xml`,"chart"))}for(const e of s.images){const o=e.data.mimetype;if(void 0===o)continue;const s=em[o];if(void 0===s)continue;let r=`image${wf(e.id)}.${s}`;const a=vf(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../media/${r}`,type:yp.image});h.push(a),i.push({path:`xl/media/${r}`,imageSrc:e.data.path})}const d=[...s.charts,...s.images];if(d.length){const e=vf(t.relsFiles,`xl/worksheets/_rels/sheet${n}.xml.rels`,{target:`../drawings/drawing${n}.xml`,type:yp.drawing});i.push(Zf(jS(h,s,d),`xl/drawings/drawing${n}.xml`,"drawing")),c=Jf`<drawing r:id="${e}" />`}const u=Jf`
2351
- <worksheet ${Xf(r)}>
2352
- ${cC(s)}
2353
- <sheetFormatPr ${Xf(a)} />
2354
- ${nC(s.cols)}
2355
- ${sC(t,e,s)}
2356
- ${lC(s.merges)}
2357
- ${Qf(BS(t.dxfs,s.conditionalFormats))}
2358
- ${aC(t,e,n)}
2350
+ `),"xl/workbook.xml","workbook")}(e,i)),t.push(...function(e,t){const i=[];let o=1;for(const[n,s]of Object.entries(e.sheets)){const r=[["xmlns",Cp.worksheet],["xmlns:r",Ip]],a=[["defaultRowHeight",gf(D)],["defaultColWidth",pf(F)]],l=uC(s,n,o,t,i);o+=s.filterTables.length;let c=ev``;const h=[];for(const o of s.charts){const s=Ef(o.id),r=bf(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../charts/chart${s}.xml`,type:xp.chart});h.push(r),i.push(jf(MS(o,n,e),`xl/charts/chart${s}.xml`,"chart"))}for(const e of s.images){const o=e.data.mimetype;if(void 0===o)continue;const s=tm[o];if(void 0===s)continue;let r=`image${yf(e.id)}.${s}`;const a=bf(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../media/${r}`,type:xp.image});h.push(a),i.push({path:`xl/media/${r}`,imageSrc:e.data.path})}const d=[...s.charts,...s.images];if(d.length){const e=bf(t.relsFiles,`xl/worksheets/_rels/sheet${n}.xml.rels`,{target:`../drawings/drawing${n}.xml`,type:xp.drawing});i.push(jf(XS(h,s,d),`xl/drawings/drawing${n}.xml`,"drawing")),c=ev`<drawing r:id="${e}" />`}const u=ev`
2351
+ <worksheet ${Yf(r)}>
2352
+ ${hC(s)}
2353
+ <sheetFormatPr ${Yf(a)} />
2354
+ ${sC(s.cols)}
2355
+ ${rC(t,e,s)}
2356
+ ${cC(s.merges)}
2357
+ ${Jf(HS(t.dxfs,s.conditionalFormats))}
2358
+ ${lC(t,e,n)}
2359
2359
  ${c}
2360
2360
  ${l}
2361
2361
  </worksheet>
2362
- `;i.push(Zf(Yf(u),`xl/worksheets/sheet${n}.xml`,"sheet"))}return vf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:yp.sharedStrings,target:"sharedStrings.xml"}),vf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:yp.styles,target:"styles.xml"}),i}(e,i)),t.push(function(e){const t=Jf`
2363
- <styleSheet ${Xf([["xmlns",Sp.styleSheet],["xmlns:r",xp]])}>
2364
- ${function(e){const t=[];for(let[i,o]of Object.entries(e)){const e=[["numFmtId",parseInt(i)+Np],["formatCode",o.format]];t.push(Jf`
2365
- <numFmt ${Xf(e)}/>
2366
- `)}return Jf`
2362
+ `;i.push(jf(Kf(u),`xl/worksheets/sheet${n}.xml`,"sheet"))}return bf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:xp.sharedStrings,target:"sharedStrings.xml"}),bf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:xp.styles,target:"styles.xml"}),i}(e,i)),t.push(function(e){const t=ev`
2363
+ <styleSheet ${Yf([["xmlns",Cp.styleSheet],["xmlns:r",Ip]])}>
2364
+ ${function(e){const t=[];for(let[i,o]of Object.entries(e)){const e=[["numFmtId",parseInt(i)+_p],["formatCode",o.format]];t.push(ev`
2365
+ <numFmt ${Yf(e)}/>
2366
+ `)}return ev`
2367
2367
  <numFmts count="${e.length}">
2368
- ${Qf(t)}
2368
+ ${Jf(t)}
2369
2369
  </numFmts>
2370
2370
  `}(e.numFmts)}
2371
- ${i=e.fonts,Jf`
2371
+ ${i=e.fonts,ev`
2372
2372
  <fonts count="${i.length}">
2373
- ${Qf(Object.values(i).map(JS))}
2373
+ ${Jf(Object.values(i).map(eC))}
2374
2374
  </fonts>
2375
2375
  `}
2376
- ${function(e){const t=[];for(let i of Object.values(e))void 0!==i.reservedAttribute?t.push(Jf`
2376
+ ${function(e){const t=[];for(let i of Object.values(e))void 0!==i.reservedAttribute?t.push(ev`
2377
2377
  <fill>
2378
2378
  <patternFill patternType="${i.reservedAttribute}" />
2379
2379
  </fill>
2380
- `):t.push(Jf`
2380
+ `):t.push(ev`
2381
2381
  <fill>
2382
2382
  <patternFill patternType="solid">
2383
- <fgColor rgb="${rs(i.fgColor.rgb)}" />
2383
+ <fgColor rgb="${as(i.fgColor.rgb)}" />
2384
2384
  <bgColor indexed="64" />
2385
2385
  </patternFill>
2386
2386
  </fill>
2387
- `);return Jf`
2387
+ `);return ev`
2388
2388
  <fills count="${e.length}">
2389
- ${Qf(t)}
2389
+ ${Jf(t)}
2390
2390
  </fills>
2391
2391
  `}(e.fills)}
2392
- ${function(e){const t=[];for(let i of Object.values(e))t.push(Jf`
2392
+ ${function(e){const t=[];for(let i of Object.values(e))t.push(ev`
2393
2393
  <border>
2394
- <left ${eC(i.left)} />
2395
- <right ${eC(i.right)} />
2396
- <top ${eC(i.top)} />
2397
- <bottom ${eC(i.bottom)} />
2398
- <diagonal ${eC(i.diagonal)} />
2394
+ <left ${tC(i.left)} />
2395
+ <right ${tC(i.right)} />
2396
+ <top ${tC(i.top)} />
2397
+ <bottom ${tC(i.bottom)} />
2398
+ <diagonal ${tC(i.diagonal)} />
2399
2399
  </border>
2400
- `);return Jf`
2400
+ `);return ev`
2401
2401
  <borders count="${e.length}">
2402
- ${Qf(t)}
2402
+ ${Jf(t)}
2403
2403
  </borders>
2404
2404
  `}(e.borders)}
2405
- ${function(e){const t=[];for(let i of e){const e=[["numFmtId",i.numFmtId],["fillId",i.fillId],["fontId",i.fontId],["borderId",i.borderId]],o=[];i.alignment&&i.alignment.vertical&&o.push(["vertical",i.alignment.vertical]),i.alignment&&i.alignment.horizontal&&o.push(["horizontal",i.alignment.horizontal]),t.push(Jf`
2406
- <xf ${Xf(e)}>
2407
- ${o?Jf`<alignment ${Xf(o)} />`:""}
2405
+ ${function(e){const t=[];for(let i of e){const e=[["numFmtId",i.numFmtId],["fillId",i.fillId],["fontId",i.fontId],["borderId",i.borderId]],o=[];i.alignment&&i.alignment.vertical&&o.push(["vertical",i.alignment.vertical]),i.alignment&&i.alignment.horizontal&&o.push(["horizontal",i.alignment.horizontal]),t.push(ev`
2406
+ <xf ${Yf(e)}>
2407
+ ${o?ev`<alignment ${Yf(o)} />`:""}
2408
2408
  </xf>
2409
- `)}return Jf`
2409
+ `)}return ev`
2410
2410
  <cellXfs count="${e.length}">
2411
- ${Qf(t)}
2411
+ ${Jf(t)}
2412
2412
  </cellXfs>
2413
2413
  `}(e.styles)}
2414
- ${function(e){const t=[];for(const i of e){let e=Jf``;i.font&&(e=JS(i.font));let o=Jf``;i.fill&&(o=Jf`
2414
+ ${function(e){const t=[];for(const i of e){let e=ev``;i.font&&(e=eC(i.font));let o=ev``;i.fill&&(o=ev`
2415
2415
  <fill>
2416
2416
  <patternFill>
2417
- <bgColor rgb="${rs(i.fill.fgColor.rgb)}" />
2417
+ <bgColor rgb="${as(i.fill.fgColor.rgb)}" />
2418
2418
  </patternFill>
2419
2419
  </fill>
2420
- `),t.push(Jf`
2420
+ `),t.push(ev`
2421
2421
  <dxf>
2422
2422
  ${e}
2423
2423
  ${o}
2424
2424
  </dxf>
2425
- `)}return Jf`
2425
+ `)}return ev`
2426
2426
  <dxfs count="${e.length}">
2427
- ${Qf(t)}
2427
+ ${Jf(t)}
2428
2428
  </dxfs>
2429
2429
  `}(e.dxfs)}
2430
2430
  </styleSheet>
2431
- `;var i;return Zf(Yf(t),"xl/styles.xml","styles")}(i)),t.push(function(e){const t=[["xmlns",Sp.sst],["count",e.length],["uniqueCount",e.length]],i=e.map((e=>Jf`<si><t>${e}</t></si>`));return Zf(Yf(Jf`
2432
- <sst ${Xf(t)}>
2433
- ${Qf(i)}
2431
+ `;var i;return jf(Kf(t),"xl/styles.xml","styles")}(i)),t.push(function(e){const t=[["xmlns",Cp.sst],["count",e.length],["uniqueCount",e.length]],i=e.map((e=>ev`<si><t>${e}</t></si>`));return jf(Kf(ev`
2432
+ <sst ${Yf(t)}>
2433
+ ${Jf(i)}
2434
2434
  </sst>
2435
- `),"xl/sharedStrings.xml","sharedStrings")}(i.sharedStrings)),t.push(...function(e){const t=[];for(const i of e){const e=[];for(const t of i.rels){const i=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&i.push(["TargetMode",t.targetMode]),e.push(Jf`
2436
- <Relationship ${Xf(i)} />
2437
- `)}const o=Jf`
2438
- <Relationships xmlns="${Sp.Relationships}">
2439
- ${Qf(e)}
2435
+ `),"xl/sharedStrings.xml","sharedStrings")}(i.sharedStrings)),t.push(...function(e){const t=[];for(const i of e){const e=[];for(const t of i.rels){const i=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&i.push(["TargetMode",t.targetMode]),e.push(ev`
2436
+ <Relationship ${Yf(i)} />
2437
+ `)}const o=ev`
2438
+ <Relationships xmlns="${Cp.Relationships}">
2439
+ ${Jf(e)}
2440
2440
  </Relationships>
2441
- `;t.push(Zf(Yf(o),i.path))}return t}(i.relsFiles)),t.push(function(e){const t=[],i=Object.entries(em).map((([e,t])=>function(e,t){return Jf`
2441
+ `;t.push(jf(Kf(o),i.path))}return t}(i.relsFiles)),t.push(function(e){const t=[],i=Object.entries(tm).map((([e,t])=>function(e,t){return ev`
2442
2442
  <Default Extension="${e}" ContentType="${t}" />
2443
- `}(t,e)));for(const i of e)"contentType"in i&&i.contentType&&t.push(Kf("/"+i.path,wp[i.contentType]));return Zf(Yf(Jf`
2444
- <Types xmlns="${Sp.Types}">
2445
- ${Qf(Object.values(i))}
2443
+ `}(t,e)));for(const i of e)"contentType"in i&&i.contentType&&t.push(Qf("/"+i.path,yp[i.contentType]));return jf(Kf(ev`
2444
+ <Types xmlns="${Cp.Types}">
2445
+ ${Jf(Object.values(i))}
2446
2446
  <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
2447
2447
  <Default Extension="xml" ContentType="application/xml" />
2448
- ${Qf(t)}
2448
+ ${Jf(t)}
2449
2449
  </Types>
2450
- `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",yp.document],["Target","xl/workbook.xml"]];return Zf(Yf(Jf`
2451
- <Relationships xmlns="${Sp.Relationships}">
2452
- <Relationship ${Xf(e)} />
2450
+ `),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",xp.document],["Target","xl/workbook.xml"]];return jf(Kf(ev`
2451
+ <Relationships xmlns="${Cp.Relationships}">
2452
+ <Relationship ${Yf(e)} />
2453
2453
  </Relationships>
2454
- `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function dC(e,t,i,o,n){let s=i;if(!e.filterTables.length)return new mp("");const r=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const i=vf(o.relsFiles,r,{target:`../tables/table${s}.xml`,type:yp.table});n.push(Zf(iC(t,s,e),`xl/tables/table${s}.xml`,"table")),a.push(Jf`<tablePart r:id="${i}" />`),s++}return Jf`
2454
+ `),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function uC(e,t,i,o,n){let s=i;if(!e.filterTables.length)return new fp("");const r=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const i=bf(o.relsFiles,r,{target:`../tables/table${s}.xml`,type:xp.table});n.push(jf(oC(t,s,e),`xl/tables/table${s}.xml`,"table")),a.push(ev`<tablePart r:id="${i}" />`),s++}return ev`
2455
2455
  <tableParts count="${e.filterTables.length}">
2456
- ${Qf(a)}
2456
+ ${Jf(a)}
2457
2457
  </tableParts>
2458
- `}var uC;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(uC||(uC={}));const gC={},pC={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:N,HEADER_WIDTH:_,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:F,DEFAULT_CELL_HEIGHT:D,SCROLLBAR_WIDTH:k},mC={autofillModifiersRegistry:xn,autofillRulesRegistry:In,cellMenuRegistry:ra,colMenuRegistry:aa,linkMenuRegistry:is,functionRegistry:ju,featurePluginRegistry:Bb,statefulUIPluginRegistry:Hb,coreViewsPluginRegistry:$b,corePluginRegistry:zb,rowMenuRegistry:la,sidePanelRegistry:Tg,figureRegistry:gr,chartSidePanelComponentRegistry:bg,chartComponentRegistry:lr,chartRegistry:ar,topbarMenuRegistry:Yu,topbarComponentRegistry:Ag,clickableCellRegistry:Wb,otRegistry:Qu,inverseCommandRegistry:vr,urlRegistry:Io,cellPopoverRegistry:ss},fC={arg:da,toBoolean:zo,toJsDate:Bo,toNumber:ko,toString:Po,toXC:Wt,toZone:Vi,toCartesian:$t,numberToLetters:Bt,UuidGenerator:Pi,formatValue:gi,computeTextWidth:Pe,createEmptyWorkbookData:xv,createEmptySheet:yv,createEmptyExcelSheet:Iv,getDefaultChartJsRuntime:ks,chartFontColor:Ss,ChartColors:bs,EvaluationError:c,CellErrorLevel:l,getFillingMode:Vs,rgbaToHex:Rt,colorToRGBA:Tt,positionToZone:ro,isDefined:it,lazy:rt},vC={isMarkdownLink:je,parseMarkdownLink:Ke,markdownLink:Ye,openLink:Oo,urlRepresentation:Mo},bC={ChartPanel:Sg,ChartFigure:hr,ChartJsComponent:ho,Grid:pp,GridOverlay:Qg,ScorecardChart:Co,LineConfigPanel:pg,LineBarPieDesignPanel:hg,BarConfigPanel:ng,LineBarPieConfigPanel:og,GaugeChartConfigPanel:ug,GaugeChartDesignPanel:gg,ScorecardChartConfigPanel:fg,ScorecardChartDesignPanel:vg,FigureComponent:Mg};e.AbstractChart=as,e.CorePlugin=Tv,e.DATETIME_FORMAT=Y,e.DispatchResult=un,e.EvaluationError=c,e.Model=class extends db{constructor(e={},i={},o=[],n=new Pi,s=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={...t,type:e};let o=this.status;if(this.getters.isReadonly()&&(n=i,!cn.has(n.type)))return new un(67);var n;if(!this.session.canApplyOptimisticUpdate())return new un(64);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{dn(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(dn(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i)}this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(dn(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return un.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={...t,type:e},o=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,un.Success},o=Ev(e,o);const r=Sv(e,s);this.state=new IS,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.history=new wS(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new $v(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 xS(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of zb.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of Hb.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t)}for(let e of $b.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.coreHandlers.push(t)}for(let e of Bb.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}const i=e.layers.map((e=>[t,e]));return this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const i=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Cb(CS(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],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:s("Anonymous").toString()},i=e.transportService||new dS;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new un(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=_e(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=xv();for(let t of this.handlers)t instanceof Tv&&t.export(e);return e.revisionId=this.session.getRevisionId()||Q,e=_e(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={...xv(),sheets:[Iv(bv,"Sheet1")]};for(let t of this.handlers)t instanceof Rv&&t.exportForExcel(e);return e=_e(e),hC(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=yo,e.Revision=bb,e.SPREADSHEET_DIMENSIONS=pC,e.Spreadsheet=hS,e.UIPlugin=Gv,e.__info__=gC,e.addFunction=function(e,t){ju.add(e,t)},e.astToFormula=Xm,e.compile=cf,e.components=bC,e.convertAstNodes=jm,e.coreTypes=hn,e.findCellInNewZone=no,e.functionCache=lf,e.helpers=fC,e.invalidateEvaluationCommands=an,e.links=vC,e.load=Sv,e.parse=qm,e.readonlyAllowedCommands=cn,e.registries=mC,e.setTranslationMethod=function(e){i=e},e.tokenize=Im,Object.defineProperty(e,"__esModule",{value:!0}),gC.version="16.2.17",gC.date="2023-10-03T12:42:54.642Z",gC.hash="146867a"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
2458
+ `}var gC;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(gC||(gC={}));const pC={},mC={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:N,HEADER_WIDTH:_,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:F,DEFAULT_CELL_HEIGHT:D,SCROLLBAR_WIDTH:k},fC={autofillModifiersRegistry:In,autofillRulesRegistry:Rn,cellMenuRegistry:aa,colMenuRegistry:la,linkMenuRegistry:os,functionRegistry:Xu,featurePluginRegistry:Hb,statefulUIPluginRegistry:$b,coreViewsPluginRegistry:Wb,corePluginRegistry:Bb,rowMenuRegistry:ca,sidePanelRegistry:Ag,figureRegistry:pr,chartSidePanelComponentRegistry:Sg,chartComponentRegistry:cr,chartRegistry:lr,topbarMenuRegistry:Ku,topbarComponentRegistry:Mg,clickableCellRegistry:Gb,otRegistry:Ju,inverseCommandRegistry:br,urlRegistry:Ro,cellPopoverRegistry:rs},vC={arg:ua,toBoolean:Bo,toJsDate:Ho,toNumber:Lo,toString:Uo,toXC:Gt,toZone:zi,toCartesian:Wt,numberToLetters:Ht,UuidGenerator:Ui,formatValue:pi,computeTextWidth:Ue,createEmptyWorkbookData:Iv,createEmptySheet:xv,createEmptyExcelSheet:Rv,getDefaultChartJsRuntime:Ls,chartFontColor:Cs,ChartColors:Ss,EvaluationError:c,CellErrorLevel:l,getFillingMode:zs,rgbaToHex:Tt,colorToRGBA:At,positionToZone:ao,isDefined:ot,lazy:at},bC={isMarkdownLink:Xe,parseMarkdownLink:Qe,markdownLink:Ke,openLink:No,urlRepresentation:Oo},SC={ChartPanel:Cg,ChartFigure:dr,ChartJsComponent:uo,Grid:mp,GridOverlay:Jg,ScorecardChart:Eo,LineConfigPanel:mg,LineBarPieDesignPanel:dg,BarConfigPanel:sg,LineBarPieConfigPanel:ng,GaugeChartConfigPanel:gg,GaugeChartDesignPanel:pg,ScorecardChartConfigPanel:vg,ScorecardChartDesignPanel:bg,FigureComponent:Og};e.AbstractChart=ls,e.CorePlugin=Av,e.DATETIME_FORMAT=Y,e.DispatchResult=gn,e.EvaluationError=c,e.Model=class extends ub{constructor(e={},i={},o=[],n=new Ui,s=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={...t,type:e};let o=this.status;if(this.getters.isReadonly()&&(n=i,!hn.has(n.type)))return new gn(67);var n;if(!this.session.canApplyOptimisticUpdate())return new gn(64);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{un(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(un(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i)}this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(un(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return gn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={...t,type:e},o=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,gn.Success},o=wv(e,o);const r=Cv(e,s);this.state=new RS,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.history=new yS(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Wv(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 IS(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Bb.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of $b.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t)}for(let e of Wb.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.coreHandlers.push(t)}for(let e of Hb.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}const i=e.layers.map((e=>[t,e]));return this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const i=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Eb(ES(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],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:s("Anonymous").toString()},i=e.transportService||new uS;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return new gn(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Fe(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Iv();for(let t of this.handlers)t instanceof Av&&t.export(e);return e.revisionId=this.session.getRevisionId()||Q,e=Fe(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={...Iv(),sheets:[Rv(Sv,"Sheet1")]};for(let t of this.handlers)t instanceof Tv&&t.exportForExcel(e);return e=Fe(e),dC(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=xo,e.Revision=Sb,e.SPREADSHEET_DIMENSIONS=mC,e.Spreadsheet=dS,e.UIPlugin=qv,e.__info__=pC,e.addFunction=function(e,t){Xu.add(e,t)},e.astToFormula=Ym,e.compile=hf,e.components=SC,e.convertAstNodes=Xm,e.coreTypes=dn,e.findCellInNewZone=so,e.functionCache=cf,e.helpers=vC,e.invalidateEvaluationCommands=ln,e.links=bC,e.load=Cv,e.parse=Zm,e.readonlyAllowedCommands=hn,e.registries=fC,e.setTranslationMethod=function(e){i=e},e.tokenize=Rm,Object.defineProperty(e,"__esModule",{value:!0}),pC.version="16.2.18",pC.date="2023-10-10T07:29:40.321Z",pC.hash="451fa09"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);