@odoo/o-spreadsheet 16.2.2 → 16.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/o-spreadsheet.cjs.js +226 -96
- package/dist/o-spreadsheet.d.ts +14 -7
- package/dist/o-spreadsheet.esm.js +226 -96
- package/dist/o-spreadsheet.iife.js +226 -96
- package/dist/o-spreadsheet.iife.min.js +238 -238
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"use strict";let o=e=>e;function i(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const n=function(e,...t){return i(o(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 i(o(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,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=11982760,x="#01666b",I="#188038",R="#E6F4EA",T="#CEEAD6",A="#E0E2E4",M=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#CC4125","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6D9EEB","#6FA8DC","#8E7CC3","#C27BA0","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#85200C","#990000","#B45F06","#BF9000","#38761D","#134F5C","#1155CC","#0B5394","#351C75","#741B47","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"],O=26,N=48,_=96,F=23,D=15,k=18,P=14,L=4,U=4,V=3,z=U,B=17,H=250,$=1,W="400",G=10,q="'Roboto', arial",Z=["thin","#000"],j=["thin",I],X=/[ymdhs:]/,Y=a.InvalidReference,K="START_REVISION",Q=20,J="??",ee="difference",te="#00A04A",oe="#DC6965",ie=.4,ne=["'","*","?","/","\\","[","]"],se=/'|\*|\?|\/|\\|\[|\]/,re="|",ae=s("Invalid expression");var le;!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"}(le||(le={}));const ce="\n",he=[6,7,8,9,10,11,12,14,18,24,36],de=new Date(1899,11,30),ue=864e5,ge=2e3,pe=(new Date).getFullYear(),me=new Date(0)-de,fe=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ve=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,be=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Se(e){let t;const o=(e=e.trim()).match(be);if(o){if(t=function(e){if(e=e.trim(),be.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),i=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),n=i.length>=2,s=3===i.length;let r=Number(i[0]),a=n?Number(i[1]):0,l=s?Number(i[2]):0,c=s?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!n)return null;r>=12&&t?r-=12:r<12&&o&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,r,a,l)}}return null}(o[0]),null===t)return null;e=e.replace(o[0],"").trim()}let i;const n=e.match(fe),s=e.match(ve);if(n||s){let t;if(n?(t=n[0],i=Ce(t,"mdy")):(t=s[0],i=Ce(t,"ymd")),null===i)return null;e=e.replace(t,"").trim()}return""!==e||!i&&!t?null:i&&t?{value:i.value+t.value,format:i.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(i.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,i.jsDate.getMonth()+t.jsDate.getMonth()-11,i.jsDate.getDate()+t.jsDate.getDate()-30,i.jsDate.getHours()+t.jsDate.getHours(),i.jsDate.getMinutes()+t.jsDate.getMinutes(),i.jsDate.getSeconds()+t.jsDate.getSeconds())}:i||t}function Ce(e,t){const o="mdy"===t;if(o||"ymd"===t){const t=e.split(/\/|-|\s/),i=o?0:1,n=o?1:2,s=o?2:0,r=Number(t[i]),a=Number(t[n]),l=2===t[i].length&&r<10||2===t[n].length&&a<10,c=t[s]?function(e){const t=Number(e);switch(e.length){case 1:return ge+t;case 2:return ge+(ge+t>pe+10?-100:0)+t;case 3:case 4:return t}return 0}(t[s]):pe,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-de;let g=l?`mm${d}dd`:`m${d}d`;return t[s]&&(g=o?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/ue),format:g,jsDate:h}}return null}function Ee(e){const t=Math.trunc(e);let o=new Date(t*ue-me),i=e-t;i=i<0?1+i:i;const n=Math.round(24*i),s=Math.round(24*(i-n/24)*60),r=Math.round(24*(i-n/24-s/24/60)*60*60);return o.setHours(n),o.setMinutes(s),o.setSeconds(r),o}function we(e){const t=e.getTime()-de.getTime();return Math.round(t/ue)}function ye(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function xe(e){return ye(e)===e.getDate()}function Ie(e,t,o){const i=e.getFullYear(),n=e.getMonth(),s=e.getDate(),r=new Date(i,n+t);return o&&s===ye(e)||s>ye(r)?r.setDate(ye(r)):r.setDate(s),r}function Re(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Te(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const i=Ee(e),n=Ee(t);let s=i.getDate(),r=n.getDate();const a=i.getMonth(),l=n.getMonth(),c=i.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(o){case 0:31===s&&(s=30),30===s&&31===r&&(r=30),1===a&&s===(Re(c)?29:28)&&(s=30,1===l&&r===(Re(h)?29:28)&&(r=30)),d=c+(30*a+s)/360,u=h+(30*l+r)/360;break;case 1:let o=365;const i=c===h;if(!i&&!(c+1===h)||!i&&a<l||!i&&a===l&&s<r){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Re(o)?366:365;o=t/e}else i?Re(c)&&(o=366):(Re(c)&&a<2&&(o=366),Re(h)&&(l>1||1===l&&29===r)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===s&&(s=30),31===r&&(r=30),d=c+(30*a+s)/360,u=h+(30*l+r)/360}return u-d}function Ae(e){return JSON.stringify(e,Object.keys(e).sort())}function Me(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&(null==e?void 0:e.constructor)===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ne(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function _e(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function Fe(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function De(e,t,o){return e<t?t:e>o?o:e}function ke(e,t=1){return t*(e+U)-U}function Pe(e,t,o){e.save(),e.font=Ue(o);const i=e.measureText(t).width;return e.restore(),i}function Le(e){return Math.round(96*e/72)}function Ue(e){return`${e.italic?"italic ":""}${e.bold?"bold":W} ${Ve(e)}px ${q}`}function Ve(e){return Le((null==e?void 0:e.fontSize)||G)}function ze(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/o)),n=Array(i);for(let t=0;t<i;t++)n[t]=e+t*o;return n}function Be(e){return e.reduce(((e,t,o,i)=>{if(1===Math.abs(t-i[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*He(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}function $e(e){return null!==Se(e)}const We=/^\[([^\[]+)\]\((.+)\)$/,Ge=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function qe(e){return We.test(e)}function Ze(e){return Ge.test(e)}function je(e,t){return`[${e}](${t})`}function Xe(e){const t=e.match(We)||[],o=t[1],i=t[2];if(!o||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:i}}const Ye="o-spreadsheet://";function Ke(e){return e.startsWith(Ye)}function Qe(e){return`${Ye}${e}`}function Je(e){if(e.startsWith(Ye))return e.substr(Ye.length);throw new Error(`${e} is not a valid sheet link`)}function et(e){return void 0!==e}function tt(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?tt(e):!e))}function ot(e,t){for(let[o,i]of Object.entries(t))if(Ae(i)===Ae(e))return parseInt(o,10);const o=Object.keys(t),i=0===o.length?0:Math.max(...o.map((e=>parseInt(e,10))));return t[i+1]=e,i+1}function it(e){let t="";for(let o=0,i=e.length;o<i;o++)t+=e[o];return t}function nt(e){let t,o=!1;const i=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return i.map=e=>nt((()=>e(i()))),i}function st(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function rt(e,t){return"after"===e?t+1:t}function at(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let i of o){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!at(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function lt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function ct(e){return e?e.toLowerCase():""}const ht=[" ","\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))],dt=new RegExp(ht.join("|"),"g"),ut=/\r\n|\r|\n/g;function gt(e){return e?e=(e=e.replace(dt," ")).replace(ut,ce):""}const pt=/rgba?\(|\s+|\)/gi,mt=/^#([A-F\d]{2}){3,4}$/g,ft=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function vt(e){return bt(e.toString(16).padStart(6,"0"))}function bt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(pt,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const i=t.map((e=>parseInt(e,10)));255!==o&&i.push(o);return"#"+it(i.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(mt))throw new Error(`invalid color input: ${e}`);return t}function St(e){try{return bt(e),!0}catch(e){return!1}}const Ct=e=>e>=0&&e<=255;function Et(e,t,o,i=1){if(!Ct(e)||!Ct(t)||!Ct(o)||i<0||i>1)throw new Error(`Invalid RGBA values ${[e,t,o,i]}`);return{a:i,b:o,g:t,r:e}}function wt(e){let{r:t,g:o,b:i}=xt(e);t/=255,o/=255,i/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(o)+.0722*n(i)}function yt(e){let t=e.r.toString(16),o=e.g.toString(16),i=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1==t.length&&(t="0"+t),1==o.length&&(o="0"+o),1==i.length&&(i="0"+i),1==n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+o+i+n).toUpperCase()}function xt(e){let t,o,i,n;if(7===(e=bt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=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),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:o,b:i}}function It(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),i=e.l-t/2,n=0,s=0,r=0;return 0<=e.h&&e.h<60?(n=t,s=o,r=0):60<=e.h&&e.h<120?(n=o,s=t,r=0):120<=e.h&&e.h<180?(n=0,s=t,r=o):180<=e.h&&e.h<240?(n=0,s=o,r=t):240<=e.h&&e.h<300?(n=o,s=0,r=t):300<=e.h&&e.h<360&&(n=t,s=0,r=o),n=Math.round(255*(n+i)),s=Math.round(255*(s+i)),r=Math.round(255*(r+i)),{a:e.a,r:n,g:s,b:r}}function Rt(e){const t=e.r/255,o=e.g/255,i=e.b/255;let n=Math.min(t,o,i),s=Math.max(t,o,i),r=s-n,a=0,l=0,c=0;return a=0==r?0:s==t?(o-i)/r%6:s==o?(i-t)/r+2:(t-o)/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 Tt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),At=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Mt=new RegExp(/^([A-Z]{1,3})+$/,"i"),Ot=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Nt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),_t=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[Tt.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 Ft(e){return Ot.test(e)}function Dt(e){return Nt.test(e)}function kt(e){return Mt.test(e)}function Pt(e){return At.test(e)}function Lt(e){const t=e.split("!"),o=t.pop();return{sheetName:_e(t.join("!"))||void 0,xc:o}}function Ut(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Ut(Math.floor(e/26)-1)+Ut(e%26)}function Vt(e){let t=0;const o=e.length;for(let i=0;i<o;i++){t+=(e.charCodeAt(i)-65+(i<o-1?1:0))*26**(o-i-1)}return t}function zt(e){const t=(e=e.toUpperCase().trim()).match(Tt);if(null!==t){const[o,i,n]=t;if(o===e){return{col:Vt(i),row:parseInt(n,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function Bt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+Ut(e)+(o.rowFixed?"$":"")+String(t+1)}const Ht=140,$t=20,Wt=.035;function Gt(e){return $t+(Ht-$t)*Math.exp(-Wt*(e-1))}const qt=/(^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+)(?!\w|!)/,Zt="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",jt="(\\s*-)?",Xt="(\\s*[\\$€])?",Yt="^(("+[jt+Xt+Zt,jt+Zt+Xt,Xt+jt+Zt].join(")|(")+"))$",Kt=new RegExp(Yt,"i");function Qt(e){return!!e&&Kt.test(e.trim())}const Jt=/[,\$€]+/g;function eo(e){e=e.replace(Jt,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function to(e,t,o){const i=[...e].sort(((e,t)=>e-t));let n=(i.length+(o?-1:1))*t;if(o||n--,Number.isInteger(n))return i[n];const s=Math.ceil(n),r=Math.floor(n);return i[s]*(n-r)+i[r]*(s-n)}const oo=20,io=11,no=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,so=/0/g,ro={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")},ao={0:s("Sunday"),1:s("Monday"),2:s("Tuesday"),3:s("Wednesday"),4:s("Thursday"),5:s("Friday"),6:s("Saturday")},lo={};function co(e){let t=lo[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let i;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(i=e.substring(t+1).indexOf("]")+t+2,0===i)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,i-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");i=n>-1?n+t:e.length;const s=e.substring(t,i);s.match(X)?o.push({type:"DATE",format:s}):o.push({type:"NUMBER",format:Io(s)})}t=i}return o}(e),lo[e]=t),t}function ho(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=So(e));return function(e,t){if("DATE"===t[0].type)return fo(e,t[0].format);let o=e<0?"-":"";for(let i of t)switch(i.type){case"NUMBER":o+=uo(Math.abs(e),i.format);break;case"STRING":o+=i.format}return o}(e,co(t));case"object":return"0"}}function uo(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let o=0;void 0!==t.decimalPart&&(o=t.decimalPart.length);const{integerDigits:i,decimalDigits:n}=po(e,o);let s=function(e,t,o){var i;const n="0"===e?"":e;let s=n;const r=t.length-n.length;if(r>0){const e=(t.substring(0,r).match(so)||[]).length;s="0".repeat(e)+s}o&&(s=(null===(i=s.match(no))||void 0===i?void 0:i.join(","))||s);return s}(i,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(s+="."+function(e,t){let o=e;if(t.length-e.length>0){const i=(t.substring(e.length,t.length+1).match(so)||[]).length;o+="0".repeat(i)}return o}(n||"",t.decimalPart)),t.isPercent&&(s+="%"),s}const go=[];function po(e,t=oo){let o=go[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),go[t]=o);const[i,n]=o.format(e).split(".");return{integerDigits:i,decimalDigits:n}}function mo(e){try{return fo(1,e),!0}catch(e){return!1}}function fo(e,t){const o=Ee(e),i=t.indexOf("h");let n="",s="";return i>0?(n=vo(o,t.substring(0,i-1)),s=bo(o,t.substring(i))):0===i?s=bo(o,t):i<0&&(n=vo(o,t)),n+(n&&s?" ":"")+s}function vo(e,t){var o;const i=null===(o=t.match(/\/|-|\s/))||void 0===o?void 0:o[0];return(i?t.split(i):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return ao[e.getDay()].slice(0,3);case"dddd":return ao[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ro[e.getMonth()].slice(0,3);case"mmmm":return ro[e.getMonth()];case"mmmmm":return ro[e.getMonth()].slice(0,1);case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(i)}function bo(e,t){let o=t.split(/:|\s/);const i=e.getHours(),n="a"===o[o.length-1];let s=i,r="";return n&&(s=0===s?12:s>12?s-12:s,r=i>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-de)/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 So(e){let{integerDigits:t,decimalDigits:o}=po(e);if(!o)return"0";const i=t.replace("-","").length;if(i+2>io)return"0";const n=io-i-1;return({decimalDigits:o}=po(e,Math.min(n,o.length))),o?"0."+"0".repeat(o.length):"0"}function Co(e){if($e(e)){return Se(e).format}if(!Qt(e))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const i=e.match(/[\d]/),n="[$"+o.values().next().value+"]";return i.index<o.index?"#,##"+t+n:n+"#,##"+t}return e.includes("%")?t+"%":void 0}function Eo(e,t,o){return To(co(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:o}]:e)).flat())}function wo(e,t){const o=co(e).map((e=>"NUMBER"===e.type?{...e,format:yo(e.format,t)}:e)),i=To(o);return lo[i]=o,i}function yo(e,t){var o;const i={...e},n=Math.sign(t),s=(null===(o=i.decimalPart)||void 0===o?void 0:o.length)||0,r=Math.min(Math.max(0,s+n),oo);return i.decimalPart="0".repeat(r),""===i.decimalPart&&delete i.decimalPart,i}const xo=/,*?$/;function Io(e){var t;if(function(e){return Boolean(e.replace(Ro,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const o=e.includes("%"),i=(null===(t=e.match(xo))||void 0===t?void 0:t[0])||"",n=i?1e3**i.length:1;let s=e.slice(0,e.length-(i.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:o,thousandsSeparator:r,decimalPart:c,magnitude:n}:{integerPart:l,isPercent:o,thousandsSeparator:r,magnitude:n}}const Ro=/[,#0.%]/g;function To(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}class Ao{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 Ao?e:new Ao(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:i}=this._zone;if(void 0!==i&&void 0!==o)return{left:e,top:t,right:i,bottom:o};if(void 0===o&&void 0!==i)return{right:i,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===i&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(s("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=Dt(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),i=void 0===t.bottom,n=void 0===t.right;return i&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed,t.left===t.right&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed)),n&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed,t.top===t.bottom&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed)),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){var e,t,o,i,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===(o=c[0])||void 0===o?void 0:o.colFixed)||!1,rowFixed:(null===(i=c[1])||void 0===i?void 0:i.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 Ao({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 Mo(e,t,o){const i=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:i})}function Oo(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function No(e,t,o){const i=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let o=0,i=0,n=(t=t.toLocaleLowerCase()).length,s=0;for(let r=0;r<n;r++)t[r]===e[s]?(s++,i+=100+i-r/200):i=0,o+=i;return s===e.length?o:0}(e,o(t));n>0&&i.push({score:n,elem:t})})),i.sort(((e,t)=>t.score-e.score)),i.map((e=>e.elem))}function _o(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}class Fo{constructor(){this.isFastIdStrategy=!1,this.fastIdStart=0}setIsFastStrategy(e){this.isFastIdStrategy=e}uuidv4(){return this.isFastIdStrategy?(this.fastIdStart++,String(this.fastIdStart)):window.crypto&&window.crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))):"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}}function Do(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let o,i,n,s,r=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Ft(c))n=s=Vt(c),o=i=0,r=!0;else if(Dt(c))o=i=parseInt(c,10)-1,n=s=0,a=!0;else{const e=zt(c);n=s=e.col,o=i=e.row,l=!0}if(2===t.length)if(Ft(h))s=Vt(h),r=!0;else if(Dt(h))i=parseInt(h,10)-1,a=!0;else{const e=zt(h);s=e.col,i=e.row,o=r?i:o,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:o,left:n,bottom:r?void 0:i,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 ko(e){const t=Do(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Po(e){const{bottom:t,top:o,left:i,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(i)||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 Lo(e){const{top:t,bottom:o,left:i,right:n}=e,r="hasHeader"in e&&e.hasHeader,a=t===o&&i===n;if(void 0===o&&void 0!==n)return 0!==t||r?`${Bt(i,t)}:${Ut(n)}`:`${Ut(i)}:${Ut(n)}`;if(void 0===n&&void 0!==o)return 0!==i||r?`${Bt(i,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==n)return a?Bt(i,t):`${Bt(i,t)}:${Bt(n,o)}`;throw new Error(s("Bad zone format"))}function Uo(e,t,o,i,n){const s="left"===t?"columns":"rows",r="before"===i?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?Jo(e,s,"RESIZE",n):r<e[t]?Jo(e,s,"MOVE",n):{...e}}function Vo(e,t,o,i,n){const s="left"===t?"columns":"rows",r="before"===i?o-1:o,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?Jo(e,s,"RESIZE",n):r<e[t]?Jo(e,s,"MOVE",n):{...e}}function zo(e,t,o){const i="left"===t?"right":"bottom";let n=e[t],s=e[i];for(let r of o.sort(((e,t)=>t-e)))e[t]>r&&(n--,s--),e[t]<r&&e[i]>=r&&s--;return{...e,[t]:n,[i]:s}}function Bo(e,t,o){const i="left"===t?"right":"bottom";let n=e[t],s=e[i];const r=e[i];for(let i of o.sort(((e,t)=>t-e)))e[t]>i&&(n--,void 0!==s&&s--),void 0!==r&&void 0!==s&&e[t]<=i&&r>=i&&s--;if(!(void 0!==s&&n>s))return{...e,[t]:n,[i]:s}}function Ho(...e){return{top:Math.min(...e.map((e=>e.top))),left:Math.min(...e.map((e=>e.left))),bottom:Math.max(...e.map((e=>e.bottom))),right:Math.max(...e.map((e=>e.right)))}}function $o(e,t){if(Go(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 Wo(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function Go(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function qo(e,t,o){const{left:i,right:n,top:s,bottom:r}=o;return e>=i&&e<=n&&t>=s&&t<=r}function Zo(e,t){return Wo(Ho(t,e),t)}function jo(e,t){const o=e.map(Do),i=t.map(ko),n=Math.max(...o.concat(i).map((e=>e.bottom||0))),s=Math.max(...o.concat(i).map((e=>e.right||0))),r=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),a=i.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 o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(r.map(Qo).flat(),a.map(Qo).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),i=[];let n=oi(t);for(const{col:e,row:t}of o)if(!qo(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else i.push(n),n=oi({col:e,row:t});return[...i,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=[],o=Xo(e),i=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>i(e,t)?Ho(e,t):e),o.shift());t.push(e)}return Xo(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===s+1?void 0:e.right}))).map(Lo)}function Xo(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>Zo(e,t)))||o.push(e)}return o.reverse()}function Yo(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Ko(e){const{numberOfCols:t,numberOfRows:o}=Yo(e);return 1===t||1===o}function Qo(e){const t=[],[o,i]=[e.right,e.left].sort(((e,t)=>e-t)),[n,s]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ze(o,i+1))for(const o of ze(n,s+1))t.push({col:e,row:o});return t}function Jo(e,t,o,i){const n="both"===t?i[0]:"columns"===t?i:0,s="both"===t?i[1]:"rows"===t?i:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(ii(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=n,l.top+=s),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=s),l}function ei(e,t){let o,i;const{left:n,right:s,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=n?l:c!=s?c:l,i=h!=r?h:d!=a?d:h,{col:o,row:i}}function ti(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 oi(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function ii(e){return void 0===e.right}function ni(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function si(...e){return e.length<2||1===jo(e.map(Lo),[]).length}class ri 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;at(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){var t,o,i,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===(o=r.options)||void 0===o?void 0:o.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=null===(i=r.options)||void 0===i?void 0:i.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})}}ri.template="o-spreadsheet-ChartJsComponent",ri.props={figure:Object};const ai={};let li=0;function ci(e,...t){const o="__sheet__"+li++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],i=[];let n=[];function s(e,t){const i=[];for(const n of o[e]){let r=t&&t+" "+n||n;r.includes("&")&&(r=n.replace(/&/g,t||"")),e<o.length-1&&(r=s(e+1,r)),i.push(r)}return i.join(", ")}function r(){n.length&&(i.push(s(0)+" {"),i.push(...n),i.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),o.pop()):("{"===t[0]&&(r(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return i.join("\n")}(t),ai[e]=o}(o,String.raw(e,...t)),function(e){const t=ai[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function hi({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function di(e){const t=ui(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function ui(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}function gi(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const pi=1.2;ci`
|
|
1
|
+
!function(e,t){"use strict";let o=e=>e;function i(e,...t){if(1===t.length&&"object"==typeof t[0]){const o=t[0];e=e.replace(/\%\(?([^\)]+)\)s/g,((e,t)=>o[t]))}else t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));return e}const n=function(e,...t){return i(o(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 i(o(e),...this.values)}toString(){return this.valueOf()}}var a,l;!function(e){e.NotAvailable="#N/A",e.InvalidReference="#REF",e.BadExpression="#BAD_EXPR",e.CircularDependency="#CYCLE",e.UnknownFunction="#NAME?",e.GenericError="#ERROR"}(a||(a={})),function(e){e[e.silent=0]="silent",e[e.error=1]="error"}(l||(l={}));class c extends Error{constructor(e,t,o=l.error){super(t),this.errorType=e,this.logLevel=o}}class h extends c{constructor(e){super(a.BadExpression,e)}}class d extends c{constructor(){super(a.CircularDependency,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=11982760,x="#01666b",I="#188038",R="#E6F4EA",T="#CEEAD6",A="#E0E2E4",M=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC","#DD7E6B","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#A4C2F4","#9FC5E8","#B4A7D6","#D5A6BD","#CC4125","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6D9EEB","#6FA8DC","#8E7CC3","#C27BA0","#A61C00","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3C78D8","#3D85C6","#674EA7","#A64D79","#85200C","#990000","#B45F06","#BF9000","#38761D","#134F5C","#1155CC","#0B5394","#351C75","#741B47","#5B0F00","#660000","#783F04","#7F6000","#274E13","#0C343D","#1C4587","#073763","#20124D","#4C1130"],O=26,N=48,_=96,F=23,D=15,k=18,P=14,L=4,U=4,V=3,z=U,B=17,H=250,$=1,W="400",G=10,q="'Roboto', arial",Z=["thin","#000"],j=["thin",I],X=/[ymdhs:]/,Y=a.InvalidReference,K="START_REVISION",Q=20,J="??",ee="difference",te="#00A04A",oe="#DC6965",ie=.4,ne=["'","*","?","/","\\","[","]"],se=/'|\*|\?|\/|\\|\[|\]/,re="|",ae=s("Invalid expression");var le;!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"}(le||(le={}));const ce="\n",he=[6,7,8,9,10,11,12,14,18,24,36],de=new Date(1899,11,30),ue=864e5,ge=2e3,pe=(new Date).getFullYear(),me=new Date(0)-de,fe=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,ve=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,be=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Se(e){let t;const o=(e=e.trim()).match(be);if(o){if(t=function(e){if(e=e.trim(),be.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),i=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),n=i.length>=2,s=3===i.length;let r=Number(i[0]),a=n?Number(i[1]):0,l=s?Number(i[2]):0,c=s?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!n)return null;r>=12&&t?r-=12:r<12&&o&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new Date(1899,11,30,r,a,l)}}return null}(o[0]),null===t)return null;e=e.replace(o[0],"").trim()}let i;const n=e.match(fe),s=e.match(ve);if(n||s){let t;if(n?(t=n[0],i=Ce(t,"mdy")):(t=s[0],i=Ce(t,"ymd")),null===i)return null;e=e.replace(t,"").trim()}return""!==e||!i&&!t?null:i&&t?{value:i.value+t.value,format:i.format+" "+("hhhh:mm:ss"===t.format?"hh:mm:ss":t.format),jsDate:new Date(i.jsDate.getFullYear()+t.jsDate.getFullYear()-1899,i.jsDate.getMonth()+t.jsDate.getMonth()-11,i.jsDate.getDate()+t.jsDate.getDate()-30,i.jsDate.getHours()+t.jsDate.getHours(),i.jsDate.getMinutes()+t.jsDate.getMinutes(),i.jsDate.getSeconds()+t.jsDate.getSeconds())}:i||t}function Ce(e,t){const o="mdy"===t;if(o||"ymd"===t){const t=e.split(/\/|-|\s/),i=o?0:1,n=o?1:2,s=o?2:0,r=Number(t[i]),a=Number(t[n]),l=2===t[i].length&&r<10||2===t[n].length&&a<10,c=t[s]?function(e){const t=Number(e);switch(e.length){case 1:return ge+t;case 2:return ge+(ge+t>pe+10?-100:0)+t;case 3:case 4:return t}return 0}(t[s]):pe,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-de;let g=l?`mm${d}dd`:`m${d}d`;return t[s]&&(g=o?g+d+"yyyy":"yyyy"+d+g),{value:Math.round(u/ue),format:g,jsDate:h}}return null}function Ee(e){const t=Math.trunc(e);let o=new Date(t*ue-me),i=e-t;i=i<0?1+i:i;const n=Math.round(24*i),s=Math.round(24*(i-n/24)*60),r=Math.round(24*(i-n/24-s/24/60)*60*60);return o.setHours(n),o.setMinutes(s),o.setSeconds(r),o}function we(e){const t=e.getTime()-de.getTime();return Math.round(t/ue)}function ye(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function xe(e){return ye(e)===e.getDate()}function Ie(e,t,o){const i=e.getFullYear(),n=e.getMonth(),s=e.getDate(),r=new Date(i,n+t);return o&&s===ye(e)||s>ye(r)?r.setDate(ye(r)):r.setDate(s),r}function Re(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Te(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const i=Ee(e),n=Ee(t);let s=i.getDate(),r=n.getDate();const a=i.getMonth(),l=n.getMonth(),c=i.getFullYear(),h=n.getFullYear();let d=0,u=0;switch(o){case 0:31===s&&(s=30),30===s&&31===r&&(r=30),1===a&&s===(Re(c)?29:28)&&(s=30,1===l&&r===(Re(h)?29:28)&&(r=30)),d=c+(30*a+s)/360,u=h+(30*l+r)/360;break;case 1:let o=365;const i=c===h;if(!i&&!(c+1===h)||!i&&a<l||!i&&a===l&&s<r){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Re(o)?366:365;o=t/e}else i?Re(c)&&(o=366):(Re(c)&&a<2&&(o=366),Re(h)&&(l>1||1===l&&29===r)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===s&&(s=30),31===r&&(r=30),d=c+(30*a+s)/360,u=h+(30*l+r)/360}return u-d}function Ae(e){return JSON.stringify(e,Object.keys(e).sort())}function Me(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ne(e){const t=Array.isArray(e)?[]:{};switch(typeof e){case"object":if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&(null==e?void 0:e.constructor)===Object}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");for(const o in e)t[o]=Ne(e[o]);return t;case"number":case"string":case"boolean":case"function":case"undefined":return e;default:throw new Error("Unsupported type: "+typeof e)}}function _e(e){return e.startsWith("'")&&(e=e.slice(1,-1).replace(/''/g,"'")),e}function Fe(e){var t;return(null===(t=e.match(/\w/g))||void 0===t?void 0:t.length)!==e.length&&(e=`'${e}'`),e}function De(e,t,o){return e<t?t:e>o?o:e}function ke(e,t=1){return t*(e+U)-U}function Pe(e,t,o){e.save(),e.font=Ue(o);const i=e.measureText(t).width;return e.restore(),i}function Le(e){return Math.round(96*e/72)}function Ue(e){return`${e.italic?"italic ":""}${e.bold?"bold":W} ${Ve(e)}px ${q}`}function Ve(e){return Le((null==e?void 0:e.fontSize)||G)}function ze(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const i=Math.ceil(Math.abs((t-e)/o)),n=Array(i);for(let t=0;t<i;t++)n[t]=e+t*o;return n}function Be(e){return e.reduce(((e,t,o,i)=>{if(1===Math.abs(t-i[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*He(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}function $e(e){return null!==Se(e)}const We=/^\[([^\[]+)\]\((.+)\)$/,Ge=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function qe(e){return We.test(e)}function Ze(e){return Ge.test(e)}function je(e,t){return`[${e}](${t})`}function Xe(e){const t=e.match(We)||[],o=t[1],i=t[2];if(!o||!i)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:i}}const Ye="o-spreadsheet://";function Ke(e){return e.startsWith(Ye)}function Qe(e){return`${Ye}${e}`}function Je(e){if(e.startsWith(Ye))return e.substr(Ye.length);throw new Error(`${e} is not a valid sheet link`)}function et(e){return void 0!==e}function tt(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?tt(e):!e))}function ot(e,t){for(let[o,i]of Object.entries(t))if(Ae(i)===Ae(e))return parseInt(o,10);const o=Object.keys(t),i=0===o.length?0:Math.max(...o.map((e=>parseInt(e,10))));return t[i+1]=e,i+1}function it(e){let t="";for(let o=0,i=e.length;o<i;o++)t+=e[o];return t}function nt(e){let t,o=!1;const i=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return i.map=e=>nt((()=>e(i()))),i}function st(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function rt(e,t){return"after"===e?t+1:t}function at(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;const o=new Set;Object.keys(e).forEach((e=>o.add(e))),Object.keys(t).forEach((e=>o.add(e)));for(let i of o){if(typeof e[i]!=typeof e[i])return!1;if("object"==typeof e[i]){if(!at(e[i],t[i]))return!1}else if(e[i]!==t[i])return!1}return!0}function lt(e){const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}function ct(e){return e?e.toLowerCase():""}const ht=[" ","\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))],dt=new RegExp(ht.join("|"),"g"),ut=/\r\n|\r|\n/g;function gt(e){return e?e=(e=e.replace(dt," ")).replace(ut,ce):""}const pt=/rgba?\(|\s+|\)/gi,mt=/^#([A-F\d]{2}){3,4}$/g,ft=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function vt(e){return bt(e.toString(16).padStart(6,"0"))}function bt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(pt,"").split(",");let o=255;if(3!==t.length&&4!==t.length)throw new Error("invalid color");if(4===t.length){const e=parseFloat(t.pop()||"1");o=Math.round(255*(e||1))}const i=t.map((e=>parseInt(e,10)));255!==o&&i.push(o);return"#"+it(i.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(mt))throw new Error(`invalid color input: ${e}`);return t}function St(e){try{return bt(e),!0}catch(e){return!1}}const Ct=e=>e>=0&&e<=255;function Et(e,t,o,i=1){if(!Ct(e)||!Ct(t)||!Ct(o)||i<0||i>1)throw new Error(`Invalid RGBA values ${[e,t,o,i]}`);return{a:i,b:o,g:t,r:e}}function wt(e){let{r:t,g:o,b:i}=xt(e);t/=255,o/=255,i/=255;const n=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*n(t)+.7152*n(o)+.0722*n(i)}function yt(e){let t=e.r.toString(16),o=e.g.toString(16),i=e.b.toString(16),n=Math.round(255*e.a).toString(16);return 1==t.length&&(t="0"+t),1==o.length&&(o="0"+o),1==i.length&&(i="0"+i),1==n.length&&(n="0"+n),"ff"===n&&(n=""),("#"+t+o+i+n).toUpperCase()}function xt(e){let t,o,i,n;if(7===(e=bt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),i=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),o=parseInt(e[3]+e[4],16),i=parseInt(e[5]+e[6],16),n=parseInt(e[7]+e[8],16)}return n=+(n/255).toFixed(3),{a:n,r:t,g:o,b:i}}function It(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),i=e.l-t/2,n=0,s=0,r=0;return 0<=e.h&&e.h<60?(n=t,s=o,r=0):60<=e.h&&e.h<120?(n=o,s=t,r=0):120<=e.h&&e.h<180?(n=0,s=t,r=o):180<=e.h&&e.h<240?(n=0,s=o,r=t):240<=e.h&&e.h<300?(n=o,s=0,r=t):300<=e.h&&e.h<360&&(n=t,s=0,r=o),n=Math.round(255*(n+i)),s=Math.round(255*(s+i)),r=Math.round(255*(r+i)),{a:e.a,r:n,g:s,b:r}}function Rt(e){const t=e.r/255,o=e.g/255,i=e.b/255;let n=Math.min(t,o,i),s=Math.max(t,o,i),r=s-n,a=0,l=0,c=0;return a=0==r?0:s==t?(o-i)/r%6:s==o?(i-t)/r+2:(t-o)/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 Tt=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),At=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Mt=new RegExp(/^([A-Z]{1,3})+$/,"i"),Ot=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Nt=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),_t=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[Tt.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 Ft(e){return Ot.test(e)}function Dt(e){return Nt.test(e)}function kt(e){return Mt.test(e)}function Pt(e){return At.test(e)}function Lt(e){const t=e.split("!"),o=t.pop();return{sheetName:_e(t.join("!"))||void 0,xc:o}}function Ut(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):Ut(Math.floor(e/26)-1)+Ut(e%26)}function Vt(e){let t=0;const o=e.length;for(let i=0;i<o;i++){t+=(e.charCodeAt(i)-65+(i<o-1?1:0))*26**(o-i-1)}return t}function zt(e){const t=(e=e.toUpperCase().trim()).match(Tt);if(null!==t){const[o,i,n]=t;if(o===e){return{col:Vt(i),row:parseInt(n,10)-1}}}throw new Error(`Invalid cell description: ${e}`)}function Bt(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+Ut(e)+(o.rowFixed?"$":"")+String(t+1)}const Ht=140,$t=20,Wt=.035;function Gt(e){return $t+(Ht-$t)*Math.exp(-Wt*(e-1))}const qt=/(^-?\d+(\.?\d*(e\d+)?)?|^-?\.\d+)(?!\w|!)/,Zt="(\\s*(\\d+(,\\d{3,})*(\\.\\d*)?)|(\\.\\d+))(e(\\+|-)?\\d+)?(\\s*%)?",jt="(\\s*-)?",Xt="(\\s*[\\$€])?",Yt="^(("+[jt+Xt+Zt,jt+Zt+Xt,Xt+jt+Zt].join(")|(")+"))$",Kt=new RegExp(Yt,"i");function Qt(e){return!!e&&Kt.test(e.trim())}const Jt=/[,\$€]+/g;function eo(e){e=e.replace(Jt,"");let t=Number(e);return isNaN(t)&&e.includes("%")&&(t=Number(e.split("%")[0]),!isNaN(t))?t/100:t}function to(e,t,o){const i=[...e].sort(((e,t)=>e-t));let n=(i.length+(o?-1:1))*t;if(o||n--,Number.isInteger(n))return i[n];const s=Math.ceil(n),r=Math.floor(n);return i[s]*(n-r)+i[r]*(s-n)}const oo=20,io=11,no=/(\d+?)(?=(\d{3})+(?!\d)|$)/g,so=/0/g,ro={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")},ao={0:s("Sunday"),1:s("Monday"),2:s("Tuesday"),3:s("Wednesday"),4:s("Thursday"),5:s("Friday"),6:s("Saturday")},lo={};function co(e){let t=lo[e];return void 0===t&&(t=function(e){if(""===e)throw new Error("A format cannot be empty");let t=0,o=[];for(;t<e.length;){let i;if("["===e.charAt(t)){if("$"!==e.charAt(t+1))throw new Error(`Currency formats have to be prefixed by a $: ${e}`);if(i=e.substring(t+1).indexOf("]")+t+2,0===i)throw new Error(`Invalid currency brackets format: ${e}`);const n=e.substring(t+2,i-1);if(n.includes("["))throw new Error(`Invalid currency format: ${e}`);o.push({type:"STRING",format:n})}else{const n=e.substring(t).indexOf("[");i=n>-1?n+t:e.length;const s=e.substring(t,i);s.match(X)?o.push({type:"DATE",format:s}):o.push({type:"NUMBER",format:Ro(s)})}t=i}return o}(e),lo[e]=t),t}function ho(e,t){switch(typeof e){case"string":return e;case"boolean":return e?"TRUE":"FALSE";case"number":t||(t=Co(e));return function(e,t){if("DATE"===t[0].type)return vo(e,t[0].format);let o=e<0?"-":"";for(let i of t)switch(i.type){case"NUMBER":o+=uo(Math.abs(e),i.format);break;case"STRING":o+=i.format}return o}(e,co(t));case"object":return"0"}}function uo(e,t){t.isPercent&&(e*=100),e/=t.magnitude;let o=0;void 0!==t.decimalPart&&(o=t.decimalPart.length);const{integerDigits:i,decimalDigits:n}=po(e,o);let s=function(e,t,o){var i;const n="0"===e?"":e;let s=n;const r=t.length-n.length;if(r>0){const e=(t.substring(0,r).match(so)||[]).length;s="0".repeat(e)+s}o&&(s=(null===(i=s.match(no))||void 0===i?void 0:i.join(","))||s);return s}(i,t.integerPart,t.thousandsSeparator);return void 0!==t.decimalPart&&(s+="."+function(e,t){let o=e;if(t.length-e.length>0){const i=(t.substring(e.length,t.length+1).match(so)||[]).length;o+="0".repeat(i)}return o}(n||"",t.decimalPart)),t.isPercent&&(s+="%"),s}const go=[];function po(e,t=oo){const o=e.toString();if(o.includes("e"))return function(e,t=oo){let o=go[t];o||(o=new Intl.NumberFormat("en-US",{maximumFractionDigits:t,useGrouping:!1}),go[t]=o);const[i,n]=o.format(e).split(".");return{integerDigits:i,decimalDigits:n}}(e,t);if(Number.isInteger(e))return{integerDigits:o,decimalDigits:void 0};const i=o.indexOf(".");let n=o.substring(0,i),s=o.substring(i+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:o}=function(e,t){let o="0",i=e,n=e.slice(0,t);const s=t;if(Number(Number(e[s])<5))return{integerDigits:o,decimalDigits:n};const r=(Number(n)+1).toString();r.length>n.length?(o=(Number(o)+1).toString(),i=void 0):i=r;return{integerDigits:o,decimalDigits:i}}(s,t);s=o,"0"!==e&&(n=(Number(n)+Number(e)).toString())}return{integerDigits:n,decimalDigits:mo(s||"")}}function mo(e){let t=e.length-1;for(;t>=0&&"0"===e[t];)t--;return e.slice(0,t+1)||void 0}function fo(e){try{return vo(1,e),!0}catch(e){return!1}}function vo(e,t){const o=Ee(e),i=t.indexOf("h");let n="",s="";return i>0?(n=bo(o,t.substring(0,i-1)),s=So(o,t.substring(i))):0===i?s=So(o,t):i<0&&(n=bo(o,t)),n+(n&&s?" ":"")+s}function bo(e,t){var o;const i=null===(o=t.match(/\/|-|\s/))||void 0===o?void 0:o[0];return(i?t.split(i):[t]).map((o=>{switch(o){case"d":return e.getDate();case"dd":return e.getDate().toString().padStart(2,"0");case"ddd":return ao[e.getDay()].slice(0,3);case"dddd":return ao[e.getDay()];case"m":return e.getMonth()+1;case"mm":return String(e.getMonth()+1).padStart(2,"0");case"mmm":return ro[e.getMonth()].slice(0,3);case"mmmm":return ro[e.getMonth()];case"mmmmm":return ro[e.getMonth()].slice(0,1);case"yy":const o=String(e.getFullYear()).replace("-","").padStart(2,"0");return o.slice(o.length-2);case"yyyy":return e.getFullYear();default:throw new Error(`invalid format: ${t}`)}})).join(i)}function So(e,t){let o=t.split(/:|\s/);const i=e.getHours(),n="a"===o[o.length-1];let s=i,r="";return n&&(s=0===s?12:s>12?s-12:s,r=i>=12?" PM":" AM",o.pop()),o.map((o=>{switch(o){case"hhhh":return Math.floor((e.getTime()-de)/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 Co(e){let{integerDigits:t,decimalDigits:o}=po(e);if(!o)return"0";const i=t.replace("-","").length;if(i+2>io)return"0";const n=io-i-1;return({decimalDigits:o}=po(e,Math.min(n,o.length))),o?"0."+"0".repeat(o.length):"0"}function Eo(e){if($e(e)){return Se(e).format}if(!Qt(e))return;const t=e.includes(".")?"0.00":"0",o=e.match(/[\$€]/);if(o){const i=e.match(/[\d]/),n="[$"+o.values().next().value+"]";return i.index<o.index?"#,##"+t+n:n+"#,##"+t}return e.includes("%")?t+"%":void 0}function wo(e,t,o){return Ao(co(e||"#,##0").map((e=>"NUMBER"===e.type?[{...e,format:{...e.format,magnitude:t,decimalPart:void 0}},{type:"STRING",format:o}]:e)).flat())}function yo(e,t){const o=co(e).map((e=>"NUMBER"===e.type?{...e,format:xo(e.format,t)}:e)),i=Ao(o);return lo[i]=o,i}function xo(e,t){var o;const i={...e},n=Math.sign(t),s=(null===(o=i.decimalPart)||void 0===o?void 0:o.length)||0,r=Math.min(Math.max(0,s+n),oo);return i.decimalPart="0".repeat(r),""===i.decimalPart&&delete i.decimalPart,i}const Io=/,*?$/;function Ro(e){var t;if(function(e){return Boolean(e.replace(To,""))}(e=e.trim()))throw new Error(`Invalid number format: ${e}`);const o=e.includes("%"),i=(null===(t=e.match(Io))||void 0===t?void 0:t[0])||"",n=i?1e3**i.length:1;let s=e.slice(0,e.length-(i.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:o,thousandsSeparator:r,decimalPart:c,magnitude:n}:{integerPart:l,isPercent:o,thousandsSeparator:r,magnitude:n}}const To=/[,#0.%]/g;function Ao(e){let t="";for(let o of e){let e;switch(o.type){case"NUMBER":const t=o.format;e=t.integerPart,t.thousandsSeparator&&(e=e.slice(0,-3)+","+e.slice(-3)),void 0!==t.decimalPart&&(e+="."+t.decimalPart),t.isPercent&&(e+="%"),t.magnitude&&(e+=",".repeat(Math.log10(t.magnitude)/3));break;case"STRING":e=`[$${o.format}]`;break;case"DATE":e=o.format}t+=e}return t}class Mo{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 Mo?e:new Mo(e,t.getSheetSize)}get unboundedZone(){return this._zone}get zone(){const{left:e,top:t,bottom:o,right:i}=this._zone;if(void 0!==i&&void 0!==o)return{left:e,top:t,right:i,bottom:o};if(void 0===o&&void 0!==i)return{right:i,top:t,left:e,bottom:this.getSheetSize(this.sheetId).numberOfRows-1};if(void 0===i&&void 0!==o)return{bottom:o,left:e,top:t,right:this.getSheetSize(this.sheetId).numberOfCols-1};throw new Error(s("Bad zone format"))}static getRangeParts(e,t){const o=e.split(":").map((e=>{const t=Dt(e);return{colFixed:!t&&e.startsWith("$"),rowFixed:t?e.startsWith("$"):e.includes("$",1)}})),i=void 0===t.bottom,n=void 0===t.right;return i&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed,t.left===t.right&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed)),n&&(o[0].colFixed=o[0].colFixed||o[1].colFixed,o[1].colFixed=o[0].colFixed||o[1].colFixed,t.top===t.bottom&&(o[0].rowFixed=o[0].rowFixed||o[1].rowFixed,o[1].rowFixed=o[0].rowFixed||o[1].rowFixed)),o}get isFullCol(){return void 0===this._zone.bottom}get isFullRow(){return void 0===this._zone.right}get rangeData(){return{_zone:this._zone,_sheetId:this.sheetId}}orderZone(){var e,t,o,i,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===(o=c[0])||void 0===o?void 0:o.colFixed)||!1,rowFixed:(null===(i=c[1])||void 0===i?void 0:i.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 Mo({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 Oo(e,t,o){const i=o.sheetId===e?t:o.sheetId;return o.clone({sheetId:i})}function No(e,t,o){return o?e.getRangeFromSheetXC(t,o):void 0}function _o(e,t,o){const i=[];return t.forEach((t=>{const n=function(e,t){e=e.toLocaleLowerCase();let o=0,i=0,n=(t=t.toLocaleLowerCase()).length,s=0;for(let r=0;r<n;r++)t[r]===e[s]?(s++,i+=100+i-r/200):i=0,o+=i;return s===e.length?o:0}(e,o(t));n>0&&i.push({score:n,elem:t})})),i.sort(((e,t)=>t.score-e.score)),i.map((e=>e.elem))}function Fo(e){const t=[];for(let o=0;o<e;o++){const e={cells:{}};t.push(e)}return t}class Do{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 ko(e){const t=function(e){const t=(e=e.split("!").pop()).replace(/\$/g,"").split(":").map((e=>e.trim()));let o,i,n,s,r=!1,a=!1,l=!1;const c=t[0],h=t[1]&&t[1];if(Ft(c))n=s=Vt(c),o=i=0,r=!0;else if(Dt(c))o=i=parseInt(c,10)-1,n=s=0,a=!0;else{const e=zt(c);n=s=e.col,o=i=e.row,l=!0}if(2===t.length)if(Ft(h))s=Vt(h),r=!0;else if(Dt(h))i=parseInt(h,10)-1,a=!0;else{const e=zt(h);s=e.col,i=e.row,o=r?i:o,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:o,left:n,bottom:r?void 0:i,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 Po(e){const t=ko(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Lo(e){const{bottom:t,top:o,left:i,right:n}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(i)||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 Uo(e){const{top:t,bottom:o,left:i,right:n}=e,r="hasHeader"in e&&e.hasHeader,a=t===o&&i===n;if(void 0===o&&void 0!==n)return 0!==t||r?`${Bt(i,t)}:${Ut(n)}`:`${Ut(i)}:${Ut(n)}`;if(void 0===n&&void 0!==o)return 0!==i||r?`${Bt(i,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==n)return a?Bt(i,t):`${Bt(i,t)}:${Bt(n,o)}`;throw new Error(s("Bad zone format"))}function Vo(e,t,o,i,n){const s="left"===t?"columns":"rows",r="before"===i?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?ei(e,s,"RESIZE",n):r<e[t]?ei(e,s,"MOVE",n):{...e}}function zo(e,t,o,i,n){const s="left"===t?"columns":"rows",r="before"===i?o-1:o,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?ei(e,s,"RESIZE",n):r<e[t]?ei(e,s,"MOVE",n):{...e}}function Bo(e,t,o){const i="left"===t?"right":"bottom";let n=e[t],s=e[i];for(let r of o.sort(((e,t)=>t-e)))e[t]>r&&(n--,s--),e[t]<r&&e[i]>=r&&s--;return{...e,[t]:n,[i]:s}}function Ho(e,t,o){const i="left"===t?"right":"bottom";let n=e[t],s=e[i];const r=e[i];for(let i of o.sort(((e,t)=>t-e)))e[t]>i&&(n--,void 0!==s&&s--),void 0!==r&&void 0!==s&&e[t]<=i&&r>=i&&s--;if(!(void 0!==s&&n>s))return{...e,[t]:n,[i]:s}}function $o(...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 Wo(e,t){if(qo(e,t))return{top:Math.max(e.top,t.top),left:Math.max(e.left,t.left),bottom:Math.min(e.bottom,t.bottom),right:Math.min(e.right,t.right)}}function Go(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function qo(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function Zo(e,t,o){const{left:i,right:n,top:s,bottom:r}=o;return e>=i&&e<=n&&t>=s&&t<=r}function jo(e,t){return Go($o(t,e),t)}function Xo(e,t){const o=e.map(ko),i=t.map(Po),n=Math.max(...o.concat(i).map((e=>e.bottom||0))),s=Math.max(...o.concat(i).map((e=>e.right||0))),r=o.map((e=>({...e,bottom:void 0===e.bottom?n+1:e.bottom,right:void 0===e.right?s+1:e.right}))),a=i.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 o=new Set(t.map((({col:e,row:t})=>`${e}-${t}`)));return e.filter((({col:e,row:t})=>!o.has(`${e}-${t}`)))}(r.map(Jo).flat(),a.map(Jo).flat()),c=function(e){if(0===e.length)return[];const[t,...o]=[...e].sort(((e,t)=>e.row-t.row)).sort(((e,t)=>e.col-t.col)),i=[];let n=ii(t);for(const{col:e,row:t}of o)if(!Zo(e,t,n))if(e===n.left&&t===n.bottom+1){const e=n.bottom+1;n={...n,bottom:e}}else i.push(n),n=ii({col:e,row:t});return[...i,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=[],o=Yo(e),i=(e,t)=>e.top===t.top&&e.bottom===t.bottom&&e.right+1===t.left;for(;o.length;){const e=o.reduce(((e,t)=>i(e,t)?$o(e,t):e),o.shift());t.push(e)}return Yo(t)}(c).map((e=>({...e,bottom:e.bottom===n+1?void 0:e.bottom,right:e.right===s+1?void 0:e.right}))).map(Uo)}function Yo(e){const t=[...e].sort(((e,t)=>t.right-e.right)).sort(((e,t)=>t.bottom-e.bottom)).sort(((e,t)=>e.top-t.top)).sort(((e,t)=>e.left-t.left)).reverse(),o=[];for(;0!==t.length;){const e=t.shift();t.some((t=>jo(e,t)))||o.push(e)}return o.reverse()}function Ko(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function Qo(e){const{numberOfCols:t,numberOfRows:o}=Ko(e);return 1===t||1===o}function Jo(e){const t=[],[o,i]=[e.right,e.left].sort(((e,t)=>e-t)),[n,s]=[e.top,e.bottom].sort(((e,t)=>e-t));for(const e of ze(o,i+1))for(const o of ze(n,s+1))t.push({col:e,row:o});return t}function ei(e,t,o,i){const n="both"===t?i[0]:"columns"===t?i:0,s="both"===t?i[1]:"rows"===t?i:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(ni(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=n,l.top+=s),void 0!==l.right&&(l.right+=n),void 0!==l.bottom&&(l.bottom+=s),l}function ti(e,t){let o,i;const{left:n,right:s,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=n?l:c!=s?c:l,i=h!=r?h:d!=a?d:h,{col:o,row:i}}function oi(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 ii(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function ni(e){return void 0===e.right}function si(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function ri(...e){return e.length<2||1===Xo(e.map(Uo),[]).length}class ai 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;at(e,t)||(this.updateChartJs(t),e=t)}))}createChart(e){const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){var t,o,i,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===(o=r.options)||void 0===o?void 0:o.valueLabel)&&(this.chart.config.options.valueLabel=r.options.valueLabel)):this.chart.data.datasets=void 0,this.chart.config.options.tooltips=null===(i=r.options)||void 0===i?void 0:i.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})}}ai.template="o-spreadsheet-ChartJsComponent",ai.props={figure:Object};const li={};let ci=0;function hi(e,...t){const o="__sheet__"+ci++;return function(e,t){const o=document.createElement("style");o.textContent=function(e){const t=e.split(/(\{|\}|;)/).map((e=>e.trim())),o=[],i=[];let n=[];function s(e,t){const i=[];for(const n of o[e]){let r=t&&t+" "+n||n;r.includes("&")&&(r=n.replace(/&/g,t||"")),e<o.length-1&&(r=s(e+1,r)),i.push(r)}return i.join(", ")}function r(){n.length&&(i.push(s(0)+" {"),i.push(...n),i.push("}"),n=[])}for(;t.length;){let e=t.shift();"}"===e?(r(),o.pop()):("{"===t[0]&&(r(),o.push(e.split(/\s*,\s*/)),t.shift()),";"===t[0]&&n.push(" "+e+";"))}return i.join("\n")}(t),li[e]=o}(o,String.raw(e,...t)),function(e){const t=li[e];t.setAttribute("component",e),document.head.appendChild(t)}(o),o}function di({strikethrough:e,underline:t}){return e||t?`${e?"line-through":""} ${t?"underline":""}`:"none"}function ui(e){const t=gi(e);return e?(e.fillColor&&(t.background=e.fillColor),t):t}function gi(e){const t={};if(!e)return t;if(e.bold&&(t["font-weight"]="bold"),e.italic&&(t["font-style"]="italic"),e.strikethrough||e.underline){let o=e.strikethrough?"line-through":"";o=e.underline?o+" underline":o,t["text-decoration"]=o}return e.textColor&&(t.color=e.textColor),t}function pi(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>`${e}:${t};`)).join(" ")}const mi=1.2;hi`
|
|
2
2
|
div.o-scorecard {
|
|
3
3
|
font-family: ${q};
|
|
4
4
|
user-select: none;
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
|
|
18
18
|
.o-title-text {
|
|
19
19
|
text-align: left;
|
|
20
|
-
height: ${
|
|
21
|
-
line-height: ${
|
|
20
|
+
height: ${mi+"em"};
|
|
21
|
+
line-height: ${mi+"em"};
|
|
22
22
|
overflow: hidden;
|
|
23
23
|
white-space: nowrap;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.o-key-text {
|
|
27
|
-
line-height: ${
|
|
28
|
-
height: ${
|
|
27
|
+
line-height: ${mi+"em"};
|
|
28
|
+
height: ${mi+"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: ${
|
|
44
|
-
height: ${
|
|
43
|
+
line-height: ${mi+"em"};
|
|
44
|
+
height: ${mi+"em"};
|
|
45
45
|
overflow: hidden;
|
|
46
46
|
white-space: nowrap;
|
|
47
47
|
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
`;class mi 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 wt(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get figure(){return this.props.figure}get chartStyle(){return gi({padding:`${this.chartPadding}px`,background:this.backgroundColor})}get chartContentStyle(){return gi({height:`${this.getDrawableHeight()}px`})}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),o=t.getElementMaxFontSize(this.getDrawableHeight(),this);let i=function(e,t,o,i=.25){let n=1;if(o(n)>e)return n;if(o(t)<e)return t;let s=(n+t)/2,r=o(s),a=0;for(;Math.abs(r-e)>i&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,s=(n+t)/2,r=o(s),a++;return s}(e,o,(e=>t.getElementWidth(e,this.ctx,this)))/o;const n=(new vi).getElementMaxFontSize(this.getDrawableHeight(),this)*i,s=(new fi).getElementMaxFontSize(this.getDrawableHeight(),this)*i;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=ui(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),gi(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*pi:0,t}getWidestElement(){const e=new fi,t=new vi;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}mi.template="o-spreadsheet-ScorecardChart";class fi{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.baseline,n="neutral"!==o.baselineArrowDirection?"A "+i:i;t.font=`${e}px ${q}`;let s=t.measureText(n).width;return t.font=`${.9*e}px ${q}`,s+=t.measureText(o.baselineDescr).width,s}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/pi}}class vi{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.keyValue||"";return t.font=`${e}px ${q}`,t.measureText(i).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/pi}}mi.props={figure:Object};class bi{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 Si(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const Ci=new bi;function Ei(e,t){return{url:e=Si(e),label:t||e,isExternal:!0,isUrlEditable:!0}}Ci.add("sheet_URL",{match:e=>Ke(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=Je(e);return t.tryGetSheetName(o)||s("Invalid sheet")},open(e,t){const o=Je(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o})},sequence:0});const wi={createLink:Ei,match:e=>Ze(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function yi(e){return Ci.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||wi}function xi(e,t){return yi(e.url).urlRepresentation(e.url,t)}function Ii(e,t){yi(e.url).open(e.url,t)}function Ri(e){if("string"==typeof e){if(qe(e)){const{label:t,url:o}=Xe(e);return yi(o).createLink(o,t)}return Ze(e)?Ei(e):void 0}}const Ti=["number","string","boolean","undefined"];function Ai(e,t){if(!e())throw new Error(t)}const Mi=e=>s("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Oi(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(Qt(e)||""===e)return eo(e);const t=Se(e);if(t)return t.value;throw new Error(Mi(e));default:return 0}}function Ni(e){if(""===e)throw new Error(Mi(e));return Oi(e)}function _i(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function Fi(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const Di=e=>s("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function ki(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(Di(e))}return!1;case"number":return!!e;default:return!1}}function Pi(e){return Ee(Oi(e))}function Li(e,t,o){for(let i of e)if(Array.isArray(i)){const e=i.length,o=i[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)t(i[o][n])}else o(i)}function Ui(e,t){Li(e,t,t)}function Vi(e,t){Li(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(Ni(e))}))}function zi(e,t,o,i){let n=i;for(let i of e)if(Array.isArray(i)){const e=i.length,o=i[0].length;for(let s=0;s<o;s++)for(let o=0;o<e;o++)n=t(n,i[o][s])}else n=o(n,i);return n}function Bi(e,t,o){return zi(e,t,t,o)}function Hi(e,t,o){return zi(e,((e,o)=>"number"==typeof o?t(e,o):e),((e,o)=>t(e,Ni(o))),o)}function $i(e,t,o){return zi(e,((e,o)=>null!=o?t(e,"number"==typeof o?o:"boolean"==typeof o?Oi(o):0):e),((e,o)=>t(e,Oi(o))),o)}function Wi(e,t){return function(e,t,o){for(let i of e)if(Array.isArray(i)){const e=i.length,o=i[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)if(!t(i[o][n]))return}else if(!o(i))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(Di(e));return ki(e)}(e))))}function Gi(e,t){let o,i,n=e.substring(0,2);"<="===n||">="===n||"<>"===n?(o=n,i=e.substring(2)):(n=e.substring(0,1),"<"===n||">"===n||"="===n?(o=n,i=e.substring(1)):(o="=",i=e)),Qt(i)?i=Oi(i):"TRUE"!==i&&"FALSE"!==i||(i=ki(i));const s={operator:o,operand:i};return"string"==typeof i&&(t&&(i+="*"),s.regexp=function(e){let t="",o="";for(let i of e)"?"===i&&"~"!==o?t+=".":"*"===i&&"~"!==o?t+=".*":("*"!==i&&"?"!==i||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(i)&&(t+="\\"),t+=i),o=i;return new RegExp("^"+t+"$","i")}(i)),s}function qi(e,t){const{operator:o,operand:i}=t;if(void 0===e||void 0===i)return!1;if("number"==typeof i&&"="===o)return _i(e)===_i(i);if("<>"===o||"="===o){let n;return n=typeof e==typeof i&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===i),"="===o?n:!n}if(typeof e==typeof i)switch(o){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function Zi(e,t,o=!1){const i=e.length;if(i%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<i-1;t+=2){const i=e[t];if(!Array.isArray(i)||i.length!==n||i[0].length!==r)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=_i(e[t+1]);a.push(Gi(l,o))}for(let o=0;o<n;o++)for(let n=0;n<r;n++){let s=!0;for(let t=0;t<i-1;t+=2){if(s=qi(e[t][o][n],a[t/2]),!s)break}s&&t(o,n)}}function ji(e,t){return Fi(e[0][t])}function Xi(e,t){return Fi(e[t][0])}function Yi(e,t,o,i,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"===o&&d===t?(a=d,l=h):"nextSmaller"===o&&d<=t?(void 0===a||a<d||a===d&&"asc"===i&&l<h||a===d&&"desc"===i&&l>h)&&(a=d,l=h):"nextGreater"===o&&d>=t&&(void 0===a||a>d||a===d&&"asc"===i&&l<h||a===d&&"desc"===i&&l>h)&&(a=d,l=h),"asc"===i&&d>t||"desc"===i&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function Ki(e,t,o,i,n,s=!1){if(null==t)return-1;const r=s?(e,t)=>n(e,i-t-1):n;let a,l=-1;for(let n=0;n<i;n++){const c=r(e,n);if(c===t)return s?i-n-1:n;"nextSmaller"===o?(!a&&Qi(t,c)>=0||Qi(t,c)>=0&&Qi(c,a)>0)&&(a=c,l=n):"nextGreater"===o&&(!a&&Qi(t,c)<=0||Qi(t,c)<=0&&Qi(c,a)<0)&&(a=c,l=n)}return s?i-l-1:l}function Qi(e,t){let o=Ti.indexOf(typeof e)-Ti.indexOf(typeof t);return 0===o&&("string"==typeof e&&"string"==typeof t?o=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?o=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(o=Number(e)-Number(t))),o}var Ji,en;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(Ji||(Ji={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(en||(en={}));const tn=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),on=new Set([...tn,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),nn=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),sn=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 rn(e){return sn.has(e.type)}class an{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new an}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var ln,cn,hn;function dn(e,t){return gn(un(e||""),t)}function un(e){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return Qt(e)||$e(e)?Oi(e):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function gn(e,t){const o=Ri(e);return o?{...pn(un(o.label),t||Co(o.label)),link:o}:pn(e,t)}function pn(e,t){try{for(const o of bn){const i=o(e,t);if(i)return i}return function(e,t){return{type:Ji.text,value:e,format:t,isAutoSummable:!0,defaultAlign:"left",formattedValue:ho(e,t)}}((e||"").toString(),t)}catch(t){return vn((e||"").toString(),new c(a.GenericError,t.message||ae))}}function mn(e,t){return{type:Ji.number,value:e||0,format:t,isAutoSummable:!0,defaultAlign:"right",formattedValue:ho(e,t)}}e.CommandResult=void 0,(ln=e.CommandResult||(e.CommandResult={}))[ln.Success=0]="Success",ln[ln.CancelledForUnknownReason=1]="CancelledForUnknownReason",ln[ln.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",ln[ln.MergeIsDestructive=3]="MergeIsDestructive",ln[ln.CellIsMerged=4]="CellIsMerged",ln[ln.InvalidTarget=5]="InvalidTarget",ln[ln.EmptyUndoStack=6]="EmptyUndoStack",ln[ln.EmptyRedoStack=7]="EmptyRedoStack",ln[ln.NotEnoughElements=8]="NotEnoughElements",ln[ln.NotEnoughSheets=9]="NotEnoughSheets",ln[ln.MissingSheetName=10]="MissingSheetName",ln[ln.DuplicatedSheetName=11]="DuplicatedSheetName",ln[ln.DuplicatedSheetId=12]="DuplicatedSheetId",ln[ln.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",ln[ln.WrongSheetMove=14]="WrongSheetMove",ln[ln.WrongSheetPosition=15]="WrongSheetPosition",ln[ln.InvalidAnchorZone=16]="InvalidAnchorZone",ln[ln.SelectionOutOfBound=17]="SelectionOutOfBound",ln[ln.TargetOutOfSheet=18]="TargetOutOfSheet",ln[ln.WrongCutSelection=19]="WrongCutSelection",ln[ln.WrongPasteSelection=20]="WrongPasteSelection",ln[ln.WrongPasteOption=21]="WrongPasteOption",ln[ln.WrongFigurePasteOption=22]="WrongFigurePasteOption",ln[ln.EmptyClipboard=23]="EmptyClipboard",ln[ln.EmptyRange=24]="EmptyRange",ln[ln.InvalidRange=25]="InvalidRange",ln[ln.InvalidZones=26]="InvalidZones",ln[ln.InvalidSheetId=27]="InvalidSheetId",ln[ln.InvalidFigureId=28]="InvalidFigureId",ln[ln.InputAlreadyFocused=29]="InputAlreadyFocused",ln[ln.MaximumRangesReached=30]="MaximumRangesReached",ln[ln.InvalidChartDefinition=31]="InvalidChartDefinition",ln[ln.InvalidDataSet=32]="InvalidDataSet",ln[ln.InvalidLabelRange=33]="InvalidLabelRange",ln[ln.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",ln[ln.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",ln[ln.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",ln[ln.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",ln[ln.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",ln[ln.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",ln[ln.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",ln[ln.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",ln[ln.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",ln[ln.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",ln[ln.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",ln[ln.InvalidAutofillSelection=45]="InvalidAutofillSelection",ln[ln.WrongComposerSelection=46]="WrongComposerSelection",ln[ln.MinBiggerThanMax=47]="MinBiggerThanMax",ln[ln.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",ln[ln.MidBiggerThanMax=49]="MidBiggerThanMax",ln[ln.MinBiggerThanMid=50]="MinBiggerThanMid",ln[ln.FirstArgMissing=51]="FirstArgMissing",ln[ln.SecondArgMissing=52]="SecondArgMissing",ln[ln.MinNaN=53]="MinNaN",ln[ln.MidNaN=54]="MidNaN",ln[ln.MaxNaN=55]="MaxNaN",ln[ln.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",ln[ln.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",ln[ln.MinInvalidFormula=58]="MinInvalidFormula",ln[ln.MidInvalidFormula=59]="MidInvalidFormula",ln[ln.MaxInvalidFormula=60]="MaxInvalidFormula",ln[ln.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",ln[ln.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",ln[ln.InvalidSortZone=63]="InvalidSortZone",ln[ln.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",ln[ln.MergeOverlap=65]="MergeOverlap",ln[ln.TooManyHiddenElements=66]="TooManyHiddenElements",ln[ln.Readonly=67]="Readonly",ln[ln.InvalidViewportSize=68]="InvalidViewportSize",ln[ln.InvalidScrollingDirection=69]="InvalidScrollingDirection",ln[ln.FigureDoesNotExist=70]="FigureDoesNotExist",ln[ln.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",ln[ln.InvalidCellPopover=72]="InvalidCellPopover",ln[ln.EmptyTarget=73]="EmptyTarget",ln[ln.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",ln[ln.FrozenPaneOverlap=75]="FrozenPaneOverlap",ln[ln.ValuesNotChanged=76]="ValuesNotChanged",ln[ln.InvalidFilterZone=77]="InvalidFilterZone",ln[ln.FilterOverlap=78]="FilterOverlap",ln[ln.FilterNotFound=79]="FilterNotFound",ln[ln.MergeInFilter=80]="MergeInFilter",ln[ln.NonContinuousTargets=81]="NonContinuousTargets",ln[ln.DuplicatedFigureId=82]="DuplicatedFigureId",ln[ln.InvalidSelectionStep=83]="InvalidSelectionStep",ln[ln.DuplicatedChartId=84]="DuplicatedChartId",ln[ln.ChartDoesNotExist=85]="ChartDoesNotExist",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(cn||(cn={})),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"}(hn||(hn={}));const fn={type:Ji.empty,value:"",format:void 0,isAutoSummable:!0,defaultAlign:"left",formattedValue:""};function vn(e,t){return{type:Ji.error,value:t.errorType,error:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:t.errorType}}const bn=[function(e,t){if(""===e)return function(e){return void 0===e?fn:{type:Ji.empty,value:"",format:e,isAutoSummable:!0,defaultAlign:"left",formattedValue:""}}(t)},function(e,t){if(t&&"number"==typeof e&&mo(t))return function(e,t){const o=ho(e,t);return{type:Ji.number,value:e,format:t,isAutoSummable:!1,defaultAlign:"right",formattedValue:o}}(e,t)},function(e,t){return"number"==typeof e?mn(e,t):null===e?mn(0,t):void 0},function(e,t){if("boolean"==typeof e)return function(e,t){const o=e?"TRUE":"FALSE";return{type:Ji.boolean,value:e,format:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:o}}(e,t)}],Sn=new bi;Sn.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const o=`${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:o},tooltip:{props:{content:o}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t)=>{var o;e.current+=e.increment;const i=e.current.toString(),n=ho(e.current,null===(o=t.cell)||void 0===o?void 0:o.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i},tooltip:i?{props:{content:n}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{var i,n,s;const r=(null===(i=t.cell)||void 0===i?void 0:i.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:dn(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,o,i)=>{e.current+=e.increment;let n=0,s=0;switch(i){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=o.createAdaptedRanges(r.dependencies,n,s,a),c=o.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 Cn=new bi,En=/(\d+)$/,wn=/^(.*\D+)/,yn=/^(.*\D+)(\d+)$/;function xn(e,t,o){let i=[],n=!1;for(let s of t){s===e&&(n=!0);const t=dn(null==s?void 0:s.content);if(o(t))i.push(t);else{if(n)return i;i=[]}}return i}function In(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let o=e[0];for(let i=1;i<e.length;i++){const n=e[i];t.push(n-o),o=n}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}Cn.add("simple_value_copy",{condition:(e,t)=>{var o;return 1===t.length&&!e.isFormula&&!(null===(o=e.format)||void 0===o?void 0:o.match(X))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&dn(e.content).type===Ji.text&&yn.test(e.content),generateRule:(e,t)=>{const o=parseInt(e.content.match(En)[0]),i=e.content.match(wn)[0],n=e.content.length-i.length,s=xn(e,t,(e=>e.type===Ji.text&&yn.test(e.value))).filter((e=>i===e.value.toString().match(wn)[0])).map((e=>parseInt(e.value.toString().match(En)[0]))),r=In(s);return{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:i,current:o,increment:r,numberPostfixLength:n}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&dn(e.content).type===Ji.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&&dn(e.content).type===Ji.number,generateRule:(e,t)=>{const o=In(xn(e,t,(e=>e.type===Ji.number)).map((e=>Number(e.value)))),i=dn(e.content);return{type:"INCREMENT_MODIFIER",increment:o,current:i.type===Ji.number?i.value:0}},sequence:40});ci`
|
|
53
|
+
`;class fi 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 wt(this.backgroundColor)>.3?"#525252":"#C8C8C8"}get figure(){return this.props.figure}get chartStyle(){return pi({padding:`${this.chartPadding}px`,background:this.backgroundColor})}get chartContentStyle(){return pi({height:`${this.getDrawableHeight()}px`})}get chartPadding(){return.02*this.props.figure.width}getTextStyles(){const e=.96*this.props.figure.width,t=this.getWidestElement(),o=t.getElementMaxFontSize(this.getDrawableHeight(),this);let i=function(e,t,o,i=.25){let n=1;if(o(n)>e)return n;if(o(t)<e)return t;let s=(n+t)/2,r=o(s),a=0;for(;Math.abs(r-e)>i&&a<20;)r>=e?t=(n+t)/2:n=(n+t)/2,s=(n+t)/2,r=o(s),a++;return s}(e,o,(e=>t.getElementWidth(e,this.ctx,this)))/o;const n=(new bi).getElementMaxFontSize(this.getDrawableHeight(),this)*i,s=(new vi).getElementMaxFontSize(this.getDrawableHeight(),this)*i;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=gi(e.cellStyle);return t["font-size"]=`${e.fontSize}px`,t.display="inline-block",!t.color&&e.color&&(t.color=e.color),pi(t)}getDrawableHeight(){const e=2*this.chartPadding;let t=this.props.figure.height-e;return t-=this.title?18*mi:0,t}getWidestElement(){const e=new vi,t=new bi;return e.getElementWidth(.35,this.ctx,this)>t.getElementWidth(.65,this.ctx,this)?e:t}}fi.template="o-spreadsheet-ScorecardChart";class vi{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.baseline,n="neutral"!==o.baselineArrowDirection?"A "+i:i;t.font=`${e}px ${q}`;let s=t.measureText(n).width;return t.font=`${.9*e}px ${q}`,s+=t.measureText(o.baselineDescr).width,s}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.35*e:0)/mi}}class bi{getElementWidth(e,t,o){if(!o.runtime)return 0;const i=o.keyValue||"";return t.font=`${e}px ${q}`,t.measureText(i).width}getElementMaxFontSize(e,t){if(!t.runtime)return 0;return(""!==t.baseline||t.baselineDescr?.65*e:e)/mi}}fi.props={figure:Object};class Si{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 Ci(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const Ei=new Si;function wi(e,t){return{url:e=Ci(e),label:t||e,isExternal:!0,isUrlEditable:!0}}Ei.add("sheet_URL",{match:e=>Ke(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=Je(e);return t.tryGetSheetName(o)||s("Invalid sheet")},open(e,t){const o=Je(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o})},sequence:0});const yi={createLink:wi,match:e=>Ze(e),open:e=>window.open(e,"_blank"),urlRepresentation:e=>e,sequence:0};function xi(e){return Ei.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((t=>t.match(e)))||yi}function Ii(e,t){return xi(e.url).urlRepresentation(e.url,t)}function Ri(e,t){xi(e.url).open(e.url,t)}function Ti(e){if("string"==typeof e){if(qe(e)){const{label:t,url:o}=Xe(e);return xi(o).createLink(o,t)}return Ze(e)?wi(e):void 0}}const Ai=["number","string","boolean","undefined"];function Mi(e,t){if(!e())throw new Error(t)}const Oi=e=>s("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function Ni(e){switch(typeof e){case"number":return e;case"boolean":return e?1:0;case"string":if(Qt(e)||""===e)return eo(e);const t=Se(e);if(t)return t.value;throw new Error(Oi(e));default:return 0}}function _i(e){if(""===e)throw new Error(Oi(e));return Ni(e)}function Fi(e){switch(typeof e){case"string":return e;case"number":return e.toString();case"boolean":return e?"TRUE":"FALSE";default:return""}}function Di(e){return"string"==typeof e?e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""):e}const ki=e=>s("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a number.",e);function Pi(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(ki(e))}return!1;case"number":return!!e;default:return!1}}function Li(e){return Ee(Ni(e))}function Ui(e,t,o){for(let i of e)if(Array.isArray(i)){const e=i.length,o=i[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)t(i[o][n])}else o(i)}function Vi(e,t){Ui(e,t,t)}function zi(e,t){Ui(e,(e=>{"number"==typeof e&&t(e)}),(e=>{t(_i(e))}))}function Bi(e,t,o,i){let n=i;for(let i of e)if(Array.isArray(i)){const e=i.length,o=i[0].length;for(let s=0;s<o;s++)for(let o=0;o<e;o++)n=t(n,i[o][s])}else n=o(n,i);return n}function Hi(e,t,o){return Bi(e,t,t,o)}function $i(e,t,o){return Bi(e,((e,o)=>"number"==typeof o?t(e,o):e),((e,o)=>t(e,_i(o))),o)}function Wi(e,t,o){return Bi(e,((e,o)=>null!=o?t(e,"number"==typeof o?o:"boolean"==typeof o?Ni(o):0):e),((e,o)=>t(e,Ni(o))),o)}function Gi(e,t){return function(e,t,o){for(let i of e)if(Array.isArray(i)){const e=i.length,o=i[0].length;for(let n=0;n<o;n++)for(let o=0;o<e;o++)if(!t(i[o][n]))return}else if(!o(i))return}(e,(e=>"boolean"==typeof e?t(e):"number"!=typeof e||t(!!e)),(e=>null==e||t(function(e){if(""===e)throw new Error(ki(e));return Pi(e)}(e))))}function qi(e,t){let o,i,n=e.substring(0,2);"<="===n||">="===n||"<>"===n?(o=n,i=e.substring(2)):(n=e.substring(0,1),"<"===n||">"===n||"="===n?(o=n,i=e.substring(1)):(o="=",i=e)),Qt(i)?i=Ni(i):"TRUE"!==i&&"FALSE"!==i||(i=Pi(i));const s={operator:o,operand:i};return"string"==typeof i&&(t&&(i+="*"),s.regexp=function(e){let t="",o="";for(let i of e)"?"===i&&"~"!==o?t+=".":"*"===i&&"~"!==o?t+=".*":("*"!==i&&"?"!==i||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(i)&&(t+="\\"),t+=i),o=i;return new RegExp("^"+t+"$","i")}(i)),s}function Zi(e,t){const{operator:o,operand:i}=t;if(void 0===e||void 0===i)return!1;if("number"==typeof i&&"="===o)return Fi(e)===Fi(i);if("<>"===o||"="===o){let n;return n=typeof e==typeof i&&("string"==typeof e&&t.regexp?t.regexp.test(e):e===i),"="===o?n:!n}if(typeof e==typeof i)switch(o){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function ji(e,t,o=!1){const i=e.length;if(i%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<i-1;t+=2){const i=e[t];if(!Array.isArray(i)||i.length!==n||i[0].length!==r)throw new Error(s("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const l=Fi(e[t+1]);a.push(qi(l,o))}for(let o=0;o<n;o++)for(let n=0;n<r;n++){let s=!0;for(let t=0;t<i-1;t+=2){if(s=Zi(e[t][o][n],a[t/2]),!s)break}s&&t(o,n)}}function Xi(e,t){return Di(e[0][t])}function Yi(e,t){return Di(e[t][0])}function Ki(e,t,o,i,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"===o&&d===t?(a=d,l=h):"nextSmaller"===o&&d<=t?(void 0===a||a<d||a===d&&"asc"===i&&l<h||a===d&&"desc"===i&&l>h)&&(a=d,l=h):"nextGreater"===o&&d>=t&&(void 0===a||a>d||a===d&&"asc"===i&&l<h||a===d&&"desc"===i&&l>h)&&(a=d,l=h),"asc"===i&&d>t||"desc"===i&&d<=t?p=h-1:g=c+1):g=c+1}return void 0!==l?l:-1}function Qi(e,t,o,i,n,s=!1){if(null==t)return-1;const r=s?(e,t)=>n(e,i-t-1):n;let a,l=-1;for(let n=0;n<i;n++){const c=r(e,n);if(c===t)return s?i-n-1:n;"nextSmaller"===o?(!a&&Ji(t,c)>=0||Ji(t,c)>=0&&Ji(c,a)>0)&&(a=c,l=n):"nextGreater"===o&&(!a&&Ji(t,c)<=0||Ji(t,c)<=0&&Ji(c,a)<0)&&(a=c,l=n)}return s?i-l-1:l}function Ji(e,t){let o=Ai.indexOf(typeof e)-Ai.indexOf(typeof t);return 0===o&&("string"==typeof e&&"string"==typeof t?o=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?o=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(o=Number(e)-Number(t))),o}var en,tn;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(en||(en={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(tn||(tn={}));const on=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","DELETE_CELL","INSERT_CELL","UNDO","REDO"]),nn=new Set([...on,"DUPLICATE_SHEET","EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","MOVE_CONDITIONAL_FORMAT"]),sn=new Set(["START","ACTIVATE_SHEET","COPY","PREPARE_SELECTION_INPUT_EXPANSION","STOP_SELECTION_INPUT","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","SELECT_SEARCH_NEXT_MATCH","SELECT_SEARCH_PREVIOUS_MATCH","REFRESH_SEARCH","UPDATE_SEARCH","CLEAR_SEARCH","EVALUATE_CELLS","SET_CURRENT_CONTENT","SET_FORMULA_VISIBILITY","OPEN_CELL_POPOVER","CLOSE_CELL_POPOVER","UPDATE_FILTER"]),rn=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 an(e){return rn.has(e.type)}class ln{constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>0!==e))}static get Success(){return new ln}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}var cn,hn,dn;function un(e,t){return pn(gn(e||""),t)}function gn(e){if(e.startsWith("="))throw new Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);return Qt(e)||$e(e)?Ni(e):function(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}(e)?"TRUE"===e.toUpperCase():e}function pn(e,t){const o=Ti(e);return o?{...mn(gn(o.label),t||Eo(o.label)),link:o}:mn(e,t)}function mn(e,t){try{for(const o of Sn){const i=o(e,t);if(i)return i}return function(e,t){return{type:en.text,value:e,format:t,isAutoSummable:!0,defaultAlign:"left",formattedValue:ho(e,t)}}((e||"").toString(),t)}catch(t){return bn((e||"").toString(),new c(a.GenericError,t.message||ae))}}function fn(e,t){return{type:en.number,value:e||0,format:t,isAutoSummable:!0,defaultAlign:"right",formattedValue:ho(e,t)}}e.CommandResult=void 0,(cn=e.CommandResult||(e.CommandResult={}))[cn.Success=0]="Success",cn[cn.CancelledForUnknownReason=1]="CancelledForUnknownReason",cn[cn.WillRemoveExistingMerge=2]="WillRemoveExistingMerge",cn[cn.MergeIsDestructive=3]="MergeIsDestructive",cn[cn.CellIsMerged=4]="CellIsMerged",cn[cn.InvalidTarget=5]="InvalidTarget",cn[cn.EmptyUndoStack=6]="EmptyUndoStack",cn[cn.EmptyRedoStack=7]="EmptyRedoStack",cn[cn.NotEnoughElements=8]="NotEnoughElements",cn[cn.NotEnoughSheets=9]="NotEnoughSheets",cn[cn.MissingSheetName=10]="MissingSheetName",cn[cn.DuplicatedSheetName=11]="DuplicatedSheetName",cn[cn.DuplicatedSheetId=12]="DuplicatedSheetId",cn[cn.ForbiddenCharactersInSheetName=13]="ForbiddenCharactersInSheetName",cn[cn.WrongSheetMove=14]="WrongSheetMove",cn[cn.WrongSheetPosition=15]="WrongSheetPosition",cn[cn.InvalidAnchorZone=16]="InvalidAnchorZone",cn[cn.SelectionOutOfBound=17]="SelectionOutOfBound",cn[cn.TargetOutOfSheet=18]="TargetOutOfSheet",cn[cn.WrongCutSelection=19]="WrongCutSelection",cn[cn.WrongPasteSelection=20]="WrongPasteSelection",cn[cn.WrongPasteOption=21]="WrongPasteOption",cn[cn.WrongFigurePasteOption=22]="WrongFigurePasteOption",cn[cn.EmptyClipboard=23]="EmptyClipboard",cn[cn.EmptyRange=24]="EmptyRange",cn[cn.InvalidRange=25]="InvalidRange",cn[cn.InvalidZones=26]="InvalidZones",cn[cn.InvalidSheetId=27]="InvalidSheetId",cn[cn.InvalidFigureId=28]="InvalidFigureId",cn[cn.InputAlreadyFocused=29]="InputAlreadyFocused",cn[cn.MaximumRangesReached=30]="MaximumRangesReached",cn[cn.InvalidChartDefinition=31]="InvalidChartDefinition",cn[cn.InvalidDataSet=32]="InvalidDataSet",cn[cn.InvalidLabelRange=33]="InvalidLabelRange",cn[cn.InvalidScorecardKeyValue=34]="InvalidScorecardKeyValue",cn[cn.InvalidScorecardBaseline=35]="InvalidScorecardBaseline",cn[cn.InvalidGaugeDataRange=36]="InvalidGaugeDataRange",cn[cn.EmptyGaugeRangeMin=37]="EmptyGaugeRangeMin",cn[cn.GaugeRangeMinNaN=38]="GaugeRangeMinNaN",cn[cn.EmptyGaugeRangeMax=39]="EmptyGaugeRangeMax",cn[cn.GaugeRangeMaxNaN=40]="GaugeRangeMaxNaN",cn[cn.GaugeRangeMinBiggerThanRangeMax=41]="GaugeRangeMinBiggerThanRangeMax",cn[cn.GaugeLowerInflectionPointNaN=42]="GaugeLowerInflectionPointNaN",cn[cn.GaugeUpperInflectionPointNaN=43]="GaugeUpperInflectionPointNaN",cn[cn.GaugeLowerBiggerThanUpper=44]="GaugeLowerBiggerThanUpper",cn[cn.InvalidAutofillSelection=45]="InvalidAutofillSelection",cn[cn.WrongComposerSelection=46]="WrongComposerSelection",cn[cn.MinBiggerThanMax=47]="MinBiggerThanMax",cn[cn.LowerBiggerThanUpper=48]="LowerBiggerThanUpper",cn[cn.MidBiggerThanMax=49]="MidBiggerThanMax",cn[cn.MinBiggerThanMid=50]="MinBiggerThanMid",cn[cn.FirstArgMissing=51]="FirstArgMissing",cn[cn.SecondArgMissing=52]="SecondArgMissing",cn[cn.MinNaN=53]="MinNaN",cn[cn.MidNaN=54]="MidNaN",cn[cn.MaxNaN=55]="MaxNaN",cn[cn.ValueUpperInflectionNaN=56]="ValueUpperInflectionNaN",cn[cn.ValueLowerInflectionNaN=57]="ValueLowerInflectionNaN",cn[cn.MinInvalidFormula=58]="MinInvalidFormula",cn[cn.MidInvalidFormula=59]="MidInvalidFormula",cn[cn.MaxInvalidFormula=60]="MaxInvalidFormula",cn[cn.ValueUpperInvalidFormula=61]="ValueUpperInvalidFormula",cn[cn.ValueLowerInvalidFormula=62]="ValueLowerInvalidFormula",cn[cn.InvalidSortZone=63]="InvalidSortZone",cn[cn.WaitingSessionConfirmation=64]="WaitingSessionConfirmation",cn[cn.MergeOverlap=65]="MergeOverlap",cn[cn.TooManyHiddenElements=66]="TooManyHiddenElements",cn[cn.Readonly=67]="Readonly",cn[cn.InvalidViewportSize=68]="InvalidViewportSize",cn[cn.InvalidScrollingDirection=69]="InvalidScrollingDirection",cn[cn.FigureDoesNotExist=70]="FigureDoesNotExist",cn[cn.InvalidConditionalFormatId=71]="InvalidConditionalFormatId",cn[cn.InvalidCellPopover=72]="InvalidCellPopover",cn[cn.EmptyTarget=73]="EmptyTarget",cn[cn.InvalidFreezeQuantity=74]="InvalidFreezeQuantity",cn[cn.FrozenPaneOverlap=75]="FrozenPaneOverlap",cn[cn.ValuesNotChanged=76]="ValuesNotChanged",cn[cn.InvalidFilterZone=77]="InvalidFilterZone",cn[cn.FilterOverlap=78]="FilterOverlap",cn[cn.FilterNotFound=79]="FilterNotFound",cn[cn.MergeInFilter=80]="MergeInFilter",cn[cn.NonContinuousTargets=81]="NonContinuousTargets",cn[cn.DuplicatedFigureId=82]="DuplicatedFigureId",cn[cn.InvalidSelectionStep=83]="InvalidSelectionStep",cn[cn.DuplicatedChartId=84]="DuplicatedChartId",cn[cn.ChartDoesNotExist=85]="ChartDoesNotExist",function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(hn||(hn={})),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"}(dn||(dn={}));const vn={type:en.empty,value:"",format:void 0,isAutoSummable:!0,defaultAlign:"left",formattedValue:""};function bn(e,t){return{type:en.error,value:t.errorType,error:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:t.errorType}}const Sn=[function(e,t){if(""===e)return function(e){return void 0===e?vn:{type:en.empty,value:"",format:e,isAutoSummable:!0,defaultAlign:"left",formattedValue:""}}(t)},function(e,t){if(t&&"number"==typeof e&&fo(t))return function(e,t){const o=ho(e,t);return{type:en.number,value:e,format:t,isAutoSummable:!1,defaultAlign:"right",formattedValue:o}}(e,t)},function(e,t){return"number"==typeof e?fn(e,t):null===e?fn(0,t):void 0},function(e,t){if("boolean"==typeof e)return function(e,t){const o=e?"TRUE":"FALSE";return{type:en.boolean,value:e,format:t,isAutoSummable:!1,defaultAlign:"center",formattedValue:o}}(e,t)}],Cn=new Si;Cn.add("ALPHANUMERIC_INCREMENT_MODIFIER",{apply:(e,t)=>{e.current+=e.increment;const o=`${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:o},tooltip:{props:{content:o}}}}}).add("INCREMENT_MODIFIER",{apply:(e,t)=>{var o;e.current+=e.increment;const i=e.current.toString(),n=ho(e.current,null===(o=t.cell)||void 0===o?void 0:o.format);return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:i},tooltip:i?{props:{content:n}}:void 0}}}).add("COPY_MODIFIER",{apply:(e,t,o)=>{var i,n,s;const r=(null===(i=t.cell)||void 0===i?void 0:i.content)||"";return{cellData:{border:t.border,style:t.cell&&t.cell.style,format:t.cell&&t.cell.format,content:r},tooltip:r?{props:{content:un(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,o,i)=>{e.current+=e.increment;let n=0,s=0;switch(i){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=o.createAdaptedRanges(r.dependencies,n,s,a),c=o.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 En=new Si,wn=/(\d+)$/,yn=/^(.*\D+)/,xn=/^(.*\D+)(\d+)$/;function In(e,t,o){let i=[],n=!1;for(let s of t){s===e&&(n=!0);const t=un(null==s?void 0:s.content);if(o(t))i.push(t);else{if(n)return i;i=[]}}return i}function Rn(e){let t=1;return e.length>=2&&(t=function(e){const t=[];let o=e[0];for(let i=1;i<e.length;i++){const n=e[i];t.push(n-o),o=n}return t.reduce(((e,t)=>e+t),0)/t.length}(e)*e.length),t}En.add("simple_value_copy",{condition:(e,t)=>{var o;return 1===t.length&&!e.isFormula&&!(null===(o=e.format)||void 0===o?void 0:o.match(X))},generateRule:()=>({type:"COPY_MODIFIER"}),sequence:10}).add("increment_alphanumeric_value",{condition:e=>!e.isFormula&&un(e.content).type===en.text&&xn.test(e.content),generateRule:(e,t)=>{const o=parseInt(e.content.match(wn)[0]),i=e.content.match(yn)[0],n=e.content.length-i.length,s=In(e,t,(e=>e.type===en.text&&xn.test(e.value))).filter((e=>i===e.value.toString().match(yn)[0])).map((e=>parseInt(e.value.toString().match(wn)[0]))),r=Rn(s);return{type:"ALPHANUMERIC_INCREMENT_MODIFIER",prefix:i,current:o,increment:r,numberPostfixLength:n}},sequence:15}).add("copy_text",{condition:e=>!e.isFormula&&un(e.content).type===en.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&&un(e.content).type===en.number,generateRule:(e,t)=>{const o=Rn(In(e,t,(e=>e.type===en.number)).map((e=>Number(e.value)))),i=un(e.content);return{type:"INCREMENT_MODIFIER",increment:o,current:i.type===en.number?i.value:0}},sequence:40});hi`
|
|
54
54
|
.o-error-tooltip {
|
|
55
55
|
font-size: 13px;
|
|
56
56
|
background-color: white;
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
width: ${180}px;
|
|
60
60
|
box-sizing: border-box !important;
|
|
61
61
|
}
|
|
62
|
-
`;class
|
|
62
|
+
`;class Tn extends t.Component{}Tn.maxSize={maxHeight:80},Tn.template="o-spreadsheet-ErrorToolTip",Tn.components={},Tn.props={text:String,onClosed:{type:Function,optional:!0}};const An={onHover:(e,t)=>{const o=t.getEvaluatedCell(e);return o.type===en.error&&o.error.logLevel>l.silent?{isOpen:!0,props:{text:o.error.message},Component:Tn,cellCorner:"TopRight"}:{isOpen:!1}}};hi`
|
|
63
63
|
.o-filter-menu-value {
|
|
64
64
|
padding: 4px;
|
|
65
65
|
line-height: 20px;
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
width: 20px;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
`;class
|
|
71
|
+
`;class Mn 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"}))}}Mn.template="o-spreadsheet-FilterMenuValueItem",Mn.props={value:String,isChecked:Boolean,isSelected:Boolean,onMouseMove:Function,onClick:Function,scrolledTo:{type:String,optional:!0}};const On=hi`
|
|
72
72
|
.o-filter-menu {
|
|
73
73
|
box-sizing: border-box;
|
|
74
74
|
padding: 8px 16px;
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
`;class
|
|
164
|
+
`;class Nn extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{at(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getFilter({sheetId:t,...e});if(!o)return[];const i=(o.filteredZone?Jo(o.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:o})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:o}).formattedValue)),n=this.env.model.getters.getFilterValues({sheetId:t,...e}),s=[...i,...n],r=n.map(ct);return[...new Set(s.map(ct))].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=>ct(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?_o(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const o=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...o,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let o;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));o=-1===e?void 0:e}switch(e.key){case"ArrowDown":o=void 0===o?0:Math.min(o+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":o=void 0===o?t.length-1:Math.max(o-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==o&&this.checkValue(t[o]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==o?t[o].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,o;const i=this.props.filterPosition,n=this.filterTable;if(!i||!n||!n.contentZone)return;const s=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:s,col:i.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(o=(t=this.props).onClosed)||void 0===o||o.call(t)}}Nn.size={width:H,height:295},Nn.template="o-spreadsheet-FilterMenu",Nn.style=On,Nn.components={FilterMenuValueItem:Mn},Nn.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const _n={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:Nn,cellCorner:"BottomLeft"})};function Fn(e,t){return!!t.target&&e.contains(t.target)}function Dn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function kn(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Pn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Pn(t)}function Ln(){const e=t.useState({x:0,y:0,width:0,height:0});let o=document.querySelector(".o-spreadsheet");function i(){if(o||(o=document.querySelector(".o-spreadsheet")),o){const{top:t,left:i,width:n,height:s}=o.getBoundingClientRect();e.x=i,e.y=t,e.width=n,e.height=s}}return i(),t.onMounted(i),t.onPatched(i),e}function Un(e){const o=t.useState({x:0,y:0,width:0,height:0});function i(){const t=e.el;if(null===t)return;const{top:i,left:n,width:s,height:r}=t.getBoundingClientRect();o.x=n,o.y=i,o.width=s,o.height=r}return t.onMounted(i),t.onPatched(i),o}function Vn(e,t){return(o=Wo(zn(e),zn(t)))?{x:o.left,y:o.top,width:o.right-o.left,height:o.bottom-o.top}:void 0;var o}function zn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}hi`
|
|
165
165
|
.o-popover {
|
|
166
166
|
position: absolute;
|
|
167
167
|
z-index: ${le.Popover};
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
width: fit-content;
|
|
171
171
|
height: fit-content;
|
|
172
172
|
}
|
|
173
|
-
`;class
|
|
173
|
+
`;class Bn extends t.Component{constructor(){super(...arguments),this.popoverRef=t.useRef("popover"),this.currentPosition=void 0,this.currentDisplayValue=void 0,this.spreadsheetRect=Ln()}setup(){this.containerRect=function(){const e=t.useState({x:0,y:0,width:0,height:0}),o=t.useComponent(),i=Ln();function n(){const t=o.env,n="getPopoverContainerRect"in t?t.getPopoverContainerRect():i;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,o,i;if(!this.containerRect)throw new Error("Popover container is not defined");const n=this.popoverRef.el,s=Vn(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 $n(s,this.containerRect,a,c):new Wn(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===(i=(o=this.props).onPopoverMoved)||void 0===i||i.call(o)),this.currentPosition=u}))}get popoverStyle(){return pi({"z-index":`${this.props.zIndex}`})}}Bn.template="o-spreadsheet-Popover",Bn.defaultProps={positioning:"BottomLeft",verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{},zIndex:le.Popover},Bn.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 Hn{constructor(e,t,o,i){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=o,this.spreadsheetOffset=i}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 o=this.getMaxHeight(e.height),i=this.getMaxWidth(e.width),n=Math.min(o,e.height),s=Math.min(i,e.width),r=this.shouldRenderAtBottom(e.height),a=this.shouldRenderAtRight(e.width);t=r?t:-t;return{"max-height":o+"px","max-width":i+"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),o=this.shouldRenderAtRight(e.width);return t&&o?"BottomRight":t&&!o?"BottomLeft":!t&&o?"TopRight":"TopLeft"}}class $n extends Hn{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 Wn extends Hn{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}}hi`
|
|
174
174
|
.o-menu {
|
|
175
175
|
background-color: white;
|
|
176
176
|
padding: ${8}px 0px;
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
`;class
|
|
223
|
+
`;class Gn extends t.Component{constructor(){super(...arguments),this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=Un(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 o=16+t;return this.props.maxHeight?Math.min(o,this.props.maxHeight):o}get popoverProps(){const e=1===this.props.depth;return{anchorRect:{x:this.props.position.x-H*(this.props.depth-1),y:this.props.position.y,width:e?0:H,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,o,i;const n=await(null===(t=e.action)||void 0===t?void 0:t.call(e,this.env));this.close(),null===(i=(o=this.props).onMenuClicked)||void 0===i||i.call(o,{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=>Fn(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 o=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+this.props.depth*H,y:o-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=e.children(this.env),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var o;return(null===(o=e.parentMenu)||void 0===o?void 0:o.id)===t.id}closeSubMenu(){this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 0}onClickMenu(e,t){this.isEnabled(e)&&(this.isRoot(e)?this.openSubMenu(e,t):this.activateMenu(e))}onMouseOver(e,t){e.isEnabled(this.env)&&(this.isRoot(e)?this.openSubMenu(e,t):this.closeSubMenu())}}Gn.template="o-spreadsheet-Menu",Gn.components={Menu:Gn,Popover:Bn},Gn.defaultProps={depth:1},Gn.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}};hi`
|
|
224
224
|
.o-link-tool {
|
|
225
225
|
font-size: 13px;
|
|
226
226
|
background-color: white;
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
cursor: pointer;
|
|
268
268
|
color: #000;
|
|
269
269
|
}
|
|
270
|
-
`;class
|
|
270
|
+
`;class qn extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:o,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. ${Bt(e,t)} is not a link.`)}getUrlRepresentation(e){return Ii(e,this.env.model.getters)}openLink(){Ri(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:o}=this.props.cellPosition,i=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:o}),n=(null==i?void 0:i.textColor)===x||null==i?void 0:i.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:o,sheetId:e,content:this.link.label,style:{...i,textColor:n,underline:void 0}})}}qn.components={Menu:Gn},qn.template="o-spreadsheet-LinkDisplay";const Zn={onHover:(e,t)=>{const o=t.getEvaluatedCell(e);return!t.isDashboard()&&o.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:qn,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}};function jn(e){return e.map(Yn).sort(((e,t)=>e.sequence-t.sequence))}qn.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const Xn=new Do;function Yn(e){const t=e.name,o=e.children;return{id:e.id||Xn.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,action:e.action,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(Yn):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon,description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class Kn extends Si{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,o){"function"!=typeof o&&void 0===o.id&&(o.id=e);const i=t.splice(0,1)[0];let n=this.content[i];if(!n)throw new Error(`Path ${i+":"+t.join(":")} not found`);for(let e of t){const o=n.children;if(!o||"function"==typeof o)throw new Error(`${e} is either not a node or it's dynamically computed`);if(n=o.find((t=>t.id===e)),!n)throw new Error(`Path ${i+":"+t.join(":")} not found`)}return n.children||(n.children=[]),n.children.push(o),this}getMenuItems(){return jn(this.getAll())}}const Qn=new Kn;Qn.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:()=>je(e.name,Qe(e.id))})))));hi`
|
|
271
271
|
.o-link-editor {
|
|
272
272
|
font-size: 13px;
|
|
273
273
|
background-color: white;
|
|
@@ -340,13 +340,13 @@
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
`;class Qn extends t.Component{constructor(){super(...arguments),this.menuItems=Kn.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Ln(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.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,o=Ri(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return xi(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:o,row:i}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:o,row:i,sheetId:this.env.model.getters.getActiveSheetId(),content:je(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()}}}Qn.template="o-spreadsheet-LinkEditor",Qn.components={Menu:Wn};const Jn={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Qn,cellCorner:"BottomLeft"})};Qn.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const es=new bi;function ts(e){return 8===(e=bt(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}es.add("ErrorToolTip",Tn).add("LinkCell",qn).add("LinkEditor",Jn).add("FilterMenu",Nn);class os{constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function is(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Bo(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Uo(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function ns(e,t,o,i){let n=!1;const s=[];for(let i in o){let r=o[i];if(r.labelCell){const e=as(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=as(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Y?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[i]=r}let r=i;const a=as(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(et),labelRange:r}}function ss(e,t,o){return o.map((o=>({dataRange:Mo(e,t,o.dataRange),labelCell:o.labelCell?Mo(e,t,o.labelCell):void 0})))}function rs(e,t,o){return o?Mo(e,t,o):void 0}function as(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function ls(e,t,o,i){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(o,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 o={...r,left:t,right:t};n.push(cs(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?i||n.push(cs(e,a,r,void 0)):n.push(cs(e,a,r,i?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function cs(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${Lo(o)}`);if(i){const n=Lo(o),s=Lo(i);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Lo(o))}}function hs(e,t){var o;const i=null===(o=t.labelCell)||void 0===o?void 0:o.zone;let n=t.dataRange.zone;if(i){const{numberOfRows:e,numberOfCols:t}=Yo(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 ds(e,t){let o;if(e.labelRange){const i=is(Do(e.labelRange),t);o=i?Lo(i):void 0}const i=e.dataSets.map(Do).map((e=>is(e,t))).filter(et).map(Lo);return{...e,labelRange:o,dataSets:i}}const us=["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 gs{constructor(){this.graphColorIndex=0}next(){return us[this.graphColorIndex++%us.length]}}function ps(e){return e&&wt(e)<.3?"#FFFFFF":"#000000"}function ms(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!_t.test(e)));if(t)return 32;if(e.dataSets.map(Do).some((e=>e.top!==e.bottom&&ii(e))))return 32}return 0}function fs(e){if(e.labelRange){if(!_t.test(e.labelRange||""))return 33}return 0}function vs(e,t,o){if(e){if("text"===o||(null==t?void 0:t.type)!==Ji.number||e.type!==Ji.number)return e.formattedValue;{let i=t.value-e.value;if("percentage"===o&&0!==i&&(i=i/e.value*100),"percentage"!==o&&e.format)return ho(i,e.format);const n=Math.abs(parseFloat(i.toFixed(2))).toLocaleString();return"percentage"===o?n+"%":n}}return""}function bs(e,t,o,i,n){if("text"===t||(null==e?void 0:e.type)!==Ji.number||(null==o?void 0:o.type)!==Ji.number)return;const s=o.value-e.value;return s>0?i:s<0?n:void 0}function Ss(e,t,o){if("text"===o||(null==e?void 0:e.type)!==Ji.number||(null==t?void 0:t.type)!==Ji.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const Cs={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")},Es={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")},ws={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")}},ys={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")},xs={Custom:s("Custom")},Is=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function Rs(e,t){if(t.dataRange){const o=t.labelCell?[Lo(t.labelCell.zone)]:[],i=jo([Lo(t.dataRange.zone)],o)[0];if(void 0===i)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Ts(e,t){const o=ze(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((o=>{const i=e[o],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[o]}));return i||n.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function As(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of ze(0,e.length)){const s=e[o];for(const e of ze(0,t.length))i[s][e]+="number"==typeof(n=t[e].data[o])?n:0}var n;return{labels:Object.keys(i),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(i).map((e=>e[t]))})))}}function Ms(e){return e?e.length>Q?e.substring(0,Q)+"…":e:""}function Os(e,t,o,i){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:o},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var o,n,s,r,a;let l=null===(n=null===(o=t.datasets)||void 0===o?void 0:o[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=i&&"number"==typeof c?ho(c,i):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(Ms),datasets:[]}}}function Ns(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<Rs(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:ze(0,Rs(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function _s(e,t){for(const o of t){const t=e.getRangeFormats(o.dataRange).find((e=>void 0!==e&&!mo(e)));if(t)return t}}function Fs(e,t){const o=[];for(const[i,n]of Object.entries(t)){let t;if(n.labelCell){const o=n.labelCell,s=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=s&&o?Ms(s.formattedValue):t=`${ws.Series} ${parseInt(i)+1}`}else t=t=`${ws.Series} ${parseInt(i)+1}`;let s=n.dataRange?Rs(e,n):[];o.push({data:s,label:t})}return o}function Ds(e){return 0===e?"origin":e-1}class ks extends os{constructor(e,t,o){super(e,t,o),this.type="bar",this.dataSets=ls(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Oo(o,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 ds(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,ms,fs)}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=ss(this.sheetId,e,this.dataSets),o=rs(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new ks(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ks(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>hs(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:ts(this.background||w),fontColor:ts(ps(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=ns(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new ks(n,this.sheetId,this.getters)}}function Ps(e){return e.dataRange&&!_t.test(e.dataRange)?36:0}function Ls(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Us(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function Vs(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function zs(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 Bs extends os{constructor(e,t,o){super(e,t,o),this.type="gauge",this.dataRange=Oo(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Ps,e.chainValidations(Ls(Vs,e.batchValidations),Ls(zs,e.batchValidations),Us),e.chainValidations((o=zs,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=is(Do(e.dataRange),t)),{...e,dataRange:o?Lo(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=rs(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new Bs(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Bs(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=as(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new Bs(o,this.sheetId,this.getters)}}const Hs={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},$s={inSeconds:function(e){return Math.floor(e/Hs.second)},inMinutes:function(e){return Math.floor(e/Hs.minute)},inHours:function(e){return Math.floor(e/Hs.hour)},inDays:function(e){return Math.floor(e/Hs.day)},inMonths:function(e){return Math.floor(e/Hs.month)},inYears:function(e){return Math.floor(e/Hs.year)}},Ws=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function Gs(e,t){const o=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),i=function(e,t){const o=e.map((e=>{var t;return null===(t=Se(e))||void 0===t?void 0:t.jsDate}));if(o.some((e=>void 0===e))||e.length<2)return;const i=o.map((e=>e.getTime())),n=Math.max(...i)-Math.min(...i),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(Hs.second>=Hs[s]&&$s.inSeconds(n)<180)return"second";if(Hs.minute>=Hs[s]&&$s.inMinutes(n)<180)return"minute";if(Hs.hour>=Hs[s]&&$s.inHours(n)<96)return"hour";if(Hs.day>=Hs[s]&&$s.inDays(n)<90)return"day";if(Hs.month>=Hs[s]&&$s.inMonths(n)<36)return"month";return"year"}(e,o),n={};return i&&(n[i]=o),{parser:o,displayFormats:n,unit:i}}class qs extends os{constructor(e,t,o){super(e,t,o),this.type="line",this.dataSets=ls(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Oo(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}static validateChartDefinition(e,t){return e.checkValidations(t,ms,fs)}static transformDefinition(e,t){return ds(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}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=ns(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new qs(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>hs(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:ts(this.background||w),fontColor:ts(ps(this.background)),dataSets:e}}copyForSheetId(e){const t=ss(this.sheetId,e,this.dataSets),o=rs(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new qs(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new qs(t,e,this.getters)}}function Zs(e,t){return Xs(e,t)||Ys(e,t)}function js(e,t){return function(e,t){return!e.labelsAsText&&Xs(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&Ys(e.labelRange,t)}(e,t)?"linear":"category"}function Xs(e,t){if(!e||!Ys(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&Ws.test(o))}function Ys(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class Ks extends os{constructor(e,t,o){super(e,t,o),this.type="pie",this.dataSets=ls(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Oo(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return ds(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,ms,fs)}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,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=ss(this.sheetId,e,this.dataSets),o=rs(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Ks(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Ks(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>hs(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:ts(this.background||w),fontColor:ts(ps(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=ns(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new Ks(n,this.sheetId,this.getters)}}function Qs(e,t){const o=[],i=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function Js(e){return e.keyValue&&!_t.test(e.keyValue)?34:0}function er(e){return e.baseline&&!_t.test(e.baseline)?35:0}class tr extends os{constructor(e,t,o){super(e,t,o),this.type="scorecard",this.keyValue=Oo(o,t,e.keyValue),this.baseline=Oo(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,Js,er)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:ee,baselineColorUp:te,baselineColorDown:oe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=is(Do(e.baseline),t)),e.keyValue&&(i=is(Do(e.keyValue),t)),{...e,baseline:o?Lo(o):void 0,keyValue:i?Lo(i):void 0}}copyForSheetId(e){const t=rs(this.sheetId,e,this.baseline),o=rs(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new tr(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new tr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=as(this.baseline,e),o=as(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new tr(i,this.sheetId,this.getters)}}const or=new bi;or.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new ks(e,t,o),getChartRuntime:function(e,t){let o=Ns(t,e.dataSets,e.labelRange).formattedValues,i=Fs(t,e.dataSets);({labels:o,dataSetsValues:i}=Ts(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=As(o,i));const n=function(e,t,o){var i;const n=ps(e.background),s=Os(e,t,n,o),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===(i=s.options)||void 0===i?void 0:i.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=>o?ho(e,o):(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,o,_s(t,e.dataSets)),s=new gs;for(let{label:e,data:t}of i){const o=s.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};n.data.datasets.push(i)}return{chartJsConfig:n,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("Bar"),sequence:10}),or.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new qs(e,t,o),getChartRuntime:function(e,t){const o=js(e,t),i=Ns(t,e.dataSets,e.labelRange);let n="linear"===o?i.values:i.formattedValues,s=Fs(t,e.dataSets);({labels:n,dataSetsValues:s}=Ts(n,s)),"time"===o&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Ne(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=st(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=As(n,s));const r=_s(t,e.dataSets),a=function(e,t,o){var i;const n=ps(e.background),s=Os(e,t,n,o),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(i=s.options)||void 0===i?void 0:i.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=>o?ho(e,o):(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"===o?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=Gs(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>ho(e,l),a.options.tooltips.callbacks.title=e=>{var t;return ho((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new gs;for(let[t,{label:i,data:r}]of s.entries()){["linear","time"].includes(o)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=xt(s);e.stacked&&(l.a=ie);const h={label:i,data:r,lineTension:0,borderColor:s,backgroundColor:yt(l),pointBackgroundColor:s,fill:!!e.stacked&&Ds(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}),or.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new Ks(e,t,o),getChartRuntime:function(e,t){let o=Ns(t,e.dataSets,e.labelRange).formattedValues,i=Fs(t,e.dataSets);({labels:o,dataSetsValues:i}=Ts(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=As(o,i));const n=function(e,t,o){var i;const n=ps(e.background),s=Os(e,t,n,o),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===(i=s.options)||void 0===i?void 0:i.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,o,_s(t,e.dataSets)),s=new gs;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Qs(s,i)};n.data.datasets.push(o)}return{chartJsConfig:n,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("Pie"),sequence:30}),or.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new tr(e,t,o),getChartRuntime:function(e,t){let o,i,s="",r="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),s=String(o.value),r=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:vs(i,o,e.baselineMode),baselineArrow:Ss(i,o,e.baselineMode),baselineColor:bs(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:ps(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)=>tr.validateChartDefinition(e,t),transformDefinition:(e,t)=>tr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>tr.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),or.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new Bs(e,t,o),getChartRuntime:function(e,t){const o=function(e){const t=Os(e,[],ps(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),i=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:De(e,l,c),color:i.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:De(e,l,c),color:i.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(i.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===Ji.number&&(f=De(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return o.options.valueLabel.display=b,o.options.valueLabel.formatter=v,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>Bs.validateChartDefinition(e,t),transformDefinition:(e,t)=>Bs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Bs.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const ir=new bi;ir.add("line",ri),ir.add("bar",ri),ir.add("pie",ri),ir.add("gauge",ri),ir.add("scorecard",mi);const nr=new bi;ci`
|
|
343
|
+
`;class Jn extends t.Component{constructor(){super(...arguments),this.menuItems=Qn.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=Un(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,o=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t});return i.link?{url:i.link.url,label:i.formattedValue,isUrlEditable:i.link.isUrlEditable}:{label:i.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,o=Ti(t);o&&(this.link.url=o.url,this.link.label=o.label,this.link.isUrlEditable=o.isUrlEditable)}getUrlRepresentation(e){return Ii(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:o,row:i}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:o,row:i,sheetId:this.env.model.getters.getActiveSheetId(),content:je(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()}}}Jn.template="o-spreadsheet-LinkEditor",Jn.components={Menu:Gn};const es={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:Jn,cellCorner:"BottomLeft"})};Jn.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const ts=new Si;function os(e){return 8===(e=bt(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}ts.add("ErrorToolTip",An).add("LinkCell",Zn).add("LinkEditor",es).add("FilterMenu",_n);class is{constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function ns(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Ho(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Vo(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function ss(e,t,o,i){let n=!1;const s=[];for(let i in o){let r=o[i];if(r.labelCell){const e=ls(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=ls(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===Y?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[i]=r}let r=i;const a=ls(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(et),labelRange:r}}function rs(e,t,o){return o.map((o=>({dataRange:Oo(e,t,o.dataRange),labelCell:o.labelCell?Oo(e,t,o.labelCell):void 0})))}function as(e,t,o){return o?Oo(e,t,o):void 0}function ls(e,t){if(!e)return;const o=t(e);switch(o.changeType){case"NONE":return e;case"REMOVE":return;default:return o.range}}function cs(e,t,o,i){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(o,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 o={...r,left:t,right:t};n.push(hs(e,a,o,i?{top:o.top,bottom:o.top,left:o.left,right:o.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?i||n.push(hs(e,a,r,void 0)):n.push(hs(e,a,r,i?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function hs(e,t,o,i){if(o.left!==o.right&&o.top!==o.bottom)throw new Error(`Zone should be a single column or row: ${Uo(o)}`);if(i){const n=Uo(o),s=Uo(i);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,Uo(o))}}function ds(e,t){var o;const i=null===(o=t.labelCell)||void 0===o?void 0:o.zone;let n=t.dataRange.zone;if(i){const{numberOfRows:e,numberOfCols:t}=Ko(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 us(e,t){let o;if(e.labelRange){const i=ns(ko(e.labelRange),t);o=i?Uo(i):void 0}const i=e.dataSets.map(ko).map((e=>ns(e,t))).filter(et).map(Uo);return{...e,labelRange:o,dataSets:i}}const gs=["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 ps{constructor(){this.graphColorIndex=0}next(){return gs[this.graphColorIndex++%gs.length]}}function ms(e){return e&&wt(e)<.3?"#FFFFFF":"#000000"}function fs(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!_t.test(e)));if(t)return 32;if(e.dataSets.map(ko).some((e=>e.top!==e.bottom&&ni(e))))return 32}return 0}function vs(e){if(e.labelRange){if(!_t.test(e.labelRange||""))return 33}return 0}function bs(e,t,o){if(e){if("text"===o||(null==t?void 0:t.type)!==en.number||e.type!==en.number)return e.formattedValue;{let i=t.value-e.value;if("percentage"===o&&0!==i&&(i=i/e.value*100),"percentage"!==o&&e.format)return ho(i,e.format);const n=Math.abs(parseFloat(i.toFixed(2))).toLocaleString();return"percentage"===o?n+"%":n}}return""}function Ss(e,t,o,i,n){if("text"===t||(null==e?void 0:e.type)!==en.number||(null==o?void 0:o.type)!==en.number)return;const s=o.value-e.value;return s>0?i:s<0?n:void 0}function Cs(e,t,o){if("text"===o||(null==e?void 0:e.type)!==en.number||(null==t?void 0:t.type)!==en.number)return"neutral";const i=t.value-e.value;return i>0?"up":i<0?"down":"neutral"}const Es={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")},ws={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")},ys={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")}},xs={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")},Is={Custom:s("Custom")},Rs=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function Ts(e,t){if(t.dataRange){const o=t.labelCell?[Uo(t.labelCell.zone)]:[],i=Xo([Uo(t.dataRange.zone)],o)[0];if(void 0===i)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,i);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function As(e,t){const o=ze(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((o=>{const i=e[o],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[o]}));return i||n.some((e=>0===e||Boolean(e)))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>e.data[t]))})))}}function Ms(e,t){const o=new Set(e),i={};o.forEach((e=>{i[e]=new Array(t.length).fill(0)}));for(const o of ze(0,e.length)){const s=e[o];for(const e of ze(0,t.length))i[s][e]+="number"==typeof(n=t[e].data[o])?n:0}var n;return{labels:Object.keys(i),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(i).map((e=>e[t]))})))}}function Os(e){return e?e.length>Q?e.substring(0,Q)+"…":e:""}function Ns(e,t,o,i){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:o},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var o,n,s,r,a;let l=null===(n=null===(o=t.datasets)||void 0===o?void 0:o[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=i&&"number"==typeof c?ho(c,i):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(Os),datasets:[]}}}function _s(e,t,o){let i={values:[],formattedValues:[]};if(o)o.invalidXc||o.invalidSheetName||(i={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e)))});else if(1===t.length)for(let o=0;o<Ts(e,t[0]).length;o++)i.formattedValues.push(""),i.values.push("");else if(t[0]){i={formattedValues:ze(0,Ts(e,t[0]).length).map((e=>e.toString())),values:i.formattedValues}}return i}function Fs(e,t){for(const o of t){const t=e.getRangeFormats(o.dataRange).find((e=>void 0!==e&&!fo(e)));if(t)return t}}function Ds(e,t){const o=[];for(const[i,n]of Object.entries(t)){let t;if(n.labelCell){const o=n.labelCell,s=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=s&&o?Os(s.formattedValue):t=`${ys.Series} ${parseInt(i)+1}`}else t=t=`${ys.Series} ${parseInt(i)+1}`;let s=n.dataRange?Ts(e,n):[];o.push({data:s,label:t})}return o}function ks(e){return 0===e?"origin":e-1}class Ps extends is{constructor(e,t,o){super(e,t,o),this.type="bar",this.dataSets=cs(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=No(o,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 us(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,fs,vs)}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=rs(this.sheetId,e,this.dataSets),o=as(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Ps(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Ps(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>ds(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:os(this.background||w),fontColor:os(ms(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=ss(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new Ps(n,this.sheetId,this.getters)}}function Ls(e){return e.dataRange&&!_t.test(e.dataRange)?36:0}function Us(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Vs(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function zs(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function Bs(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 Hs extends is{constructor(e,t,o){super(e,t,o),this.type="gauge",this.dataRange=No(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Ls,e.chainValidations(Us(zs,e.batchValidations),Us(Bs,e.batchValidations),Vs),e.chainValidations((o=Bs,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var o}static transformDefinition(e,t){let o;return e.dataRange&&(o=ns(ko(e.dataRange),t)),{...e,dataRange:o?Uo(o):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=as(this.sheetId,e,this.dataRange),o=this.getDefinitionWithSpecificRanges(t,e);return new Hs(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Hs(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=ls(this.dataRange,e);if(this.dataRange===t)return this;const o=this.getDefinitionWithSpecificRanges(t);return new Hs(o,this.sheetId,this.getters)}}const $s={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Ws={inSeconds:function(e){return Math.floor(e/$s.second)},inMinutes:function(e){return Math.floor(e/$s.minute)},inHours:function(e){return Math.floor(e/$s.hour)},inDays:function(e){return Math.floor(e/$s.day)},inMonths:function(e){return Math.floor(e/$s.month)},inYears:function(e){return Math.floor(e/$s.year)}},Gs=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function qs(e,t){const o=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),i=function(e,t){const o=e.map((e=>{var t;return null===(t=Se(e))||void 0===t?void 0:t.jsDate}));if(o.some((e=>void 0===e))||e.length<2)return;const i=o.map((e=>e.getTime())),n=Math.max(...i)-Math.min(...i),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($s.second>=$s[s]&&Ws.inSeconds(n)<180)return"second";if($s.minute>=$s[s]&&Ws.inMinutes(n)<180)return"minute";if($s.hour>=$s[s]&&Ws.inHours(n)<96)return"hour";if($s.day>=$s[s]&&Ws.inDays(n)<90)return"day";if($s.month>=$s[s]&&Ws.inMonths(n)<36)return"month";return"year"}(e,o),n={};return i&&(n[i]=o),{parser:o,displayFormats:n,unit:i}}class Zs extends is{constructor(e,t,o){super(e,t,o),this.type="line",this.dataSets=cs(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=No(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}static validateChartDefinition(e,t){return e.checkValidations(t,fs,vs)}static transformDefinition(e,t){return us(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}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=ss(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new Zs(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>ds(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:os(this.background||w),fontColor:os(ms(this.background)),dataSets:e}}copyForSheetId(e){const t=rs(this.sheetId,e,this.dataSets),o=as(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Zs(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Zs(t,e,this.getters)}}function js(e,t){return Ys(e,t)||Ks(e,t)}function Xs(e,t){return function(e,t){return!e.labelsAsText&&Ys(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&Ks(e.labelRange,t)}(e,t)?"linear":"category"}function Ys(e,t){if(!e||!Ks(e,t))return!1;const o=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(o&&Gs.test(o))}function Ks(e,t){if(!e)return!1;const o=t.getRangeValues(e);return!o.some((e=>isNaN(Number(e))&&e))&&!o.every((e=>!e))}class Qs extends is{constructor(e,t,o){super(e,t,o),this.type="pie",this.dataSets=cs(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=No(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return us(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,fs,vs)}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,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,o||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=rs(this.sheetId,e,this.dataSets),o=as(this.sheetId,e,this.labelRange),i=this.getDefinitionWithSpecificDataSets(t,o,e);return new Qs(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Qs(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>ds(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:os(this.background||w),fontColor:os(ms(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:i}=ss(this.getters,e,this.dataSets,this.labelRange);if(!i)return this;const n=this.getDefinitionWithSpecificDataSets(t,o);return new Qs(n,this.sheetId,this.getters)}}function Js(e,t){const o=[],i=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=i;t++)o.push(e.next());return o}function er(e){return e.keyValue&&!_t.test(e.keyValue)?34:0}function tr(e){return e.baseline&&!_t.test(e.baseline)?35:0}class or extends is{constructor(e,t,o){super(e,t,o),this.type="scorecard",this.keyValue=No(o,t,e.keyValue),this.baseline=No(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,er,tr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:ee,baselineColorUp:te,baselineColorDown:oe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let o,i;return e.baseline&&(o=ns(ko(e.baseline),t)),e.keyValue&&(i=ns(ko(e.keyValue),t)),{...e,baseline:o?Uo(o):void 0,keyValue:i?Uo(i):void 0}}copyForSheetId(e){const t=as(this.sheetId,e,this.baseline),o=as(this.sheetId,e,this.keyValue),i=this.getDefinitionWithSpecificRanges(t,o,e);return new or(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new or(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=ls(this.baseline,e),o=ls(this.keyValue,e);if(this.baseline===t&&this.keyValue===o)return this;const i=this.getDefinitionWithSpecificRanges(t,o);return new or(i,this.sheetId,this.getters)}}const ir=new Si;ir.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new Ps(e,t,o),getChartRuntime:function(e,t){let o=_s(t,e.dataSets,e.labelRange).formattedValues,i=Ds(t,e.dataSets);({labels:o,dataSetsValues:i}=As(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=Ms(o,i));const n=function(e,t,o){var i;const n=ms(e.background),s=Ns(e,t,n,o),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===(i=s.options)||void 0===i?void 0:i.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=>o?ho(e,o):(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,o,Fs(t,e.dataSets)),s=new ps;for(let{label:e,data:t}of i){const o=s.next(),i={label:e,data:t,borderColor:o,backgroundColor:o};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>Ps.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ps.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ps.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),ir.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new Zs(e,t,o),getChartRuntime:function(e,t){const o=Xs(e,t),i=_s(t,e.dataSets,e.labelRange);let n="linear"===o?i.values:i.formattedValues,s=Ds(t,e.dataSets);({labels:n,dataSetsValues:s}=As(n,s)),"time"===o&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],i=Ne(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=st(o,e);for(let t of i)t.data[e]=void 0}return{labels:o,dataSetsValues:i}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=Ms(n,s));const r=Fs(t,e.dataSets),a=function(e,t,o){var i;const n=ms(e.background),s=Ns(e,t,n,o),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,o=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,i]of o.entries())i.fillStyle=t.datasets[e].borderColor;return o}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(i=s.options)||void 0===i?void 0:i.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=>o?ho(e,o):(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"===o?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=qs(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===o&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>ho(e,l),a.options.tooltips.callbacks.title=e=>{var t;return ho((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new ps;for(let[t,{label:i,data:r}]of s.entries()){["linear","time"].includes(o)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=xt(s);e.stacked&&(l.a=ie);const h={label:i,data:r,lineTension:0,borderColor:s,backgroundColor:yt(l),pointBackgroundColor:s,fill:!!e.stacked&&ks(t)};a.data.datasets.push(h)}return{chartJsConfig:a,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("Line"),sequence:20}),ir.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new Qs(e,t,o),getChartRuntime:function(e,t){let o=_s(t,e.dataSets,e.labelRange).formattedValues,i=Ds(t,e.dataSets);({labels:o,dataSetsValues:i}=As(o,i)),e.aggregated&&({labels:o,dataSetsValues:i}=Ms(o,i));const n=function(e,t,o){var i;const n=ms(e.background),s=Ns(e,t,n,o),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===(i=s.options)||void 0===i?void 0:i.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,o,Fs(t,e.dataSets)),s=new ps;for(let{label:e,data:t}of i){const o={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:Js(s,i)};n.data.datasets.push(o)}return{chartJsConfig:n,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("Pie"),sequence:30}),ir.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new or(e,t,o),getChartRuntime:function(e,t){let o,i,s="",r="";if(e.keyValue){const i={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(i),s=String(o.value),r=o.formattedValue}const a=e.baseline;if(a){const o={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};i=t.getEvaluatedCell(o)}const l=t.getBackgroundOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:bs(i,o,e.baselineMode),baselineArrow:Cs(i,o,e.baselineMode),baselineColor:Ss(i,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:ms(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)=>or.validateChartDefinition(e,t),transformDefinition:(e,t)=>or.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>or.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),ir.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new Hs(e,t,o),getChartRuntime:function(e,t){const o=function(e){const t=Ns(e,[],ms(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),i=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:De(e,l,c),color:i.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:De(e,l,c),color:i.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(i.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===en.number&&(f=De(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return o.options.valueLabel.display=b,o.options.valueLabel.formatter=v,o.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:o,background:t.getBackgroundOfSingleCellChart(e.background,p)}},validateChartDefinition:(e,t)=>Hs.validateChartDefinition(e,t),transformDefinition:(e,t)=>Hs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Hs.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const nr=new Si;nr.add("line",ai),nr.add("bar",ai),nr.add("pie",ai),nr.add("gauge",ai),nr.add("scorecard",fi);const sr=new Si;hi`
|
|
344
344
|
.o-chart-container {
|
|
345
345
|
width: 100%;
|
|
346
346
|
height: 100%;
|
|
347
347
|
position: relative;
|
|
348
348
|
}
|
|
349
|
-
`;class sr extends t.Component{get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=ir.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}sr.template="o-spreadsheet-ChartFigure",sr.components={},sr.props={figure:Object,onFigureDeleted:Function};class rr extends t.Component{get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function ar(e,t){const o=Ne(t),i=e.getSheetViewDimension(),n=i.width,s=i.height;if(o.width>n){const e=n/o.width;o.width=n,o.height=o.height*e}if(o.height>s){const e=s/o.height;o.height=s,o.width=o.width*e}return o}rr.template="o-spreadsheet-ImageFigure",rr.components={},rr.props={figure:Object,onFigureDeleted:Function};const lr=new bi;function cr(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 hr(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 dr(e,t,o){return{id:"delete",name:s("Delete"),sequence:10,action:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()}}}lr.add("chart",{Component:sr,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return Zn([{id:"edit",name:s("Edit"),sequence:1,action:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")}},cr(e,o),hr(e,o),dr(e,t,o)])}}),lr.add("image",{Component:rr,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return Zn([cr(e,o),hr(e,o),{id:"reset_size",name:s("Reset size"),sequence:4,action:()=>{const t=o.model.getters.getImageSize(e),{height:i,width:n}=ar(o.model.getters,t);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:i,width:n})}},dr(e,t,o)])}});const ur=(new bi).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Be(o)){const o=0===i[0]?0:i[0]-1,n=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,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 sn.values())ur.contains(e)||ur.add(e,gr);function gr(e){return[e]}function pr(e,t){const o=or.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function mr(e,t){var o;let i=e;e.left!==e.right&&(i={...e,left:e.left+1});const s=[Lo(i)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===ni(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(o=a.style)||void 0===o?void 0:o.fillColor)||void 0,keyValue:Lo(e),baselineMode:ee,baselineColorUp:te,baselineColorDown:oe};let l="";const c=t.getEvaluatedCellsInZone(r,{...i,bottom:i.top}),h=!!c.find((e=>e.type!==Ji.empty&&e.type!==Ji.number));if(h){const e=c.filter((e=>e.type!==Ji.error&&e.type!==Ji.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=Lo({...e,right:e.left,top:h?e.top+1:e.top}));const u=i.right===i.left?"none":"top";return Zs(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!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 fr=[Ji.number,Ji.error,Ji.text,Ji.boolean];function vr(e,t,o,i,n){let r=an.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let n=i.top;n<=i.bottom;n++){o=[];for(let s=i.left;s<=i.right;s++){let i=e.model.getters.getMerge({sheetId:t,col:s,row:n});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n});else{const o=e.model.getters.getContiguousZone(t,i);Wo(o,i)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,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?"),(()=>{i=o,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=o;e.model.selection.selectZone({cell:{col:t,row:n},zone:i}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function br(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}const Sr={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 Cr(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(78)?e.raiseError(Sr.filterOverlap):i.isCancelledBecause(80)?e.raiseError(Sr.mergeInFilter):i.isCancelledBecause(81)&&e.raiseError(Sr.nonContinuousTargets)}const Er={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 wr(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Er.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Er.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Er.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(Er.frozenPaneOverlap))}function yr(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});wr(e,i)}function xr(e,t,o){const i=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o});wr(e,i)}function Ir(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 Rr(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 Tr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Ar(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const Mr=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},Or=async e=>{br(e),await e.clipboard.write(e.model.getters.getClipboardContent())},Nr=async e=>Fr(e),_r=async e=>Fr(e,"onlyValue");async function Fr(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const n=e.model.getters.getSelectedZones();i&&i.content!==o?xr(e,n,i.content):yr(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 Dr=e=>yr(e,e.model.getters.getSelectedZones(),"onlyFormat"),kr=e=>!e.model.getters.isCutOperation(),Pr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},Lr=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Ur=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?s("Delete column %s",Ut(t)):s("Delete columns %s - %s",Ut(t),Ut(o))},Vr=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},zr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});wr(e,o)},Br=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});wr(e,o)},Hr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});wr(e,o)},$r=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});wr(e,o)},Wr=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},Gr=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},qr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},Zr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const jr=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},Xr=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},Yr=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},Kr=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();vr(e,i,t.cell,o[0],"ascending")},Qr=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();vr(e,i,t.cell,o[0],"descending")},Jr=e=>1===e.model.getters.getSelectedZones().length,ea=new Yn;ea.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Or}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Mr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Nr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:kr}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:_r}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Dr}).add("add_row_before",{name:e=>{const t=Rr(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:Wr,isVisible:Jr}).add("add_column_before",{name:e=>{const t=Ir(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:qr,isVisible:Jr}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:Jr,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:Br}).add("delete_row",{name:Pr,sequence:110,action:Lr,isVisible:Jr}).add("delete_column",{name:Ur,sequence:120,action:Vr,isVisible:Jr}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:Jr}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:Hr}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:$r}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:Xr});const ta=new Yn;ta.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Or}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Mr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Nr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:kr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:_r}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Dr}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:Jr,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Kr}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:Qr}).add("add_column_before",{name:e=>{const t=Ir(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=Ir(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:Zr}).add("delete_column",{name:Ur,sequence:90,action:Vr}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?s("Clear column %s",Ut(t)):s("Clear columns %s - %s",Ut(t),Ut(o))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?s("Hide column %s",Ut(o).toString()):i-o+1===t.length?s("Hide columns %s - %s",Ut(o).toString(),Ut(i).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(),o=e.model.getters.getHiddenColsGroups(t).flat();return e.model.getters.getNumberCols(t)>o.length+e.model.getters.getElementsFromSelection("COL").length},separator:!0}).add("unhide_columns",{name: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:jr});const oa=new Yn;oa.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:Or}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Mr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Nr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:kr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:_r}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Dr}).add("add_row_before",{name:e=>{const t=Rr(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:Wr}).add("add_row_after",{name:e=>{const t=Rr(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:Gr}).add("delete_row",{name:Pr,sequence:70,action:Lr}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?s("Hide row %s",(o+1).toString()):i-o+1===t.length?s("Hide rows %s - %s",(o+1).toString(),(i+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(),o=e.model.getters.getHiddenRowsGroups(t).flat();return e.model.getters.getNumberRows(t)>o.length+e.model.getters.getElementsFromSelection("ROW").length},separator:!0}).add("unhide_rows",{name: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:jr});const ia=/(.*?)\((.*?)\)(.*)/,na=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function sa(e,t=""){return function(e){let t,o=e.match(ia),i=o[1].trim(),n=[],s=!1,r=!1,a=!1;for(let e of o[2].split(",")){const o=e.trim().toUpperCase();let i=na.find((e=>o===e));i?n.push(i):"RANGE<ANY>"===o?n.push("RANGE"):"OPTIONAL"===o?s=!0:"REPEATING"===o?r=!0:"LAZY"===o?a=!0:o.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}let l=o[3].trim();const c={name:i,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 ra(e){let t=0,o=0,i=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||o++,n.repeating&&i++;const n=e;return n.minArgRequired=o,n.maxArgPossible=i?1/0:t,n.nbrArgRepeating=i,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,i),n.hidden=e.hidden||!1,n}const aa={description:s("Apply a large number format"),args:[sa("value (number)",s("The number.")),sa("unit (string, optional)",s("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:(e,t)=>{const o=Math.abs(Oi(e.value)),i=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return Eo(i,1e3,"k");case"m":return Eo(i,1e6,"m");case"b":return Eo(i,1e9,"b");default:throw new Error(s("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?Eo(i,0,""):o<1e8?Eo(i,1e3,"k"):o<1e11?Eo(i,1e6,"m"):Eo(i,1e9,"b")},compute:function(e){return Oi(e)}};var la=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:aa});const ca={description:s("Absolute value of a number."),args:[sa("value (number)",s("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Oi(e))},isExported:!0},ha={description:s("Inverse cosine of a value, in radians."),args:[sa("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=Oi(e);return Ai((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},da={description:s("Inverse hyperbolic cosine of a number."),args:[sa("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=Oi(e);return Ai((()=>t>=1),s("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ua={description:s("Inverse cotangent of a value."),args:[sa("value (number)",s("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Oi(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},ga={description:s("Inverse hyperbolic cotangent of a value."),args:[sa("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=Oi(e);return Ai((()=>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},pa={description:s("Inverse sine of a value, in radians."),args:[sa("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=Oi(e);return Ai((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},ma={description:s("Inverse hyperbolic sine of a number."),args:[sa("value (number)",s("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Oi(e))},isExported:!0},fa={description:s("Inverse tangent of a value, in radians."),args:[sa("value (number)",s("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Oi(e))},isExported:!0},va={description:s("Angle from the X axis to a point (x,y), in radians."),args:[sa("x (number)",s("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),sa("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 o=Oi(e),i=Oi(t);return Ai((()=>0!==o||0!==i),s("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(i,o)},isExported:!0},ba={description:s("Inverse hyperbolic tangent of a number."),args:[sa("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=Oi(e);return Ai((()=>Math.abs(t)<1),s("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Sa={description:s("Rounds number up to nearest multiple of factor."),args:[sa("value (number)",s("The value to round up to the nearest integer multiple of factor.")),sa("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 o=Oi(e),i=Oi(t);return Ai((()=>i>=0||o<=0),s("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.ceil(o/i)*i:0},isExported:!0},Ca={description:s("Rounds number up to nearest multiple of factor."),args:[sa("number (number)",s("The value to round up to the nearest integer multiple of significance.")),sa("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),sa("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,o=0){let i=Oi(t);if(0===i)return 0;const n=Oi(e);if(i=Math.abs(i),n>=0)return Math.ceil(n/i)*i;return 0===Oi(o)?-Math.floor(Math.abs(n)/i)*i:-Math.ceil(Math.abs(n)/i)*i},isExported:!0},Ea={description:s("Rounds number up to nearest multiple of factor."),args:[sa("number (number)",s("The value to round up to the nearest integer multiple of significance.")),sa("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 Ca.compute(e,t,0)},isExported:!0},wa={description:s("Cosine of an angle provided in radians."),args:[sa("angle (number)",s("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Oi(e))},isExported:!0},ya={description:s("Hyperbolic cosine of any real number."),args:[sa("value (number)",s("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Oi(e))},isExported:!0},xa={description:s("Cotangent of an angle provided in radians."),args:[sa("angle (number)",s("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Oi(e);return Ai((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Ia={description:s("Hyperbolic cotangent of any real number."),args:[sa("value (number)",s("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Oi(e);return Ai((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Ra={description:s("Number of empty values."),args:[sa("value1 (any, range)",s("The first value or range in which to count the number of blanks.")),sa("value2 (any, range, repeating)",s("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Bi(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Ta={description:s("A conditional count across a range."),args:[sa("range (range)",s("The range that is tested against criterion.")),sa("criterion (string)",s("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return Zi(e,((e,o)=>{t+=1})),t},isExported:!0},Aa={description:s("Count values depending on multiple criteria."),args:[sa("criteria_range1 (range)",s("The range to check against criterion1.")),sa("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),sa("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.")),sa("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return Zi(e,((e,o)=>{t+=1})),t},isExported:!0};function Ma(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Oa={description:s("Counts number of unique values in a range."),args:[sa("value1 (any, range)",s("The first value or range to consider for uniqueness.")),sa("value2 (any, range, repeating)",s("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Bi(e,((e,t)=>Ma(t)?e.add(t):e),new Set).size}},Na={description:s("Counts number of unique values in a range, filtered by a set of criteria."),args:[sa("range (range)",s("The range of cells from which the number of unique values will be counted.")),sa("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),sa("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.")),sa("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.")),sa("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return Zi(t,((t,i)=>{const n=e[t][i];Ma(n)&&o.add(n)})),o.size}},_a={description:s("Cosecant of an angle provided in radians."),args:[sa("angle (number)",s("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Oi(e);return Ai((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Fa={description:s("Hyperbolic cosecant of any real number."),args:[sa("value (number)",s("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Oi(e);return Ai((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Da={description:s("Converts from another base to decimal."),args:[sa("value (string)",s("The number to convert.")),sa(",base (number)",s("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=Oi(t);o=Math.floor(o),Ai((()=>2<=o&&o<=36),s("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const i=_i(e);if(""===i)return 0;Ai((()=>!!i.match(/^-?[a-z0-9]+$/i)),s("The value (%s) must be a valid base %s representation.",i,o.toString()));const n=parseInt(i,o);return Ai((()=>!isNaN(n)),s("The value (%s) must be a valid base %s representation.",i,o.toString())),n},isExported:!0},ka={description:s("Converts an angle value in radians to degrees."),args:[sa("angle (number)",s("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Oi(e)/Math.PI},isExported:!0},Pa={description:s("Euler's number, e (~2.718) raised to a power."),args:[sa("value (number)",s("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Oi(e))},isExported:!0},La={description:s("Rounds number down to nearest multiple of factor."),args:[sa("value (number)",s("The value to round down to the nearest integer multiple of factor.")),sa("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 o=Oi(e),i=Oi(t);return Ai((()=>i>=0||o<=0),s("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.floor(o/i)*i:0},isExported:!0},Ua={description:s("Rounds number down to nearest multiple of factor."),args:[sa("number (number)",s("The value to round down to the nearest integer multiple of significance.")),sa("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),sa("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,o=0){let i=Oi(t);if(0===i)return 0;const n=Oi(e);if(i=Math.abs(i),n>=0)return Math.floor(n/i)*i;return 0===Oi(o)?-Math.ceil(Math.abs(n)/i)*i:-Math.floor(Math.abs(n)/i)*i},isExported:!0},Va={description:s("Rounds number down to nearest multiple of factor."),args:[sa("number (number)",s("The value to round down to the nearest integer multiple of significance.")),sa("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 Ua.compute(e,t,0)},isExported:!0},za={description:s("Whether the provided value is even."),args:[sa("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Ni(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Ba={description:s("Rounds number up to nearest multiple of factor."),args:[sa("number (number)",s("The value to round up to the nearest integer multiple of significance.")),sa("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 Ca.compute(e,t,0)},isExported:!0},Ha={description:s("Whether the provided value is even."),args:[sa("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Ni(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},$a={description:s("The logarithm of a number, base e (euler's number)."),args:[sa("value (number)",s("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Oi(e);return Ai((()=>t>0),s("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Wa={description:s("Modulo (remainder) operator."),args:[sa("dividend (number)",s("The number to be divided to find the remainder.")),sa("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Oi(t);Ai((()=>0!==o),s("The divisor must be different from 0."));const i=Oi(e)%o;return i>0&&o<0||i<0&&o>0?i+o:i},isExported:!0},Ga={description:s("Rounds a number up to the nearest odd integer."),args:[sa("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=Oi(e);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},qa={description:s("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},Za={description:s("A number raised to a power."),args:[sa("base (number)",s("The number to raise to the exponent power.")),sa("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Oi(e),i=Oi(t);return Ai((()=>o>=0||Number.isInteger(i)),s("The exponent (%s) must be an integer when the base is negative.",i.toString())),Math.pow(o,i)},isExported:!0},ja={description:s("Result of multiplying a series of numbers together."),args:[sa("factor1 (number, range<number>)",s("The first number or range to calculate for the product.")),sa("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,o=1;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(o*=i,t+=1);else null!=i&&(o*=Ni(i),t+=1);return 0===t?0:o},isExported:!0},Xa={description:s("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ya={description:s("Random integer between two values, inclusive."),args:[sa("low (number)",s("The low end of the random range.")),sa("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 o=Oi(e);Number.isInteger(o)||(o=Math.ceil(o));let i=Oi(t);return Number.isInteger(i)||(i=Math.floor(i)),Ai((()=>o<=i),s("The high (%s) must be greater than or equal to the low (%s).",i.toString(),o.toString())),o+Math.ceil((i-o+1)*Math.random())-1},isExported:!0},Ka={description:s("Rounds a number according to standard rules."),args:[sa("value (number)",s("The value to round to places number of places.")),sa("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 o=Oi(e);let i=Oi(t);const n=Math.abs(o);let s;return 0===i?s=Math.round(n):(Number.isInteger(i)||(i=Math.trunc(i)),s=Math.round(n*Math.pow(10,i))/Math.pow(10,i)),o>=0?s:-s},isExported:!0},Qa={description:s("Rounds down a number."),args:[sa("value (number)",s("The value to round to places number of places, always rounding down.")),sa("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 o=Oi(e);let i=Oi(t);const n=Math.abs(o);let s;return 0===i?s=Math.floor(n):(Number.isInteger(i)||(i=Math.trunc(i)),s=Math.floor(n*Math.pow(10,i))/Math.pow(10,i)),o>=0?s:-s},isExported:!0},Ja={description:s("Rounds up a number."),args:[sa("value (number)",s("The value to round to places number of places, always rounding up.")),sa("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 o=Oi(e);let i=Oi(t);const n=Math.abs(o);let s;return 0===i?s=Math.ceil(n):(Number.isInteger(i)||(i=Math.trunc(i)),s=Math.ceil(n*Math.pow(10,i))/Math.pow(10,i)),o>=0?s:-s},isExported:!0},el={description:s("Secant of an angle provided in radians."),args:[sa("angle (number)",s("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Oi(e))},isExported:!0},tl={description:s("Hyperbolic secant of any real number."),args:[sa("value (number)",s("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Oi(e))},isExported:!0},ol={description:s("Sine of an angle provided in radians."),args:[sa("angle (number)",s("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Oi(e))},isExported:!0},il={description:s("Hyperbolic sine of any real number."),args:[sa("value (number)",s("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Oi(e))},isExported:!0},nl={description:s("Positive square root of a positive number."),args:[sa("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=Oi(e);return Ai((()=>t>=0),s("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},sl={description:s("Sum of a series of numbers and/or cells."),args:[sa("value1 (number, range<number>)",s("The first number or range to add together.")),sa("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 Hi(e,((e,t)=>e+t),0)},isExported:!0},rl={description:s("A conditional sum across a range."),args:[sa("criteria_range (range)",s("The range which is tested against criterion.")),sa("criterion (string)",s("The pattern or test to apply to range.")),sa("sum_range (range, default=criteria_range)",s("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let i=0;return Zi([e,t],((e,t)=>{const n=o[e][t];"number"==typeof n&&(i+=n)})),i},isExported:!0},al={description:s("Sums a range depending on multiple criteria."),args:[sa("sum_range (range)",s("The range to sum.")),sa("criteria_range1 (range)",s("The range to check against criterion1.")),sa("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),sa("criteria_range2 (any, range, repeating)",s("Additional ranges to check.")),sa("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return Zi(t,((t,i)=>{const n=e[t][i];"number"==typeof n&&(o+=n)})),o},isExported:!0},ll={description:s("Tangent of an angle provided in radians."),args:[sa("angle (number)",s("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Oi(e))},isExported:!0},cl={description:s("Hyperbolic tangent of any real number."),args:[sa("value (number)",s("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Oi(e))},isExported:!0},hl={description:s("Truncates a number."),args:[sa("value (number)",s("The value to be truncated.")),sa("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 o=Oi(e);let i=Oi(t);return 0===i?Math.trunc(o):(Number.isInteger(i)||(i=Math.trunc(i)),Math.trunc(o*Math.pow(10,i))/Math.pow(10,i))},isExported:!0};var dl=Object.freeze({__proto__:null,ABS:ca,ACOS:ha,ACOSH:da,ACOT:ua,ACOTH:ga,ASIN:pa,ASINH:ma,ATAN:fa,ATAN2:va,ATANH:ba,CEILING:Sa,CEILING_MATH:Ca,CEILING_PRECISE:Ea,COS:wa,COSH:ya,COT:xa,COTH:Ia,COUNTBLANK:Ra,COUNTIF:Ta,COUNTIFS:Aa,COUNTUNIQUE:Oa,COUNTUNIQUEIFS:Na,CSC:_a,CSCH:Fa,DECIMAL:Da,DEGREES:ka,EXP:Pa,FLOOR:La,FLOOR_MATH:Ua,FLOOR_PRECISE:Va,ISEVEN:za,ISO_CEILING:Ba,ISODD:Ha,LN:$a,MOD:Wa,ODD:Ga,PI:qa,POWER:Za,PRODUCT:ja,RAND:Xa,RANDBETWEEN:Ya,ROUND:Ka,ROUNDDOWN:Qa,ROUNDUP:Ja,SEC:el,SECH:tl,SIN:ol,SINH:il,SQRT:nl,SUM:sl,SUMIF:rl,SUMIFS:al,TAN:ll,TANH:cl,TRUNC:hl});function ul(e,t,o){let i=[],n=[],r=0,a=0;Ui([e],(e=>{i.push(e),r+=1})),Ui([t],(e=>{n.push(e),a+=1})),Ai((()=>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=i[e],o=n[e];"number"==typeof t&&"number"==typeof o&&(l+=1,c+=t,h+=o)}Ai((()=>0!==l&&(!o||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=i[e],o=n[e];"number"==typeof t&&"number"==typeof o&&(g+=(t-d)*(o-u))}return g/(l-(o?1:0))}function gl(e,t,o){let i=0,n=0;const r=o?$i:Hi;n=r(e,((e,t)=>(i+=1,e+t)),0),Ai((()=>0!==i&&(!t||1!==i)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/i;return r(e,((e,t)=>e+Math.pow(t-a,2)),0)/(i-(t?1:0))}function pl(e,t,o){const i=Oi(t);Ai((()=>o?0<=i&&i<=1:0<i&&i<1),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return Ui(e,(e=>{"number"==typeof e&&(n=Yi(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,e),a++)})),Ai((()=>0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),o||Ai((()=>1/(a+1)<=i&&i<=a/(a+1)),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),to(r,i,o)}const ml={description:s("Average magnitude of deviations from mean."),args:[sa("value1 (number, range<number>)",s("The first value or range of the sample.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=Hi(e,((e,o)=>(t+=1,e+o)),0);Ai((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const i=o/t;return Hi(e,((e,t)=>e+Math.abs(i-t)),0)/t},isExported:!0},fl={description:s("Numerical average value in a dataset, ignoring text."),args:[sa("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),sa("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 o=Hi(e,((e,o)=>(t+=1,e+o)),0);return Ai((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},vl=s("[[FUNCTION_NAME]] has mismatched range sizes."),bl=s("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Sl={description:s("Weighted average."),args:[sa("values (number, range<number>)",s("Values to average.")),sa("weights (number, range<number>)",s("Weights for each corresponding value.")),sa("additional_values (number, range<number>, repeating)",s("Additional values to average.")),sa("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,o,i=0,n=0;Ai((()=>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],o=e[r+1],Array.isArray(t)){Ai((()=>Array.isArray(o)),vl);let e=t.length,r=t[0].length;Ai((()=>e===o.length&&r===o[0].length),vl);for(let a=0;a<e;a++)for(let e=0;e<r;e++){let r=t[a][e],l=o[a][e],c="number"==typeof r,h="number"==typeof l;Ai((()=>c===h),s("[[FUNCTION_NAME]] expects number values.")),h&&(Ai((()=>l>=0),bl),i+=r*l,n+=l)}}else o=Oi(o),t=Oi(t),Ai((()=>o>=0),bl),i+=t*o,n+=o;return Ai((()=>0!==n),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/n}},Cl={description:s("Numerical average value in a dataset."),args:[sa("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),sa("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 o=$i(e,((e,o)=>(t+=1,e+o)),0);return Ai((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},El={description:s("Average of values depending on criteria."),args:[sa("criteria_range (range)",s("The range to check against criterion.")),sa("criterion (string)",s("The pattern or test to apply to criteria_range.")),sa("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,o){null==o&&(o=e);let i=0,n=0;return Zi([e,t],((t,s)=>{const r=(o||e)[t][s];"number"==typeof r&&(i+=1,n+=r)})),Ai((()=>0!==i),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},wl={description:s("Average of values depending on multiple criteria."),args:[sa("average_range (range)",s("The range to average.")),sa("criteria_range1 (range)",s("The range to check against criterion1.")),sa("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),sa("criteria_range2 (any, range, repeating)",s("Additional criteria_range and criterion to check.")),sa("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=0,i=0;return Zi(t,((t,n)=>{const s=e[t][n];"number"==typeof s&&(o+=1,i+=s)})),Ai((()=>0!==o),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o},isExported:!0},yl={description:s("The number of numeric values in dataset."),args:[sa("value1 (number, range<number>)",s("The first value or range to consider when counting.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||Qt(o)||Se(o))&&(t+=1);return t},isExported:!0},xl={description:s("The number of values in a dataset."),args:[sa("value1 (any, range)",s("The first value or range to consider when counting.")),sa("value2 (any, range, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Bi(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Il={description:s("The covariance of a dataset."),args:[sa("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),sa("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return ul(e,t,!1)},isExported:!0},Rl={description:s("The covariance of a dataset."),args:[sa("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),sa("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return ul(e,t,!1)},isExported:!0},Tl={description:s("The sample covariance of a dataset."),args:[sa("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),sa("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return ul(e,t,!0)},isExported:!0},Al={description:s("Nth largest element from a data set."),args:[sa("data (any, range)",s("Array or range containing the dataset to consider.")),sa("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 o=Math.trunc(Oi(t));let i,n=[],r=0;Ui([e],(e=>{"number"==typeof e&&(i=Yi(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(i+1,0,e),r++,r>o&&(n.shift(),r--))}));const a=n.shift();return Ai((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Ai((()=>r>=o),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},Ml={description:s("Maximum value in a numeric dataset."),args:[sa("value1 (number, range<number>)",s("The first value or range to consider when calculating the maximum value.")),sa("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=Hi(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Ol={description:s("Maximum numeric value in a dataset."),args:[sa("value1 (any, range)",s("The first value or range to consider when calculating the maximum value.")),sa("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=$i(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Nl={description:s("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[sa("range (range)",s("The range of cells from which the maximum will be determined.")),sa("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),sa("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.")),sa("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.")),sa("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return Zi(t,((t,i)=>{const n=e[t][i];"number"==typeof n&&(o=o<n?n:o)})),o===-1/0?0:o},isExported:!0},_l={description:s("Median value in a numeric dataset."),args:[sa("value1 (any, range)",s("The first value or range to consider when calculating the median value.")),sa("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 Vi(e,(e=>{t.push(e)})),pl(t,.5,!0)},isExported:!0},Fl={description:s("Minimum value in a numeric dataset."),args:[sa("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),sa("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=Hi(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Dl={description:s("Minimum numeric value in a dataset."),args:[sa("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),sa("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=$i(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},kl={description:s("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[sa("range (range)",s("The range of cells from which the minimum will be determined.")),sa("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),sa("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.")),sa("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.")),sa("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;return Zi(t,((t,i)=>{const n=e[t][i];"number"==typeof n&&(o=o>n?n:o)})),o===1/0?0:o},isExported:!0},Pl={description:s("Value at a given percentile of a dataset."),args:[sa("data (any, range)",s("The array or range containing the dataset to consider.")),sa("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 Ul.compute(e,t)},isExported:!0},Ll={description:s("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[sa("data (any, range)",s("The array or range containing the dataset to consider.")),sa("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 pl([e],t,!1)},isExported:!0},Ul={description:s("Value at a given percentile of a dataset."),args:[sa("data (any, range)",s("The array or range containing the dataset to consider.")),sa("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 pl([e],t,!0)},isExported:!0},Vl={description:s("Value nearest to a specific quartile of a dataset."),args:[sa("data (any, range)",s("The array or range containing the dataset to consider.")),sa("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 Bl.compute(e,t)},isExported:!0},zl={description:s("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[sa("data (any, range)",s("The array or range containing the dataset to consider.")),sa("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 pl([e],.25*Math.trunc(Oi(t)),!1)},isExported:!0},Bl={description:s("Value nearest to a specific quartile of a dataset."),args:[sa("data (any, range)",s("The array or range containing the dataset to consider.")),sa("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 pl([e],.25*Math.trunc(Oi(t)),!0)},isExported:!0},Hl={description:s("Nth smallest element in a data set."),args:[sa("data (any, range)",s("The array or range containing the dataset to consider.")),sa("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 o=Math.trunc(Oi(t));let i,n=[],r=0;Ui([e],(e=>{"number"==typeof e&&(i=Yi(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(i+1,0,e),r++,r>o&&(n.pop(),r--))}));const a=n.pop();return Ai((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Ai((()=>r>=o),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},$l={description:s("Standard deviation."),args:[sa("value1 (number, range<number>)",s("The first value or range of the sample.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Xl.compute(...e))},isExported:!0},Wl={description:s("Standard deviation of entire population."),args:[sa("value1 (number, range<number>)",s("The first value or range of the population.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Yl.compute(...e))},isExported:!0},Gl={description:s("Standard deviation."),args:[sa("value1 (number, range<number>)",s("The first value or range of the sample.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Kl.compute(...e))},isExported:!0},ql={description:s("Standard deviation of sample (text as 0)."),args:[sa("value1 (number, range<number>)",s("The first value or range of the sample.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ql.compute(...e))},isExported:!0},Zl={description:s("Standard deviation of entire population."),args:[sa("value1 (number, range<number>)",s("The first value or range of the population.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jl.compute(...e))},isExported:!0},jl={description:s("Standard deviation of entire population (text as 0)."),args:[sa("value1 (number, range<number>)",s("The first value or range of the population.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ec.compute(...e))},isExported:!0},Xl={description:s("Variance."),args:[sa("value1 (number, range<number>)",s("The first value or range of the sample.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return gl(e,!0,!1)},isExported:!0},Yl={description:s("Variance of entire population."),args:[sa("value1 (number, range<number>)",s("The first value or range of the population.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return gl(e,!1,!1)},isExported:!0},Kl={description:s("Variance."),args:[sa("value1 (number, range<number>)",s("The first value or range of the sample.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return gl(e,!0,!1)},isExported:!0},Ql={description:s("Variance of sample (text as 0)."),args:[sa("value1 (number, range<number>)",s("The first value or range of the sample.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return gl(e,!0,!0)},isExported:!0},Jl={description:s("Variance of entire population."),args:[sa("value1 (number, range<number>)",s("The first value or range of the population.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return gl(e,!1,!1)},isExported:!0},ec={description:s("Variance of entire population (text as 0)."),args:[sa("value1 (number, range<number>)",s("The first value or range of the population.")),sa("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return gl(e,!1,!0)},isExported:!0};var tc=Object.freeze({__proto__:null,AVEDEV:ml,AVERAGE:fl,AVERAGE_WEIGHTED:Sl,AVERAGEA:Cl,AVERAGEIF:El,AVERAGEIFS:wl,COUNT:yl,COUNTA:xl,COVAR:Il,COVARIANCE_P:Rl,COVARIANCE_S:Tl,LARGE:Al,MAX:Ml,MAXA:Ol,MAXIFS:Nl,MEDIAN:_l,MIN:Fl,MINA:Dl,MINIFS:kl,PERCENTILE:Pl,PERCENTILE_EXC:Ll,PERCENTILE_INC:Ul,QUARTILE:Vl,QUARTILE_EXC:zl,QUARTILE_INC:Bl,SMALL:Hl,STDEV:$l,STDEV_P:Wl,STDEV_S:Gl,STDEVA:ql,STDEVP:Zl,STDEVPA:jl,VAR:Xl,VAR_P:Yl,VAR_S:Kl,VARA:Ql,VARP:Jl,VARPA:ec});function oc(e,t,o){var i;const n=new Map,r=e.length;for(let t=r-1;t>=0;t--)n.set(_i(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=_i(t).toUpperCase();if(a=null!==(i=n.get(e))&&void 0!==i?i:-1,-1===a)throw new Error(s("The field (%s) must be one of %s.",_i(t),[...n.keys()].toString()))}const l=o[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 i=[],s=!0;for(let r=0;r<o.length;r++){const a=_i(o[r][0]).toUpperCase(),l=n.get(a),c=o[r][t];if(void 0!==c){if(void 0===l){s=!1;break}i.push([e[l].slice(1,h)]),i.push(c)}}if(s){if(!(i.length>0)){c=new Set(Array(h-1).keys());break}Zi(i,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const ic=[sa("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.")),sa("field (any)",s("Indicates which column in database contains the values to be extracted and operated on.")),sa("criteria (range)",s("An array or range containing zero or more criteria to filter the database values by before operating."))],nc={description:s("Average of a set of values from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return fl.compute([i])},isExported:!0},sc={description:s("Counts values from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return yl.compute([i])},isExported:!0},rc={description:s("Counts values and text from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return xl.compute([i])},isExported:!0},ac={description:s("Single value from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return Ai((()=>1===i.length),s("More than one match found in DGET evaluation.")),i[0]},isExported:!0},lc={description:s("Maximum of values from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return Ml.compute([i])},isExported:!0},cc={description:s("Minimum of values from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return Fl.compute([i])},isExported:!0},hc={description:s("Product of values from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return ja.compute([i])},isExported:!0},dc={description:s("Standard deviation of population sample from table."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return $l.compute([i])},isExported:!0},uc={description:s("Standard deviation of entire population from table."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return Zl.compute([i])},isExported:!0},gc={description:s("Sum of values from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return sl.compute([i])},isExported:!0},pc={description:s("Variance of population sample from table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return Xl.compute([i])},isExported:!0},mc={description:s("Variance of a population from a table-like range."),args:ic,returns:["NUMBER"],compute:function(e,t,o){const i=oc(e,t,o);return Jl.compute([i])},isExported:!0};var fc=Object.freeze({__proto__:null,DAVERAGE:nc,DCOUNT:sc,DCOUNTA:rc,DGET:ac,DMAX:lc,DMIN:cc,DPRODUCT:hc,DSTDEV:dc,DSTDEVP:uc,DSUM:gc,DVAR:pc,DVARP:mc});const vc={description:s("Converts year/month/day into a date."),args:[sa("year (number)",s("The year component of the date.")),sa("month (number)",s("The month component of the date.")),sa("day (number)",s("The day component of the date."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o){let i=Math.trunc(Oi(e));const n=Math.trunc(Oi(t)),r=Math.trunc(Oi(o));Ai((()=>0<=i&&i<=9999),s("The year (%s) must be between 0 and 9999 inclusive.",i.toString())),i<1900&&(i+=1900);const a=we(new Date(i,n-1,r));return Ai((()=>a>=0),s("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},bc={description:s("Converts a date string to a date value."),args:[sa("date_string (string)",s("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=_i(e),o=Se(t);return Ai((()=>null!==o),s("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},Sc={description:s("Day of the month that a specific date falls on."),args:[sa("date (string)",s("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Pi(e).getDate()},isExported:!0},Cc={description:s("Number of days between two dates."),args:[sa("end_date (date)",s("The end of the date range.")),sa("start_date (date)",s("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=Pi(e),i=Pi(t),n=o.getTime()-i.getTime();return Math.round(n/ue)},isExported:!0},Ec={description:s("Number of days between two dates on a 360-day year (months of 30 days)."),args:[sa("start_date (date)",s("The start date to consider in the calculation.")),sa("end_date (date)",s("The end date to consider in the calculation.")),sa("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,o=0){const i=Oi(e),n=Oi(t),s=ki(o)?4:0,r=Bc.compute(e,t,s);return Math.sign(n-i)*Math.round(360*r)},isExported:!0},wc={description:s("Date a number of months before/after another date."),args:[sa("start_date (date)",s("The date from which to calculate the result.")),sa("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 we(Ie(Pi(e),Math.trunc(Oi(t)),!1))},isExported:!0},yc={description:s("Last day of a month before or after a date."),args:[sa("start_date (date)",s("The date from which to calculate the result.")),sa("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 o=Pi(e),i=Math.trunc(Oi(t)),n=o.getFullYear(),s=o.getMonth();return we(new Date(n,s+i+1,0))},isExported:!0},xc={description:s("Hour component of a specific time."),args:[sa("time (date)",s("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Pi(e).getHours()},isExported:!0},Ic={description:s("ISO week number of the year."),args:[sa("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=Pi(e),o=t.getFullYear();let i=1;for(;4!==new Date(o,0,i).getDay();)i+=1;const n=new Date(o,0,i-3);let s=31;for(;4!==new Date(o,11,s).getDay();)s-=1;const r=new Date(o,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(o,11,s+3+1);break;case-1:let e=1;for(;4!==new Date(o-1,0,e).getDay();)e+=1;l=new Date(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/ue;return Math.floor(c/7)+1},isExported:!0},Rc={description:s("Minute component of a specific time."),args:[sa("time (date)",s("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Pi(e).getMinutes()},isExported:!0},Tc={description:s("Month of the year a specific date falls in"),args:[sa("date (date)",s("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Pi(e).getMonth()+1},isExported:!0},Ac={description:s("Net working days between two provided days."),args:[sa("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),sa("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),sa("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,o){return Oc.compute(e,t,1,o)},isExported:!0};function Mc(e){if("string"==typeof e){Ai((()=>{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 o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return Ai((()=>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 Oc={description:s("Net working days between two dates (specifying weekends)."),args:[sa("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),sa("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),sa("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),sa("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o=1,i){const n=Pi(e),s=Pi(t),r=Mc(o);let a=new Set;void 0!==i&&Ui([i],(e=>{const t=Pi(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},Nc={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()-de.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ue)+o},isExported:!0},_c={description:s("Minute component of a specific time."),args:[sa("time (date)",s("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Pi(e).getSeconds()},isExported:!0},Fc={description:s("Converts hour/minute/second into a time."),args:[sa("hour (number)",s("The hour component of the time.")),sa("minute (number)",s("The minute component of the time.")),sa("second (number)",s("The second component of the time."))],returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,o){let i=Math.trunc(Oi(e)),n=Math.trunc(Oi(t)),r=Math.trunc(Oi(o));return n+=Math.floor(r/60),r=r%60+(r<0?60:0),i+=Math.floor(n/60),n=n%60+(n<0?60:0),i%=24,Ai((()=>i>=0),s("The function [[FUNCTION_NAME]] result cannot be negative")),i/24+n/1440+r/86400},isExported:!0},Dc={description:s("Converts a time string into its serial number representation."),args:[sa("time_string (string)",s("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=_i(e),o=Se(t);Ai((()=>null!==o),s("The time_string (%s) cannot be parsed to date/time.",t));const i=o.value-Math.trunc(o.value);return i<0?1+i:i},isExported:!0},kc={description:s("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return we(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Pc={description:s("Day of the week of the date provided (as number)."),args:[sa("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.")),sa("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 o=Pi(e),i=Math.round(Oi(t)),n=o.getDay();return Ai((()=>[1,2,3].includes(i)),s("The type (%s) must be 1, 2 or 3.",i.toString())),1===i?n+1:2===i?0===n?7:n:0===n?6:n-1},isExported:!0},Lc={description:s("Week number of the year."),args:[sa("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.")),sa("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 o=Pi(e),i=Math.round(Oi(t));if(Ai((()=>1===i||2===i||11<=i&&i<=17||21===i),s("The type (%s) is out of range.",i.toString())),21===i)return Ic.compute(e);let n;n=1===i||2===i?i-1:i-10==7?0:i-10;const r=o.getFullYear();let a=1,l=new Date(r,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(r,0,a);const c=(o.getTime()-l.getTime())/ue;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Uc={description:s("Date after a number of workdays."),args:[sa("start_date (date)",s("The date from which to begin counting.")),sa("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),sa("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,o){return Vc.compute(e,t,1,o)},isExported:!0},Vc={description:s("Date after a number of workdays (specifying weekends)."),args:[sa("start_date (date)",s("The date from which to begin counting.")),sa("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),sa("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),sa("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,o=1,i){let n=Pi(e),r=Math.trunc(Oi(t));"string"==typeof o&&Ai((()=>"1111111"!==o),s("The weekend (%s) must be different from '1111111'.",o));const a=Mc(o);let l=new Set;void 0!==i&&Ui([i],(e=>{const t=Pi(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-de.getTime();return Math.round(g/ue)},isExported:!0},zc={description:s("Year specified by a given date."),args:[sa("date (date)",s("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Pi(e).getFullYear()},isExported:!0},Bc={description:s("Exact number of years between two dates."),args:[sa("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.")),sa("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.")),sa("day_count_convention (number, default=0)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o=0){let i=Math.trunc(Oi(e)),n=Math.trunc(Oi(t));const r=Math.trunc(Oi(o));return Ai((()=>i>=0),s("The start_date (%s) must be positive or null.",i.toString())),Ai((()=>n>=0),s("The end_date (%s) must be positive or null.",n.toString())),Ai((()=>0<=r&&r<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",r.toString())),Te(i,n,r)}},Hc={description:s("First day of the month preceding a date."),args:[sa("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Pi(e),o=t.getFullYear(),i=t.getMonth();return we(new Date(o,i,1))}},$c={description:s("Last day of the month following a date."),args:[sa("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return yc.compute(e,0)}},Wc={description:s("Quarter of the year a specific date falls in"),args:[sa("date (date)",s("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Pi(e).getMonth()+1)/3)}},Gc={description:s("First day of the quarter of the year a specific date falls in."),args:[sa("date (date)",s("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Wc.compute(e),o=zc.compute(e);return we(new Date(o,3*(t-1),1))}},qc={description:s("Last day of the quarter of the year a specific date falls in."),args:[sa("date (date)",s("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Wc.compute(e),o=zc.compute(e);return we(new Date(o,3*t,0))}},Zc={description:s("First day of the year a specific date falls in."),args:[sa("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 we(new Date(t,0,1))}},jc={description:s("Last day of the year a specific date falls in."),args:[sa("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 we(new Date(t+1,0,0))}};var Xc=Object.freeze({__proto__:null,DATE:vc,DATEVALUE:bc,DAY:Sc,DAYS:Cc,DAYS360:Ec,EDATE:wc,EOMONTH:yc,HOUR:xc,ISOWEEKNUM:Ic,MINUTE:Rc,MONTH:Tc,NETWORKDAYS:Ac,NETWORKDAYS_INTL:Oc,NOW:Nc,SECOND:_c,TIME:Fc,TIMEVALUE:Dc,TODAY:kc,WEEKDAY:Pc,WEEKNUM:Lc,WORKDAY:Uc,WORKDAY_INTL:Vc,YEAR:zc,YEARFRAC:Bc,MONTH_START:Hc,MONTH_END:$c,QUARTER:Wc,QUARTER_START:Gc,QUARTER_END:qc,YEAR_START:Zc,YEAR_END:jc});const Yc={description:s("Compare two numeric values, returning 1 if they're equal."),args:[sa(" (number)",s("The first number to compare.")),sa(" (number, default=0)",s("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Oi(e)===Oi(t)?1:0},isExported:!0};var Kc=Object.freeze({__proto__:null,DELTA:Yc});function Qc(e,t){Ai((()=>e<t),s("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function Jc(e,t){Ai((()=>t<e),s("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function eh(e){Ai((()=>[1,2,4].includes(e)),s("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function th(e){Ai((()=>0<=e&&e<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function oh(e){Ai((()=>e>0),s("The redemption (%s) must be strictly positive.",e.toString()))}function ih(e){Ai((()=>e>0),s("The price (%s) must be strictly positive.",e.toString()))}function nh(e){Ai((()=>e>0),s("The number_of_periods (%s) must be greater than 0.",e.toString()))}function sh(e){Ai((()=>e>0),s("The rate (%s) must be strictly positive.",e.toString()))}function rh(e){Ai((()=>e>0),s("The life (%s) must be strictly positive.",e.toString()))}function ah(e){Ai((()=>e>=0),s("The cost (%s) must be positive or null.",e.toString()))}function lh(e){Ai((()=>e>0),s("The period (%s) must be strictly positive.",e.toString()))}function ch(e){Ai((()=>e>=0),s("The salvage (%s) must be positive or null.",e.toString()))}function hh(e){Ai((()=>e>0),s("The present value (%s) must be strictly positive.",e.toString()))}function dh(e,t){Ai((()=>e<=t),s("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function uh(e){Ai((()=>e>0),s("The investment (%s) must be strictly positive.",e.toString()))}function gh(e){Ai((()=>e>0),s("The discount (%s) must be strictly positive.",e.toString()))}function ph(e){Ai((()=>e<1),s("The discount (%s) must be smaller than 1.",e.toString()))}function mh(e){Ai((()=>e>0),s("The depreciation factor (%s) must be strictly positive.",e.toString()))}function fh(e,t){const o=Pi(e),i=Pi(t),n=new Date(o);n.setFullYear(o.getFullYear()+1),Ai((()=>i.getTime()<=n.getTime()),s("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function vh(e,t,o){nh(o),Ai((()=>e>0),s("The first_period (%s) must be strictly positive.",e.toString())),Ai((()=>t>0),s("The last_period (%s) must be strictly positive.",t.toString())),Ai((()=>e<=t),s("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Ai((()=>t<=o),s("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function bh(e){Ai((()=>e>-1),s("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Sh(e,t){Ai((()=>e.length===t.length&&e[0].length===t[0].length),s("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Ch(e){Ai((()=>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 Eh=[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))];function wh(e,t,o,i,n=1e-10,r){let a,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(Ai((()=>g<i&&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,Ai((()=>g<i),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const yh={description:s("Accrued interest of security paying at maturity."),args:[sa("issue (date)",s("The date the security was initially issued.")),sa("maturity (date)",s("The maturity date of the security.")),sa("rate (number)",s("The annualized rate of interest.")),sa("redemption (number)",s("The redemption amount per 100 face value, or par.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Oi(e)),r=Math.trunc(Oi(t)),a=Oi(i),l=Oi(o),c=Math.trunc(Oi(n));Jc(r,s),th(c),oh(a),sh(l);return a*l*Bc.compute(s,r,n)},isExported:!0},xh={description:s("Depreciation for an accounting period."),args:[sa("cost (number)",s("The initial cost of the asset.")),sa("purchase_date (date)",s("The date the asset was purchased.")),sa("first_period_end (date)",s("The date the first period ended.")),sa("salvage (number)",s("The value of the asset at the end of depreciation.")),sa("period (number)",s("The single period within life for which to calculate depreciation.")),sa("rate (number)",s("The deprecation rate.")),sa(" (number, optional)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r,a=0){a=a||0;const l=Oi(e),c=Math.trunc(Oi(t)),h=Math.trunc(Oi(o)),d=Oi(i),u=Oi(n),g=Oi(r),p=Math.trunc(Oi(a));!function(e){Ai((()=>e>0),s("The cost (%s) must be strictly positive.",e.toString()))}(l),ch(d),function(e,t){Ai((()=>e<=t),s("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Ai((()=>e>=0),s("The period (%s) must be positive or null.",e.toString()))}(u),sh(g),th(p),Ai((()=>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=Bc.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},Ih={description:s("Days in coupon period containing settlement date."),args:Eh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Oi(e)),s=Math.trunc(Oi(t)),r=Math.trunc(Oi(o)),a=Math.trunc(Oi(i));if(Qc(n,s),eh(r),th(a),1===a){const n=Oh.compute(e,t,o,i);return Ah.compute(e,t,o,i)-n}return(3===a?365:360)/r},isExported:!0},Rh={description:s("Days from settlement until next coupon."),args:Eh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Oi(e)),s=Math.trunc(Oi(t)),r=Math.trunc(Oi(o)),a=Math.trunc(Oi(i));Qc(n,s),eh(r),th(a);const l=Oh.compute(n,s,o,i);if([1,2,3].includes(a))return n-l;if(4===a){const e=Te(l,n,a);return Math.round(360*e)}const c=Pi(n),h=Pi(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&&xe(h)&&xe(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&xe(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Th={description:s("Days from settlement until next coupon."),args:Eh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Oi(e)),s=Math.trunc(Oi(t)),r=Math.trunc(Oi(o)),a=Math.trunc(Oi(i));Qc(n,s),eh(r),th(a);const l=Ah.compute(n,s,o,i);if([1,2,3].includes(a))return l-n;if(4===a){const e=Te(n,l,a);return Math.round(360*e)}const c=Rh.compute(e,t,o,a);return Ih.compute(e,t,o,a)-c},isExported:!0},Ah={description:s("Next coupon date after the settlement date."),args:Eh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Oi(e)),s=Math.trunc(Oi(t)),r=Math.trunc(Oi(o)),a=Math.trunc(Oi(i));Qc(n,s),eh(r),th(a);const l=12/r,c=Mh.compute(e,t,o,i);return we(Ie(Pi(s),-(c-1)*l,!0))},isExported:!0},Mh={description:s("Number of coupons between settlement and maturity."),args:Eh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Oi(e)),s=Math.trunc(Oi(t)),r=Math.trunc(Oi(o)),a=Math.trunc(Oi(i));Qc(n,s),eh(r),th(a);let l=1,c=s;const h=12/r;for(;c>n;)c=we(Ie(Pi(c),-h,!1)),l++;return l-1},isExported:!0},Oh={description:s("Last coupon date prior to or on the settlement date."),args:Eh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Oi(e)),s=Math.trunc(Oi(t)),r=Math.trunc(Oi(o)),a=Math.trunc(Oi(i));Qc(n,s),eh(r),th(a);const l=12/r,c=Mh.compute(e,t,o,i);return we(Ie(Pi(s),-c*l,!0))},isExported:!0},Nh={description:s("Cumulative interest paid over a set of periods."),args:[sa("rate (number)",s("The interest rate.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("present_value (number)",s("The current value of the annuity.")),sa("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),sa("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),sa("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,o,i,n,s=0){const r=Oi(i),a=Oi(n),l=Oi(e),c=Oi(o),h=Oi(t);vh(r,a,h),sh(l),hh(c);let d=0;for(let t=r;t<=a;t++){d+=$h.compute(e,t,h,o,0,s)}return d},isExported:!0},_h={description:s("Cumulative principal paid over a set of periods."),args:[sa("rate (number)",s("The interest rate.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("present_value (number)",s("The current value of the annuity.")),sa("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),sa("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),sa("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,o,i,n,s=0){const r=Oi(i),a=Oi(n),l=Oi(e),c=Oi(o),h=Oi(t);vh(r,a,h),sh(l),hh(c);let d=0;for(let t=r;t<=a;t++){d+=Jh.compute(e,t,h,o,0,s)}return d},isExported:!0},Fh={description:s("Depreciation via declining balance method."),args:[sa("cost (number)",s("The initial cost of the asset.")),sa("salvage (number)",s("The value of the asset at the end of depreciation.")),sa("life (number)",s("The number of periods over which the asset is depreciated.")),sa("period (number)",s("The single period within life for which to calculate depreciation.")),sa("month (number, optional)",s("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,...n){const r=Oi(e),a=Oi(t),l=Oi(o),c=Math.trunc(Oi(i)),h=n.length?Math.trunc(Oi(n[0])):12,d=l+(12===h?0:1);ah(r),ch(a),lh(c),rh(l),Ai((()=>1<=h&&h<=12),s("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Ai((()=>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},Dh={description:s("Depreciation via double-declining balance method."),args:[sa("cost (number)",s("The initial cost of the asset.")),sa("salvage (number)",s("The value of the asset at the end of depreciation.")),sa("life (number)",s("The number of periods over which the asset is depreciated.")),sa("period (number)",s("The single period within life for which to calculate depreciation.")),sa("factor (number, default=2)",s("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,n=2){n=n||0;const s=Oi(e),r=Oi(t),a=Oi(o),l=Oi(i),c=Oi(n);if(ah(s),ch(r),lh(l),rh(a),dh(l,a),mh(c),0===s||r>=s)return 0;const h=c/a;if(h>1)return 1===i?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},kh={description:s("Discount rate of a security based on price."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("price (number)",s("The price at which the security is bought per 100 face value.")),sa("redemption (number)",s("The redemption amount per 100 face value, or par.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Oi(e)),r=Math.trunc(Oi(t)),a=Oi(o),l=Oi(i),c=Math.trunc(Oi(n));Qc(s,r),th(c),ih(a),oh(l);return(l-a)/l/Bc.compute(s,r,c)},isExported:!0},Ph={description:s("Convert a decimal fraction to decimal value."),args:[sa("fractional_price (number)",s("The price quotation given using fractional decimal conventions.")),sa("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 o=Oi(e),i=Math.trunc(Oi(t));Ai((()=>i>0),s("The unit (%s) must be strictly positive.",i.toString()));const n=Math.trunc(o);return n+(o-n)*(10**Math.ceil(Math.log10(i))/i)},isExported:!0},Lh={description:s("Convert a decimal value to decimal fraction."),args:[sa("decimal_price (number)",s("The price quotation given as a decimal value.")),sa("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 o=Oi(e),i=Math.trunc(Oi(t));Ai((()=>i>0),s("The unit (%s) must be strictly positive.",i.toString()));const n=Math.trunc(o);return n+(o-n)*(i/10**Math.ceil(Math.log10(i)))},isExported:!0},Uh={description:s("Number of periods for an investment to reach a value."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("rate (number)",s("The annualized rate of interest.")),sa("yield (number)",s("The expected annual yield of the security.")),sa("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r=0){r=r||0;const a=Math.trunc(Oi(e)),l=Math.trunc(Oi(t)),c=Oi(o),h=Oi(i),d=Math.trunc(Oi(n)),u=Math.trunc(Oi(r));Qc(a,l),eh(d),th(u),Ai((()=>c>=0),s("The rate (%s) must be positive or null.",c.toString())),Ai((()=>h>=0),s("The yield (%s) must be positive or null.",h.toString()));const g=Bc.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},Vh={description:s("Annual effective interest rate."),args:[sa("nominal_rate (number)",s("The nominal interest rate per year.")),sa("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Oi(e),i=Math.trunc(Oi(t));return Ai((()=>o>0),s("The nominal rate (%s) must be strictly greater than 0.",o.toString())),Ai((()=>i>0),s("The number of periods by year (%s) must strictly greater than 0.",i.toString())),Math.pow(1+o/i,i)-1},isExported:!0},zh={description:s("Future value of an annuity investment."),args:[sa("rate (number)",s("The interest rate.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("payment_amount (number)",s("The amount per period to be paid.")),sa("present_value (number, default=0)",s("The current value of the annuity.")),sa("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,o,i=0,n=0){i=i||0,n=n||0;const s=Oi(e),r=Oi(t),a=Oi(o),l=Oi(i),c=ki(n)?1:0;return s?-l*(1+s)**r-a*(1+s*c)*((1+s)**r-1)/s:-(l+a*r)},isExported:!0},Bh={description:s("Future value of principal from series of rates."),args:[sa("principal (number)",s("The amount of initial capital or value to compound against.")),sa("rate_schedule (number, range<number>)",s("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Bi([t],((e,t)=>e*(1+Oi(t))),Oi(e))},isExported:!0},Hh={description:s("Calculates effective interest rate."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("investment (number)",s("The amount invested in the security.")),sa("redemption (number)",s("The amount to be received at maturity.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){const s=Math.trunc(Oi(e)),r=Math.trunc(Oi(t)),a=Oi(i),l=Oi(o);Qc(s,r),uh(l),oh(a);return(a-l)/l/Bc.compute(s,r,n)},isExported:!0},$h={description:s("Payment on the principal of an investment."),args:[sa("rate (number)",s("The annualized rate of interest.")),sa("period (number)",s("The amortization period, in terms of number of periods.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("present_value (number)",s("The current value of the annuity.")),sa("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),sa("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,o,i,n=0,s=0){return Qh.compute(e,o,i,n,s)-Jh.compute(e,t,o,i,n,s)},isExported:!0},Wh={description:s("Internal rate of return given periodic cashflows."),args:[sa("cashflow_amounts (number, range<number>)",s("An array or range containing the income or payments associated with the investment.")),sa("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 o=Oi(t);bh(o);let i=!1,n=!1,r=[];Vi([e],(e=>{e>0&&(i=!0),e<0&&(n=!0),r.push(e)})),Ai((()=>i&&n),s("The cashflow_amounts must include negative and positive values."));const a=r.shift();return wh((function(e){return function(e,t,o){const i=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*e**(i-n))),t*e**i)}(e,a,r)}),(function(e){return function(e,t,o){const i=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*(i-n)*e**(i-n-1))),t*i*e**(i-1))}(e,a,r)}),o+1,20,1e-5)-1},isExported:!0},Gh={description:s("Returns the interest paid at a particular period of an investment."),args:[sa("rate (number)",s("The interest rate.")),sa("period (number)",s("The period for which you want to view the interest payment.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("present_value (number)",s("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,i){const n=Oi(e),r=Oi(t),a=Oi(o),l=Oi(i);Ai((()=>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:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("rate (number)",s("The annualized rate of interest.")),sa("yield (number)",s("The expected annual yield of the security.")),sa("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,s=0){return Uh.compute(e,t,o,i,n,s)/(1+Oi(i)/Math.trunc(Oi(n)))},isExported:!0},Zh={description:s("Modified internal rate of return."),args:[sa("cashflow_amounts (range<number>)",s("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),sa("financing_rate (number)",s("The interest rate paid on funds invested.")),sa("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,o){const i=Oi(t),n=Oi(o),r=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(et).map(Oi);var a;const l=r.length;let c=0,h=0;for(const e of ze(0,l)){const t=r[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(i+1)**e}Ai((()=>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},jh={description:s("Annual nominal interest rate."),args:[sa("effective_rate (number)",s("The effective interest rate per year.")),sa("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Oi(e),i=Math.trunc(Oi(t));return Ai((()=>o>0),s("The effective rate (%s) must must strictly greater than 0.",o.toString())),Ai((()=>i>0),s("The number of periods by year (%s) must strictly greater than 0.",i.toString())),(Math.pow(o+1,1/i)-1)*i},isExported:!0},Xh={description:s("Number of payment periods for an investment."),args:[sa("rate (number)",s("The interest rate.")),sa("payment_amount (number)",s("The amount of each payment made.")),sa("present_value (number)",s("The current value of the annuity.")),sa("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),sa("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,o,i=0,n=0){i=i||0,n=n||0;const s=Oi(e),r=Oi(t),a=Oi(o),l=Oi(i),c=ki(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 Yh={description:s("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[sa("discount (number)",s("The discount rate of the investment over one period.")),sa("cashflow1 (number, range<number>)",s("The first future cash flow.")),sa("cashflow2 (number, range<number>, repeating)",s("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=Oi(e);return Ai((()=>-1!==o),s("The discount (%s) must be different from -1.",o.toString())),function(e,t,o){let i=0;return Hi(o,((t,o)=>(i++,t+o/(1+e)**i)),t)}(o,0,t)},isExported:!0},Kh={description:s("Computes the number of periods needed for an investment to reach a value."),args:[sa("rate (number)",s("The rate at which the investment grows each period.")),sa("present_value (number)",s("The investment's current value.")),sa("future_value (number)",s("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const i=Oi(e),n=Oi(t),r=Oi(o);return sh(i),Ai((()=>n>0),s("The present_value (%s) must be strictly positive.",n.toString())),Ai((()=>r>0),s("The future_value (%s) must be strictly positive.",r.toString())),(Math.log(r)-Math.log(n))/Math.log(1+i)},isExported:!0},Qh={description:s("Periodic payment for an annuity investment."),args:[sa("rate (number)",s("The annualized rate of interest.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("present_value (number)",s("The current value of the annuity.")),sa("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),sa("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,o,i=0,n=0){i=i||0,n=n||0;const s=Oi(t),r=Oi(e),a=ki(n)?1:0;let l=Oi(i),c=Oi(o);if(nh(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},Jh={description:s("Payment on the principal of an investment."),args:[sa("rate (number)",s("The annualized rate of interest.")),sa("period (number)",s("The amortization period, in terms of number of periods.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("present_value (number)",s("The current value of the annuity.")),sa("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),sa("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,o,i,n=0,r=0){n=n||0,r=r||0;const a=Oi(o),l=Oi(e),c=Oi(t),h=ki(r)?1:0,d=Oi(n),u=Oi(i);nh(a),Ai((()=>c>0&&c<=a),s("The period must be between 1 and number_of_periods",a.toString()));const g=Qh.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},ed={description:s("Present value of an annuity investment."),args:[sa("rate (number)",s("The interest rate.")),sa("number_of_periods (number)",s("The number of payments to be made.")),sa("payment_amount (number)",s("The amount per period to be paid.")),sa("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),sa("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,o,i=0,n=0){i=i||0,n=n||0;const s=Oi(e),r=Oi(t),a=Oi(o),l=Oi(i),c=ki(n)?1:0;return s?-(a*(1+s*c)*((1+s)**r-1)/s+l)/(1+s)**r:-(l+a*r)},isExported:!0},td={description:s("Price of a security paying periodic interest."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("rate (number)",s("The annualized rate of interest.")),sa("yield (number)",s("The expected annual yield of the security.")),sa("redemption (number)",s("The redemption amount per 100 face value, or par.")),sa("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r,a=0){a=a||0;const l=Math.trunc(Oi(e)),c=Math.trunc(Oi(t)),h=Oi(o),d=Oi(i),u=Oi(n),g=Math.trunc(Oi(r)),p=Math.trunc(Oi(a));Qc(l,c),eh(g),th(p),Ai((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Ai((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString())),oh(u);const m=Bc.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},od={description:s("Price of a discount security."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("discount (number)",s("The discount rate of the security at time of purchase.")),sa("redemption (number)",s("The redemption amount per 100 face value, or par.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Oi(e)),r=Math.trunc(Oi(t)),a=Oi(o),l=Oi(i),c=Math.trunc(Oi(n));Qc(s,r),th(c),gh(a),oh(l);return l-a*l*Bc.compute(s,r,c)},isExported:!0},id={description:s("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("issue (date)",s("The date the security was initially issued.")),sa("rate (number)",s("The annualized rate of interest.")),sa("yield (number)",s("The expected annual yield of the security.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r=0){r=r||0;const a=Math.trunc(Oi(e)),l=Math.trunc(Oi(t)),c=Math.trunc(Oi(o)),h=Oi(i),d=Oi(n),u=Math.trunc(Oi(r));Jc(a,c),Qc(a,l),th(u),Ai((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Ai((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString()));const g=Bc.compute(a,l,u),p=Bc.compute(a,c,u);return(100+Bc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},nd=.1,sd={description:s("Interest rate of an annuity investment."),args:[sa("number_of_periods (number)",s("The number of payments to be made.")),sa("payment_per_period (number)",s("The amount per period to be paid.")),sa("present_value (number)",s("The current value of the annuity.")),sa("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),sa("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period.")),sa("rate_guess (number, default=0.1)",s("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,i=0,n=0,r=.1){i=i||0,n=n||0,r=r||nd;const a=Oi(e),l=Oi(t),c=ki(n)?1:0,h=Oi(r);let d=Oi(i),u=Oi(o);nh(a),Ai((()=>[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())),bh(h),d-=l*c,u+=l*c;return wh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),o=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},rd={description:s("Amount received at maturity for a security."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("investment (number)",s("The amount invested (irrespective of face value of each security).")),sa("discount (number)",s("The discount rate of the security invested in.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Oi(e)),r=Math.trunc(Oi(t)),a=Oi(o),l=Oi(i),c=Math.trunc(Oi(n));Qc(s,r),th(c),uh(a),gh(l);return a/(1-l*Bc.compute(s,r,c))},isExported:!0},ad={description:s("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[sa("number_of_periods (number)",s("The number of periods.")),sa("present_value (number)",s("The present value of the investment.")),sa("future_value (number)",s("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const i=Oi(e),n=Oi(t),s=Oi(o);return nh(i),(s/n)**(1/i)-1},isExported:!0},ld={description:s("Depreciation of an asset using the straight-line method."),args:[sa("cost (number)",s("The initial cost of the asset.")),sa("salvage (number)",s("The value of the asset at the end of depreciation.")),sa("life (number)",s("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(Oi(e)-Oi(t))/Oi(o)},isExported:!0},cd={description:s("Depreciation via sum of years digit method."),args:[sa("cost (number)",s("The initial cost of the asset.")),sa("salvage (number)",s("The value of the asset at the end of depreciation.")),sa("life (number)",s("The number of periods over which the asset is depreciated.")),sa("period (number)",s("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i){const n=Oi(e),s=Oi(t),r=Oi(o),a=Oi(i);lh(a),rh(r),dh(a,r);return(r-a+1)/(r*(r+1)/2)*(n-s)},isExported:!0},hd={description:s("Price of a US Treasury bill."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(Oi(e)),n=Math.trunc(Oi(t)),s=Oi(o);Qc(i,n),fh(i,n),gh(s),ph(s);return 100*(1-s*Bc.compute(i,n,2))},isExported:!0},dd={description:s("Equivalent rate of return for a US Treasury bill."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(Oi(e)),n=Math.trunc(Oi(t)),s=Oi(o);Qc(i,n),fh(i,n),gh(s),ph(s);const r=Cc.compute(n,i);if(r<=182)return 365*s/(360-s*r);const a=hd.compute(i,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},ud={description:s("The yield of a US Treasury bill based on price."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("price (number)",s("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(Oi(e)),n=Math.trunc(Oi(t)),s=Oi(o);Qc(i,n),fh(i,n),ih(s);return(100-s)/s*(1/Bc.compute(i,n,2))},isExported:!0},gd={description:s("Variable declining balance. WARNING : does not handle decimal periods."),args:[sa("cost (number)",s("The initial cost of the asset.")),sa("salvage (number)",s("The value of the asset at the end of depreciation.")),sa("life (number)",s("The number of periods over which the asset is depreciated.")),sa("start (number)",s("Starting period to calculate depreciation.")),sa("end (number)",s("Ending period to calculate depreciation.")),sa("factor (number, default=2)",s("The number of months in the first year of depreciation.")),sa("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,o,i,n,r=2,a=false){r=r||0;const l=Oi(e),c=Oi(t),h=Oi(o),d=Math.trunc(Oi(i)),u=Math.trunc(Oi(n)),g=Oi(r),p=ki(a);if(ah(l),ch(c),function(e,t,o){rh(o),Ai((()=>e>=0),s("The start_period (%s) must be greater or equal than 0.",e.toString())),Ai((()=>t>=0),s("The end_period (%s) must be greater or equal than 0.",t.toString())),Ai((()=>e<=t),s("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Ai((()=>t<=o),s("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),mh(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,o=(f-c)/(h-e);!p&&o>t?(S=!0,v=o):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},pd={description:s("Internal rate of return given non-periodic cash flows."),args:[sa("cashflow_amounts (range<number>)",s("An range containing the income or payments associated with the investment.")),sa("cashflow_dates (range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts.")),sa("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o=.1){const i=Oi(o=o||0),n=e.flat().map(Oi),r=t.flat().map(Oi);var a;Sh(e,t),a=n,Ai((()=>a.some((e=>e>0))&&a.some((e=>e<0))),s("There must be both positive and negative values in cashflow_amounts.")),Ch(r),bh(i);const l=new Map;for(const e of ze(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 wh((e=>{let t=h[0];for(const o of ze(1,h.length)){const i=(c[0]-c[o])/365;t+=h[o]*(1+e)**i}return t}),(e=>{let t=0;for(const o of ze(1,h.length)){const i=(c[0]-c[o])/365;t+=i*h[o]*(1+e)**(i-1)}return t}),i,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},md={description:s("Net present value given to non-periodic cash flows.."),args:[sa("discount (number)",s("The discount rate of the investment over one period.")),sa("cashflow_amounts (number, range<number>)",s("An range containing the income or payments associated with the investment.")),sa("cashflow_dates (number, range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const i=Oi(e),n=Array.isArray(t)?t.flat().map(Ni):[Ni(t)],r=Array.isArray(o)?o.flat().map(Ni):[Ni(o)];if(Array.isArray(o)&&Array.isArray(t)?Sh(t,o):Ai((()=>n.length===r.length),s("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Ch(r),sh(i),1===n.length)return n[0];const a=new Map;for(const e of ze(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 ze(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+i)**t}return h},isExported:!0},fd={description:s("Annual yield of a security paying periodic interest."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("rate (number)",s("The annualized rate of interest.")),sa("price (number)",s("The price at which the security is bought per 100 face value.")),sa("redemption (number)",s("The redemption amount per 100 face value, or par.")),sa("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r,a=0){a=a||0;const l=Math.trunc(Oi(e)),c=Math.trunc(Oi(t)),h=Oi(o),d=Oi(i),u=Oi(n),g=Math.trunc(Oi(r)),p=Math.trunc(Oi(a));Qc(l,c),eh(g),th(p),Ai((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ih(d),oh(u);const m=Bc.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=wh((function(e){return function(e,t,o,i,n,s){let r=s-(e+n*(1-t))*i**(o-1+t);for(let e=1;e<=o;e++)r+=n*i**(e-1);return r}(d,v,f,e,b,u)}),(function(e){return function(e,t,o,i,n){let s=-(e+n*(1-t))*(o-1+t)*i**(o-2+t);for(let e=1;e<=o;e++)s+=n*(e-1)*i**(e-2);return s}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},vd={description:s("Annual yield of a discount security."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("price (number)",s("The price at which the security is bought per 100 face value.")),sa("redemption (number)",s("The redemption amount per 100 face value, or par.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Oi(e)),r=Math.trunc(Oi(t)),a=Oi(o),l=Oi(i),c=Math.trunc(Oi(n));Qc(s,r),th(c),ih(a),oh(l);return(l/a-1)/Bc.compute(e,t,n)},isExported:!0},bd={description:s("Annual yield of a security paying interest at maturity."),args:[sa("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),sa("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),sa("issue (date)",s("The date the security was initially issued.")),sa("rate (number)",s("The annualized rate of interest.")),sa("price (number)",s("The price at which the security is bought.")),sa("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r=0){r=r||0;const a=Math.trunc(Oi(e)),l=Math.trunc(Oi(t)),c=Math.trunc(Oi(o)),h=Oi(i),d=Oi(n),u=Math.trunc(Oi(r));Qc(a,l),th(u),Ai((()=>a>=c),s("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Ai((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ih(d);const g=Bc.compute(c,l,u),p=Bc.compute(c,a,u),m=Bc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Sd=Object.freeze({__proto__:null,ACCRINTM:yh,AMORLINC:xh,COUPDAYS:Ih,COUPDAYBS:Rh,COUPDAYSNC:Th,COUPNCD:Ah,COUPNUM:Mh,COUPPCD:Oh,CUMIPMT:Nh,CUMPRINC:_h,DB:Fh,DDB:Dh,DISC:kh,DOLLARDE:Ph,DOLLARFR:Lh,DURATION:Uh,EFFECT:Vh,FV:zh,FVSCHEDULE:Bh,INTRATE:Hh,IPMT:$h,IRR:Wh,ISPMT:Gh,MDURATION:qh,MIRR:Zh,NOMINAL:jh,NPER:Xh,NPV:Yh,PDURATION:Kh,PMT:Qh,PPMT:Jh,PV:ed,PRICE:td,PRICEDISC:od,PRICEMAT:id,RATE:sd,RECEIVED:rd,RRI:ad,SLN:ld,SYD:cd,TBILLPRICE:hd,TBILLEQ:dd,TBILLYIELD:ud,VDB:gd,XIRR:pd,XNPV:md,YIELD:fd,YIELDDISC:vd,YIELDMAT:bd});const Cd={description:s("Whether a value is an error other than #N/A."),args:[sa("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},Ed={description:s("Whether a value is an error."),args:[sa("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},wd={description:s("Whether a value is `true` or `false`."),args:[sa("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},yd={description:s("Whether a value is the error #N/A."),args:[sa("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},xd={description:s("Whether a value is non-textual."),args:[sa("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},Id={description:s("Whether a value is a number."),args:[sa("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},Rd={description:s("Whether a value is text."),args:[sa("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},Td={description:s("Whether the referenced cell is empty"),args:[sa("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},Ad={description:s("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Md=Object.freeze({__proto__:null,ISERR:Cd,ISERROR:Ed,ISLOGICAL:wd,ISNA:yd,ISNONTEXT:xd,ISNUMBER:Id,ISTEXT:Rd,ISBLANK:Td,NA:Ad});const Od={description:s("Logical `and` operator."),args:[sa("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.")),sa("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return Wi(e,(e=>(t=!0,o=o&&e,o))),Ai((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Nd={description:s("Returns value depending on logical expression."),args:[sa("logical_expression (boolean)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),sa("value_if_true (any, lazy)",s("The value the function returns if logical_expression is TRUE.")),sa("value_if_false (any, lazy, default=FALSE)",s("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,o=(()=>!1)){const i=ki(e)?t():o();return null==i?"":i},isExported:!0},_d={description:s("Value if it is not an error, otherwise 2nd argument."),args:[sa("value (any, lazy)",s("The value to return if value itself is not an error.")),sa('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 o;try{return e().format}catch(e){return null===(o=t())||void 0===o?void 0:o.format}},compute:function(e,t=(()=>"")){let o;try{o=e()}catch(e){o=t()}return null==o?"":o},isExported:!0},Fd={description:s("Value if it is not an #N/A error, otherwise 2nd argument."),args:[sa("value (any, lazy)",s("The value to return if value itself is not #N/A an error.")),sa('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 o;try{o=e()}catch(i){o=i.errorType===a.NotAvailable?t():e()}return null==o?"":o},isExported:!0},Dd={description:s("Returns a value depending on multiple logical expressions."),args:[sa("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.")),sa("value1 (any, lazy)",s("The returned value if condition1 is TRUE.")),sa("condition2 (boolean, lazy, repeating)",s("Additional conditions to be evaluated if the previous ones are FALSE.")),sa("value2 (any, lazy, repeating)",s("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){Ai((()=>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(ki(e[t]())){const o=e[t+1]();return null!==o?o:""}throw new Error(s("No match."))},isExported:!0},kd={description:s("Returns opposite of provided logical value."),args:[sa("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!ki(e)},isExported:!0},Pd={description:s("Logical `or` operator."),args:[sa("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.")),sa("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Wi(e,(e=>(t=!0,o=o||e,!o))),Ai((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Ld={description:s("Logical `xor` operator."),args:[sa("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.")),sa("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Wi(e,(e=>(t=!0,o=o?!e:e,!0))),Ai((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Ud=Object.freeze({__proto__:null,AND:Od,IF:Nd,IFERROR:_d,IFNA:Fd,IFS:Dd,NOT:kd,OR:Pd,XOR:Ld});function Vd(e,t){if(void 0===e)throw new g(s("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",_i(t)))}const zd={description:s("Column number of a specified cell."),args:[sa("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 o=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Ai((()=>!!o),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return ko(o).left+1},isExported:!0},Bd={description:s("Number of columns in a specified array or range."),args:[sa("range (meta)",s("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return t.right-t.left+1},isExported:!0},Hd={description:s("Horizontal lookup"),args:[sa("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),sa("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.")),sa("index (number)",s("The row index of the value to be returned, where the first row in range is numbered 1.")),sa("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,o,i=true){const n=Math.trunc(Oi(o)),r=Fi(e);Ai((()=>1<=n&&n<=t[0].length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=ki(i)?Yi(t,r,"nextSmaller","asc",t.length,Xi):Ki(t,r,"strict",t.length,Xi);const l=t[a];return Vd(l,e),l[n-1]},isExported:!0},$d={description:s("Look up a value."),args:[sa("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),sa("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.")),sa("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,o){let i=t.length,n=t[0].length;const r=Fi(e),a=n>=i,l=Yi(t,r,"nextSmaller","asc",a?n:i,a?ji:Xi);return Vd(t[0][l],e),void 0===o?a?t[i-1][l]:t[l][n-1]:(i=o.length,n=o[0].length,Ai((()=>1===i||1===n),s("The result_range must be a single row or a single column.")),i>1?(Ai((()=>l<=i-1),s("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),o[l][0]):(Ai((()=>l<=n-1),s("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),o[0][l]))},isExported:!0},Wd={description:s("Position of item in range that matches value."),args:[sa("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),sa("range (any, range)",s("The one-dimensional array to be searched.")),sa("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,o=1){let i=Oi(o);const n=Fi(e),r=t.length,a=t[0].length;Ai((()=>1===r||1===a),s("The range must be a single row or a single column."));let l=-1;const c=1===r?ji:Xi,h=1===r?t[0].length:t.length;switch(i=Math.sign(i),i){case 1:l=Yi(t,n,"nextSmaller","asc",h,c);break;case 0:l=Ki(t,n,"strict",h,c);break;case-1:l=Yi(t,n,"nextGreater","desc",h,c)}return Vd(1===r?t[0][l]:t[l],e),l+1},isExported:!0},Gd={description:s("Row number of a specified cell."),args:[sa("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)),Ai((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return ko(e).top+1},isExported:!0},qd={description:s("Number of rows in a specified array or range."),args:[sa("range (meta)",s("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=ko(e);return t.bottom-t.top+1},isExported:!0},Zd={description:s("Vertical lookup."),args:[sa("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),sa("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.")),sa("index (number)",s("The column index of the value to be returned, where the first column in range is numbered 1.")),sa("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,o,i=true){const n=Math.trunc(Oi(o)),r=Fi(e);Ai((()=>1<=n&&n<=t.length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=ki(i)?Yi(t,r,"nextSmaller","asc",t[0].length,ji):Ki(t,r,"strict",t[0].length,ji);const l=t[n-1][a];return Vd(l,e),l},isExported:!0},jd={description:s("Search a range for a match and return the corresponding item from a second range."),args:[sa("search_key (any)",s("The value to search for.")),sa("lookup_range (any, range)",s("The range to consider for the search. Should be a single column or a single row.")),sa("return_range (any, range)",s("The range containing the return value. Should have the same dimensions as lookup_range.")),sa("if_not_found (any, lazy, optional)",s("If a valid match is not found, return this value.")),sa("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.")),sa("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,o,i,n=0,r=1){const a=Math.trunc(Oi(n)),l=Math.trunc(Oi(r)),c=Fi(e);Ai((()=>1===t.length||1===t[0].length),s("lookup_range should be either a single row or single column.")),Ai((()=>1===o.length||1===o[0].length),s("return_range should be either a single row or single column.")),Ai((()=>o.length===t.length&&o[0].length===t[0].length),s("return_range should have the same dimensions as lookup_range.")),Ai((()=>[-1,1,-2,2].includes(l)),s("searchMode should be a value in [-1, 1, -2, 2].")),Ai((()=>[-1,0,1].includes(a)),s("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?ji:Xi,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=Yi(t,c,u,2===l?"asc":"desc",d,h)}else p=Ki(t,c,u,d,h,g);if(-1!==p)return 1===t.length?o[0][p]:o[p][0];const m=null==i?void 0:i();return Vd(m,e),m},isExported:!0};var Xd=Object.freeze({__proto__:null,COLUMN:zd,COLUMNS:Bd,HLOOKUP:Hd,LOOKUP:$d,MATCH:Wd,ROW:Gd,ROWS:qd,VLOOKUP:Zd,XLOOKUP:jd});const Yd={description:s("Sum of two numbers."),args:[sa("value1 (number)",s("The first addend.")),sa("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 Oi(e)+Oi(t)}},Kd={description:s("Concatenation of two values."),args:[sa("value1 (string)",s("The value to which value2 will be appended.")),sa("value2 (string)",s("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return _i(e)+_i(t)},isExported:!0},Qd={description:s("One number divided by another."),args:[sa("dividend (number)",s("The number to be divided.")),sa("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 o=Oi(t);return Ai((()=>0!==o),s("The divisor must be different from zero.")),Oi(e)/o}};function Jd(e){return null==e}const eu={number:0,string:"",boolean:!1},tu={description:s("Equal."),args:[sa("value1 (any)",s("The first value.")),sa("value2 (any)",s("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=Jd(e)?eu[typeof t]:e,t=Jd(t)?eu[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function ou(e,t,o){e=Jd(e)?eu[typeof t]:e,t=Jd(t)?eu[typeof e]:t,"number"!=typeof e&&(e=_i(e).toUpperCase()),"number"!=typeof t&&(t=_i(t).toUpperCase());const i=typeof e,n=typeof t;return"string"===i&&"number"===n||("string"!==n||"number"!==i)&&o(e,t)}const iu={description:s("Strictly greater than."),args:[sa("value1 (any)",s("The value to test as being greater than value2.")),sa("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return ou(e,t,((e,t)=>e>t))}},nu={description:s("Greater than or equal to."),args:[sa("value1 (any)",s("The value to test as being greater than or equal to value2.")),sa("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return ou(e,t,((e,t)=>e>=t))}},su={description:s("Less than."),args:[sa("value1 (any)",s("The value to test as being less than value2.")),sa("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!nu.compute(e,t)}},ru={description:s("Less than or equal to."),args:[sa("value1 (any)",s("The value to test as being less than or equal to value2.")),sa("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!iu.compute(e,t)}},au={description:s("Difference of two numbers."),args:[sa("value1 (number)",s("The minuend, or number to be subtracted from.")),sa("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 Oi(e)-Oi(t)}},lu={description:s("Product of two numbers"),args:[sa("factor1 (number)",s("The first multiplicand.")),sa("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 Oi(e)*Oi(t)}},cu={description:s("Not equal."),args:[sa("value1 (any)",s("The first value.")),sa("value2 (any)",s("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!tu.compute(e,t)}},hu={description:s("A number raised to a power."),args:[sa("base (number)",s("The number to raise to the exponent power.")),sa("exponent (number)",s("The exponent to raise base to."))],returns:["BOOLEAN"],compute:function(e,t){return Za.compute(e,t)}},du={description:s("A number with the sign reversed."),args:[sa("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-Oi(e)}},uu={description:s("Value interpreted as a percentage."),args:[sa("percentage (number)",s("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Oi(e)/100}},gu={description:s("A specified number, unchanged."),args:[sa("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 pu=Object.freeze({__proto__:null,ADD:Yd,CONCAT:Kd,DIVIDE:Qd,EQ:tu,GT:iu,GTE:nu,LT:su,LTE:ru,MINUS:au,MULTIPLY:lu,NE:cu,POW:hu,UMINUS:du,UNARY_PERCENT:uu,UPLUS:gu});const mu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,fu={description:s("Gets character associated with number."),args:[sa("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(Oi(e));return Ai((()=>t>=1),s("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},vu={description:s("Remove non-printable characters from a piece of text."),args:[sa("text (string)",s("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=_i(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},bu={description:s("Appends strings to one another."),args:[sa("string1 (string, range<string>)",s("The initial string.")),sa("string2 (string, range<string>, repeating)",s("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Bi(e,((e,t)=>e+_i(t)),"")},isExported:!0},Su={description:s("Tests whether two strings are identical."),args:[sa("string1 (string)",s("The first string to compare.")),sa("string2 (string)",s("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return _i(e)===_i(t)},isExported:!0},Cu={description:s("First position of string found in text, case-sensitive."),args:[sa("search_for (string)",s("The string to look for within text_to_search.")),sa("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),sa("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=_i(e),n=_i(t),r=Oi(o);Ai((()=>""!==n),s("The text_to_search must be non-empty.")),Ai((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(i,r-1);return Ai((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i.toString(),n)),a+1},isExported:!0},Eu={description:s("Concatenates elements of arrays with delimiter."),args:[sa("delimiter (string)",s("The character or string to place between each concatenated value.")),sa("value_or_array1 (string, range<string>)",s("The value or values to be appended using delimiter.")),sa("value_or_array2 (string, range<string>, repeating)",s("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=_i(e);return Bi(t,((e,t)=>(e?e+o:"")+_i(t)),"")}},wu={description:s("Substring from beginning of specified string."),args:[sa("text (string)",s("The string from which the left portion will be returned.")),sa("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 o=t.length?Oi(t[0]):1;return Ai((()=>o>=0),s("The number_of_characters (%s) must be positive or null.",o.toString())),_i(e).substring(0,o)},isExported:!0},yu={description:s("Length of a string."),args:[sa("text (string)",s("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return _i(e).length},isExported:!0},xu={description:s("Converts a specified string to lowercase."),args:[sa("text (string)",s("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return _i(e).toLowerCase()},isExported:!0},Iu={description:s("A segment of a string."),args:[sa("text (string)",s("The string to extract a segment from.")),sa(" (number)",s("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),sa(" (number)",s("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const i=_i(e),n=Oi(t),r=Oi(o);return Ai((()=>n>=1),s("The starting_at argument (%s) must be positive greater than one.",n.toString())),Ai((()=>r>=0),s("The extract_length argument (%s) must be positive or null.",r.toString())),i.slice(n-1,n+r-1)},isExported:!0},Ru={description:s("Capitalizes each word in a specified string."),args:[sa("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 _i(e).replace(mu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Tu={description:s("Replaces part of a text string with different text."),args:[sa("text (string)",s("The text, a part of which will be replaced.")),sa("position (number)",s("The position where the replacement will begin (starting from 1).")),sa("length (number)",s("The number of characters in the text to be replaced.")),sa("new_text (string)",s("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,i){const n=Oi(t);Ai((()=>n>=1),s("The position (%s) must be greater than or equal to 1.",n.toString()));const r=_i(e),a=Oi(o),l=_i(i);return r.substring(0,n-1)+l+r.substring(n-1+a)},isExported:!0},Au={description:s("A substring from the end of a specified string."),args:[sa("text (string)",s("The string from which the right portion will be returned.")),sa("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 o=t.length?Oi(t[0]):1;Ai((()=>o>=0),s("The number_of_characters (%s) must be positive or null.",o.toString()));const i=_i(e),n=i.length;return i.substring(n-o,n)},isExported:!0},Mu={description:s("First position of string found in text, ignoring case."),args:[sa("search_for (string)",s("The string to look for within text_to_search.")),sa("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),sa("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=_i(e).toLowerCase(),n=_i(t).toLowerCase(),r=Oi(o);Ai((()=>""!==n),s("The text_to_search must be non-empty.")),Ai((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(i,r-1);return Ai((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i,n)),a+1},isExported:!0},Ou={description:s("Replaces existing text with new text in a string."),args:[sa("text_to_search (string)",s("The text within which to search and replace.")),sa("search_for (string)",s("The string to search for within text_to_search.")),sa("replace_with (string)",s("The string that will replace search_for.")),sa("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,o,i){const n=Oi(i);Ai((()=>n>=0),s("The occurrenceNumber (%s) must be positive or null.",n.toString()));const r=_i(e),a=_i(t);if(""===a)return r;const l=_i(o),c=new RegExp(Oe(a),"g");if(0===n)return r.replace(c,l);let h=0;return r.replace(c,(e=>++h===n?l:e))},isExported:!0},Nu={description:s("Combines text from multiple strings and/or arrays."),args:[sa("delimiter (string)",s(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),sa("ignore_empty (boolean)",s("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),sa("text1 (string, range<string>)",s("Any text item. This could be a string, or an array of strings in a range.")),sa("text2 (string, range<string>, repeating)",s("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const i=_i(e),n=ki(t);let s=0;return Bi(o,((e,t)=>n&&""===_i(t)?e:(s++?e+i:"")+_i(t)),"")},isExported:!0},_u={description:s("Removes space characters."),args:[sa("text (string)",s("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return _i(e).trim()},isExported:!0},Fu={description:s("Converts a specified string to uppercase."),args:[sa("text (string)",s("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return _i(e).toUpperCase()},isExported:!0},Du={description:s("Converts a number to text according to a specified format."),args:[sa("number (number)",s("The number, date or time to format.")),sa("format (string)",s("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return ho(Oi(e),_i(t))},isExported:!0};var ku=Object.freeze({__proto__:null,CHAR:fu,CLEAN:vu,CONCATENATE:bu,EXACT:Su,FIND:Cu,JOIN:Eu,LEFT:wu,LEN:yu,LOWER:xu,MID:Iu,PROPER:Ru,REPLACE:Tu,RIGHT:Au,SEARCH:Mu,SUBSTITUTE:Ou,TEXTJOIN:Nu,TRIM:_u,UPPER:Fu,TEXT:Du});const Pu={description:s("Creates a hyperlink in a cell."),args:[sa("url (string)",s("The full URL of the link enclosed in quotation marks.")),sa("link_label (string, optional)",s("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=_i(e).trim(),i=_i(t)||o;return""===o?i:je(i,o)},isExported:!0};var Lu=Object.freeze({__proto__:null,HYPERLINK:Pu});const Uu=[{name:s("Database"),functions:fc},{name:s("Date"),functions:Xc},{name:s("Financial"),functions:Sd},{name:s("Info"),functions:Md},{name:s("Lookup"),functions:Xd},{name:s("Logical"),functions:Ud},{name:s("Math"),functions:dl},{name:s("Misc"),functions:la},{name:s("Operator"),functions:pu},{name:s("Statistical"),functions:tc},{name:s("Text"),functions:ku},{name:s("Engineering"),functions:Kc},{name:s("Web"),functions:Lu}],Vu=/^[A-Z0-9\_\.]+$/;function zu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Bu(e()):Bu(e)}))}function Bu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Hu=new class extends bi{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Vu))throw new Error(s("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=ra(t);return function(e){let t=!1,o=!1,i=!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=o||t||i,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,o=n.optional,i=n.default}}(o.args),this.mapping[e]=function(...e){const t=o.compute.bind(this),i=o.computeFormat?o.computeFormat.bind(this):()=>{};return{value:t(...zu(e)),format:i(...e)}},super.add(e,o),this}};for(let e of Uu){const t=e.functions;for(let o in t){const i=t[o];i.category=i.category||e.name,o=o.replace(/_/g,"."),Hu.add(o,{isExported:!1,...i})}}function $u(e,t,o){const i=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:i,quantity:o}).isCancelledBecause(65)&&e.raiseError(Is)}const Wu=new Yn;Wu.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:Mr}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:Or}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:Nr}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:kr}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:_r}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:Dr}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:Jr,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Kr}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:Qr}).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:Pr,sequence:80,action:Lr}).addChild("edit_delete_column",["edit"],{name:Ur,sequence:90,action:Vr}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:Hr}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:$r}).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=Rr(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:Wr,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Rr(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:Gr,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Ir(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=Ir(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:Zr,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:Br,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===ni(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+n+Math.max(0,(r-t.width)/2),y:i+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:s,size:n,definition:mr(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=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(!i)throw new Error("No image provider was given to the environment");const n=ar(e.model.getters,i.size),r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-o),c=Math.min(a.height,r.height-i);return{x:o+n+Math.max(0,(l-t.width)/2),y:i+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:r,size:n,definition:i})}},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"],(()=>Gu(Hu.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=Hu.content;return[...new Set(Hu.getAll().map((e=>e.category)))].filter(et).sort().map(((t,o)=>{const i=Object.keys(e).filter((o=>e[o].category===t));return{name:t,sequence:60+10*o,children:Gu(i)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:Xr}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name: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=>$u(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>$u(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();$u(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=>$u(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>$u(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();$u(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:ys.Automatic,sequence:10,separator:!0,action:e=>Tr(e,"")}).addChild("format_number_number",["format","format_number"],{name:ys.Number,description:"1,000.12",sequence:20,action:e=>Tr(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:ys.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>Tr(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:ys.Currency,description:"$1,000.12",sequence:37,action:e=>Tr(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:ys.CurrencyRounded,description:"$1,000",sequence:38,action:e=>Tr(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:ys.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:ys.Date,description:"9/26/2008",sequence:40,action:e=>Tr(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:ys.Time,description:"10:43:00 PM",sequence:50,action:e=>Tr(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:ys.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>Tr(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:ys.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>Tr(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>Ar(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>Ar(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>Ar(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>Ar(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=>Ar(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>Ar(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>Ar(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>Ar(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>Ar(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>Ar(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=>Ar(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>Ar(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>Ar(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:jr,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(),o=e.model.getters.getSelection().zones;Cr(e,t,o)},isVisible:e=>!Yr(e),isEnabled:e=>(e=>si(...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:Yr});for(let e of he)Wu.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>Ar(t,{fontSize:e})});function Gu(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const qu=new class extends bi{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},Zu={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function ju(e,t){const o=Zu[e.key];e.shiftKey?t.resizeAnchorZone(o,e.ctrlKey?"end":1):t.moveAnchorCell(o,e.ctrlKey?"end":1)}const Xu=new Fo;ci`
|
|
349
|
+
`;class rr extends t.Component{get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=nr.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}rr.template="o-spreadsheet-ChartFigure",rr.components={},rr.props={figure:Object,onFigureDeleted:Function};class ar extends t.Component{get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function lr(e,t){const o=Ne(t),i=e.getSheetViewDimension(),n=i.width,s=i.height;if(o.width>n){const e=n/o.width;o.width=n,o.height=o.height*e}if(o.height>s){const e=s/o.height;o.height=s,o.width=o.width*e}return o}ar.template="o-spreadsheet-ImageFigure",ar.components={},ar.props={figure:Object,onFigureDeleted:Function};const cr=new Si;function hr(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 dr(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 ur(e,t,o){return{id:"delete",name:s("Delete"),sequence:10,action:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e}),t()}}}cr.add("chart",{Component:rr,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,o){return jn([{id:"edit",name:s("Edit"),sequence:1,action:()=>{o.model.dispatch("SELECT_FIGURE",{id:e}),o.openSidePanel("ChartPanel")}},hr(e,o),dr(e,o),ur(e,t,o)])}}),cr.add("image",{Component:ar,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,o){return jn([hr(e,o),dr(e,o),{id:"reset_size",name:s("Reset size"),sequence:4,action:()=>{const t=o.model.getters.getImageSize(e),{height:i,width:n}=lr(o.model.getters,t);o.model.dispatch("UPDATE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),id:e,height:i,width:n})}},ur(e,t,o)])}});const gr=(new Si).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let o=e.base;"after"===e.position&&o++;for(let i=0;i<e.quantity;i++)t.push(i+o);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],o=[...e.elements].sort(((e,t)=>e-t));for(let i of Be(o)){const o=0===i[0]?0:i[0]-1,n=0===i[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:i.length,base:o,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 rn.values())gr.contains(e)||gr.add(e,pr);function pr(e){return[e]}function mr(e,t){const o=ir.getAll().find((t=>t.match(e.type)));if(!o)throw new Error("Unknown chart type.");return o.transformDefinition(e,t)}function fr(e,t){var o;let i=e;e.left!==e.right&&(i={...e,left:e.left+1});const s=[Uo(i)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===si(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(o=a.style)||void 0===o?void 0:o.fillColor)||void 0,keyValue:Uo(e),baselineMode:ee,baselineColorUp:te,baselineColorDown:oe};let l="";const c=t.getEvaluatedCellsInZone(r,{...i,bottom:i.top}),h=!!c.find((e=>e.type!==en.empty&&e.type!==en.number));if(h){const e=c.filter((e=>e.type!==en.error&&e.type!==en.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=Uo({...e,right:e.left,top:h?e.top+1:e.top}));const u=i.right===i.left?"none":"top";return js(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!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 vr=[en.number,en.error,en.text,en.boolean];function br(e,t,o,i,n){let r=ln.Success,a=i.right>i.left;if(e.model.getters.doesIntersectMerge(t,i)){let o;a=!1;for(let n=i.top;n<=i.bottom;n++){o=[];for(let s=i.left;s<=i.right;s++){let i=e.model.getters.getMerge({sheetId:t,col:s,row:n});i&&!o.includes(i.id.toString())&&o.push(i.id.toString())}if(o.length>=2){a=!0;break}}}const{col:l,row:c}=o;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n});else{const o=e.model.getters.getContiguousZone(t,i);Go(o,i)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,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?"),(()=>{i=o,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:i,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=o;e.model.selection.selectZone({cell:{col:t,row:n},zone:i}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function Sr(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}const Cr={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 Er(e,t,o){const i=e.model.dispatch("CREATE_FILTER_TABLE",{target:o,sheetId:t});i.isCancelledBecause(78)?e.raiseError(Cr.filterOverlap):i.isCancelledBecause(80)?e.raiseError(Cr.mergeInFilter):i.isCancelledBecause(81)&&e.raiseError(Cr.nonContinuousTargets)}const wr={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 yr(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(wr.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(wr.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(wr.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(wr.frozenPaneOverlap))}function xr(e,t,o){const i=e.model.dispatch("PASTE",{target:t,pasteOption:o});yr(e,i)}function Ir(e,t,o){const i=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:o});yr(e,i)}function Rr(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 Tr(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 Ar(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Mr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const Or=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},Nr=async e=>{Sr(e),await e.clipboard.write(e.model.getters.getClipboardContent())},_r=async e=>Dr(e),Fr=async e=>Dr(e,"onlyValue");async function Dr(e,t){const o=e.model.getters.getClipboardTextContent(),i=await e.clipboard.readText();switch(i.status){case"ok":const n=e.model.getters.getSelectedZones();i&&i.content!==o?Ir(e,n,i.content):xr(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 kr=e=>xr(e,e.model.getters.getSelectedZones(),"onlyFormat"),Pr=e=>!e.model.getters.isCutOperation(),Lr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(o+1).toString())},Ur=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.top;e<=o.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Vr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?s("Delete column %s",Ut(t)):s("Delete columns %s - %s",Ut(t),Ut(o))},zr=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const o=e.model.getters.getSelectedZones()[0];for(let e=o.left;e<=o.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},Br=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});yr(e,o)},Hr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});yr(e,o)},$r=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});yr(e,o)},Wr=e=>{const t=e.model.getters.getSelectedZone(),o=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});yr(e,o)},Gr=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.top,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:o,quantity:i,dimension:"ROW"})},qr=e=>{const t=e.model.getters.getActiveRows();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.bottom,i=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:o,quantity:i,dimension:"ROW"})},Zr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.min(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.left,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:o,quantity:i})},jr=e=>{const t=e.model.getters.getActiveCols();let o,i;if(t.size)o=Math.max(...t),i=t.size;else{const t=e.model.getters.getSelectedZones()[0];o=t.right,i=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:o,quantity:i})};const Xr=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},Yr=e=>{let{col:t,row:o}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:o,popoverType:"LinkEditor"})},Kr=e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,o)},Qr=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();br(e,i,t.cell,o[0],"ascending")},Jr=e=>{const{anchor:t,zones:o}=e.model.getters.getSelection(),i=e.model.getters.getActiveSheetId();br(e,i,t.cell,o[0],"descending")},ea=e=>1===e.model.getters.getSelectedZones().length,ta=new Kn;ta.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Nr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Or}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:_r}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Pr}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:Fr}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:kr}).add("add_row_before",{name:e=>{const t=Tr(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:Gr,isVisible:ea}).add("add_column_before",{name:e=>{const t=Rr(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:Zr,isVisible:ea}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:ea,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:Br}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:Hr}).add("delete_row",{name:Lr,sequence:110,action:Ur,isVisible:ea}).add("delete_column",{name:Vr,sequence:120,action:zr,isVisible:ea}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:ea}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:$r}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:Wr}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:Yr});const oa=new Kn;oa.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Nr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Or}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:_r}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Pr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Fr}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:kr}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:ea,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Qr}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:Jr}).add("add_column_before",{name:e=>{const t=Rr(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:Zr}).add("add_column_after",{name:e=>{const t=Rr(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:jr}).add("delete_column",{name:Vr,sequence:90,action:zr,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("COL");return e.model.getters.canRemoveHeaders(t,"COL",o)}}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,o;const i=e.model.getters.getActiveCols();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.left,o=i.right}return t===o?s("Clear column %s",Ut(t)):s("Clear columns %s - %s",Ut(t),Ut(o))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveCols()].map((o=>e.model.getters.getColsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let o=t[0],i=t[t.length-1];return 1===t.length?s("Hide column %s",Ut(o).toString()):i-o+1===t.length?s("Hide columns %s - %s",Ut(o).toString(),Ut(i).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(),o=e.model.getters.getElementsFromSelection("COL");return e.model.getters.canRemoveHeaders(t,"COL",o)},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:Xr});const ia=new Kn;ia.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:Nr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Or}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:_r}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Pr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Fr}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:kr}).add("add_row_before",{name:e=>{const t=Tr(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:Gr}).add("add_row_after",{name:e=>{const t=Tr(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:qr}).add("delete_row",{name:Lr,sequence:70,action:Ur,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getElementsFromSelection("ROW");return e.model.getters.canRemoveHeaders(t,"ROW",o)}}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,o;const i=e.model.getters.getActiveRows();if(0!==i.size)t=Math.min(...i),o=Math.max(...i);else{const i=e.model.getters.getSelectedZones()[0];t=i.top,o=i.bottom}return t===o?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(o+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=[...e.model.getters.getActiveRows()].map((o=>e.model.getters.getRowsZone(t,o,o)));e.model.dispatch("DELETE_CONTENT",{target:o,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let o=t[0],i=t[t.length-1];return 1===t.length?s("Hide row %s",(o+1).toString()):i-o+1===t.length?s("Hide rows %s - %s",(o+1).toString(),(i+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(),o=e.model.getters.getElementsFromSelection("ROW");return e.model.getters.canRemoveHeaders(t,"ROW",o)},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:Xr});const na=/(.*?)\((.*?)\)(.*)/,sa=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function ra(e,t=""){return function(e){let t,o=e.match(na),i=o[1].trim(),n=[],s=!1,r=!1,a=!1;for(let e of o[2].split(",")){const o=e.trim().toUpperCase();let i=sa.find((e=>o===e));i?n.push(i):"RANGE<ANY>"===o?n.push("RANGE"):"OPTIONAL"===o?s=!0:"REPEATING"===o?r=!0:"LAZY"===o?a=!0:o.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}let l=o[3].trim();const c={name:i,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 aa(e){let t=0,o=0,i=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||o++,n.repeating&&i++;const n=e;return n.minArgRequired=o,n.maxArgPossible=i?1/0:t,n.nbrArgRepeating=i,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const o=e-t;return e=>{if(e<=o)return e;return o+((e-o)%t||t)}}(t,i),n.hidden=e.hidden||!1,n}const la={description:s("Apply a large number format"),args:[ra("value (number)",s("The number.")),ra("unit (string, optional)",s("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:(e,t)=>{const o=Math.abs(Ni(e.value)),i=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return wo(i,1e3,"k");case"m":return wo(i,1e6,"m");case"b":return wo(i,1e9,"b");default:throw new Error(s("The formatting unit should be 'k', 'm' or 'b'."))}}return o<1e5?wo(i,0,""):o<1e8?wo(i,1e3,"k"):o<1e11?wo(i,1e6,"m"):wo(i,1e9,"b")},compute:function(e){return Ni(e)}};var ca=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:la});const ha={description:s("Absolute value of a number."),args:[ra("value (number)",s("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Ni(e))},isExported:!0},da={description:s("Inverse cosine of a value, in radians."),args:[ra("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=Ni(e);return Mi((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},ua={description:s("Inverse hyperbolic cosine of a number."),args:[ra("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=Ni(e);return Mi((()=>t>=1),s("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},ga={description:s("Inverse cotangent of a value."),args:[ra("value (number)",s("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Ni(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},pa={description:s("Inverse hyperbolic cotangent of a value."),args:[ra("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=Ni(e);return Mi((()=>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},ma={description:s("Inverse sine of a value, in radians."),args:[ra("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=Ni(e);return Mi((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},fa={description:s("Inverse hyperbolic sine of a number."),args:[ra("value (number)",s("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Ni(e))},isExported:!0},va={description:s("Inverse tangent of a value, in radians."),args:[ra("value (number)",s("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Ni(e))},isExported:!0},ba={description:s("Angle from the X axis to a point (x,y), in radians."),args:[ra("x (number)",s("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),ra("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 o=Ni(e),i=Ni(t);return Mi((()=>0!==o||0!==i),s("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(i,o)},isExported:!0},Sa={description:s("Inverse hyperbolic tangent of a number."),args:[ra("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=Ni(e);return Mi((()=>Math.abs(t)<1),s("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ca={description:s("Rounds number up to nearest multiple of factor."),args:[ra("value (number)",s("The value to round up to the nearest integer multiple of factor.")),ra("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 o=Ni(e),i=Ni(t);return Mi((()=>i>=0||o<=0),s("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.ceil(o/i)*i:0},isExported:!0},Ea={description:s("Rounds number up to nearest multiple of factor."),args:[ra("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ra("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ra("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,o=0){let i=Ni(t);if(0===i)return 0;const n=Ni(e);if(i=Math.abs(i),n>=0)return Math.ceil(n/i)*i;return 0===Ni(o)?-Math.floor(Math.abs(n)/i)*i:-Math.ceil(Math.abs(n)/i)*i},isExported:!0},wa={description:s("Rounds number up to nearest multiple of factor."),args:[ra("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ra("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 Ea.compute(e,t,0)},isExported:!0},ya={description:s("Cosine of an angle provided in radians."),args:[ra("angle (number)",s("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Ni(e))},isExported:!0},xa={description:s("Hyperbolic cosine of any real number."),args:[ra("value (number)",s("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Ni(e))},isExported:!0},Ia={description:s("Cotangent of an angle provided in radians."),args:[ra("angle (number)",s("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Ni(e);return Mi((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Ra={description:s("Hyperbolic cotangent of any real number."),args:[ra("value (number)",s("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Ni(e);return Mi((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Ta={description:s("Number of empty values."),args:[ra("value1 (any, range)",s("The first value or range in which to count the number of blanks.")),ra("value2 (any, range, repeating)",s("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Hi(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Aa={description:s("A conditional count across a range."),args:[ra("range (range)",s("The range that is tested against criterion.")),ra("criterion (string)",s("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return ji(e,((e,o)=>{t+=1})),t},isExported:!0},Ma={description:s("Count values depending on multiple criteria."),args:[ra("criteria_range1 (range)",s("The range to check against criterion1.")),ra("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ra("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.")),ra("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return ji(e,((e,o)=>{t+=1})),t},isExported:!0};function Oa(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Na={description:s("Counts number of unique values in a range."),args:[ra("value1 (any, range)",s("The first value or range to consider for uniqueness.")),ra("value2 (any, range, repeating)",s("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Hi(e,((e,t)=>Oa(t)?e.add(t):e),new Set).size}},_a={description:s("Counts number of unique values in a range, filtered by a set of criteria."),args:[ra("range (range)",s("The range of cells from which the number of unique values will be counted.")),ra("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ra("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.")),ra("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.")),ra("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=new Set;return ji(t,((t,i)=>{const n=e[t][i];Oa(n)&&o.add(n)})),o.size}},Fa={description:s("Cosecant of an angle provided in radians."),args:[ra("angle (number)",s("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Ni(e);return Mi((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Da={description:s("Hyperbolic cosecant of any real number."),args:[ra("value (number)",s("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Ni(e);return Mi((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},ka={description:s("Converts from another base to decimal."),args:[ra("value (string)",s("The number to convert.")),ra(",base (number)",s("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let o=Ni(t);o=Math.floor(o),Mi((()=>2<=o&&o<=36),s("The base (%s) must be between 2 and 36 inclusive.",o.toString()));const i=Fi(e);if(""===i)return 0;Mi((()=>!!i.match(/^-?[a-z0-9]+$/i)),s("The value (%s) must be a valid base %s representation.",i,o.toString()));const n=parseInt(i,o);return Mi((()=>!isNaN(n)),s("The value (%s) must be a valid base %s representation.",i,o.toString())),n},isExported:!0},Pa={description:s("Converts an angle value in radians to degrees."),args:[ra("angle (number)",s("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Ni(e)/Math.PI},isExported:!0},La={description:s("Euler's number, e (~2.718) raised to a power."),args:[ra("value (number)",s("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Ni(e))},isExported:!0},Ua={description:s("Rounds number down to nearest multiple of factor."),args:[ra("value (number)",s("The value to round down to the nearest integer multiple of factor.")),ra("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 o=Ni(e),i=Ni(t);return Mi((()=>i>=0||o<=0),s("The factor (%s) must be positive when the value (%s) is positive.",i.toString(),o.toString())),i?Math.floor(o/i)*i:0},isExported:!0},Va={description:s("Rounds number down to nearest multiple of factor."),args:[ra("number (number)",s("The value to round down to the nearest integer multiple of significance.")),ra("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ra("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,o=0){let i=Ni(t);if(0===i)return 0;const n=Ni(e);if(i=Math.abs(i),n>=0)return Math.floor(n/i)*i;return 0===Ni(o)?-Math.ceil(Math.abs(n)/i)*i:-Math.floor(Math.abs(n)/i)*i},isExported:!0},za={description:s("Rounds number down to nearest multiple of factor."),args:[ra("number (number)",s("The value to round down to the nearest integer multiple of significance.")),ra("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 Va.compute(e,t,0)},isExported:!0},Ba={description:s("Whether the provided value is even."),args:[ra("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=_i(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Ha={description:s("Rounds number up to nearest multiple of factor."),args:[ra("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ra("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 Ea.compute(e,t,0)},isExported:!0},$a={description:s("Whether the provided value is even."),args:[ra("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=_i(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Wa={description:s("The logarithm of a number, base e (euler's number)."),args:[ra("value (number)",s("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Ni(e);return Mi((()=>t>0),s("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},Ga={description:s("Modulo (remainder) operator."),args:[ra("dividend (number)",s("The number to be divided to find the remainder.")),ra("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Ni(t);Mi((()=>0!==o),s("The divisor must be different from 0."));const i=Ni(e)%o;return i>0&&o<0||i<0&&o>0?i+o:i},isExported:!0},qa={description:s("Rounds a number up to the nearest odd integer."),args:[ra("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=Ni(e);let o=Math.ceil(Math.abs(t));return o=1&o?o:o+1,t<0?-o:o},isExported:!0},Za={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:[ra("base (number)",s("The number to raise to the exponent power.")),ra("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const o=Ni(e),i=Ni(t);return Mi((()=>o>=0||Number.isInteger(i)),s("The exponent (%s) must be an integer when the base is negative.",i.toString())),Math.pow(o,i)},isExported:!0},Xa={description:s("Result of multiplying a series of numbers together."),args:[ra("factor1 (number, range<number>)",s("The first number or range to calculate for the product.")),ra("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,o=1;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(o*=i,t+=1);else null!=i&&(o*=_i(i),t+=1);return 0===t?0:o},isExported:!0},Ya={description:s("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},Ka={description:s("Random integer between two values, inclusive."),args:[ra("low (number)",s("The low end of the random range.")),ra("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 o=Ni(e);Number.isInteger(o)||(o=Math.ceil(o));let i=Ni(t);return Number.isInteger(i)||(i=Math.floor(i)),Mi((()=>o<=i),s("The high (%s) must be greater than or equal to the low (%s).",i.toString(),o.toString())),o+Math.ceil((i-o+1)*Math.random())-1},isExported:!0},Qa={description:s("Rounds a number according to standard rules."),args:[ra("value (number)",s("The value to round to places number of places.")),ra("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 o=Ni(e);let i=Ni(t);const n=Math.abs(o);let s;return 0===i?s=Math.round(n):(Number.isInteger(i)||(i=Math.trunc(i)),s=Math.round(n*Math.pow(10,i))/Math.pow(10,i)),o>=0?s:-s},isExported:!0},Ja={description:s("Rounds down a number."),args:[ra("value (number)",s("The value to round to places number of places, always rounding down.")),ra("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 o=Ni(e);let i=Ni(t);const n=Math.abs(o);let s;return 0===i?s=Math.floor(n):(Number.isInteger(i)||(i=Math.trunc(i)),s=Math.floor(n*Math.pow(10,i))/Math.pow(10,i)),o>=0?s:-s},isExported:!0},el={description:s("Rounds up a number."),args:[ra("value (number)",s("The value to round to places number of places, always rounding up.")),ra("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 o=Ni(e);let i=Ni(t);const n=Math.abs(o);let s;return 0===i?s=Math.ceil(n):(Number.isInteger(i)||(i=Math.trunc(i)),s=Math.ceil(n*Math.pow(10,i))/Math.pow(10,i)),o>=0?s:-s},isExported:!0},tl={description:s("Secant of an angle provided in radians."),args:[ra("angle (number)",s("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Ni(e))},isExported:!0},ol={description:s("Hyperbolic secant of any real number."),args:[ra("value (number)",s("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Ni(e))},isExported:!0},il={description:s("Sine of an angle provided in radians."),args:[ra("angle (number)",s("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Ni(e))},isExported:!0},nl={description:s("Hyperbolic sine of any real number."),args:[ra("value (number)",s("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Ni(e))},isExported:!0},sl={description:s("Positive square root of a positive number."),args:[ra("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=Ni(e);return Mi((()=>t>=0),s("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},rl={description:s("Sum of a series of numbers and/or cells."),args:[ra("value1 (number, range<number>)",s("The first number or range to add together.")),ra("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 $i(e,((e,t)=>e+t),0)},isExported:!0},al={description:s("A conditional sum across a range."),args:[ra("criteria_range (range)",s("The range which is tested against criterion.")),ra("criterion (string)",s("The pattern or test to apply to range.")),ra("sum_range (range, default=criteria_range)",s("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,o){void 0===o&&(o=e);let i=0;return ji([e,t],((e,t)=>{const n=o[e][t];"number"==typeof n&&(i+=n)})),i},isExported:!0},ll={description:s("Sums a range depending on multiple criteria."),args:[ra("sum_range (range)",s("The range to sum.")),ra("criteria_range1 (range)",s("The range to check against criterion1.")),ra("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ra("criteria_range2 (any, range, repeating)",s("Additional ranges to check.")),ra("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let o=0;return ji(t,((t,i)=>{const n=e[t][i];"number"==typeof n&&(o+=n)})),o},isExported:!0},cl={description:s("Tangent of an angle provided in radians."),args:[ra("angle (number)",s("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Ni(e))},isExported:!0},hl={description:s("Hyperbolic tangent of any real number."),args:[ra("value (number)",s("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Ni(e))},isExported:!0},dl={description:s("Truncates a number."),args:[ra("value (number)",s("The value to be truncated.")),ra("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 o=Ni(e);let i=Ni(t);return 0===i?Math.trunc(o):(Number.isInteger(i)||(i=Math.trunc(i)),Math.trunc(o*Math.pow(10,i))/Math.pow(10,i))},isExported:!0};var ul=Object.freeze({__proto__:null,ABS:ha,ACOS:da,ACOSH:ua,ACOT:ga,ACOTH:pa,ASIN:ma,ASINH:fa,ATAN:va,ATAN2:ba,ATANH:Sa,CEILING:Ca,CEILING_MATH:Ea,CEILING_PRECISE:wa,COS:ya,COSH:xa,COT:Ia,COTH:Ra,COUNTBLANK:Ta,COUNTIF:Aa,COUNTIFS:Ma,COUNTUNIQUE:Na,COUNTUNIQUEIFS:_a,CSC:Fa,CSCH:Da,DECIMAL:ka,DEGREES:Pa,EXP:La,FLOOR:Ua,FLOOR_MATH:Va,FLOOR_PRECISE:za,ISEVEN:Ba,ISO_CEILING:Ha,ISODD:$a,LN:Wa,MOD:Ga,ODD:qa,PI:Za,POWER:ja,PRODUCT:Xa,RAND:Ya,RANDBETWEEN:Ka,ROUND:Qa,ROUNDDOWN:Ja,ROUNDUP:el,SEC:tl,SECH:ol,SIN:il,SINH:nl,SQRT:sl,SUM:rl,SUMIF:al,SUMIFS:ll,TAN:cl,TANH:hl,TRUNC:dl});function gl(e,t,o){let i=[],n=[],r=0,a=0;Vi([e],(e=>{i.push(e),r+=1})),Vi([t],(e=>{n.push(e),a+=1})),Mi((()=>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=i[e],o=n[e];"number"==typeof t&&"number"==typeof o&&(l+=1,c+=t,h+=o)}Mi((()=>0!==l&&(!o||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=i[e],o=n[e];"number"==typeof t&&"number"==typeof o&&(g+=(t-d)*(o-u))}return g/(l-(o?1:0))}function pl(e,t,o){let i=0,n=0;const r=o?Wi:$i;n=r(e,((e,t)=>(i+=1,e+t)),0),Mi((()=>0!==i&&(!t||1!==i)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/i;return r(e,((e,t)=>e+Math.pow(t-a,2)),0)/(i-(t?1:0))}function ml(e,t,o){const i=Ni(t);Mi((()=>o?0<=i&&i<=1:0<i&&i<1),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return Vi(e,(e=>{"number"==typeof e&&(n=Ki(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,e),a++)})),Mi((()=>0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),o||Mi((()=>1/(a+1)<=i&&i<=a/(a+1)),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),to(r,i,o)}const fl={description:s("Average magnitude of deviations from mean."),args:[ra("value1 (number, range<number>)",s("The first value or range of the sample.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const o=$i(e,((e,o)=>(t+=1,e+o)),0);Mi((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const i=o/t;return $i(e,((e,t)=>e+Math.abs(i-t)),0)/t},isExported:!0},vl={description:s("Numerical average value in a dataset, ignoring text."),args:[ra("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),ra("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 o=$i(e,((e,o)=>(t+=1,e+o)),0);return Mi((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},bl=s("[[FUNCTION_NAME]] has mismatched range sizes."),Sl=s("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Cl={description:s("Weighted average."),args:[ra("values (number, range<number>)",s("Values to average.")),ra("weights (number, range<number>)",s("Weights for each corresponding value.")),ra("additional_values (number, range<number>, repeating)",s("Additional values to average.")),ra("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,o,i=0,n=0;Mi((()=>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],o=e[r+1],Array.isArray(t)){Mi((()=>Array.isArray(o)),bl);let e=t.length,r=t[0].length;Mi((()=>e===o.length&&r===o[0].length),bl);for(let a=0;a<e;a++)for(let e=0;e<r;e++){let r=t[a][e],l=o[a][e],c="number"==typeof r,h="number"==typeof l;Mi((()=>c===h),s("[[FUNCTION_NAME]] expects number values.")),h&&(Mi((()=>l>=0),Sl),i+=r*l,n+=l)}}else o=Ni(o),t=Ni(t),Mi((()=>o>=0),Sl),i+=t*o,n+=o;return Mi((()=>0!==n),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/n}},El={description:s("Numerical average value in a dataset."),args:[ra("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),ra("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 o=Wi(e,((e,o)=>(t+=1,e+o)),0);return Mi((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/t},isExported:!0},wl={description:s("Average of values depending on criteria."),args:[ra("criteria_range (range)",s("The range to check against criterion.")),ra("criterion (string)",s("The pattern or test to apply to criteria_range.")),ra("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,o){null==o&&(o=e);let i=0,n=0;return ji([e,t],((t,s)=>{const r=(o||e)[t][s];"number"==typeof r&&(i+=1,n+=r)})),Mi((()=>0!==i),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/i},isExported:!0},yl={description:s("Average of values depending on multiple criteria."),args:[ra("average_range (range)",s("The range to average.")),ra("criteria_range1 (range)",s("The range to check against criterion1.")),ra("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ra("criteria_range2 (any, range, repeating)",s("Additional criteria_range and criterion to check.")),ra("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=0,i=0;return ji(t,((t,n)=>{const s=e[t][n];"number"==typeof s&&(o+=1,i+=s)})),Mi((()=>0!==o),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/o},isExported:!0},xl={description:s("The number of numeric values in dataset."),args:[ra("value1 (number, range<number>)",s("The first value or range to consider when counting.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(t+=1);else("string"!=typeof o||Qt(o)||Se(o))&&(t+=1);return t},isExported:!0},Il={description:s("The number of values in a dataset."),args:[ra("value1 (any, range)",s("The first value or range to consider when counting.")),ra("value2 (any, range, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Hi(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Rl={description:s("The covariance of a dataset."),args:[ra("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ra("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return gl(e,t,!1)},isExported:!0},Tl={description:s("The covariance of a dataset."),args:[ra("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ra("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return gl(e,t,!1)},isExported:!0},Al={description:s("The sample covariance of a dataset."),args:[ra("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ra("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return gl(e,t,!0)},isExported:!0},Ml={description:s("Nth largest element from a data set."),args:[ra("data (any, range)",s("Array or range containing the dataset to consider.")),ra("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 o=Math.trunc(Ni(t));let i,n=[],r=0;Vi([e],(e=>{"number"==typeof e&&(i=Ki(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(i+1,0,e),r++,r>o&&(n.shift(),r--))}));const a=n.shift();return Mi((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Mi((()=>r>=o),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},Ol={description:s("Maximum value in a numeric dataset."),args:[ra("value1 (number, range<number>)",s("The first value or range to consider when calculating the maximum value.")),ra("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=$i(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Nl={description:s("Maximum numeric value in a dataset."),args:[ra("value1 (any, range)",s("The first value or range to consider when calculating the maximum value.")),ra("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=Wi(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},_l={description:s("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[ra("range (range)",s("The range of cells from which the maximum will be determined.")),ra("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ra("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.")),ra("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.")),ra("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=-1/0;return ji(t,((t,i)=>{const n=e[t][i];"number"==typeof n&&(o=o<n?n:o)})),o===-1/0?0:o},isExported:!0},Fl={description:s("Median value in a numeric dataset."),args:[ra("value1 (any, range)",s("The first value or range to consider when calculating the median value.")),ra("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 zi(e,(e=>{t.push(e)})),ml(t,.5,!0)},isExported:!0},Dl={description:s("Minimum value in a numeric dataset."),args:[ra("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),ra("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=$i(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},kl={description:s("Minimum numeric value in a dataset."),args:[ra("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),ra("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=Wi(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Pl={description:s("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[ra("range (range)",s("The range of cells from which the minimum will be determined.")),ra("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ra("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.")),ra("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.")),ra("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let o=1/0;return ji(t,((t,i)=>{const n=e[t][i];"number"==typeof n&&(o=o>n?n:o)})),o===1/0?0:o},isExported:!0},Ll={description:s("Value at a given percentile of a dataset."),args:[ra("data (any, range)",s("The array or range containing the dataset to consider.")),ra("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 Vl.compute(e,t)},isExported:!0},Ul={description:s("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[ra("data (any, range)",s("The array or range containing the dataset to consider.")),ra("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 ml([e],t,!1)},isExported:!0},Vl={description:s("Value at a given percentile of a dataset."),args:[ra("data (any, range)",s("The array or range containing the dataset to consider.")),ra("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 ml([e],t,!0)},isExported:!0},zl={description:s("Value nearest to a specific quartile of a dataset."),args:[ra("data (any, range)",s("The array or range containing the dataset to consider.")),ra("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 Hl.compute(e,t)},isExported:!0},Bl={description:s("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[ra("data (any, range)",s("The array or range containing the dataset to consider.")),ra("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 ml([e],.25*Math.trunc(Ni(t)),!1)},isExported:!0},Hl={description:s("Value nearest to a specific quartile of a dataset."),args:[ra("data (any, range)",s("The array or range containing the dataset to consider.")),ra("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 ml([e],.25*Math.trunc(Ni(t)),!0)},isExported:!0},$l={description:s("Nth smallest element in a data set."),args:[ra("data (any, range)",s("The array or range containing the dataset to consider.")),ra("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 o=Math.trunc(Ni(t));let i,n=[],r=0;Vi([e],(e=>{"number"==typeof e&&(i=Ki(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(i+1,0,e),r++,r>o&&(n.pop(),r--))}));const a=n.pop();return Mi((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),Mi((()=>r>=o),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",o.toString())),a},isExported:!0},Wl={description:s("Standard deviation."),args:[ra("value1 (number, range<number>)",s("The first value or range of the sample.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Yl.compute(...e))},isExported:!0},Gl={description:s("Standard deviation of entire population."),args:[ra("value1 (number, range<number>)",s("The first value or range of the population.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Kl.compute(...e))},isExported:!0},ql={description:s("Standard deviation."),args:[ra("value1 (number, range<number>)",s("The first value or range of the sample.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Ql.compute(...e))},isExported:!0},Zl={description:s("Standard deviation of sample (text as 0)."),args:[ra("value1 (number, range<number>)",s("The first value or range of the sample.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(Jl.compute(...e))},isExported:!0},jl={description:s("Standard deviation of entire population."),args:[ra("value1 (number, range<number>)",s("The first value or range of the population.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ec.compute(...e))},isExported:!0},Xl={description:s("Standard deviation of entire population (text as 0)."),args:[ra("value1 (number, range<number>)",s("The first value or range of the population.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(tc.compute(...e))},isExported:!0},Yl={description:s("Variance."),args:[ra("value1 (number, range<number>)",s("The first value or range of the sample.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return pl(e,!0,!1)},isExported:!0},Kl={description:s("Variance of entire population."),args:[ra("value1 (number, range<number>)",s("The first value or range of the population.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return pl(e,!1,!1)},isExported:!0},Ql={description:s("Variance."),args:[ra("value1 (number, range<number>)",s("The first value or range of the sample.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return pl(e,!0,!1)},isExported:!0},Jl={description:s("Variance of sample (text as 0)."),args:[ra("value1 (number, range<number>)",s("The first value or range of the sample.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return pl(e,!0,!0)},isExported:!0},ec={description:s("Variance of entire population."),args:[ra("value1 (number, range<number>)",s("The first value or range of the population.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return pl(e,!1,!1)},isExported:!0},tc={description:s("Variance of entire population (text as 0)."),args:[ra("value1 (number, range<number>)",s("The first value or range of the population.")),ra("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return pl(e,!1,!0)},isExported:!0};var oc=Object.freeze({__proto__:null,AVEDEV:fl,AVERAGE:vl,AVERAGE_WEIGHTED:Cl,AVERAGEA:El,AVERAGEIF:wl,AVERAGEIFS:yl,COUNT:xl,COUNTA:Il,COVAR:Rl,COVARIANCE_P:Tl,COVARIANCE_S:Al,LARGE:Ml,MAX:Ol,MAXA:Nl,MAXIFS:_l,MEDIAN:Fl,MIN:Dl,MINA:kl,MINIFS:Pl,PERCENTILE:Ll,PERCENTILE_EXC:Ul,PERCENTILE_INC:Vl,QUARTILE:zl,QUARTILE_EXC:Bl,QUARTILE_INC:Hl,SMALL:$l,STDEV:Wl,STDEV_P:Gl,STDEV_S:ql,STDEVA:Zl,STDEVP:jl,STDEVPA:Xl,VAR:Yl,VAR_P:Kl,VAR_S:Ql,VARA:Jl,VARP:ec,VARPA:tc});function ic(e,t,o){var i;const n=new Map,r=e.length;for(let t=r-1;t>=0;t--)n.set(Fi(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=Fi(t).toUpperCase();if(a=null!==(i=n.get(e))&&void 0!==i?i:-1,-1===a)throw new Error(s("The field (%s) must be one of %s.",Fi(t),[...n.keys()].toString()))}const l=o[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 i=[],s=!0;for(let r=0;r<o.length;r++){const a=Fi(o[r][0]).toUpperCase(),l=n.get(a),c=o[r][t];if(void 0!==c){if(void 0===l){s=!1;break}i.push([e[l].slice(1,h)]),i.push(c)}}if(s){if(!(i.length>0)){c=new Set(Array(h-1).keys());break}ji(i,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const nc=[ra("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.")),ra("field (any)",s("Indicates which column in database contains the values to be extracted and operated on.")),ra("criteria (range)",s("An array or range containing zero or more criteria to filter the database values by before operating."))],sc={description:s("Average of a set of values from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return vl.compute([i])},isExported:!0},rc={description:s("Counts values from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return xl.compute([i])},isExported:!0},ac={description:s("Counts values and text from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return Il.compute([i])},isExported:!0},lc={description:s("Single value from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return Mi((()=>1===i.length),s("More than one match found in DGET evaluation.")),i[0]},isExported:!0},cc={description:s("Maximum of values from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return Ol.compute([i])},isExported:!0},hc={description:s("Minimum of values from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return Dl.compute([i])},isExported:!0},dc={description:s("Product of values from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return Xa.compute([i])},isExported:!0},uc={description:s("Standard deviation of population sample from table."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return Wl.compute([i])},isExported:!0},gc={description:s("Standard deviation of entire population from table."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return jl.compute([i])},isExported:!0},pc={description:s("Sum of values from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return rl.compute([i])},isExported:!0},mc={description:s("Variance of population sample from table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return Yl.compute([i])},isExported:!0},fc={description:s("Variance of a population from a table-like range."),args:nc,returns:["NUMBER"],compute:function(e,t,o){const i=ic(e,t,o);return ec.compute([i])},isExported:!0};var vc=Object.freeze({__proto__:null,DAVERAGE:sc,DCOUNT:rc,DCOUNTA:ac,DGET:lc,DMAX:cc,DMIN:hc,DPRODUCT:dc,DSTDEV:uc,DSTDEVP:gc,DSUM:pc,DVAR:mc,DVARP:fc});const bc={description:s("Converts year/month/day into a date."),args:[ra("year (number)",s("The year component of the date.")),ra("month (number)",s("The month component of the date.")),ra("day (number)",s("The day component of the date."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o){let i=Math.trunc(Ni(e));const n=Math.trunc(Ni(t)),r=Math.trunc(Ni(o));Mi((()=>0<=i&&i<=9999),s("The year (%s) must be between 0 and 9999 inclusive.",i.toString())),i<1900&&(i+=1900);const a=we(new Date(i,n-1,r));return Mi((()=>a>=0),s("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Sc={description:s("Converts a date string to a date value."),args:[ra("date_string (string)",s("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=Fi(e),o=Se(t);return Mi((()=>null!==o),s("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(o.value)},isExported:!0},Cc={description:s("Day of the month that a specific date falls on."),args:[ra("date (string)",s("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Li(e).getDate()},isExported:!0},Ec={description:s("Number of days between two dates."),args:[ra("end_date (date)",s("The end of the date range.")),ra("start_date (date)",s("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const o=Li(e),i=Li(t),n=o.getTime()-i.getTime();return Math.round(n/ue)},isExported:!0},wc={description:s("Number of days between two dates on a 360-day year (months of 30 days)."),args:[ra("start_date (date)",s("The start date to consider in the calculation.")),ra("end_date (date)",s("The end date to consider in the calculation.")),ra("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,o=0){const i=Ni(e),n=Ni(t),s=Pi(o)?4:0,r=Hc.compute(e,t,s);return Math.sign(n-i)*Math.round(360*r)},isExported:!0},yc={description:s("Date a number of months before/after another date."),args:[ra("start_date (date)",s("The date from which to calculate the result.")),ra("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 we(Ie(Li(e),Math.trunc(Ni(t)),!1))},isExported:!0},xc={description:s("Last day of a month before or after a date."),args:[ra("start_date (date)",s("The date from which to calculate the result.")),ra("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 o=Li(e),i=Math.trunc(Ni(t)),n=o.getFullYear(),s=o.getMonth();return we(new Date(n,s+i+1,0))},isExported:!0},Ic={description:s("Hour component of a specific time."),args:[ra("time (date)",s("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Li(e).getHours()},isExported:!0},Rc={description:s("ISO week number of the year."),args:[ra("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=Li(e),o=t.getFullYear();let i=1;for(;4!==new Date(o,0,i).getDay();)i+=1;const n=new Date(o,0,i-3);let s=31;for(;4!==new Date(o,11,s).getDay();)s-=1;const r=new Date(o,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(o,11,s+3+1);break;case-1:let e=1;for(;4!==new Date(o-1,0,e).getDay();)e+=1;l=new Date(o-1,0,e-3)}const c=(t.getTime()-l.getTime())/ue;return Math.floor(c/7)+1},isExported:!0},Tc={description:s("Minute component of a specific time."),args:[ra("time (date)",s("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Li(e).getMinutes()},isExported:!0},Ac={description:s("Month of the year a specific date falls in"),args:[ra("date (date)",s("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Li(e).getMonth()+1},isExported:!0},Mc={description:s("Net working days between two provided days."),args:[ra("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),ra("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),ra("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,o){return Nc.compute(e,t,1,o)},isExported:!0};function Oc(e){if("string"==typeof e){Mi((()=>{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 o=0;o<7;o++)"1"===e[o]&&t.push((o+1)%7);return t}if("number"==typeof e)return Mi((()=>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 Nc={description:s("Net working days between two dates (specifying weekends)."),args:[ra("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),ra("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),ra("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),ra("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,o=1,i){const n=Li(e),s=Li(t),r=Oc(o);let a=new Set;void 0!==i&&Vi([i],(e=>{const t=Li(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},_c={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()-de.getTime(),o=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ue)+o},isExported:!0},Fc={description:s("Minute component of a specific time."),args:[ra("time (date)",s("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Li(e).getSeconds()},isExported:!0},Dc={description:s("Converts hour/minute/second into a time."),args:[ra("hour (number)",s("The hour component of the time.")),ra("minute (number)",s("The minute component of the time.")),ra("second (number)",s("The second component of the time."))],returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,o){let i=Math.trunc(Ni(e)),n=Math.trunc(Ni(t)),r=Math.trunc(Ni(o));return n+=Math.floor(r/60),r=r%60+(r<0?60:0),i+=Math.floor(n/60),n=n%60+(n<0?60:0),i%=24,Mi((()=>i>=0),s("The function [[FUNCTION_NAME]] result cannot be negative")),i/24+n/1440+r/86400},isExported:!0},kc={description:s("Converts a time string into its serial number representation."),args:[ra("time_string (string)",s("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=Fi(e),o=Se(t);Mi((()=>null!==o),s("The time_string (%s) cannot be parsed to date/time.",t));const i=o.value-Math.trunc(o.value);return i<0?1+i:i},isExported:!0},Pc={description:s("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return we(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},Lc={description:s("Day of the week of the date provided (as number)."),args:[ra("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.")),ra("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 o=Li(e),i=Math.round(Ni(t)),n=o.getDay();return Mi((()=>[1,2,3].includes(i)),s("The type (%s) must be 1, 2 or 3.",i.toString())),1===i?n+1:2===i?0===n?7:n:0===n?6:n-1},isExported:!0},Uc={description:s("Week number of the year."),args:[ra("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.")),ra("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 o=Li(e),i=Math.round(Ni(t));if(Mi((()=>1===i||2===i||11<=i&&i<=17||21===i),s("The type (%s) is out of range.",i.toString())),21===i)return Rc.compute(e);let n;n=1===i||2===i?i-1:i-10==7?0:i-10;const r=o.getFullYear();let a=1,l=new Date(r,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(r,0,a);const c=(o.getTime()-l.getTime())/ue;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Vc={description:s("Date after a number of workdays."),args:[ra("start_date (date)",s("The date from which to begin counting.")),ra("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),ra("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,o){return zc.compute(e,t,1,o)},isExported:!0},zc={description:s("Date after a number of workdays (specifying weekends)."),args:[ra("start_date (date)",s("The date from which to begin counting.")),ra("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),ra("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),ra("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,o=1,i){let n=Li(e),r=Math.trunc(Ni(t));"string"==typeof o&&Mi((()=>"1111111"!==o),s("The weekend (%s) must be different from '1111111'.",o));const a=Oc(o);let l=new Set;void 0!==i&&Vi([i],(e=>{const t=Li(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-de.getTime();return Math.round(g/ue)},isExported:!0},Bc={description:s("Year specified by a given date."),args:[ra("date (date)",s("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Li(e).getFullYear()},isExported:!0},Hc={description:s("Exact number of years between two dates."),args:[ra("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.")),ra("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.")),ra("day_count_convention (number, default=0)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o=0){let i=Math.trunc(Ni(e)),n=Math.trunc(Ni(t));const r=Math.trunc(Ni(o));return Mi((()=>i>=0),s("The start_date (%s) must be positive or null.",i.toString())),Mi((()=>n>=0),s("The end_date (%s) must be positive or null.",n.toString())),Mi((()=>0<=r&&r<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",r.toString())),Te(i,n,r)}},$c={description:s("First day of the month preceding a date."),args:[ra("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Li(e),o=t.getFullYear(),i=t.getMonth();return we(new Date(o,i,1))}},Wc={description:s("Last day of the month following a date."),args:[ra("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return xc.compute(e,0)}},Gc={description:s("Quarter of the year a specific date falls in"),args:[ra("date (date)",s("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Li(e).getMonth()+1)/3)}},qc={description:s("First day of the quarter of the year a specific date falls in."),args:[ra("date (date)",s("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gc.compute(e),o=Bc.compute(e);return we(new Date(o,3*(t-1),1))}},Zc={description:s("Last day of the quarter of the year a specific date falls in."),args:[ra("date (date)",s("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Gc.compute(e),o=Bc.compute(e);return we(new Date(o,3*t,0))}},jc={description:s("First day of the year a specific date falls in."),args:[ra("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=Bc.compute(e);return we(new Date(t,0,1))}},Xc={description:s("Last day of the year a specific date falls in."),args:[ra("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=Bc.compute(e);return we(new Date(t+1,0,0))}};var Yc=Object.freeze({__proto__:null,DATE:bc,DATEVALUE:Sc,DAY:Cc,DAYS:Ec,DAYS360:wc,EDATE:yc,EOMONTH:xc,HOUR:Ic,ISOWEEKNUM:Rc,MINUTE:Tc,MONTH:Ac,NETWORKDAYS:Mc,NETWORKDAYS_INTL:Nc,NOW:_c,SECOND:Fc,TIME:Dc,TIMEVALUE:kc,TODAY:Pc,WEEKDAY:Lc,WEEKNUM:Uc,WORKDAY:Vc,WORKDAY_INTL:zc,YEAR:Bc,YEARFRAC:Hc,MONTH_START:$c,MONTH_END:Wc,QUARTER:Gc,QUARTER_START:qc,QUARTER_END:Zc,YEAR_START:jc,YEAR_END:Xc});const Kc={description:s("Compare two numeric values, returning 1 if they're equal."),args:[ra(" (number)",s("The first number to compare.")),ra(" (number, default=0)",s("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Ni(e)===Ni(t)?1:0},isExported:!0};var Qc=Object.freeze({__proto__:null,DELTA:Kc});function Jc(e,t){Mi((()=>e<t),s("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function eh(e,t){Mi((()=>t<e),s("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function th(e){Mi((()=>[1,2,4].includes(e)),s("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function oh(e){Mi((()=>0<=e&&e<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function ih(e){Mi((()=>e>0),s("The redemption (%s) must be strictly positive.",e.toString()))}function nh(e){Mi((()=>e>0),s("The price (%s) must be strictly positive.",e.toString()))}function sh(e){Mi((()=>e>0),s("The number_of_periods (%s) must be greater than 0.",e.toString()))}function rh(e){Mi((()=>e>0),s("The rate (%s) must be strictly positive.",e.toString()))}function ah(e){Mi((()=>e>0),s("The life (%s) must be strictly positive.",e.toString()))}function lh(e){Mi((()=>e>=0),s("The cost (%s) must be positive or null.",e.toString()))}function ch(e){Mi((()=>e>0),s("The period (%s) must be strictly positive.",e.toString()))}function hh(e){Mi((()=>e>=0),s("The salvage (%s) must be positive or null.",e.toString()))}function dh(e){Mi((()=>e>0),s("The present value (%s) must be strictly positive.",e.toString()))}function uh(e,t){Mi((()=>e<=t),s("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function gh(e){Mi((()=>e>0),s("The investment (%s) must be strictly positive.",e.toString()))}function ph(e){Mi((()=>e>0),s("The discount (%s) must be strictly positive.",e.toString()))}function mh(e){Mi((()=>e<1),s("The discount (%s) must be smaller than 1.",e.toString()))}function fh(e){Mi((()=>e>0),s("The depreciation factor (%s) must be strictly positive.",e.toString()))}function vh(e,t){const o=Li(e),i=Li(t),n=new Date(o);n.setFullYear(o.getFullYear()+1),Mi((()=>i.getTime()<=n.getTime()),s("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function bh(e,t,o){sh(o),Mi((()=>e>0),s("The first_period (%s) must be strictly positive.",e.toString())),Mi((()=>t>0),s("The last_period (%s) must be strictly positive.",t.toString())),Mi((()=>e<=t),s("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),Mi((()=>t<=o),s("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),o.toString()))}function Sh(e){Mi((()=>e>-1),s("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Ch(e,t){Mi((()=>e.length===t.length&&e[0].length===t[0].length),s("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Eh(e){Mi((()=>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 wh=[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))];function yh(e,t,o,i,n=1e-10,r){let a,l,c,h,d=o,u=!1,g=0;do{c=e(d),isNaN(c)?(Mi((()=>g<i&&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,Mi((()=>g<i),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const xh={description:s("Accrued interest of security paying at maturity."),args:[ra("issue (date)",s("The date the security was initially issued.")),ra("maturity (date)",s("The maturity date of the security.")),ra("rate (number)",s("The annualized rate of interest.")),ra("redemption (number)",s("The redemption amount per 100 face value, or par.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Ni(e)),r=Math.trunc(Ni(t)),a=Ni(i),l=Ni(o),c=Math.trunc(Ni(n));eh(r,s),oh(c),ih(a),rh(l);return a*l*Hc.compute(s,r,n)},isExported:!0},Ih={description:s("Depreciation for an accounting period."),args:[ra("cost (number)",s("The initial cost of the asset.")),ra("purchase_date (date)",s("The date the asset was purchased.")),ra("first_period_end (date)",s("The date the first period ended.")),ra("salvage (number)",s("The value of the asset at the end of depreciation.")),ra("period (number)",s("The single period within life for which to calculate depreciation.")),ra("rate (number)",s("The deprecation rate.")),ra(" (number, optional)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r,a=0){a=a||0;const l=Ni(e),c=Math.trunc(Ni(t)),h=Math.trunc(Ni(o)),d=Ni(i),u=Ni(n),g=Ni(r),p=Math.trunc(Ni(a));!function(e){Mi((()=>e>0),s("The cost (%s) must be strictly positive.",e.toString()))}(l),hh(d),function(e,t){Mi((()=>e<=t),s("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){Mi((()=>e>=0),s("The period (%s) must be positive or null.",e.toString()))}(u),rh(g),oh(p),Mi((()=>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=Hc.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},Rh={description:s("Days in coupon period containing settlement date."),args:wh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Ni(e)),s=Math.trunc(Ni(t)),r=Math.trunc(Ni(o)),a=Math.trunc(Ni(i));if(Jc(n,s),th(r),oh(a),1===a){const n=Nh.compute(e,t,o,i);return Mh.compute(e,t,o,i)-n}return(3===a?365:360)/r},isExported:!0},Th={description:s("Days from settlement until next coupon."),args:wh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Ni(e)),s=Math.trunc(Ni(t)),r=Math.trunc(Ni(o)),a=Math.trunc(Ni(i));Jc(n,s),th(r),oh(a);const l=Nh.compute(n,s,o,i);if([1,2,3].includes(a))return n-l;if(4===a){const e=Te(l,n,a);return Math.round(360*e)}const c=Li(n),h=Li(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&&xe(h)&&xe(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&xe(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Ah={description:s("Days from settlement until next coupon."),args:wh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Ni(e)),s=Math.trunc(Ni(t)),r=Math.trunc(Ni(o)),a=Math.trunc(Ni(i));Jc(n,s),th(r),oh(a);const l=Mh.compute(n,s,o,i);if([1,2,3].includes(a))return l-n;if(4===a){const e=Te(n,l,a);return Math.round(360*e)}const c=Th.compute(e,t,o,a);return Rh.compute(e,t,o,a)-c},isExported:!0},Mh={description:s("Next coupon date after the settlement date."),args:wh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Ni(e)),s=Math.trunc(Ni(t)),r=Math.trunc(Ni(o)),a=Math.trunc(Ni(i));Jc(n,s),th(r),oh(a);const l=12/r,c=Oh.compute(e,t,o,i);return we(Ie(Li(s),-(c-1)*l,!0))},isExported:!0},Oh={description:s("Number of coupons between settlement and maturity."),args:wh,returns:["NUMBER"],compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Ni(e)),s=Math.trunc(Ni(t)),r=Math.trunc(Ni(o)),a=Math.trunc(Ni(i));Jc(n,s),th(r),oh(a);let l=1,c=s;const h=12/r;for(;c>n;)c=we(Ie(Li(c),-h,!1)),l++;return l-1},isExported:!0},Nh={description:s("Last coupon date prior to or on the settlement date."),args:wh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,o,i=0){i=i||0;const n=Math.trunc(Ni(e)),s=Math.trunc(Ni(t)),r=Math.trunc(Ni(o)),a=Math.trunc(Ni(i));Jc(n,s),th(r),oh(a);const l=12/r,c=Oh.compute(e,t,o,i);return we(Ie(Li(s),-c*l,!0))},isExported:!0},_h={description:s("Cumulative interest paid over a set of periods."),args:[ra("rate (number)",s("The interest rate.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("present_value (number)",s("The current value of the annuity.")),ra("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),ra("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),ra("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,o,i,n,s=0){const r=Ni(i),a=Ni(n),l=Ni(e),c=Ni(o),h=Ni(t);bh(r,a,h),rh(l),dh(c);let d=0;for(let t=r;t<=a;t++){d+=Wh.compute(e,t,h,o,0,s)}return d},isExported:!0},Fh={description:s("Cumulative principal paid over a set of periods."),args:[ra("rate (number)",s("The interest rate.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("present_value (number)",s("The current value of the annuity.")),ra("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),ra("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),ra("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,o,i,n,s=0){const r=Ni(i),a=Ni(n),l=Ni(e),c=Ni(o),h=Ni(t);bh(r,a,h),rh(l),dh(c);let d=0;for(let t=r;t<=a;t++){d+=ed.compute(e,t,h,o,0,s)}return d},isExported:!0},Dh={description:s("Depreciation via declining balance method."),args:[ra("cost (number)",s("The initial cost of the asset.")),ra("salvage (number)",s("The value of the asset at the end of depreciation.")),ra("life (number)",s("The number of periods over which the asset is depreciated.")),ra("period (number)",s("The single period within life for which to calculate depreciation.")),ra("month (number, optional)",s("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,...n){const r=Ni(e),a=Ni(t),l=Ni(o),c=Math.trunc(Ni(i)),h=n.length?Math.trunc(Ni(n[0])):12,d=l+(12===h?0:1);lh(r),hh(a),ch(c),ah(l),Mi((()=>1<=h&&h<=12),s("The month (%s) must be between 1 and 12 inclusive.",h.toString())),Mi((()=>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},kh={description:s("Depreciation via double-declining balance method."),args:[ra("cost (number)",s("The initial cost of the asset.")),ra("salvage (number)",s("The value of the asset at the end of depreciation.")),ra("life (number)",s("The number of periods over which the asset is depreciated.")),ra("period (number)",s("The single period within life for which to calculate depreciation.")),ra("factor (number, default=2)",s("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i,n=2){n=n||0;const s=Ni(e),r=Ni(t),a=Ni(o),l=Ni(i),c=Ni(n);if(lh(s),hh(r),ch(l),ah(a),uh(l,a),fh(c),0===s||r>=s)return 0;const h=c/a;if(h>1)return 1===i?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},Ph={description:s("Discount rate of a security based on price."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("price (number)",s("The price at which the security is bought per 100 face value.")),ra("redemption (number)",s("The redemption amount per 100 face value, or par.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Ni(e)),r=Math.trunc(Ni(t)),a=Ni(o),l=Ni(i),c=Math.trunc(Ni(n));Jc(s,r),oh(c),nh(a),ih(l);return(l-a)/l/Hc.compute(s,r,c)},isExported:!0},Lh={description:s("Convert a decimal fraction to decimal value."),args:[ra("fractional_price (number)",s("The price quotation given using fractional decimal conventions.")),ra("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 o=Ni(e),i=Math.trunc(Ni(t));Mi((()=>i>0),s("The unit (%s) must be strictly positive.",i.toString()));const n=Math.trunc(o);return n+(o-n)*(10**Math.ceil(Math.log10(i))/i)},isExported:!0},Uh={description:s("Convert a decimal value to decimal fraction."),args:[ra("decimal_price (number)",s("The price quotation given as a decimal value.")),ra("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 o=Ni(e),i=Math.trunc(Ni(t));Mi((()=>i>0),s("The unit (%s) must be strictly positive.",i.toString()));const n=Math.trunc(o);return n+(o-n)*(i/10**Math.ceil(Math.log10(i)))},isExported:!0},Vh={description:s("Number of periods for an investment to reach a value."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("rate (number)",s("The annualized rate of interest.")),ra("yield (number)",s("The expected annual yield of the security.")),ra("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r=0){r=r||0;const a=Math.trunc(Ni(e)),l=Math.trunc(Ni(t)),c=Ni(o),h=Ni(i),d=Math.trunc(Ni(n)),u=Math.trunc(Ni(r));Jc(a,l),th(d),oh(u),Mi((()=>c>=0),s("The rate (%s) must be positive or null.",c.toString())),Mi((()=>h>=0),s("The yield (%s) must be positive or null.",h.toString()));const g=Hc.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},zh={description:s("Annual effective interest rate."),args:[ra("nominal_rate (number)",s("The nominal interest rate per year.")),ra("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Ni(e),i=Math.trunc(Ni(t));return Mi((()=>o>0),s("The nominal rate (%s) must be strictly greater than 0.",o.toString())),Mi((()=>i>0),s("The number of periods by year (%s) must strictly greater than 0.",i.toString())),Math.pow(1+o/i,i)-1},isExported:!0},Bh={description:s("Future value of an annuity investment."),args:[ra("rate (number)",s("The interest rate.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("payment_amount (number)",s("The amount per period to be paid.")),ra("present_value (number, default=0)",s("The current value of the annuity.")),ra("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,o,i=0,n=0){i=i||0,n=n||0;const s=Ni(e),r=Ni(t),a=Ni(o),l=Ni(i),c=Pi(n)?1:0;return s?-l*(1+s)**r-a*(1+s*c)*((1+s)**r-1)/s:-(l+a*r)},isExported:!0},Hh={description:s("Future value of principal from series of rates."),args:[ra("principal (number)",s("The amount of initial capital or value to compound against.")),ra("rate_schedule (number, range<number>)",s("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Hi([t],((e,t)=>e*(1+Ni(t))),Ni(e))},isExported:!0},$h={description:s("Calculates effective interest rate."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("investment (number)",s("The amount invested in the security.")),ra("redemption (number)",s("The amount to be received at maturity.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){const s=Math.trunc(Ni(e)),r=Math.trunc(Ni(t)),a=Ni(i),l=Ni(o);Jc(s,r),gh(l),ih(a);return(a-l)/l/Hc.compute(s,r,n)},isExported:!0},Wh={description:s("Payment on the principal of an investment."),args:[ra("rate (number)",s("The annualized rate of interest.")),ra("period (number)",s("The amortization period, in terms of number of periods.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("present_value (number)",s("The current value of the annuity.")),ra("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ra("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,o,i,n=0,s=0){return Jh.compute(e,o,i,n,s)-ed.compute(e,t,o,i,n,s)},isExported:!0},Gh={description:s("Internal rate of return given periodic cashflows."),args:[ra("cashflow_amounts (number, range<number>)",s("An array or range containing the income or payments associated with the investment.")),ra("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 o=Ni(t);Sh(o);let i=!1,n=!1,r=[];zi([e],(e=>{e>0&&(i=!0),e<0&&(n=!0),r.push(e)})),Mi((()=>i&&n),s("The cashflow_amounts must include negative and positive values."));const a=r.shift();return yh((function(e){return function(e,t,o){const i=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*e**(i-n))),t*e**i)}(e,a,r)}),(function(e){return function(e,t,o){const i=o.length;let n=0;return o.reduce(((t,o)=>(n++,t+o*(i-n)*e**(i-n-1))),t*i*e**(i-1))}(e,a,r)}),o+1,20,1e-5)-1},isExported:!0},qh={description:s("Returns the interest paid at a particular period of an investment."),args:[ra("rate (number)",s("The interest rate.")),ra("period (number)",s("The period for which you want to view the interest payment.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("present_value (number)",s("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,o,i){const n=Ni(e),r=Ni(t),a=Ni(o),l=Ni(i);Mi((()=>0!==a),s("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(r/a))*n},isExported:!0},Zh={description:s("Modified Macaulay duration."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("rate (number)",s("The annualized rate of interest.")),ra("yield (number)",s("The expected annual yield of the security.")),ra("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,s=0){return Vh.compute(e,t,o,i,n,s)/(1+Ni(i)/Math.trunc(Ni(n)))},isExported:!0},jh={description:s("Modified internal rate of return."),args:[ra("cashflow_amounts (range<number>)",s("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),ra("financing_rate (number)",s("The interest rate paid on funds invested.")),ra("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,o){const i=Ni(t),n=Ni(o),r=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(et).map(Ni);var a;const l=r.length;let c=0,h=0;for(const e of ze(0,l)){const t=r[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(i+1)**e}Mi((()=>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},Xh={description:s("Annual nominal interest rate."),args:[ra("effective_rate (number)",s("The effective interest rate per year.")),ra("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const o=Ni(e),i=Math.trunc(Ni(t));return Mi((()=>o>0),s("The effective rate (%s) must must strictly greater than 0.",o.toString())),Mi((()=>i>0),s("The number of periods by year (%s) must strictly greater than 0.",i.toString())),(Math.pow(o+1,1/i)-1)*i},isExported:!0},Yh={description:s("Number of payment periods for an investment."),args:[ra("rate (number)",s("The interest rate.")),ra("payment_amount (number)",s("The amount of each payment made.")),ra("present_value (number)",s("The current value of the annuity.")),ra("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ra("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,o,i=0,n=0){i=i||0,n=n||0;const s=Ni(e),r=Ni(t),a=Ni(o),l=Ni(i),c=Pi(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 Kh={description:s("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[ra("discount (number)",s("The discount rate of the investment over one period.")),ra("cashflow1 (number, range<number>)",s("The first future cash flow.")),ra("cashflow2 (number, range<number>, repeating)",s("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const o=Ni(e);return Mi((()=>-1!==o),s("The discount (%s) must be different from -1.",o.toString())),function(e,t,o){let i=0;return $i(o,((t,o)=>(i++,t+o/(1+e)**i)),t)}(o,0,t)},isExported:!0},Qh={description:s("Computes the number of periods needed for an investment to reach a value."),args:[ra("rate (number)",s("The rate at which the investment grows each period.")),ra("present_value (number)",s("The investment's current value.")),ra("future_value (number)",s("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,o){const i=Ni(e),n=Ni(t),r=Ni(o);return rh(i),Mi((()=>n>0),s("The present_value (%s) must be strictly positive.",n.toString())),Mi((()=>r>0),s("The future_value (%s) must be strictly positive.",r.toString())),(Math.log(r)-Math.log(n))/Math.log(1+i)},isExported:!0},Jh={description:s("Periodic payment for an annuity investment."),args:[ra("rate (number)",s("The annualized rate of interest.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("present_value (number)",s("The current value of the annuity.")),ra("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ra("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,o,i=0,n=0){i=i||0,n=n||0;const s=Ni(t),r=Ni(e),a=Pi(n)?1:0;let l=Ni(i),c=Ni(o);if(sh(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},ed={description:s("Payment on the principal of an investment."),args:[ra("rate (number)",s("The annualized rate of interest.")),ra("period (number)",s("The amortization period, in terms of number of periods.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("present_value (number)",s("The current value of the annuity.")),ra("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ra("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,o,i,n=0,r=0){n=n||0,r=r||0;const a=Ni(o),l=Ni(e),c=Ni(t),h=Pi(r)?1:0,d=Ni(n),u=Ni(i);sh(a),Mi((()=>c>0&&c<=a),s("The period must be between 1 and number_of_periods",a.toString()));const g=Jh.compute(l,a,u,d,r);if(1===h&&1===c)return g;return g+-Bh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},td={description:s("Present value of an annuity investment."),args:[ra("rate (number)",s("The interest rate.")),ra("number_of_periods (number)",s("The number of payments to be made.")),ra("payment_amount (number)",s("The amount per period to be paid.")),ra("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ra("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,o,i=0,n=0){i=i||0,n=n||0;const s=Ni(e),r=Ni(t),a=Ni(o),l=Ni(i),c=Pi(n)?1:0;return s?-(a*(1+s*c)*((1+s)**r-1)/s+l)/(1+s)**r:-(l+a*r)},isExported:!0},od={description:s("Price of a security paying periodic interest."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("rate (number)",s("The annualized rate of interest.")),ra("yield (number)",s("The expected annual yield of the security.")),ra("redemption (number)",s("The redemption amount per 100 face value, or par.")),ra("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r,a=0){a=a||0;const l=Math.trunc(Ni(e)),c=Math.trunc(Ni(t)),h=Ni(o),d=Ni(i),u=Ni(n),g=Math.trunc(Ni(r)),p=Math.trunc(Ni(a));Jc(l,c),th(g),oh(p),Mi((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Mi((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString())),ih(u);const m=Hc.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},id={description:s("Price of a discount security."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("discount (number)",s("The discount rate of the security at time of purchase.")),ra("redemption (number)",s("The redemption amount per 100 face value, or par.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Ni(e)),r=Math.trunc(Ni(t)),a=Ni(o),l=Ni(i),c=Math.trunc(Ni(n));Jc(s,r),oh(c),ph(a),ih(l);return l-a*l*Hc.compute(s,r,c)},isExported:!0},nd={description:s("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("issue (date)",s("The date the security was initially issued.")),ra("rate (number)",s("The annualized rate of interest.")),ra("yield (number)",s("The expected annual yield of the security.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r=0){r=r||0;const a=Math.trunc(Ni(e)),l=Math.trunc(Ni(t)),c=Math.trunc(Ni(o)),h=Ni(i),d=Ni(n),u=Math.trunc(Ni(r));eh(a,c),Jc(a,l),oh(u),Mi((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),Mi((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString()));const g=Hc.compute(a,l,u),p=Hc.compute(a,c,u);return(100+Hc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},sd=.1,rd={description:s("Interest rate of an annuity investment."),args:[ra("number_of_periods (number)",s("The number of payments to be made.")),ra("payment_per_period (number)",s("The amount per period to be paid.")),ra("present_value (number)",s("The current value of the annuity.")),ra("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ra("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period.")),ra("rate_guess (number, default=0.1)",s("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,o,i=0,n=0,r=.1){i=i||0,n=n||0,r=r||sd;const a=Ni(e),l=Ni(t),c=Pi(n)?1:0,h=Ni(r);let d=Ni(i),u=Ni(o);sh(a),Mi((()=>[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())),Sh(h),d-=l*c,u+=l*c;return yh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),o=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(o-1)/e/e)}),h,40,1e-5)},isExported:!0},ad={description:s("Amount received at maturity for a security."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("investment (number)",s("The amount invested (irrespective of face value of each security).")),ra("discount (number)",s("The discount rate of the security invested in.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Ni(e)),r=Math.trunc(Ni(t)),a=Ni(o),l=Ni(i),c=Math.trunc(Ni(n));Jc(s,r),oh(c),gh(a),ph(l);return a/(1-l*Hc.compute(s,r,c))},isExported:!0},ld={description:s("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[ra("number_of_periods (number)",s("The number of periods.")),ra("present_value (number)",s("The present value of the investment.")),ra("future_value (number)",s("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,o){const i=Ni(e),n=Ni(t),s=Ni(o);return sh(i),(s/n)**(1/i)-1},isExported:!0},cd={description:s("Depreciation of an asset using the straight-line method."),args:[ra("cost (number)",s("The initial cost of the asset.")),ra("salvage (number)",s("The value of the asset at the end of depreciation.")),ra("life (number)",s("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o){return(Ni(e)-Ni(t))/Ni(o)},isExported:!0},hd={description:s("Depreciation via sum of years digit method."),args:[ra("cost (number)",s("The initial cost of the asset.")),ra("salvage (number)",s("The value of the asset at the end of depreciation.")),ra("life (number)",s("The number of periods over which the asset is depreciated.")),ra("period (number)",s("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,o,i){const n=Ni(e),s=Ni(t),r=Ni(o),a=Ni(i);ch(a),ah(r),uh(a,r);return(r-a+1)/(r*(r+1)/2)*(n-s)},isExported:!0},dd={description:s("Price of a US Treasury bill."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(Ni(e)),n=Math.trunc(Ni(t)),s=Ni(o);Jc(i,n),vh(i,n),ph(s),mh(s);return 100*(1-s*Hc.compute(i,n,2))},isExported:!0},ud={description:s("Equivalent rate of return for a US Treasury bill."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(Ni(e)),n=Math.trunc(Ni(t)),s=Ni(o);Jc(i,n),vh(i,n),ph(s),mh(s);const r=Ec.compute(n,i);if(r<=182)return 365*s/(360-s*r);const a=dd.compute(i,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},gd={description:s("The yield of a US Treasury bill based on price."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("price (number)",s("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,o){const i=Math.trunc(Ni(e)),n=Math.trunc(Ni(t)),s=Ni(o);Jc(i,n),vh(i,n),nh(s);return(100-s)/s*(1/Hc.compute(i,n,2))},isExported:!0},pd={description:s("Variable declining balance. WARNING : does not handle decimal periods."),args:[ra("cost (number)",s("The initial cost of the asset.")),ra("salvage (number)",s("The value of the asset at the end of depreciation.")),ra("life (number)",s("The number of periods over which the asset is depreciated.")),ra("start (number)",s("Starting period to calculate depreciation.")),ra("end (number)",s("Ending period to calculate depreciation.")),ra("factor (number, default=2)",s("The number of months in the first year of depreciation.")),ra("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,o,i,n,r=2,a=false){r=r||0;const l=Ni(e),c=Ni(t),h=Ni(o),d=Math.trunc(Ni(i)),u=Math.trunc(Ni(n)),g=Ni(r),p=Pi(a);if(lh(l),hh(c),function(e,t,o){ah(o),Mi((()=>e>=0),s("The start_period (%s) must be greater or equal than 0.",e.toString())),Mi((()=>t>=0),s("The end_period (%s) must be greater or equal than 0.",t.toString())),Mi((()=>e<=t),s("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),Mi((()=>t<=o),s("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),o.toString()))}(d,u,h),fh(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,o=(f-c)/(h-e);!p&&o>t?(S=!0,v=o):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},md={description:s("Internal rate of return given non-periodic cash flows."),args:[ra("cashflow_amounts (range<number>)",s("An range containing the income or payments associated with the investment.")),ra("cashflow_dates (range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts.")),ra("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,o=.1){const i=Ni(o=o||0),n=e.flat().map(Ni),r=t.flat().map(Ni);var a;Ch(e,t),a=n,Mi((()=>a.some((e=>e>0))&&a.some((e=>e<0))),s("There must be both positive and negative values in cashflow_amounts.")),Eh(r),Sh(i);const l=new Map;for(const e of ze(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 yh((e=>{let t=h[0];for(const o of ze(1,h.length)){const i=(c[0]-c[o])/365;t+=h[o]*(1+e)**i}return t}),(e=>{let t=0;for(const o of ze(1,h.length)){const i=(c[0]-c[o])/365;t+=i*h[o]*(1+e)**(i-1)}return t}),i,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},fd={description:s("Net present value given to non-periodic cash flows.."),args:[ra("discount (number)",s("The discount rate of the investment over one period.")),ra("cashflow_amounts (number, range<number>)",s("An range containing the income or payments associated with the investment.")),ra("cashflow_dates (number, range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,o){const i=Ni(e),n=Array.isArray(t)?t.flat().map(_i):[_i(t)],r=Array.isArray(o)?o.flat().map(_i):[_i(o)];if(Array.isArray(o)&&Array.isArray(t)?Ch(t,o):Mi((()=>n.length===r.length),s("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Eh(r),rh(i),1===n.length)return n[0];const a=new Map;for(const e of ze(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 ze(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+i)**t}return h},isExported:!0},vd={description:s("Annual yield of a security paying periodic interest."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("rate (number)",s("The annualized rate of interest.")),ra("price (number)",s("The price at which the security is bought per 100 face value.")),ra("redemption (number)",s("The redemption amount per 100 face value, or par.")),ra("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r,a=0){a=a||0;const l=Math.trunc(Ni(e)),c=Math.trunc(Ni(t)),h=Ni(o),d=Ni(i),u=Ni(n),g=Math.trunc(Ni(r)),p=Math.trunc(Ni(a));Jc(l,c),th(g),oh(p),Mi((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),nh(d),ih(u);const m=Hc.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=yh((function(e){return function(e,t,o,i,n,s){let r=s-(e+n*(1-t))*i**(o-1+t);for(let e=1;e<=o;e++)r+=n*i**(e-1);return r}(d,v,f,e,b,u)}),(function(e){return function(e,t,o,i,n){let s=-(e+n*(1-t))*(o-1+t)*i**(o-2+t);for(let e=1;e<=o;e++)s+=n*(e-1)*i**(e-2);return s}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},bd={description:s("Annual yield of a discount security."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("price (number)",s("The price at which the security is bought per 100 face value.")),ra("redemption (number)",s("The redemption amount per 100 face value, or par.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n=0){n=n||0;const s=Math.trunc(Ni(e)),r=Math.trunc(Ni(t)),a=Ni(o),l=Ni(i),c=Math.trunc(Ni(n));Jc(s,r),oh(c),nh(a),ih(l);return(l/a-1)/Hc.compute(e,t,n)},isExported:!0},Sd={description:s("Annual yield of a security paying interest at maturity."),args:[ra("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ra("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ra("issue (date)",s("The date the security was initially issued.")),ra("rate (number)",s("The annualized rate of interest.")),ra("price (number)",s("The price at which the security is bought.")),ra("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,o,i,n,r=0){r=r||0;const a=Math.trunc(Ni(e)),l=Math.trunc(Ni(t)),c=Math.trunc(Ni(o)),h=Ni(i),d=Ni(n),u=Math.trunc(Ni(r));Jc(a,l),oh(u),Mi((()=>a>=c),s("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),Mi((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),nh(d);const g=Hc.compute(c,l,u),p=Hc.compute(c,a,u),m=Hc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Cd=Object.freeze({__proto__:null,ACCRINTM:xh,AMORLINC:Ih,COUPDAYS:Rh,COUPDAYBS:Th,COUPDAYSNC:Ah,COUPNCD:Mh,COUPNUM:Oh,COUPPCD:Nh,CUMIPMT:_h,CUMPRINC:Fh,DB:Dh,DDB:kh,DISC:Ph,DOLLARDE:Lh,DOLLARFR:Uh,DURATION:Vh,EFFECT:zh,FV:Bh,FVSCHEDULE:Hh,INTRATE:$h,IPMT:Wh,IRR:Gh,ISPMT:qh,MDURATION:Zh,MIRR:jh,NOMINAL:Xh,NPER:Yh,NPV:Kh,PDURATION:Qh,PMT:Jh,PPMT:ed,PV:td,PRICE:od,PRICEDISC:id,PRICEMAT:nd,RATE:rd,RECEIVED:ad,RRI:ld,SLN:cd,SYD:hd,TBILLPRICE:dd,TBILLEQ:ud,TBILLYIELD:gd,VDB:pd,XIRR:md,XNPV:fd,YIELD:vd,YIELDDISC:bd,YIELDMAT:Sd});const Ed={description:s("Whether a value is an error other than #N/A."),args:[ra("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},wd={description:s("Whether a value is an error."),args:[ra("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},yd={description:s("Whether a value is `true` or `false`."),args:[ra("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},xd={description:s("Whether a value is the error #N/A."),args:[ra("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},Id={description:s("Whether a value is non-textual."),args:[ra("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},Rd={description:s("Whether a value is a number."),args:[ra("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},Td={description:s("Whether a value is text."),args:[ra("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},Ad={description:s("Whether the referenced cell is empty"),args:[ra("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},Md={description:s("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Od=Object.freeze({__proto__:null,ISERR:Ed,ISERROR:wd,ISLOGICAL:yd,ISNA:xd,ISNONTEXT:Id,ISNUMBER:Rd,ISTEXT:Td,ISBLANK:Ad,NA:Md});const Nd={description:s("Logical `and` operator."),args:[ra("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.")),ra("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!0;return Gi(e,(e=>(t=!0,o=o&&e,o))),Mi((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},_d={description:s("Returns value depending on logical expression."),args:[ra("logical_expression (boolean)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),ra("value_if_true (any, lazy)",s("The value the function returns if logical_expression is TRUE.")),ra("value_if_false (any, lazy, default=FALSE)",s("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,o=(()=>!1)){const i=Pi(e)?t():o();return null==i?"":i},isExported:!0},Fd={description:s("Value if it is not an error, otherwise 2nd argument."),args:[ra("value (any, lazy)",s("The value to return if value itself is not an error.")),ra('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 o;try{return e().format}catch(e){return null===(o=t())||void 0===o?void 0:o.format}},compute:function(e,t=(()=>"")){let o;try{o=e()}catch(e){o=t()}return null==o?"":o},isExported:!0},Dd={description:s("Value if it is not an #N/A error, otherwise 2nd argument."),args:[ra("value (any, lazy)",s("The value to return if value itself is not #N/A an error.")),ra('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 o;try{o=e()}catch(i){o=i.errorType===a.NotAvailable?t():e()}return null==o?"":o},isExported:!0},kd={description:s("Returns a value depending on multiple logical expressions."),args:[ra("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.")),ra("value1 (any, lazy)",s("The returned value if condition1 is TRUE.")),ra("condition2 (boolean, lazy, repeating)",s("Additional conditions to be evaluated if the previous ones are FALSE.")),ra("value2 (any, lazy, repeating)",s("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){Mi((()=>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(Pi(e[t]())){const o=e[t+1]();return null!==o?o:""}throw new Error(s("No match."))},isExported:!0},Pd={description:s("Returns opposite of provided logical value."),args:[ra("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!Pi(e)},isExported:!0},Ld={description:s("Logical `or` operator."),args:[ra("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.")),ra("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Gi(e,(e=>(t=!0,o=o||e,!o))),Mi((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0},Ud={description:s("Logical `xor` operator."),args:[ra("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.")),ra("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,o=!1;return Gi(e,(e=>(t=!0,o=o?!e:e,!0))),Mi((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),o},isExported:!0};var Vd=Object.freeze({__proto__:null,AND:Nd,IF:_d,IFERROR:Fd,IFNA:Dd,IFS:kd,NOT:Pd,OR:Ld,XOR:Ud});function zd(e,t){if(void 0===e)throw new g(s("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Fi(t)))}const Bd={description:s("Column number of a specified cell."),args:[ra("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 o=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));Mi((()=>!!o),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Po(o).left+1},isExported:!0},Hd={description:s("Number of columns in a specified array or range."),args:[ra("range (meta)",s("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return t.right-t.left+1},isExported:!0},$d={description:s("Horizontal lookup"),args:[ra("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ra("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.")),ra("index (number)",s("The row index of the value to be returned, where the first row in range is numbered 1.")),ra("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,o,i=true){const n=Math.trunc(Ni(o)),r=Di(e);Mi((()=>1<=n&&n<=t[0].length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=Pi(i)?Ki(t,r,"nextSmaller","asc",t.length,Yi):Qi(t,r,"strict",t.length,Yi);const l=t[a];return zd(l,e),l[n-1]},isExported:!0},Wd={description:s("Look up a value."),args:[ra("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ra("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.")),ra("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,o){let i=t.length,n=t[0].length;const r=Di(e),a=n>=i,l=Ki(t,r,"nextSmaller","asc",a?n:i,a?Xi:Yi);return zd(t[0][l],e),void 0===o?a?t[i-1][l]:t[l][n-1]:(i=o.length,n=o[0].length,Mi((()=>1===i||1===n),s("The result_range must be a single row or a single column.")),i>1?(Mi((()=>l<=i-1),s("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),o[l][0]):(Mi((()=>l<=n-1),s("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),o[0][l]))},isExported:!0},Gd={description:s("Position of item in range that matches value."),args:[ra("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ra("range (any, range)",s("The one-dimensional array to be searched.")),ra("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,o=1){let i=Ni(o);const n=Di(e),r=t.length,a=t[0].length;Mi((()=>1===r||1===a),s("The range must be a single row or a single column."));let l=-1;const c=1===r?Xi:Yi,h=1===r?t[0].length:t.length;switch(i=Math.sign(i),i){case 1:l=Ki(t,n,"nextSmaller","asc",h,c);break;case 0:l=Qi(t,n,"strict",h,c);break;case-1:l=Ki(t,n,"nextGreater","desc",h,c)}return zd(1===r?t[0][l]:t[l],e),l+1},isExported:!0},qd={description:s("Row number of a specified cell."),args:[ra("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)),Mi((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Po(e).top+1},isExported:!0},Zd={description:s("Number of rows in a specified array or range."),args:[ra("range (meta)",s("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return t.bottom-t.top+1},isExported:!0},jd={description:s("Vertical lookup."),args:[ra("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ra("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.")),ra("index (number)",s("The column index of the value to be returned, where the first column in range is numbered 1.")),ra("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,o,i=true){const n=Math.trunc(Ni(o)),r=Di(e);Mi((()=>1<=n&&n<=t.length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=Pi(i)?Ki(t,r,"nextSmaller","asc",t[0].length,Xi):Qi(t,r,"strict",t[0].length,Xi);const l=t[n-1][a];return zd(l,e),l},isExported:!0},Xd={description:s("Search a range for a match and return the corresponding item from a second range."),args:[ra("search_key (any)",s("The value to search for.")),ra("lookup_range (any, range)",s("The range to consider for the search. Should be a single column or a single row.")),ra("return_range (any, range)",s("The range containing the return value. Should have the same dimensions as lookup_range.")),ra("if_not_found (any, lazy, optional)",s("If a valid match is not found, return this value.")),ra("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.")),ra("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,o,i,n=0,r=1){const a=Math.trunc(Ni(n)),l=Math.trunc(Ni(r)),c=Di(e);Mi((()=>1===t.length||1===t[0].length),s("lookup_range should be either a single row or single column.")),Mi((()=>1===o.length||1===o[0].length),s("return_range should be either a single row or single column.")),Mi((()=>o.length===t.length&&o[0].length===t[0].length),s("return_range should have the same dimensions as lookup_range.")),Mi((()=>[-1,1,-2,2].includes(l)),s("searchMode should be a value in [-1, 1, -2, 2].")),Mi((()=>[-1,0,1].includes(a)),s("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?Xi:Yi,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=Ki(t,c,u,2===l?"asc":"desc",d,h)}else p=Qi(t,c,u,d,h,g);if(-1!==p)return 1===t.length?o[0][p]:o[p][0];const m=null==i?void 0:i();return zd(m,e),m},isExported:!0};var Yd=Object.freeze({__proto__:null,COLUMN:Bd,COLUMNS:Hd,HLOOKUP:$d,LOOKUP:Wd,MATCH:Gd,ROW:qd,ROWS:Zd,VLOOKUP:jd,XLOOKUP:Xd});const Kd={description:s("Sum of two numbers."),args:[ra("value1 (number)",s("The first addend.")),ra("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 Ni(e)+Ni(t)}},Qd={description:s("Concatenation of two values."),args:[ra("value1 (string)",s("The value to which value2 will be appended.")),ra("value2 (string)",s("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return Fi(e)+Fi(t)},isExported:!0},Jd={description:s("One number divided by another."),args:[ra("dividend (number)",s("The number to be divided.")),ra("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 o=Ni(t);return Mi((()=>0!==o),s("The divisor must be different from zero.")),Ni(e)/o}};function eu(e){return null==e}const tu={number:0,string:"",boolean:!1},ou={description:s("Equal."),args:[ra("value1 (any)",s("The first value.")),ra("value2 (any)",s("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=eu(e)?tu[typeof t]:e,t=eu(t)?tu[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function iu(e,t,o){e=eu(e)?tu[typeof t]:e,t=eu(t)?tu[typeof e]:t,"number"!=typeof e&&(e=Fi(e).toUpperCase()),"number"!=typeof t&&(t=Fi(t).toUpperCase());const i=typeof e,n=typeof t;return"string"===i&&"number"===n||("string"!==n||"number"!==i)&&o(e,t)}const nu={description:s("Strictly greater than."),args:[ra("value1 (any)",s("The value to test as being greater than value2.")),ra("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return iu(e,t,((e,t)=>e>t))}},su={description:s("Greater than or equal to."),args:[ra("value1 (any)",s("The value to test as being greater than or equal to value2.")),ra("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return iu(e,t,((e,t)=>e>=t))}},ru={description:s("Less than."),args:[ra("value1 (any)",s("The value to test as being less than value2.")),ra("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!su.compute(e,t)}},au={description:s("Less than or equal to."),args:[ra("value1 (any)",s("The value to test as being less than or equal to value2.")),ra("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!nu.compute(e,t)}},lu={description:s("Difference of two numbers."),args:[ra("value1 (number)",s("The minuend, or number to be subtracted from.")),ra("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 Ni(e)-Ni(t)}},cu={description:s("Product of two numbers"),args:[ra("factor1 (number)",s("The first multiplicand.")),ra("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 Ni(e)*Ni(t)}},hu={description:s("Not equal."),args:[ra("value1 (any)",s("The first value.")),ra("value2 (any)",s("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!ou.compute(e,t)}},du={description:s("A number raised to a power."),args:[ra("base (number)",s("The number to raise to the exponent power.")),ra("exponent (number)",s("The exponent to raise base to."))],returns:["BOOLEAN"],compute:function(e,t){return ja.compute(e,t)}},uu={description:s("A number with the sign reversed."),args:[ra("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-Ni(e)}},gu={description:s("Value interpreted as a percentage."),args:[ra("percentage (number)",s("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Ni(e)/100}},pu={description:s("A specified number, unchanged."),args:[ra("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 mu=Object.freeze({__proto__:null,ADD:Kd,CONCAT:Qd,DIVIDE:Jd,EQ:ou,GT:nu,GTE:su,LT:ru,LTE:au,MINUS:lu,MULTIPLY:cu,NE:hu,POW:du,UMINUS:uu,UNARY_PERCENT:gu,UPLUS:pu});const fu=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,vu={description:s("Gets character associated with number."),args:[ra("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(Ni(e));return Mi((()=>t>=1),s("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},bu={description:s("Remove non-printable characters from a piece of text."),args:[ra("text (string)",s("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=Fi(e);let o="";for(const e of t)e&&e.charCodeAt(0)>31&&(o+=e);return o},isExported:!0},Su={description:s("Appends strings to one another."),args:[ra("string1 (string, range<string>)",s("The initial string.")),ra("string2 (string, range<string>, repeating)",s("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Hi(e,((e,t)=>e+Fi(t)),"")},isExported:!0},Cu={description:s("Tests whether two strings are identical."),args:[ra("string1 (string)",s("The first string to compare.")),ra("string2 (string)",s("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return Fi(e)===Fi(t)},isExported:!0},Eu={description:s("First position of string found in text, case-sensitive."),args:[ra("search_for (string)",s("The string to look for within text_to_search.")),ra("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),ra("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=Fi(e),n=Fi(t),r=Ni(o);Mi((()=>""!==n),s("The text_to_search must be non-empty.")),Mi((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(i,r-1);return Mi((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i.toString(),n)),a+1},isExported:!0},wu={description:s("Concatenates elements of arrays with delimiter."),args:[ra("delimiter (string)",s("The character or string to place between each concatenated value.")),ra("value_or_array1 (string, range<string>)",s("The value or values to be appended using delimiter.")),ra("value_or_array2 (string, range<string>, repeating)",s("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const o=Fi(e);return Hi(t,((e,t)=>(e?e+o:"")+Fi(t)),"")}},yu={description:s("Substring from beginning of specified string."),args:[ra("text (string)",s("The string from which the left portion will be returned.")),ra("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 o=t.length?Ni(t[0]):1;return Mi((()=>o>=0),s("The number_of_characters (%s) must be positive or null.",o.toString())),Fi(e).substring(0,o)},isExported:!0},xu={description:s("Length of a string."),args:[ra("text (string)",s("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return Fi(e).length},isExported:!0},Iu={description:s("Converts a specified string to lowercase."),args:[ra("text (string)",s("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return Fi(e).toLowerCase()},isExported:!0},Ru={description:s("A segment of a string."),args:[ra("text (string)",s("The string to extract a segment from.")),ra(" (number)",s("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),ra(" (number)",s("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,o){const i=Fi(e),n=Ni(t),r=Ni(o);return Mi((()=>n>=1),s("The starting_at argument (%s) must be positive greater than one.",n.toString())),Mi((()=>r>=0),s("The extract_length argument (%s) must be positive or null.",r.toString())),i.slice(n-1,n+r-1)},isExported:!0},Tu={description:s("Capitalizes each word in a specified string."),args:[ra("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 Fi(e).replace(fu,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Au={description:s("Replaces part of a text string with different text."),args:[ra("text (string)",s("The text, a part of which will be replaced.")),ra("position (number)",s("The position where the replacement will begin (starting from 1).")),ra("length (number)",s("The number of characters in the text to be replaced.")),ra("new_text (string)",s("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,o,i){const n=Ni(t);Mi((()=>n>=1),s("The position (%s) must be greater than or equal to 1.",n.toString()));const r=Fi(e),a=Ni(o),l=Fi(i);return r.substring(0,n-1)+l+r.substring(n-1+a)},isExported:!0},Mu={description:s("A substring from the end of a specified string."),args:[ra("text (string)",s("The string from which the right portion will be returned.")),ra("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 o=t.length?Ni(t[0]):1;Mi((()=>o>=0),s("The number_of_characters (%s) must be positive or null.",o.toString()));const i=Fi(e),n=i.length;return i.substring(n-o,n)},isExported:!0},Ou={description:s("First position of string found in text, ignoring case."),args:[ra("search_for (string)",s("The string to look for within text_to_search.")),ra("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),ra("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,o=1){const i=Fi(e).toLowerCase(),n=Fi(t).toLowerCase(),r=Ni(o);Mi((()=>""!==n),s("The text_to_search must be non-empty.")),Mi((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(i,r-1);return Mi((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",i,n)),a+1},isExported:!0},Nu={description:s("Replaces existing text with new text in a string."),args:[ra("text_to_search (string)",s("The text within which to search and replace.")),ra("search_for (string)",s("The string to search for within text_to_search.")),ra("replace_with (string)",s("The string that will replace search_for.")),ra("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,o,i){const n=Ni(i);Mi((()=>n>=0),s("The occurrenceNumber (%s) must be positive or null.",n.toString()));const r=Fi(e),a=Fi(t);if(""===a)return r;const l=Fi(o),c=new RegExp(Oe(a),"g");if(0===n)return r.replace(c,l);let h=0;return r.replace(c,(e=>++h===n?l:e))},isExported:!0},_u={description:s("Combines text from multiple strings and/or arrays."),args:[ra("delimiter (string)",s(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),ra("ignore_empty (boolean)",s("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),ra("text1 (string, range<string>)",s("Any text item. This could be a string, or an array of strings in a range.")),ra("text2 (string, range<string>, repeating)",s("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...o){const i=Fi(e),n=Pi(t);let s=0;return Hi(o,((e,t)=>n&&""===Fi(t)?e:(s++?e+i:"")+Fi(t)),"")},isExported:!0},Fu={description:s("Removes space characters."),args:[ra("text (string)",s("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Fi(e).trim()},isExported:!0},Du={description:s("Converts a specified string to uppercase."),args:[ra("text (string)",s("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return Fi(e).toUpperCase()},isExported:!0},ku={description:s("Converts a number to text according to a specified format."),args:[ra("number (number)",s("The number, date or time to format.")),ra("format (string)",s("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return ho(Ni(e),Fi(t))},isExported:!0};var Pu=Object.freeze({__proto__:null,CHAR:vu,CLEAN:bu,CONCATENATE:Su,EXACT:Cu,FIND:Eu,JOIN:wu,LEFT:yu,LEN:xu,LOWER:Iu,MID:Ru,PROPER:Tu,REPLACE:Au,RIGHT:Mu,SEARCH:Ou,SUBSTITUTE:Nu,TEXTJOIN:_u,TRIM:Fu,UPPER:Du,TEXT:ku});const Lu={description:s("Creates a hyperlink in a cell."),args:[ra("url (string)",s("The full URL of the link enclosed in quotation marks.")),ra("link_label (string, optional)",s("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const o=Fi(e).trim(),i=Fi(t)||o;return""===o?i:je(i,o)},isExported:!0};var Uu=Object.freeze({__proto__:null,HYPERLINK:Lu});const Vu=[{name:s("Database"),functions:vc},{name:s("Date"),functions:Yc},{name:s("Financial"),functions:Cd},{name:s("Info"),functions:Od},{name:s("Lookup"),functions:Yd},{name:s("Logical"),functions:Vd},{name:s("Math"),functions:ul},{name:s("Misc"),functions:ca},{name:s("Operator"),functions:mu},{name:s("Statistical"),functions:oc},{name:s("Text"),functions:Pu},{name:s("Engineering"),functions:Qc},{name:s("Web"),functions:Uu}],zu=/^[A-Z0-9\_\.]+$/;function Bu(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Hu(e()):Hu(e)}))}function Hu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const $u=new class extends Si{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(zu))throw new Error(s("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const o=aa(t);return function(e){let t=!1,o=!1,i=!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=o||t||i,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,o=n.optional,i=n.default}}(o.args),this.mapping[e]=function(...e){const t=o.compute.bind(this),i=o.computeFormat?o.computeFormat.bind(this):()=>{};return{value:t(...Bu(e)),format:i(...e)}},super.add(e,o),this}};for(let e of Vu){const t=e.functions;for(let o in t){const i=t[o];i.category=i.category||e.name,o=o.replace(/_/g,"."),$u.add(o,{isExported:!1,...i})}}function Wu(e,t,o){const i=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:i,quantity:o}).isCancelledBecause(65)&&e.raiseError(Rs)}const Gu=new Kn;Gu.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:Or}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:Nr}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:_r}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:Pr}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:Fr}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:kr}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:ea,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:Qr}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:Jr}).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:Lr,sequence:80,action:Ur}).addChild("edit_delete_column",["edit"],{name:Vr,sequence:90,action:zr}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:$r}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:Wr}).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=Tr(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:Gr,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Tr(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=Rr(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:Zr,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Rr(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:Br}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:Hr,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,o=e.model.uuidGenerator.uuidv4(),i=t.getActiveSheetId();1===si(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+n+Math.max(0,(r-t.width)/2),y:i+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:i,id:o,position:s,size:n,definition:fr(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:o}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),o=e.model.uuidGenerator.uuidv4(),i=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(!i)throw new Error("No image provider was given to the environment");const n=lr(e.model.getters,i.size),r=function(e,t){const{x:o,y:i}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-o),c=Math.min(a.height,r.height-i);return{x:o+n+Math.max(0,(l-t.width)/2),y:i+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:o,position:r,size:n,definition:i})}},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($u.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=$u.content;return[...new Set($u.getAll().map((e=>e.category)))].filter(et).sort().map(((t,o)=>{const i=Object.keys(e).filter((o=>e[o].category===t));return{name:t,sequence:60+10*o,children:qu(i)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:Yr}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getSheetIds().indexOf(t)+1,i=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:i,position:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:o}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+o>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name: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=>Wu(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>Wu(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();Wu(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=>Wu(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>Wu(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();Wu(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:xs.Automatic,sequence:10,separator:!0,action:e=>Ar(e,"")}).addChild("format_number_number",["format","format_number"],{name:xs.Number,description:"1,000.12",sequence:20,action:e=>Ar(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:xs.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>Ar(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:xs.Currency,description:"$1,000.12",sequence:37,action:e=>Ar(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:xs.CurrencyRounded,description:"$1,000",sequence:38,action:e=>Ar(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:xs.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:xs.Date,description:"9/26/2008",sequence:40,action:e=>Ar(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:xs.Time,description:"10:43:00 PM",sequence:50,action:e=>Ar(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:xs.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>Ar(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:xs.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>Ar(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>Mr(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>Mr(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>Mr(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>Mr(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=>Mr(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>Mr(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>Mr(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>Mr(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>Mr(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>Mr(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=>Mr(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>Mr(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>Mr(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:Xr,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(),o=e.model.getters.getSelection().zones;Er(e,t,o)},isVisible:e=>!Kr(e),isEnabled:e=>(e=>ri(...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:Kr});for(let e of he)Gu.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>Mr(t,{fontSize:e})});function qu(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const Zu=new class extends Si{addTransformation(e,t,o){for(let i of t)this.content[i]||(this.content[i]=new Map),this.content[i].set(e,o);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},ju={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function Xu(e,t){const o=ju[e.key];e.shiftKey?t.resizeAnchorZone(o,e.ctrlKey?"end":1):t.moveAnchorCell(o,e.ctrlKey?"end":1)}const Yu=new Do;hi`
|
|
350
350
|
.o-selection {
|
|
351
351
|
.o-selection-input {
|
|
352
352
|
display: flex;
|
|
@@ -390,7 +390,7 @@
|
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
|
-
`;class
|
|
393
|
+
`;class Ku extends t.Component{constructor(){super(...arguments),this.id=Yu.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 o=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,o),this.previousRanges=o}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(),Xu(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}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,o;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(o=(t=this.props).onSelectionConfirmed)||void 0===o||o.call(t)}onInputChanged(e,t){const o=t.target;this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o.value}),this.triggerChange()}confirm(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const o=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===o.length&&(this.state.isMissing=!0);const i=this.env.model.getters.getActiveSheetId();this.originSheet!==i&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}Ku.template="o-spreadsheet-SelectionInput",Ku.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 Qu 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=>ys.Errors[e]||ys.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({dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart({dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart({labelRange:this.labelRange})}onUpdateAggregated(e){this.props.updateChart({aggregated:e.target.checked})}}Qu.template="o-spreadsheet-LineBarPieConfigPanel",Qu.components={SelectionInput:Ku},Qu.props={figureId:String,definition:Object,updateChart:Function};class Ju extends Qu{onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart({aggregated:e.target.checked})}}Ju.template="o-spreadsheet-BarConfigPanel";const eg=218,tg=182;function og(e){return yt(It({h:360*e.offsetX/eg,s:100,l:100*e.offsetY/tg,a:1}))}hi`
|
|
394
394
|
.o-color-picker {
|
|
395
395
|
padding: ${6}px 0px;
|
|
396
396
|
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
@@ -398,7 +398,7 @@
|
|
|
398
398
|
line-height: 1.2;
|
|
399
399
|
overflow-y: auto;
|
|
400
400
|
overflow-x: hidden;
|
|
401
|
-
width: ${
|
|
401
|
+
width: ${eg+12}px;
|
|
402
402
|
|
|
403
403
|
.o-color-picker-section-name {
|
|
404
404
|
margin: 0px ${1}px;
|
|
@@ -486,8 +486,8 @@
|
|
|
486
486
|
hsl(1turn 100% 50%) 100%
|
|
487
487
|
);
|
|
488
488
|
border: ${1}px solid #c0c0c0;
|
|
489
|
-
width: ${
|
|
490
|
-
height: ${
|
|
489
|
+
width: ${eg}px;
|
|
490
|
+
height: ${tg}px;
|
|
491
491
|
&:hover {
|
|
492
492
|
cursor: crosshair;
|
|
493
493
|
}
|
|
@@ -514,7 +514,7 @@
|
|
|
514
514
|
width: 30px;
|
|
515
515
|
height: 30px;
|
|
516
516
|
}
|
|
517
|
-
`;class
|
|
517
|
+
`;class ig extends t.Component{constructor(){super(...arguments),this.COLORS=M,this.state=t.useState({showGradient:!1,currentColor:St(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?pi({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}onColorClick(e){e&&this.props.onColorPicked(bt(e))}getCheckMarkColor(){return ms(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!St(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);const t=bt(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=og(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=og(e);this.state.style.left=`${e.offsetX+10}px`,this.state.style.top=`${e.offsetY+10}px`}get magnifyingGlassStyle(){const{display:e,background:t,left:o,top:i}=this.state.style;return pi({display:e,"background-color":"block"===e?t:void 0,left:o,top:i})}isSameColor(e,t){return function(e,t){return St(e)&&St(t)&&bt(e)===bt(t)}(e,t)}}ig.template="o-spreadsheet-ColorPicker",ig.defaultProps={currentColor:""},ig.components={Popover:Bn},ig.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},hi`
|
|
518
518
|
.o-color-picker-widget {
|
|
519
519
|
display: inline-block;
|
|
520
520
|
position: relative;
|
|
@@ -545,7 +545,7 @@
|
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
|
-
`;class
|
|
548
|
+
`;class ng 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}}}ng.template="o-spreadsheet-ColorPickerWidget",ng.components={ColorPicker:ig},ng.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 sg extends t.Component{constructor(){super(...arguments),this.state=t.useState({fillColorTool:!1})}onClick(e){this.state.fillColorTool=!1}setup(){t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}updateSelect(e,t){this.props.updateChart({[e]:t.target.value})}}sg.template="o-spreadsheet-LineBarPieDesignPanel",sg.components={ColorPickerWidget:ng},sg.props={figureId:String,definition:Object,updateChart:Function};class rg extends sg{}rg.template="o-spreadsheet-BarChartDesignPanel";class ag 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=>ys.Errors[e]||ys.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({dataRange:this.dataRange})}}ag.template="o-spreadsheet-GaugeChartConfigPanel",ag.components={SelectionInput:Ku},ag.props={figureId:String,definition:Object,updateChart:Function},hi`
|
|
549
549
|
.o-gauge-color-set {
|
|
550
550
|
table {
|
|
551
551
|
table-layout: fixed;
|
|
@@ -575,7 +575,7 @@
|
|
|
575
575
|
box-sizing: border-box;
|
|
576
576
|
}
|
|
577
577
|
}
|
|
578
|
-
`;class
|
|
578
|
+
`;class lg 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=>ys.Errors[e]||ys.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart({background:e})}updateTitle(e){this.props.updateChart({title:e.target.value})}isRangeMinInvalid(){var e,t,o;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(37))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(38))||(null===(o=this.state.sectionRuleDispatchResult)||void 0===o?void 0:o.isCancelledBecause(41)))}isRangeMaxInvalid(){var e,t,o;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===(o=this.state.sectionRuleDispatchResult)||void 0===o?void 0:o.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 o=Ne(this.props.definition.sectionRule);o[e].value=t.target.value,this.updateSectionRule(o)}updateInflectionPointType(e,t){const o=Ne(this.props.definition.sectionRule);o[e].type=t.target.value,this.updateSectionRule(o)}updateSectionColor(e,t){const o=Ne(this.props.definition.sectionRule);o.colors[e]=t,this.updateSectionRule(o),this.closeMenus()}updateRangeMin(e){let t=Ne(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=Ne(this.props.definition.sectionRule);t={...t,rangeMax:e.target.value},this.updateSectionRule(t)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart({sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}lg.template="o-spreadsheet-GaugeChartDesignPanel",lg.components={ColorPickerWidget:ng},lg.props={figureId:String,definition:Object,updateChart:Function};class cg extends Qu{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof Zs)&&js(e.labelRange,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart({labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart({stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart({aggregated:e.target.checked})}}cg.template="o-spreadsheet-LineConfigPanel";class hg extends sg{}hg.template="o-spreadsheet-LineChartDesignPanel";class dg 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=>ys.Errors[e]||ys.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({keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart({baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart({baselineMode:e.target.value})}}dg.template="o-spreadsheet-ScorecardChartConfigPanel",dg.components={SelectionInput:Ku},dg.props={figureId:String,definition:Object,updateChart:Function};class ug 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({title:e.target.value})}updateBaselineDescr(e){this.props.updateChart({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({background:e});break;case"baselineColorDown":this.props.updateChart({baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart({baselineColorUp:e})}this.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}ug.template="o-spreadsheet-ScorecardChartDesignPanel",ug.components={ColorPickerWidget:ng},ug.props={figureId:String,definition:Object,updateChart:Function};const gg=new Si;gg.add("line",{configuration:cg,design:hg}).add("bar",{configuration:Ju,design:rg}).add("pie",{configuration:Qu,design:sg}).add("gauge",{configuration:ag,design:lg}).add("scorecard",{configuration:dg,design:ug}),hi`
|
|
579
579
|
.o-chart {
|
|
580
580
|
.o-panel {
|
|
581
581
|
display: flex;
|
|
@@ -598,7 +598,7 @@
|
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
600
|
}
|
|
601
|
-
`;class
|
|
601
|
+
`;class pg extends t.Component{constructor(){super(...arguments),this.shouldUpdateChart=!0}get figureId(){return this.state.figureId}get sheetId(){return this.state.sheetId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(s("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e,sheetId:this.env.model.getters.getActiveSheetId()}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId?(this.state.figureId=e,this.state.sheetId=this.env.model.getters.getActiveSheetId(),this.shouldUpdateChart=!1):this.shouldUpdateChart=!0,this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e){if(!this.shouldUpdateChart)return;const t={...this.getChartDefinition(),...e};return this.env.model.dispatch("UPDATE_CHART",{definition:t,id:this.figureId,sheetId:this.sheetId})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const o=function(e,t){return ir.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:o,id:this.figureId,sheetId:this.sheetId})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=gg.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 ir.getKeys())e[t]=ir.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}pg.template="o-spreadsheet-ChartPanel",pg.props={onCloseSidePanel:Function};function mg(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 fg={arrowGood:{template:"ARROW_UP",img:mg('<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:mg('<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:mg('<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:mg('<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:mg('<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:mg('<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:mg('<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:mg('<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:mg('<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>')}},vg={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};hi`
|
|
602
602
|
.o-icon-picker {
|
|
603
603
|
position: absolute;
|
|
604
604
|
z-index: ${le.IconPicker};
|
|
@@ -617,7 +617,7 @@
|
|
|
617
617
|
outline: 1px solid gray;
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
|
-
`;class
|
|
620
|
+
`;class bg extends t.Component{constructor(){super(...arguments),this.icons=fg,this.iconSets=vg}onIconClick(e){e&&this.props.onIconPicked(e)}}bg.template="o-spreadsheet-IconPicker",bg.props={onIconPicked:Function},hi`
|
|
621
621
|
label {
|
|
622
622
|
vertical-align: middle;
|
|
623
623
|
}
|
|
@@ -887,13 +887,13 @@
|
|
|
887
887
|
}
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
|
-
`;class
|
|
890
|
+
`;class Sg extends t.Component{constructor(){super(...arguments),this.icons=fg,this.cellIsOperators=ws,this.iconSets=vg,this.getTextDecoration=di,this.colorNumberString=vt}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return Es.Errors[e]||Es.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 pi({"font-weight":e.style.bold?"bold":"normal","text-decoration":di(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=vt(e.minimum.color),o=e.midpoint?vt(e.midpoint.color):null,i=vt(e.maximum.color),n="background-image: linear-gradient(to right, ";return o?n+t+", "+o+", "+i+")":n+t+", "+i+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=ws[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 Es.ColorScale;case"IconSetRule":return Es.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(_t))))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 o=this.state.rules.colorScale[e];o&&(o.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,o=vt(t.minimum.color),i=vt((null===(e=t.midpoint)||void 0===e?void 0:e.color)||y),n=vt(t.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===t.midpoint?s+o+", "+n+")":s+o+", "+i+", "+n+")"}getThresholdColor(e){return vt(e?e.color:y)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:y,value:"",...o.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(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}}Sg.template="o-spreadsheet-ConditionalFormattingPanel",Sg.components={SelectionInput:Ku,IconPicker:bg,ColorPickerWidget:ng},Sg.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},hi`
|
|
891
891
|
.o-custom-currency {
|
|
892
892
|
.o-format-proposals {
|
|
893
893
|
color: black;
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
|
-
`;class
|
|
896
|
+
`;class Cg extends t.Component{setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),o=e.position,i="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,o),...this.createFormatProposals(t,n,s,i)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===sr.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{sr.add(t.toString(),e)}))}const o={name:this.env._t(Is.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[o,...sr.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const o=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=o.code,this.state.currencySymbol=o.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],o=e?"."+"0".repeat(e):"";return o&&t.push({format:"#,##0"+o,example:"1,000"+o}),t}createFormatProposals(e,t,o,i){let n=[];if(t)for(let o of e)n.push(this.createFormatProposal(i,o.example,o.format,t));if(o)for(let s of e){const e=("after"===i?" ":"")+o+" "+t;n.push(this.createFormatProposal(i,s.example,s.format,e))}return n}createFormatProposal(e,t,o,i){const n="[$"+i+"]";return{example:"before"===e?i+t:t+i,format:"before"===e?n+o:o+n}}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),o=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),i=o[0].format;return o.every((e=>e.format===i))?i:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}Cg.template="o-spreadsheet-CustomCurrencyPanel",Cg.props={onCloseSidePanel:Function},hi`
|
|
897
897
|
.o-find-and-replace {
|
|
898
898
|
.o-far-item {
|
|
899
899
|
display: block;
|
|
@@ -926,7 +926,7 @@
|
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
928
|
}
|
|
929
|
-
`;class
|
|
929
|
+
`;class Eg 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((()=>{this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})}))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.replace())}onFocusSidePanel(){this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.env.model.dispatch("REFRESH_SEARCH")}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),400)}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}Eg.template="o-spreadsheet-FindAndReplacePanel",Eg.props={onCloseSidePanel:Function};const wg=new Si;wg.add("ConditionalFormatting",{title:s("Conditional formatting"),Body:Sg}),wg.add("ChartPanel",{title:s("Chart"),Body:pg}),wg.add("FindAndReplace",{title:s("Find and Replace"),Body:Eg}),wg.add("CustomCurrency",{title:s("Custom currency format"),Body:Cg});const yg=new class extends Si{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new Do}add(e,t){const o={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,o)}};hi`
|
|
930
930
|
div.o-figure {
|
|
931
931
|
box-sizing: border-box;
|
|
932
932
|
position: absolute;
|
|
@@ -999,7 +999,7 @@
|
|
|
999
999
|
}
|
|
1000
1000
|
}
|
|
1001
1001
|
}
|
|
1002
|
-
`;class
|
|
1002
|
+
`;class xg 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=Un(this.menuButtonRef)}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return cr}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:o,height:i}=this.props.figure;return pi({left:`${e}px`,top:`${t}px`,width:`${o}px`,height:`${i}px`,"z-index":String(le.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)",pi(t)}setup(){const e=cr.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,o)=>{e===t&&(null==o||o.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,o){this.props.onClickAnchor(e,t,o)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const o={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+o[0],y:t.y+o[1]}),e.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:o}=this.menuButtonRect,i={x:e>=H?e-H:e+o,y:t};this.openContextMenu(i)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e,this.menuState.menuItems=cr.get(this.props.figure.tag).menuBuilder(this.props.figure.id,this.props.onFigureDeleted,this.env)}}function Ig(e,t,o=(()=>{})){const i=e=>{e.preventDefault(),o(e)},n=t=>{t.preventDefault(),e(t)},s=e=>{e.preventDefault(),t(e),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",s),window.removeEventListener("dragstart",r),window.removeEventListener("mousemove",n),window.removeEventListener("wheel",n)};function r(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",s),window.addEventListener("dragstart",r),window.addEventListener("mousemove",n),window.addEventListener("wheel",n,{passive:!1})}function Rg(e,t,o,i=!1){let n,s,r,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Dn();let g,p;const m=o=>{if(n=o,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=Ht;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==i){const t=s.clientX-u.left,o=h.getEdgeScrollCol(T,t,a);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-r}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==i){const t=s.clientY-u.top,o=h.getEdgeScrollRow(A,t,l);if(o.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,o.delay),o.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+o.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-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};Ig(m,(()=>{clearTimeout(c),o()}),(e=>{s=e,r=e,a=r.clientX-u.left,l=r.clientY-u.top}))}xg.template="o-spreadsheet-FigureComponent",xg.components={Menu:Gn},xg.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},xg.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}},hi`
|
|
1003
1003
|
.o-autofill {
|
|
1004
1004
|
position: absolute;
|
|
1005
1005
|
height: ${8}px;
|
|
@@ -1027,9 +1027,9 @@
|
|
|
1027
1027
|
pointer-events: none;
|
|
1028
1028
|
white-space: nowrap;
|
|
1029
1029
|
}
|
|
1030
|
-
`;class
|
|
1030
|
+
`;class Tg 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 pi({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 pi({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return pi({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=Ag),e}onMouseDown(e){let t,o;this.state.handler=!0;const i=e.clientX-this.props.position.left,n=e.clientY-this.props.position.top;Rg(this.env,((e,s,r)=>{if(this.state.position={left:r.clientX-i,top:r.clientY-n},t!==e||o!==s){const i=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getNumberCols(i),r=this.env.model.getters.getNumberRows(i);t=-1===e?t:De(e,0,n),o=-1===s?o:De(s,0,r),void 0!==t&&void 0!==o&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:o})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}Tg.template="o-spreadsheet-Autofill",Tg.props={position:Object,isVisible:Boolean};class Ag extends t.Component{}Ag.template=t.xml`
|
|
1031
1031
|
<div t-esc="props.content"/>
|
|
1032
|
-
`,
|
|
1032
|
+
`,Ag.props={content:String},hi`
|
|
1033
1033
|
.o-client-tag {
|
|
1034
1034
|
position: absolute;
|
|
1035
1035
|
border-top-left-radius: 4px;
|
|
@@ -1039,7 +1039,7 @@
|
|
|
1039
1039
|
opacity: 0;
|
|
1040
1040
|
pointer-events: none;
|
|
1041
1041
|
}
|
|
1042
|
-
`;class
|
|
1042
|
+
`;class Mg extends t.Component{get tagStyle(){const{col:e,row:t,color:o}=this.props,{height:i}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:n,y:s}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return pi({bottom:i-s+15+"px",left:n-1+"px",border:`1px solid ${o}`,"background-color":o,opacity:this.props.active?"opacity:1 !important":void 0})}}Mg.template="o-spreadsheet-ClientTag",Mg.props={active:Boolean,name:String,color:String,col:Number,row:Number},hi`
|
|
1043
1043
|
.o-autocomplete-dropdown {
|
|
1044
1044
|
pointer-events: auto;
|
|
1045
1045
|
background-color: #fff;
|
|
@@ -1058,7 +1058,7 @@
|
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
|
-
`;class
|
|
1061
|
+
`;class Og extends t.Component{}Og.template="o-spreadsheet-TextValueProvider",Og.props={values:Array,selectedIndex:Number,onValueSelected:Function};class Ng{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let o=window.getSelection();this.removeSelection();let i=document.createRange();if(e==t&&0===e)i.setStart(this.el,0),i.setEnd(this.el,0),o.addRange(i);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);i.setStart(s.node,s.offset),o.addRange(i),o.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,o,i=Pn(this.el),n=e,s=!0;do{t=i.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&&i.return(t.value),o=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:o,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 o of t){if(!o.value&&!o.class)continue;const t=document.createElement("span");t.innerText=o.value,t.style.color=o.color||"",o.class&&t.classList.add(o.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 o=t instanceof HTMLElement?t:t.parentElement;null==o||o.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:o,endSelectionOffset:i}=this.getStartAndEndSelection();return{start:this.findSizeBeforeElement(e)+o,end:this.findSizeBeforeElement(t)+i}}findSizeBeforeElement(e){let t=0,o=Pn(this.el),i=o.next(),n=!0;for(;!i.done&&i.value!==e;)i.value.hasChildNodes()||i.value.textContent&&(t+=i.value.textContent.length),("P"===i.value.nodeName||"DIV"===i.value.nodeName&&i.value!==this.el)&&(n?n=!1:t++),i=o.next();if(i.value!==e)throw new Error("Cannot find the node in the children of the element");return"P"!==e.nodeName||n||""!=e.textContent||t++,t}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=Pn(this.el),o=t.next(),i=!0;for(;!o.done;)o.value.hasChildNodes()||(e+=o.value.textContent),("P"===o.value.nodeName||"DIV"===o.value.nodeName&&o.value!==this.el)&&(i?i=!1:e+=ce),o=t.next();return e}}hi`
|
|
1062
1062
|
.o-formula-assistant {
|
|
1063
1063
|
.o-formula-assistant-head {
|
|
1064
1064
|
background-color: #f2f2f2;
|
|
@@ -1084,7 +1084,7 @@
|
|
|
1084
1084
|
color: gray;
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
1087
|
-
`;class
|
|
1087
|
+
`;class _g 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)}}_g.template="o-spreadsheet-FunctionDescriptionProvider",_g.props={functionName:String,functionDescription:Object,argToFocus:Number};const Fg=$u.content,Dg="selector-flag",kg="#4a4e4d",Pg="#3da4ab",Lg={OPERATOR:Pg,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:kg,DEBUGGER:Pg,LEFT_PAREN:kg,RIGHT_PAREN:kg,COMMA:kg,MATCHING_PAREN:"#000000"};hi`
|
|
1088
1088
|
.o-composer-container {
|
|
1089
1089
|
.o-composer {
|
|
1090
1090
|
overflow-y: auto;
|
|
@@ -1109,7 +1109,7 @@
|
|
|
1109
1109
|
|
|
1110
1110
|
span {
|
|
1111
1111
|
white-space: pre-wrap;
|
|
1112
|
-
&.${
|
|
1112
|
+
&.${Dg}:after {
|
|
1113
1113
|
content: "${"␣"}";
|
|
1114
1114
|
color: ${"#a9a9a9"};
|
|
1115
1115
|
}
|
|
@@ -1123,12 +1123,12 @@
|
|
|
1123
1123
|
pointer-events: none;
|
|
1124
1124
|
}
|
|
1125
1125
|
}
|
|
1126
|
-
`;class Lg extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Og(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:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",gi(i)}return gi({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 ju(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)}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 o=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(o,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(),o=t.slice(0,e.start)+ce+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:o,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 o=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(o,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):e.stopPropagation();const{start:o,end:i}=this.contentHelper.getCurrentSelection();this.env.model.getters.isSelectingForComposer()||"Enter"===e.key&&(e.altKey||e.ctrlKey)||(this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i}),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:o}=this.env.model.getters.getComposerSelection(),{start:i,end:n}=this.contentHelper.getCurrentSelection();i===t&&n===o||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(Hu.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?No(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 o=this.getContentLines();if(0!==o.length&&0!==o.length[0]){this.contentHelper.setText(o);const{start:t,end:i}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,i),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(),o=[],{end:i,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":o.push({value:s.value,color:Pg[s.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Lt(s.value);o.push({value:s.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":let n=s.value;["TRUE","FALSE"].includes(n.toUpperCase())?o.push({value:s.value,color:Pg.NUMBER}):o.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?o.push({value:s.value,color:Pg.MATCHING_PAREN}):o.push({value:s.value,color:Pg[s.type]||"#000"});break;default:o.push({value:s.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===n&&i===s.end&&(o[o.length-1].class=Fg)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(ce)){const e=i.value.split(ce),n=e.pop();for(const n of e)o.push({color:i.color,value:n}),t.push(o),o=[];o.push({...i,value:n})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===ni(o)?this.env.model.getters.expandZone(i,o):o,Wo(o,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}=Lt(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!_t.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,o=t.parent.toUpperCase(),i=_g[o],n=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=i,this.functionDescriptionState.argToFocus=i.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const n=this.env.model.getters.getCurrentTokens();if(n.length){e+="(";const o=n.map((e=>e.start)).indexOf(t.start);if(o+1<n.length){"LEFT_PAREN"===n[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Lg.template="o-spreadsheet-Composer",Lg.components={TextValueProvider:Mg,FunctionDescriptionProvider:Ng},Lg.defaultProps={inputStyle:""},Lg.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 Ug=3*.4*window.devicePixelRatio||1;ci`
|
|
1126
|
+
`;class Ug extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Ng(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:o}=this.props.rect;let i={};return t>this.props.delimitation.height-(t+o)&&(i.top="-3px",i.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(i.right="0px"),i.width="300px",pi(i)}return pi({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 Xu(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)}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 o=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(o,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(),o=t.slice(0,e.start)+ce+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:o,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 o=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(o,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):e.stopPropagation();const{start:o,end:i}=this.contentHelper.getCurrentSelection();this.env.model.getters.isSelectingForComposer()||"Enter"===e.key&&(e.altKey||e.ctrlKey)||(this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i}),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:o}=this.env.model.getters.getComposerSelection(),{start:i,end:n}=this.contentHelper.getCurrentSelection();i===t&&n===o||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($u.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?_o(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 o=this.getContentLines();if(0!==o.length&&0!==o.length[0]){this.contentHelper.setText(o);const{start:t,end:i}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,i),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(),o=[],{end:i,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":o.push({value:s.value,color:Lg[s.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:i}=Lt(s.value);o.push({value:s.value,color:this.rangeColor(e,i)||"#000"});break;case"SYMBOL":let n=s.value;["TRUE","FALSE"].includes(n.toUpperCase())?o.push({value:s.value,color:Lg.NUMBER}):o.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?o.push({value:s.value,color:Lg.MATCHING_PAREN}):o.push({value:s.value,color:Lg[s.type]||"#000"});break;default:o.push({value:s.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&i===n&&i===s.end&&(o[o.length-1].class=Dg)}return o}splitHtmlContentIntoLines(e){const t=[];let o=[];for(const i of e)if(i.value.includes(ce)){const e=i.value.split(ce),n=e.pop();for(const n of e)o.push({color:i.color,value:n}),t.push(o),o=[];o.push({...i,value:n})}else o.push(i);o.length&&t.push(o);const i=[];for(const e of t)e.every(this.isContentEmpty)?i.push([e[0]]):i.push(e.filter((e=>!this.isContentEmpty(e))));return i}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const o=this.env.model.getters.getHighlights(),i=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=o.find((t=>{if(t.sheetId!==i)return!1;let o=this.env.model.getters.getRangeFromSheetXC(i,e).zone;return o=1===si(o)?this.env.model.getters.expandZone(i,o):o,Go(o,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}=Lt(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!_t.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,o=t.parent.toUpperCase(),i=Fg[o],n=t.argPosition;this.functionDescriptionState.functionName=o,this.functionDescriptionState.functionDescription=i,this.functionDescriptionState.argToFocus=i.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let o=t.end,i=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(o=t.start);const n=this.env.model.getters.getCurrentTokens();if(n.length){e+="(";const o=n.map((e=>e.start)).indexOf(t.start);if(o+1<n.length){"LEFT_PAREN"===n[o+1].type&&i++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:o,end:i})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Ug.template="o-spreadsheet-Composer",Ug.components={TextValueProvider:Og,FunctionDescriptionProvider:_g},Ug.defaultProps={inputStyle:""},Ug.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 Vg=3*.4*window.devicePixelRatio||1;hi`
|
|
1127
1127
|
div.o-grid-composer {
|
|
1128
1128
|
z-index: ${le.GridComposer};
|
|
1129
1129
|
box-sizing: border-box;
|
|
1130
1130
|
position: absolute;
|
|
1131
|
-
border: ${
|
|
1131
|
+
border: ${Vg}px solid ${E};
|
|
1132
1132
|
|
|
1133
1133
|
display: flex;
|
|
1134
1134
|
align-items: center;
|
|
@@ -1144,7 +1144,7 @@
|
|
|
1144
1144
|
padding: 6px 7px;
|
|
1145
1145
|
border-radius: 4px;
|
|
1146
1146
|
}
|
|
1147
|
-
`;class
|
|
1147
|
+
`;class zg extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:void 0,delimitation:void 0});const{sheetId:e,col:o,row:i}=this.env.model.getters.getActivePosition();this.zone=this.env.model.getters.expandZone(e,ii({col:o,row:i})),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();at(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:o}=this.env.model.getters.getCurrentEditedCell();return`${o!==this.env.model.getters.getActiveSheetId()?Fe(this.env.model.getters.getSheetName(o))+"!":""}${Bt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return pi({left:e-Vg+"px",top:t-28+"px"})}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),o=this.env.model.getters.getActivePosition(),i=this.env.model.getters.getCellComputedStyle(o),{x:n,y:s,width:r,height:a}=this.rect,l=!e&&i.fillColor||"#ffffff",c=!e&&i.textColor||"#000000",h=!e&&i.fontSize||10,d=!e&&i.bold?"bold":void 0,u=!e&&i.italic?"italic":"normal",g=e?"none":di(i);let p="left";return e||(p=i.align||t.defaultAlign),pi({left:n-1+"px",top:`${s}px`,"min-width":`${r+1}px`,"min-height":`${a+1}px`,background:l,color:c,"font-size":`${Le(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 pi({"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${e}px`})}}zg.template="o-spreadsheet-GridComposer",zg.components={Composer:Ug},zg.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerUnmounted:Function,onComposerContentFocused:Function,gridDims:Object};const Bg=hi`
|
|
1148
1148
|
.o-filter-icon {
|
|
1149
1149
|
color: ${I};
|
|
1150
1150
|
position: absolute;
|
|
@@ -1168,7 +1168,7 @@
|
|
|
1168
1168
|
}
|
|
1169
1169
|
}
|
|
1170
1170
|
}
|
|
1171
|
-
`;class Bg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Bg.style=zg,Bg.template="o-spreadsheet-FilterIcon",Bg.props={position:Object,isActive:Boolean,onClick:Function};const Hg=ci``;class $g extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRowDimensionsInViewport(t,e.row),i=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((o.size-B)/2);return{x:i.end-B+this.props.gridPosition.x-2-1,y:o.end-B+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:o,row:i}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:o,row:i,popoverType:"FilterMenu"})}isPositionVisible(e,t){const o=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===o.width||0===o.height)}}$g.style=Hg,$g.template="o-spreadsheet-FilterIconsOverlay",$g.components={FilterIcon:Bg},$g.defaultProps={gridPosition:{x:0,y:0}},$g.props={gridPosition:{type:Object,optional:!0}};class Wg extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const i=e.filter((e=>this.getFigureContainer(e)===o));i.length>0&&t.push({type:o,figures:i,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates(),s=["bottomRight","topRight"].includes(e)?i:0,r=t-s,a=["bottomRight","bottomLeft"].includes(e)?n:0;return gi({left:`${s}px`,top:`${a}px`,width:`${r}px`,height:`${o-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates();return gi({left:`${["bottomRight","topRight"].includes(e)?-(i+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),i=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;xg((t=>{const{x:o,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=o?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-i;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:i,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:i,y:n})}))}startResize(e,t,o,i){i.stopPropagation();const n=i.clientX,s=i.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=lr.get(e.tag).keepRatio||!1,c=lr.get(e.tag).minFigSize||80;let h;h=l&&0!=t&&0!=o?i=>{this.dnd.figId=e.id;const l=Math.min(t*(n-i.clientX),e.width-c),h=Math.min(o*(s-i.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),o<0&&(this.dnd.y=a+e.height*d)}:i=>{this.dnd.figId=e.id;const l=Math.max(t*(i.clientX-n),c-e.width),h=Math.max(o*(i.clientY-s),c-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+h,t<0&&(this.dnd.x=r-l),o<0&&(this.dnd.y=a-h)};xg(h,(i=>{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),o&&(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?"":gi({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:o,y:i}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<o?e:e-n,y:t=t<i?t:t-s}}screenCoordinatesToInternal({x:e,y:t}){const{x:o,y:i}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=o&&e<o?e:e+n,y:t=i&&t<i?t:t+s}}}function Gg(e,o,i){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,o){let i;const{setInterval:n,clearInterval:s}=window;return t.useEffect((()=>(i=n(e,o),()=>s(i))),(()=>[o])),{pause:()=>{s(i),i=void 0},resume:()=>{void 0===i&&(i=n(e,o))}}}((function(){const{col:e,row:t}=c(),o=s.now()-l;o>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(o>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){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,i({col:e,row:t}))}return t.onMounted((()=>{const e=o.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=o.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}Wg.template="o-spreadsheet-FiguresContainer",Wg.components={FigureComponent:yg},Wg.props={onFigureDeleted:Function};class qg extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),Gg(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,o,i){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;i()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;o(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,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){e.preventDefault();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}qg.template="o-spreadsheet-GridOverlay",qg.components={FiguresContainer:Wg},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 Zg extends t.Component{constructor(){super(...arguments),this.zIndex=le.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}}}}Zg.template="o-spreadsheet-GridPopover",Zg.components={Popover:zn},Zg.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class jg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const i=this._getDimensionsInViewport(o);t-i.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start,this.state.activeElement=this._getPreviousVisibleElement(o)):i.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),i=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();o.has(i)&&i<=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),o=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),n=o-i+this.MIN_ELEMENT_SIZE,s=this._getMaxSize();xg((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>s&&(this.state.draggerLinePosition=s,this.state.delta=s-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=t.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=o.end-t.start;Ig(this.env,((e,o)=>{let i="COL"===this._getType()?e:o;if(i>=0){const e=this._getDimensionsInViewport(i);i<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=i):this._getSelectedZoneEnd()<i?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=i+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;Ig(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}ci`
|
|
1171
|
+
`;class Hg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Hg.style=Bg,Hg.template="o-spreadsheet-FilterIcon",Hg.props={position:Object,isActive:Boolean,onClick:Function};const $g=hi``;class Wg extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRowDimensionsInViewport(t,e.row),i=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((o.size-B)/2);return{x:i.end-B+this.props.gridPosition.x-2-1,y:o.end-B+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:o,row:i}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:o,row:i,popoverType:"FilterMenu"})}isPositionVisible(e,t){const o=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===o.width||0===o.height)}}Wg.style=$g,Wg.template="o-spreadsheet-FilterIconsOverlay",Wg.components={FilterIcon:Hg},Wg.defaultProps={gridPosition:{x:0,y:0}},Wg.props={gridPosition:{type:Object,optional:!0}};class Gg extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const o of["topLeft","topRight","bottomLeft","bottomRight"]){const i=e.filter((e=>this.getFigureContainer(e)===o));i.length>0&&t.push({type:o,figures:i,style:this.getContainerStyle(o),inverseViewportStyle:this.getInverseViewportPositionStyle(o)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:o}=this.env.model.getters.getMainViewportRect(),{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates(),s=["bottomRight","topRight"].includes(e)?i:0,r=t-s,a=["bottomRight","bottomLeft"].includes(e)?n:0;return pi({left:`${s}px`,top:`${a}px`,width:`${r}px`,height:`${o-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:o}=this.env.model.getters.getActiveSheetScrollInfo(),{x:i,y:n}=this.env.model.getters.getMainViewportCoordinates();return pi({left:`${["bottomRight","topRight"].includes(e)?-(i+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+o):0}px`})}getFigureContainer(e){const{x:t,y:o}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<o?"topLeft":e.x<t?"bottomLeft":e.y<o?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const o=this.env.model.getters.getActiveSheetId(),i=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;Ig((t=>{const{x:o,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=o?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-i;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:i,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:o,id:e.id,x:i,y:n})}))}startResize(e,t,o,i){i.stopPropagation();const n=i.clientX,s=i.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=cr.get(e.tag).keepRatio||!1,c=cr.get(e.tag).minFigSize||80;let h;h=l&&0!=t&&0!=o?i=>{this.dnd.figId=e.id;const l=Math.min(t*(n-i.clientX),e.width-c),h=Math.min(o*(s-i.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),o<0&&(this.dnd.y=a+e.height*d)}:i=>{this.dnd.figId=e.id;const l=Math.max(t*(i.clientX-n),c-e.width),h=Math.max(o*(i.clientY-s),c-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+h,t<0&&(this.dnd.x=r-l),o<0&&(this.dnd.y=a-h)};Ig(h,(i=>{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),o&&(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?"":pi({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:o,y:i}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<o?e:e-n,y:t=t<i?t:t-s}}screenCoordinatesToInternal({x:e,y:t}){const{x:o,y:i}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=o&&e<o?e:e+n,y:t=i&&t<i?t:t+s}}}function qg(e,o,i){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,o){let i;const{setInterval:n,clearInterval:s}=window;return t.useEffect((()=>(i=n(e,o),()=>s(i))),(()=>[o])),{pause:()=>{s(i),i=void 0},resume:()=>{void 0===i&&(i=n(e,o))}}}((function(){const{col:e,row:t}=c(),o=s.now()-l;o>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(o>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){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,i({col:e,row:t}))}return t.onMounted((()=>{const e=o.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=o.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}Gg.template="o-spreadsheet-FiguresContainer",Gg.components={FigureComponent:xg},Gg.props={onFigureDeleted:Function};class Zg 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,o,i){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;i()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;o(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,o]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,o,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,o]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,o)}onContextMenu(e){e.preventDefault();const[t,o]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,o,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}Zg.template="o-spreadsheet-GridOverlay",Zg.components={FiguresContainer:Gg},Zg.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}},Zg.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=le.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:Bn},jg.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class Xg extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0})}_computeHandleDisplay(e){const t=this._getEvOffset(e),o=this._getElementIndex(t);if(o<0)return;const i=this._getDimensionsInViewport(o);t-i.start<this.PADDING&&o!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.start,this.state.activeElement=this._getPreviousVisibleElement(o)):i.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=i.end,this.state.activeElement=o):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),o=this._getActiveElements(),i=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();o.has(i)&&i<=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),o=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),n=o-i+this.MIN_ELEMENT_SIZE,s=this._getMaxSize();Ig((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=o+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>s&&(this.state.draggerLinePosition=s,this.state.delta=s-o)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.startMovement(e))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),o=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=t.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=o.end-t.start;Rg(this.env,((e,o)=>{let i="COL"===this._getType()?e:o;if(i>=0){const e=this._getDimensionsInViewport(i);i<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=i):this._getSelectedZoneEnd()<i?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=i+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;Rg(this.env,((e,t)=>{let o="COL"===this._getType()?e:t;o!==this.lastSelectedElementIndex&&-1!==o&&(this._increaseSelection(o),this.lastSelectedElementIndex=o)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const o=this._getType();this.props.onOpenContextMenu(o,e.clientX,e.clientY)}}hi`
|
|
1172
1172
|
.o-col-resizer {
|
|
1173
1173
|
position: absolute;
|
|
1174
1174
|
top: 0;
|
|
@@ -1227,7 +1227,7 @@
|
|
|
1227
1227
|
top: calc(${P}px / 2 - ${k}px / 2);
|
|
1228
1228
|
}
|
|
1229
1229
|
}
|
|
1230
|
-
`,
|
|
1230
|
+
`,Xg.props={onOpenContextMenu:Function};class Yg extends Xg{setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(Rs)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isColHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Yg.template="o-spreadsheet-ColResizer",hi`
|
|
1231
1231
|
.o-row-resizer {
|
|
1232
1232
|
position: absolute;
|
|
1233
1233
|
top: ${O}px;
|
|
@@ -1288,7 +1288,7 @@
|
|
|
1288
1288
|
background-color: lightgrey;
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
|
-
`,
|
|
1291
|
+
`,Yg.props={onOpenContextMenu:Function};class Kg extends Xg{setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),o=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:o.has(e)?[...o]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),o=this._getSelectedZoneEnd();for(let i=t;i<=o;i++)e.push(i);const i=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e});!i.isSuccessful&&i.reasons.includes(2)&&this.env.raiseError(Rs)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let o;for(o=e-1;o>=0&&this.env.model.getters.isRowHidden(t,o);o--);return o}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}Kg.template="o-spreadsheet-RowResizer",hi`
|
|
1292
1292
|
.o-overlay {
|
|
1293
1293
|
.all {
|
|
1294
1294
|
position: absolute;
|
|
@@ -1299,7 +1299,7 @@
|
|
|
1299
1299
|
height: ${O}px;
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
1302
|
-
`,
|
|
1302
|
+
`,Kg.props={onOpenContextMenu:Function};class Qg extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function Jg(e,o,i){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}=i();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),o.drawGrid(r)}))}function ep(e){function t(e,t){return e*(0===t?1:F)}return o=>{const i=t(o.shiftKey?o.deltaY:o.deltaX,o.deltaMode),n=t(o.shiftKey?o.deltaX:o.deltaY,o.deltaMode);e(i,n)}}Qg.template="o-spreadsheet-HeadersOverlay",Qg.components={ColResizer:Yg,RowResizer:Kg},Qg.props={onOpenContextMenu:Function},hi`
|
|
1303
1303
|
.o-border {
|
|
1304
1304
|
position: absolute;
|
|
1305
1305
|
&:hover {
|
|
@@ -1309,7 +1309,7 @@
|
|
|
1309
1309
|
.o-moving {
|
|
1310
1310
|
cursor: grabbing;
|
|
1311
1311
|
}
|
|
1312
|
-
`;class
|
|
1312
|
+
`;class tp extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),o=["n","s"].includes(this.props.orientation),i=["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 pi({left:`${t?r:a}px`,top:`${e?l:c}px`,width:`${o?a-r:4}px`,height:`${i?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}tp.template="o-spreadsheet-Border",tp.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},hi`
|
|
1313
1313
|
.o-corner {
|
|
1314
1314
|
position: absolute;
|
|
1315
1315
|
height: 6px;
|
|
@@ -1331,11 +1331,11 @@
|
|
|
1331
1331
|
.o-resizing {
|
|
1332
1332
|
cursor: grabbing;
|
|
1333
1333
|
}
|
|
1334
|
-
`;class
|
|
1334
|
+
`;class op extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,o=this.isTop?e.top:e.bottom,i=this.env.model.getters.getVisibleRect({left:t,right:t,top:o,bottom:o});if(i.width*i.height==0)return"display:none";return pi({left:(this.isLeft?i.x:i.x+i.width)-4+"px",top:(this.isTop?i.y:i.y+i.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}op.template="o-spreadsheet-Corner",op.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},hi`
|
|
1335
1335
|
.o-highlight {
|
|
1336
1336
|
z-index: ${le.Highlight};
|
|
1337
1337
|
}
|
|
1338
|
-
`;class
|
|
1338
|
+
`;class ip extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const o=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const i=this.props.zone,n=e?i.right:i.left,s=t?i.bottom:i.top;let r=e?i.left:i.right,a=t?i.top:i.bottom,l=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o.id,l)});Rg(this.env,((e,t)=>{if(r!==e||a!==t){const i=this.env.model.getters.getActiveSheetId();r=De(-1===e?r:e,0,this.env.model.getters.getNumberCols(i)-1),a=De(-1===t?a:t,0,this.env.model.getters.getNumberRows(i)-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(i,c),Go(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(o.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const o=this.props.zone,i=Dn(),n=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getColIndex(e-i.left),r=this.env.model.getters.getRowIndex(t-i.top),a=-o.left,l=this.env.model.getters.getNumberCols(n)-o.right-1,c=-o.top,h=this.env.model.getters.getNumberRows(n)-o.bottom-1;let d=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,d)});let u=s,g=r;Rg(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const i=De(u-s,a,l),p=De(g-r,c,h);let m={left:o.left+i,top:o.top+p,right:o.right+i,bottom:o.bottom+p};m=this.env.model.getters.expandZone(n,m),Go(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")}))}}ip.template="o-spreadsheet-Highlight",ip.components={Corner:op,Border:tp},ip.props={zone:Object,color:String};class np{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}}hi`
|
|
1339
1339
|
.o-scrollbar {
|
|
1340
1340
|
position: absolute;
|
|
1341
1341
|
overflow: auto;
|
|
@@ -1351,7 +1351,7 @@
|
|
|
1351
1351
|
border-left: 1px solid #e2e3e3;
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
|
-
`;class
|
|
1354
|
+
`;class sp extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new np(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 pi({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return pi(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}sp.template=t.xml`
|
|
1355
1355
|
<div
|
|
1356
1356
|
t-attf-class="o-scrollbar {{props.direction}}"
|
|
1357
1357
|
t-on-scroll="onScroll"
|
|
@@ -1359,7 +1359,7 @@
|
|
|
1359
1359
|
t-att-style="positionCss">
|
|
1360
1360
|
<div t-att-style="sizeCss"/>
|
|
1361
1361
|
</div>
|
|
1362
|
-
`,
|
|
1362
|
+
`,sp.defaultProps={width:1,height:1},sp.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class rp 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})}}rp.components={ScrollBar:sp},rp.template=t.xml`
|
|
1363
1363
|
<ScrollBar
|
|
1364
1364
|
t-if="isDisplayed"
|
|
1365
1365
|
width="width"
|
|
@@ -1367,7 +1367,7 @@
|
|
|
1367
1367
|
offset="offset"
|
|
1368
1368
|
direction="'horizontal'"
|
|
1369
1369
|
onScroll.bind="onScroll"
|
|
1370
|
-
/>`,
|
|
1370
|
+
/>`,rp.defaultProps={leftOffset:0},rp.props={leftOffset:{type:Number,optional:!0}};class ap 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})}}ap.components={ScrollBar:sp},ap.template=t.xml`
|
|
1371
1371
|
<ScrollBar
|
|
1372
1372
|
t-if="isDisplayed"
|
|
1373
1373
|
height="height"
|
|
@@ -1375,13 +1375,13 @@
|
|
|
1375
1375
|
offset="offset"
|
|
1376
1376
|
direction="'vertical'"
|
|
1377
1377
|
onScroll.bind="onScroll"
|
|
1378
|
-
/>`,rp.defaultProps={topOffset:0},rp.props={topOffset:{type:Number,optional:!0}};const ap={ROW:oa,COL:ta,CELL:ea};class lp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=O,this.HEADER_WIDTH=N,this.keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===Ji.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===Ji.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(),o=this.env.model.getters.getSelectedZone(),{anchor:i}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,o,i.cell);if(this.env.model.getters.isSingleCellOrMerge(t,o)||this.env.model.getters.isEmpty(t,o)&&n.length<=1){const o=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",i=`=SUM(${o})`;this.props.onGridComposerCellFocused(i,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,o)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",ze(0,this.env.model.getters.getNumberCols(e)).reverse()),o=this.env.model.getters.findVisibleHeader(e,"ROW",ze(0,this.env.model.getters.getNumberRows(e)).reverse());this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP"),"CTRL+K":()=>Xr(this.env)}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=Ln(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())),Qg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=Jg(((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 gi({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}focus(){this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||this.hiddenInput.el.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}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:N,gridOffsetY:O})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getClientPositionKey(e){var t,o,i;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(o=e.position)||void 0===o?void 0:o.col}-${null===(i=e.position)||void 0===i?void 0:i.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:o,shiftKey:i}){o&&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"),i?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,s=t;Ig(this.env,((e,t)=>{(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 o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:o,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t}).type===Ji.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(),ju(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 o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):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:o,top:i}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?n="COL":this.env.model.getters.getActiveRows().has(i)&&(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:o,y:i}){const n=this.env.model.getters.getSelectedZones();let s="CELL";qo(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,o,i)}toggleContextMenu(e,t,o){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=ap[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const o=t.clipboardData;if(!o)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?br(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();for(const e in i)o.setData(e,i[e]);t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(en.PlainText)>-1){const e=t.getData(en.PlainText),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?yr(this.env,o):xr(this.env,o,e)}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(s("Copy/Paste is not supported in this browser."))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}lp.template="o-spreadsheet-Grid",lp.components={GridComposer:Vg,GridOverlay:qg,GridPopover:Zg,HeadersOverlay:Kg,Menu:Wn,Autofill:Rg,ClientTag:Ag,Highlight:op,Popover:zn,VerticalScrollBar:rp,HorizontalScrollBar:sp,FilterIconsOverlay:$g},lp.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class cp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const hp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],dp="000000",up={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},gp={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"},pp="http://schemas.openxmlformats.org/drawingml/2006/main",mp="http://schemas.openxmlformats.org/drawingml/2006/chart",fp={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"},vp={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"},bp="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Sp=.75,Cp=.1317,Ep=8.43,wp=12.75,yp=30,xp=100,Ip=164,Rp={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}]},Tp=["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"],Ap="[Content_Types].xml";var Mp;!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"}(Mp||(Mp={}));class Op{constructor(){this._parsingWarnings=new Set,this._conversionWarnings=new Set}addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,o){let i=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(i+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(i)||this._conversionWarnings.add(i)}}const Np=["thin"],_p=["general","left","center","right"],Fp=["Arial"],Dp=["solid"],kp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Pp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},Lp={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"},Up={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Vp={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"},Bp={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"},Hp={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},$p={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},Wp={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"},Gp={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},Zp={0:"000000",1:"FFFFFF",2:"FF0000",3:"00FF00",4:"0000FF",5:"FFFF00",6:"FF00FF",7:"00FFFF",8:"000000",9:"FFFFFF",10:"FF0000",11:"00FF00",12:"0000FF",13:"FFFF00",14:"FF00FF",15:"00FFFF",16:"800000",17:"008000",18:"000080",19:"808000",20:"800080",21:"008080",22:"C0C0C0",23:"808080",24:"9999FF",25:"993366",26:"FFFFCC",27:"CCFFFF",28:"660066",29:"FF8080",30:"0066CC",31:"CCCCFF",32:"000080",33:"FF00FF",34:"FFFF00",35:"00FFFF",36:"800080",37:"800000",38:"008080",39:"0000FF",40:"00CCFF",41:"CCFFFF",42:"CCFFCC",43:"FFFF99",44:"99CCFF",45:"FF99CC",46:"CC99FF",47:"FFCC99",48:"3366FF",49:"33CCCC",50:"99CC00",51:"FFCC00",52:"FF9900",53:"FF6600",54:"666699",55:"969696",56:"003366",57:"339966",58:"003300",59:"333300",60:"993300",61:"993366",62:"333399",63:"333333",64:"000000",65:"FFFFFF"};function jp(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=dp;else{if(!e.indexed)return;t=Zp[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=xt(e),i=Rt(o);t<0&&(i.l=i.l*(1+t));t>0&&(i.l=i.l*(1-t)+(100-100*(1-t)));return yt(It(i))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function Xp(e,t){const o=e.split("/"),i=t.split("/");let n="",s=0;for(let e=0;e<o.length-1;e++)o[e]===i[e]?s++:n+="../";return n+=i.slice(s).join("/"),n}function Yp(e,t=0){const o={};for(let i=0;i<e.length;i++)e[i]&&(o[i+t]=e[i]);return o}function Kp(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function Qp(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const Jp=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function em(e,t,o){var i,n,s;if(0===e)return;let r=Gp[e]||(null===(i=t.find((t=>t.id===e)))||void 0===i?void 0:i.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(Jp)}(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 ho(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}o.generateNotSupportedWarning(Mp.NumFmtIdNotSupported,r||`nmFmtId ${e}`)}function tm(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(Mp.DiagonalBorderNotSupported)}(e,t);const o={top:om(e.top,t),bottom:om(e.bottom,t),left:om(e.left,t),right:om(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return Yp(o,1)}function om(e,t){if(!e)return;!function(e,t){Np.includes(e.style)||t.generateNotSupportedWarning(Mp.BorderStyleNotSupported,e.style,Np)}(e,t);const o=Lp[e.style];return o?[o,jp(e.color)]:void 0}function im(e,t){return Yp(e.styles.map((o=>nm({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function nm(e,t){var o,i,n,s,r,a,l,c,h,d,u,g;return function(e,t,o){e&&e.name&&!Fp.includes(e.name)&&o.generateNotSupportedWarning(Mp.FontNotSupported,e.name,Fp);t&&t.patternType&&!Dp.includes(t.patternType)&&o.generateNotSupportedWarning(Mp.FillStyleNotSupported,t.patternType,Dp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!_p.includes(e)&&t.generateNotSupportedWarning(Mp.HorizontalAlignmentNotSupported,e,_p)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(Mp.VerticalAlignmentNotSupported)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.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)?Up[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?jp(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):jp(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:jp(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:null===(g=e.fontStyle)||void 0===g?void 0:g.size}}function sm(e,t){const o=[];for(let i of e.styles){const n=em(i.numFmtId,e.numFmts,t);n&&(o[i.numFmtId]=n)}return Yp(o,1)}function rm(e,t,o){const i=[];let n=1;for(let r of e){if(0===r.cfRules.length)continue;hm(r,t,o);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=am(n++,r);t&&i.push(t);continue;case"iconSet":const c=lm(n++,r,o);c&&i.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Vp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Vp[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&&i.push({id:(n++).toString(),ranges:r.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:nm({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var s;return i}function am(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const i=[];for(let e=0;e<o.cfvos.length;e++)i.push({color:(n=jp(o.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:zp[o.cfvos[e].type],value:o.cfvos[e].value});var n;const s=i[0],r=2===i.length?i[1]:i[2],a=3===i.length?i[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 lm(e,t,o){const i=t.cfRules[0].iconSet;if(!i)return;let n=i.cfvos,s=i.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?cm(s[0].iconSet,s[0].iconId):cm(i.iconSet,0),middle:s?cm(s[1].iconSet,s[1].iconId):cm(i.iconSet,1),upper:s?cm(s[2].iconSet,s[2].iconId):cm(i.iconSet,2)};i.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(Mp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=fg.dots.good;break;case"middle":a[e]=fg.dots.neutral;break;case"lower":a[e]=fg.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 cm(e,t){const o=Bp[e];return o?0===t?fg[o].bad:1===t?fg[o].neutral:fg[o].good:""}function hm(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(Mp.MultipleRulesCfNotSupported),kp.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(Mp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const i=t[e.cfRules[0].dxfId];i.border&&o.generateNotSupportedWarning(Mp.CfFormatBorderNotSupported),i.alignment&&o.generateNotSupportedWarning(Mp.CfFormatAlignmentNotSupported),i.numFmt&&o.generateNotSupportedWarning(Mp.CfFormatNumFmtNotSupported)}}function dm(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function um(e){return Math.round(Sp*e*100)/100}function gm(e){return Math.round(Cp*e*100)/100}function pm(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function mm(e,t){let o={};e.style&&(o=t.styles[e.style]);const i=e.format?t.formats[e.format]:void 0,n={};if(e.border){const o=t.borders[e.border];n.left=pm(o.left),n.right=pm(o.right),n.bottom=pm(o.bottom),n.top=pm(o.top)}const s={font:{size:(null==o?void 0:o.fontSize)||G,color:{rgb:(null==o?void 0:o.textColor)?o.textColor:"000000"},family:2,name:"Arial"},fill:(null==o?void 0:o.fillColor)?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:i?{format:i,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:o.align}};return s.font.strike=!!(null==o?void 0:o.strikethrough)||void 0,s.font.underline=!!(null==o?void 0:o.underline)||void 0,s.font.bold=!!(null==o?void 0:o.bold)||void 0,s.font.italic=!!(null==o?void 0:o.italic)||void 0,s}function fm(e,t){const{id:o}=bm(t.font,e.fonts),{id:i}=bm(t.fill,e.fills),{id:n}=bm(t.border,e.borders),s=function(e,t){if(!e)return 0;let o=qp[e.format];if(!o){const{id:i}=bm(e,t);o=i+Ip}return o}(t.numFmt,e.numFmts),r={fontId:o,fillId:i,borderId:n,numFmtId:s,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=bm(r,e.styles);return a}function vm(e,t,o){let i,n=e.find((e=>e.path===t));return n?(i=`rId${(n.rels.length+1).toString()}`,n.rels.push({...o,id:i})):(i="rId1",e.push({path:t,rels:[{...o,id:i}]})),i}function bm(e,t){for(let[o,i]of Object.entries(t))if(JSON.stringify(i)===JSON.stringify(e))return{id:parseInt(o,10),list:t};let o=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===o&&(t.push(e),o=t.length-1),{id:o,list:t}}const Sm=[];function Cm(e){const t=Sm.findIndex((t=>t===e));return-1===t?(Sm.push(e),Sm.length):t+1}const Em=[];function wm(e){const t=Em.findIndex((t=>t===e));return-1===t?(Em.push(e),Em.length):t+1}function ym(e){return Math.round(914400*e/96)}function xm(e,t,o){let i,n,s=e;if(({xc:s,sheetName:i}=Lt(e)),i){const e=o.sheets.findIndex((e=>e.name===i));if(e<0)throw new Error("Unable to find a sheet with the name "+i);n=e}else n=Number(t);const r=Do(s);return void 0===r.right&&(r.right=o.sheets[n].colNumber),void 0===r.bottom&&(r.bottom=o.sheets[n].rowNumber),(r.right-r.left+1)*(r.bottom-r.top+1)}function Im(e){return Math.round(96*e/914400)}function Rm(e,t){var o;let i=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)?i+=e.width:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?i+=t.sheetFormat.defaultColWidth:i+=Ep}return i/Cp}function Tm(e,t){var o;let i=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?i+=e.height:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?i+=t.sheetFormat.defaultRowHeight:i+=wp}return i/Sp}function Am(e){let t=1;return e.figures.map((o=>function(e,t,o){const i=Rm(e.anchors[0].col,o)+Im(e.anchors[0].colOffset),n=Rm(e.anchors[1].col,o)+Im(e.anchors[1].colOffset),s=Tm(e.anchors[0].row,o)+Im(e.anchors[0].rowOffset),r=Tm(e.anchors[1].row,o)+Im(e.anchors[1].rowOffset),a=n-i,l=r-s,c=Mm(e.data);return c?{id:t,x:i,y:s,width:a,height:l,tag:"chart",data:Mm(e.data)}:void 0}(o,(t++).toString(),e))).filter(et)}function Mm(e){var t;const o=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let i=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&i.reverse(),{dataSets:i,dataSetsHaveTitle:!1,labelRange:o,title:e.title||"",type:e.type,background:jp({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,labelsAsText:!1}}const Om=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Nm=new RegExp(/SUBTOTAL\(([0-9]*),/g),_m=new RegExp(Tt.source,"ig");function Fm(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let i of e.rows.map((e=>e.cells)).flat())(null==i?void 0:i.formula)&&(i.formula.content=void 0===i.formula.sharedIndex||i.formula.content?"="+i.formula.content:"="+km(i.xc,o[i.formula.sharedIndex]),i.formula.content=Dm(i.formula.content,t))}function Dm(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(Nm,((e,t)=>{const o=Wp[t];return o?o+"(":e}))).replace(Om,((e,o,i,n)=>{var s;o=Number(o)-1,n=n.replace(/\$/g,"");const r=t.externalBooks[o].sheetNames.findIndex((e=>e===i));if(-1===r)return e;const a=null===(s=t.externalBooks[o].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 km(e,t){const o=zt(t.refCellXc);let i,n=t.formula.slice();do{if(i=_m.exec(n),i){const t=zt(i[0].replace("$","")),s=zt(e),r={colFixed:i[0].startsWith("$"),rowFixed:i[0].includes("$",1)},a={col:s.col-o.col,row:s.row-o.row},l={col:r.colFixed?t.col:t.col+a.col,row:r.rowFixed?t.row:t.row+a.row};n=n.slice(0,i.index)+Bt(l.col,l.row,r)+n.slice(i.index+i[0].length)}}while(i);return n}function Pm(e,t){return e.sheets.map((o=>{Fm(o,e);const i=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],...o.cells.map((e=>zt(e.xc).col))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],yp),t[1]=Math.max(t[1],xp),t}(o),n=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!n||n.showGridLines,name:o.sheetName,colNumber:i[0],rowNumber:i[1],cells:Vm(o,e,i,t),merges:o.merges,cols:Lm(o,i[0]),rows:Um(o,i[1]),conditionalFormats:rm(o.cfs,e.dxfs,t),figures:Am(o),isVisible:o.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Lm(e,t){var o;const i={};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===(o=e.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?e.sheetFormat.defaultColWidth:Ep,i[s-1]={size:(n=r,n?Math.round(n/Cp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return i}function Um(e,t){var o;const i={};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===(o=e.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?e.sheetFormat.defaultRowHeight:wp,i[s-1]={size:(n=r,n?Math.round(n/Sp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return i}function Vm(e,t,o,i){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 o of e.rows)for(let e of o.cells)n[e.xc]={content:zm(e,r,s,i),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 i of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=Bt(e-1,i.index-1);let s=n[o];s||(s={},n[o]=s),s.style=s.style?s.style:i.styleIndex+1,s.border=s.border?s.border:t.styles[i.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[i.styleIndex].numFmtId+1}for(let i of e.cols.filter((e=>e.styleIndex)))for(let e=i.min;e<=Math.min(i.max,o[0]);e++)for(let s=1;s<=o[1];s++){const o=Bt(e-1,s-1);let r=n[o];r||(r={},n[o]=r),r.style=r.style?r.style:i.styleIndex+1,r.border=r.border?r.border:t.styles[i.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[i.styleIndex].numFmtId+1}return n}function zm(e,t,o,i){let n;switch(e.type){case"sharedString":n=o[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,o){const i=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(Mp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:Qe(Lt(e.location).sheetName);return je(i,n)}(t[e.xc],n,i)),e.formula&&(n=e.formula.content),n}const Bm={fillColor:"#000000",textColor:"#ffffff",bold:!0},Hm={bold:!0},$m=["thin","#000000FF"];function Wm(e,t){for(const o of t.sheets)for(const t of o.tables){const i=e.sheets.find((e=>e.name===o.sheetName));i&&t.autoFilter&&(i.filterTables||(i.filterTables=[]),i.filterTables.push({range:t.ref}))}!function(e,t){var o,i,n,s;const r=Kp(e.styles),a=Kp(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=ko(t.ref);for(let e=0;e<t.headerRowCount;e++)Gm(Bm,{...h,bottom:h.top+e},c.cells,r);for(let e=0;e<t.totalsRowCount;e++)Gm(Hm,{...h,top:h.bottom-e},c.cells,r);(null===(o=t.style)||void 0===o?void 0:o.showFirstColumn)&&Gm(Hm,{...h,right:h.left},c.cells,r),(null===(i=t.style)||void 0===i?void 0:i.showLastColumn)&&Gm(Hm,{...h,left:h.right},c.cells,r);for(let e=h.left;e<=h.right;e++)for(let o=h.top;o<=h.bottom;o++){const i=Bt(e,o),r=c.cells[i],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?$m:void 0,right:e===h.right?$m:void 0,top:o===h.top||(null===(s=t.style)||void 0===s?void 0:s.showRowStripes)||o>h.bottom-t.totalsRowCount?$m:void 0,bottom:o===h.bottom?$m:void 0},d=(null==r?void 0:r.border)?{...a[r.border],...l}:l;let u=a.findIndex((e=>at(e,d)));-1===u&&(u=a.length,a.push(d)),r?r.border=u:c.cells[i]={border:u}}}e.styles=Yp(r),e.borders=Yp(a)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let i of Qo(ko(t.ref))){const n=Bt(i.col,i.row),s=o.cells[n];if(s&&s.content&&s.content.startsWith("=")){let o;for(;-1!==(o=s.content.indexOf(e));){let i=s.content.slice(o+e.length),r=i.indexOf("]");i.startsWith("[")&&(r=i.indexOf("]",r+1),r=i.indexOf("]",r+1)),i=i.slice(0,r);const a=qm(i,t,n);s.content=s.content.slice(0,o)+a+s.content.slice(e.length+o+r+1)}}}}}}(e.sheets,t.sheets)}function Gm(e,t,o,i){for(let n=t.left;n<=t.right;n++)for(let s=t.top;s<=t.bottom;s++){const t=Bt(n,s),r=o[t],a=(null==r?void 0:r.style)?{...i[r.style],...e}:e;let l=i.findIndex((e=>at(e,a)));-1===l&&(l=i.length,i.push(a)),r?r.style=l:o[t]={style:l}}}function qm(e,t,o){const i=e.split(","),n=ko(t.ref),s={...n};let r=!0;if(1===i.length){const e=t.cols.findIndex((e=>e.name===i[0]));s.left=s.right=e+n.left,t.headerRowCount&&(s.top+=t.headerRowCount),t.totalsRowCount&&(s.bottom-=1)}else{switch(i[0].slice(1,i[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=zt(o).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=i[1].slice(1,i[1].length-1),a=t.cols.findIndex((t=>t.name===e));s.left=s.right=a+n.left}return r?s.top!==s.bottom?Lo(s):Bt(s.left,s.top):Y}function Zm(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function jm(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'")}function Xm(e){return new cp(e.map((([e,t])=>`${e}="${jm(t)}"`)).join(" "))}function Ym(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),i=o.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),s=n.slice(Math.max(o-3,0),Math.min(o+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${s}`)}return o}function Km(e,t){return Jm`
|
|
1378
|
+
/>`,ap.defaultProps={topOffset:0},ap.props={topOffset:{type:Number,optional:!0}};const lp={ROW:ia,COL:oa,CELL:ta};class cp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=O,this.HEADER_WIDTH=N,this.keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===en.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===en.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(),o=this.env.model.getters.getSelectedZone(),{anchor:i}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,o,i.cell);if(this.env.model.getters.isSingleCellOrMerge(t,o)||this.env.model.getters.isEmpty(t,o)&&n.length<=1){const o=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",i=`=SUM(${o})`;this.props.onGridComposerCellFocused(i,{start:5,end:5+o.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:o}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,o)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),o=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,o)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},o=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:o,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP"),"CTRL+K":()=>Yr(this.env)}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=Un(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())),Jg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=ep(((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 pi({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:N,gridOffsetY:O})}moveCanvas(e,t){const{scrollX:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getClientPositionKey(e){var t,o,i;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(o=e.position)||void 0===o?void 0:o.col}-${null===(i=e.position)||void 0===i?void 0:i.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:o,shiftKey:i}){o&&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"),i?this.env.model.selection.setAnchorCorner(e,t):o?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,s=t;Rg(this.env,((e,t)=>{(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 o=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:o,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:o,col:e,row:t}).type===en.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(),Xu(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 o=this.keyDownMapping[t];return o?(e.preventDefault(),e.stopPropagation(),void o()):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:o,top:i}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(o)?n="COL":this.env.model.getters.getActiveRows().has(i)&&(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:o,y:i}){const n=this.env.model.getters.getSelectedZones();let s="CELL";Zo(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,o,i)}toggleContextMenu(e,t,o){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:o},this.menuState.menuItems=lp[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const o=t.clipboardData;if(!o)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?Sr(this.env):this.env.model.dispatch("COPY");const i=this.env.model.getters.getClipboardContent();for(const e in i)o.setData(e,i[e]);t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(tn.PlainText)>-1){const e=t.getData(tn.PlainText),o=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?xr(this.env,o):Ir(this.env,o,e)}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(s("Copy/Paste is not supported in this browser."))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}cp.template="o-spreadsheet-Grid",cp.components={GridComposer:zg,GridOverlay:Zg,GridPopover:jg,HeadersOverlay:Qg,Menu:Gn,Autofill:Tg,ClientTag:Mg,Highlight:ip,Popover:Bn,VerticalScrollBar:ap,HorizontalScrollBar:rp,FilterIconsOverlay:Wg},cp.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class hp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const dp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],up="000000",gp={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},pp={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"},mp="http://schemas.openxmlformats.org/drawingml/2006/main",fp="http://schemas.openxmlformats.org/drawingml/2006/chart",vp={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"},bp={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"},Sp="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Cp=.75,Ep=.1317,wp=8.43,yp=12.75,xp=30,Ip=100,Rp=164,Tp={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}]},Ap=["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"],Mp="[Content_Types].xml";var Op;!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"}(Op||(Op={}));class Np{constructor(){this._parsingWarnings=new Set,this._conversionWarnings=new Set}addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,o){let i=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;o&&(i+=`Only ${o.join(", ")} are currently supported.`),this._conversionWarnings.has(i)||this._conversionWarnings.add(i)}}const _p=["thin"],Fp=["general","left","center","right"],Dp=["Arial"],kp=["solid"],Pp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Lp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},Up={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"},Vp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const zp={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},Bp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},Hp={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"},$p={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},Wp={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},Gp={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},Zp={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"};function Xp(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=up;else{if(!e.indexed)return;t=jp[e.indexed]}var o;return t=6===(o=t).length?"#"+o+"FF":"#"+o.slice(2)+o.slice(0,2),e.tint&&(t=function(e,t){const o=xt(e),i=Rt(o);t<0&&(i.l=i.l*(1+t));t>0&&(i.l=i.l*(1-t)+(100-100*(1-t)));return yt(It(i))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function Yp(e,t){const o=e.split("/"),i=t.split("/");let n="",s=0;for(let e=0;e<o.length-1;e++)o[e]===i[e]?s++:n+="../";return n+=i.slice(s).join("/"),n}function Kp(e,t=0){const o={};for(let i=0;i<e.length;i++)e[i]&&(o[i+t]=e[i]);return o}function Qp(e){const t=[];for(let o of Object.keys(e).map(Number))t[o]=e[o];return t}function Jp(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const em=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function tm(e,t,o){var i,n,s;if(0===e)return;let r=qp[e]||(null===(i=t.find((t=>t.id===e)))||void 0===i?void 0:i.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(em)}(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 ho(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}o.generateNotSupportedWarning(Op.NumFmtIdNotSupported,r||`nmFmtId ${e}`)}function om(e,t){const o=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(Op.DiagonalBorderNotSupported)}(e,t);const o={top:im(e.top,t),bottom:im(e.bottom,t),left:im(e.left,t),right:im(e.right,t)};return Object.keys(o).forEach((e=>void 0===o[e]&&delete o[e])),o}));return Kp(o,1)}function im(e,t){if(!e)return;!function(e,t){_p.includes(e.style)||t.generateNotSupportedWarning(Op.BorderStyleNotSupported,e.style,_p)}(e,t);const o=Up[e.style];return o?[o,Xp(e.color)]:void 0}function nm(e,t){return Kp(e.styles.map((o=>sm({fontStyle:e.fonts[o.fontId],fillStyle:e.fills[o.fillId],alignment:o.alignment},t))),1)}function sm(e,t){var o,i,n,s,r,a,l,c,h,d,u,g;return function(e,t,o){e&&e.name&&!Dp.includes(e.name)&&o.generateNotSupportedWarning(Op.FontNotSupported,e.name,Dp);t&&t.patternType&&!kp.includes(t.patternType)&&o.generateNotSupportedWarning(Op.FillStyleNotSupported,t.patternType,kp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!Fp.includes(e)&&t.generateNotSupportedWarning(Op.HorizontalAlignmentNotSupported,e,Fp)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(Op.VerticalAlignmentNotSupported)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.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)?Vp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?Xp(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):Xp(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:Xp(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:null===(g=e.fontStyle)||void 0===g?void 0:g.size}}function rm(e,t){const o=[];for(let i of e.styles){const n=tm(i.numFmtId,e.numFmts,t);n&&(o[i.numFmtId]=n)}return Kp(o,1)}function am(e,t,o){const i=[];let n=1;for(let r of e){if(0===r.cfRules.length)continue;dm(r,t,o);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=lm(n++,r);t&&i.push(t);continue;case"iconSet":const c=cm(n++,r,o);c&&i.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=zp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=zp[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&&i.push({id:(n++).toString(),ranges:r.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:sm({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},o)}})}}var s;return i}function lm(e,t){const o=t.cfRules[0].colorScale;if(!o||o.cfvos.length!==o.colors.length||o.cfvos.length<2||o.cfvos.length>3)return;const i=[];for(let e=0;e<o.cfvos.length;e++)i.push({color:(n=Xp(o.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:Bp[o.cfvos[e].type],value:o.cfvos[e].value});var n;const s=i[0],r=2===i.length?i[1]:i[2],a=3===i.length?i[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 cm(e,t,o){const i=t.cfRules[0].iconSet;if(!i)return;let n=i.cfvos,s=i.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=Bp[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?hm(s[0].iconSet,s[0].iconId):hm(i.iconSet,0),middle:s?hm(s[1].iconSet,s[1].iconId):hm(i.iconSet,1),upper:s?hm(s[2].iconSet,s[2].iconId):hm(i.iconSet,2)};i.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(o.generateNotSupportedWarning(Op.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=vg.dots.good;break;case"middle":a[e]=vg.dots.neutral;break;case"lower":a[e]=vg.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 hm(e,t){const o=Hp[e];return o?0===t?vg[o].bad:1===t?vg[o].neutral:vg[o].good:""}function dm(e,t,o){if(e.cfRules.length>1&&o.generateNotSupportedWarning(Op.MultipleRulesCfNotSupported),Pp.includes(e.cfRules[0].type)||o.generateNotSupportedWarning(Op.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const i=t[e.cfRules[0].dxfId];i.border&&o.generateNotSupportedWarning(Op.CfFormatBorderNotSupported),i.alignment&&o.generateNotSupportedWarning(Op.CfFormatAlignmentNotSupported),i.numFmt&&o.generateNotSupportedWarning(Op.CfFormatNumFmtNotSupported)}}function um(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function gm(e){return Math.round(Cp*e*100)/100}function pm(e){return Math.round(Ep*e*100)/100}function mm(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function fm(e,t){let o={};e.style&&(o=t.styles[e.style]);const i=e.format?t.formats[e.format]:void 0,n={};if(e.border){const o=t.borders[e.border];n.left=mm(o.left),n.right=mm(o.right),n.bottom=mm(o.bottom),n.top=mm(o.top)}const s={font:{size:(null==o?void 0:o.fontSize)||G,color:{rgb:(null==o?void 0:o.textColor)?o.textColor:"000000"},family:2,name:"Arial"},fill:(null==o?void 0:o.fillColor)?{fgColor:{rgb:o.fillColor}}:{reservedAttribute:"none"},numFmt:i?{format:i,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:o.align}};return s.font.strike=!!(null==o?void 0:o.strikethrough)||void 0,s.font.underline=!!(null==o?void 0:o.underline)||void 0,s.font.bold=!!(null==o?void 0:o.bold)||void 0,s.font.italic=!!(null==o?void 0:o.italic)||void 0,s}function vm(e,t){const{id:o}=Sm(t.font,e.fonts),{id:i}=Sm(t.fill,e.fills),{id:n}=Sm(t.border,e.borders),s=function(e,t){if(!e)return 0;let o=Zp[e.format];if(!o){const{id:i}=Sm(e,t);o=i+Rp}return o}(t.numFmt,e.numFmts),r={fontId:o,fillId:i,borderId:n,numFmtId:s,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=Sm(r,e.styles);return a}function bm(e,t,o){let i,n=e.find((e=>e.path===t));return n?(i=`rId${(n.rels.length+1).toString()}`,n.rels.push({...o,id:i})):(i="rId1",e.push({path:t,rels:[{...o,id:i}]})),i}function Sm(e,t){for(let[o,i]of Object.entries(t))if(JSON.stringify(i)===JSON.stringify(e))return{id:parseInt(o,10),list:t};let o=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===o&&(t.push(e),o=t.length-1),{id:o,list:t}}const Cm=[];function Em(e){const t=Cm.findIndex((t=>t===e));return-1===t?(Cm.push(e),Cm.length):t+1}const wm=[];function ym(e){const t=wm.findIndex((t=>t===e));return-1===t?(wm.push(e),wm.length):t+1}function xm(e){return Math.round(914400*e/96)}function Im(e,t,o){let i,n,s=e;if(({xc:s,sheetName:i}=Lt(e)),i){const e=o.sheets.findIndex((e=>e.name===i));if(e<0)throw new Error("Unable to find a sheet with the name "+i);n=e}else n=Number(t);const r=ko(s);return void 0===r.right&&(r.right=o.sheets[n].colNumber),void 0===r.bottom&&(r.bottom=o.sheets[n].rowNumber),(r.right-r.left+1)*(r.bottom-r.top+1)}function Rm(e){return Math.round(96*e/914400)}function Tm(e,t){var o;let i=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)?i+=e.width:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?i+=t.sheetFormat.defaultColWidth:i+=wp}return i/Ep}function Am(e,t){var o;let i=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?i+=e.height:(null===(o=t.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?i+=t.sheetFormat.defaultRowHeight:i+=yp}return i/Cp}function Mm(e){let t=1;return e.figures.map((o=>function(e,t,o){const i=Tm(e.anchors[0].col,o)+Rm(e.anchors[0].colOffset),n=Tm(e.anchors[1].col,o)+Rm(e.anchors[1].colOffset),s=Am(e.anchors[0].row,o)+Rm(e.anchors[0].rowOffset),r=Am(e.anchors[1].row,o)+Rm(e.anchors[1].rowOffset),a=n-i,l=r-s,c=Om(e.data);return c?{id:t,x:i,y:s,width:a,height:l,tag:"chart",data:Om(e.data)}:void 0}(o,(t++).toString(),e))).filter(et)}function Om(e){var t;const o=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let i=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&i.reverse(),{dataSets:i,dataSetsHaveTitle:!1,labelRange:o,title:e.title||"",type:e.type,background:Xp({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,labelsAsText:!1}}const Nm=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),_m=new RegExp(/SUBTOTAL\(([0-9]*),/g),Fm=new RegExp(Tt.source,"ig");function Dm(e,t){const o=function(e){const t={};for(let o of e.rows)for(let e of o.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let i of e.rows.map((e=>e.cells)).flat())(null==i?void 0:i.formula)&&(i.formula.content=void 0===i.formula.sharedIndex||i.formula.content?"="+i.formula.content:"="+Pm(i.xc,o[i.formula.sharedIndex]),i.formula.content=km(i.formula.content,t))}function km(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(_m,((e,t)=>{const o=Gp[t];return o?o+"(":e}))).replace(Nm,((e,o,i,n)=>{var s;o=Number(o)-1,n=n.replace(/\$/g,"");const r=t.externalBooks[o].sheetNames.findIndex((e=>e===i));if(-1===r)return e;const a=null===(s=t.externalBooks[o].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 Pm(e,t){const o=zt(t.refCellXc);let i,n=t.formula.slice();do{if(i=Fm.exec(n),i){const t=zt(i[0].replace("$","")),s=zt(e),r={colFixed:i[0].startsWith("$"),rowFixed:i[0].includes("$",1)},a={col:s.col-o.col,row:s.row-o.row},l={col:r.colFixed?t.col:t.col+a.col,row:r.rowFixed?t.row:t.row+a.row};n=n.slice(0,i.index)+Bt(l.col,l.row,r)+n.slice(i.index+i[0].length)}}while(i);return n}function Lm(e,t){return e.sheets.map((o=>{Dm(o,e);const i=function(e){const t=[0,0];for(let o of e.rows)t[0]=Math.max(t[0],...o.cells.map((e=>zt(e.xc).col))),t[1]=Math.max(t[1],o.index);return t[0]=Math.max(t[0],xp),t[1]=Math.max(t[1],Ip),t}(o),n=o.sheetViews[0];return{id:o.sheetName,areGridLinesVisible:!n||n.showGridLines,name:o.sheetName,colNumber:i[0],rowNumber:i[1],cells:zm(o,e,i,t),merges:o.merges,cols:Um(o,i[0]),rows:Vm(o,i[1]),conditionalFormats:am(o.cfs,e.dxfs,t),figures:Mm(o),isVisible:o.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Um(e,t){var o;const i={};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===(o=e.sheetFormat)||void 0===o?void 0:o.defaultColWidth)?e.sheetFormat.defaultColWidth:wp,i[s-1]={size:(n=r,n?Math.round(n/Ep*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return i}function Vm(e,t){var o;const i={};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===(o=e.sheetFormat)||void 0===o?void 0:o.defaultRowHeight)?e.sheetFormat.defaultRowHeight:yp,i[s-1]={size:(n=r,n?Math.round(n/Cp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return i}function zm(e,t,o,i){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 o of e.rows)for(let e of o.cells)n[e.xc]={content:Bm(e,r,s,i),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 i of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=o[0];e++){const o=Bt(e-1,i.index-1);let s=n[o];s||(s={},n[o]=s),s.style=s.style?s.style:i.styleIndex+1,s.border=s.border?s.border:t.styles[i.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[i.styleIndex].numFmtId+1}for(let i of e.cols.filter((e=>e.styleIndex)))for(let e=i.min;e<=Math.min(i.max,o[0]);e++)for(let s=1;s<=o[1];s++){const o=Bt(e-1,s-1);let r=n[o];r||(r={},n[o]=r),r.style=r.style?r.style:i.styleIndex+1,r.border=r.border?r.border:t.styles[i.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[i.styleIndex].numFmtId+1}return n}function Bm(e,t,o,i){let n;switch(e.type){case"sharedString":n=o[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,o){const i=e.display||t;e.relTarget||e.location||o.generateNotSupportedWarning(Op.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:Qe(Lt(e.location).sheetName);return je(i,n)}(t[e.xc],n,i)),e.formula&&(n=e.formula.content),n}const Hm={fillColor:"#000000",textColor:"#ffffff",bold:!0},$m={bold:!0},Wm=["thin","#000000FF"];function Gm(e,t){for(const o of t.sheets)for(const t of o.tables){const i=e.sheets.find((e=>e.name===o.sheetName));i&&t.autoFilter&&(i.filterTables||(i.filterTables=[]),i.filterTables.push({range:t.ref}))}!function(e,t){var o,i,n,s;const r=Qp(e.styles),a=Qp(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=Po(t.ref);for(let e=0;e<t.headerRowCount;e++)qm(Hm,{...h,bottom:h.top+e},c.cells,r);for(let e=0;e<t.totalsRowCount;e++)qm($m,{...h,top:h.bottom-e},c.cells,r);(null===(o=t.style)||void 0===o?void 0:o.showFirstColumn)&&qm($m,{...h,right:h.left},c.cells,r),(null===(i=t.style)||void 0===i?void 0:i.showLastColumn)&&qm($m,{...h,left:h.right},c.cells,r);for(let e=h.left;e<=h.right;e++)for(let o=h.top;o<=h.bottom;o++){const i=Bt(e,o),r=c.cells[i],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?Wm:void 0,right:e===h.right?Wm:void 0,top:o===h.top||(null===(s=t.style)||void 0===s?void 0:s.showRowStripes)||o>h.bottom-t.totalsRowCount?Wm:void 0,bottom:o===h.bottom?Wm:void 0},d=(null==r?void 0:r.border)?{...a[r.border],...l}:l;let u=a.findIndex((e=>at(e,d)));-1===u&&(u=a.length,a.push(d)),r?r.border=u:c.cells[i]={border:u}}}e.styles=Kp(r),e.borders=Kp(a)}(e,t),function(e,t){for(let o of e){const e=t.find((e=>e.sheetName===o.name)).tables;for(let t of e){const e=t.name+"[";for(let i of Jo(Po(t.ref))){const n=Bt(i.col,i.row),s=o.cells[n];if(s&&s.content&&s.content.startsWith("=")){let o;for(;-1!==(o=s.content.indexOf(e));){let i=s.content.slice(o+e.length),r=i.indexOf("]");i.startsWith("[")&&(r=i.indexOf("]",r+1),r=i.indexOf("]",r+1)),i=i.slice(0,r);const a=Zm(i,t,n);s.content=s.content.slice(0,o)+a+s.content.slice(e.length+o+r+1)}}}}}}(e.sheets,t.sheets)}function qm(e,t,o,i){for(let n=t.left;n<=t.right;n++)for(let s=t.top;s<=t.bottom;s++){const t=Bt(n,s),r=o[t],a=(null==r?void 0:r.style)?{...i[r.style],...e}:e;let l=i.findIndex((e=>at(e,a)));-1===l&&(l=i.length,i.push(a)),r?r.style=l:o[t]={style:l}}}function Zm(e,t,o){const i=e.split(","),n=Po(t.ref),s={...n};let r=!0;if(1===i.length){const e=t.cols.findIndex((e=>e.name===i[0]));s.left=s.right=e+n.left,t.headerRowCount&&(s.top+=t.headerRowCount),t.totalsRowCount&&(s.bottom-=1)}else{switch(i[0].slice(1,i[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=zt(o).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=i[1].slice(1,i[1].length-1),a=t.cols.findIndex((t=>t.name===e));s.left=s.right=a+n.left}return r?s.top!==s.bottom?Uo(s):Bt(s.left,s.top):Y}function jm(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function Xm(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'")}function Ym(e){return new hp(e.map((([e,t])=>`${e}="${Xm(t)}"`)).join(" "))}function Km(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),i=o.querySelector("parsererror");if(i){const t=i.innerHTML,o=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),s=n.slice(Math.max(o-3,0),Math.min(o+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${s}`)}return o}function Qm(e,t){return ef`
|
|
1379
1379
|
<Override ContentType="${t}" PartName="${e}" />
|
|
1380
|
-
`}function Qm(e){return new cp(e.join("\n"))}function Jm(e,...t){let o=[e[0]];for(let i=0;i<t.length;i++){const n=t[i]instanceof cp?t[i]:jm(t[i]);o.push(n+e[i+1])}return new cp(it(o))}function ef(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function tf(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class of{constructor(e){this.value=e}asString(){return Qp(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class nf{constructor(e,t,o){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(et)}mapOnElements(e,t){var o;const i=[],n=this.currentFile;let s;if(e.children){const t=null===(o=this.querySelector(e.parent,e.query))||void 0===o?void 0:o.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{i.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,i}catchErrorOnElement(e,t){const o=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([o,e.message].join("\n"))}extractAttr(e,t,o){const i=e.attributes[t];i||this.handleMissingValue(e,`attribute "${t}"`,o);const n=(null==i?void 0:i.value)?i.value:null==o?void 0:o.default;return void 0===n?void 0:new of(n)}extractTextContent(e,t){var o;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const i="preserve"===(null===(o=null==e?void 0:e.attributes["xml:space"])||void 0===o?void 0:o.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=i?n:n.trim()),n?Qp(n):null==t?void 0:t.default}extractChildAttr(e,t,o,i){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}>`,i);const r=s?null===(n=this.extractAttr(s,o,i))||void 0===n?void 0:n.asString():null==i?void 0:i.default;return void 0!==r?new of(r):void 0}extractChildTextContent(e,t,o){if(void 0!==(null==o?void 0:o.default)&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let i=this.querySelector(e,t);return i||this.handleMissingValue(e,`child <${t}>`,o),i?this.extractTextContent(i,o):null==o?void 0:o.default}handleMissingValue(e,t,o){if(null==o?void 0:o.required){if(!(null==o?void 0:o.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${o.default}`)}}extractColor(e,t,o){var i,n,s,r,a;if(!e)return o?{rgb:o}:void 0;const l=null===(i=this.extractAttr(e,"theme"))||void 0===i?void 0:i.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 o=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}querySelector(e,t){return t=this.areNamespaceIgnored?ef(t):tf(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?ef(t):tf(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 sf extends nf{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:dp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:dp}).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 rf extends nf{constructor(e,t,o,i){super(e,t,o),this.theme=i}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var o,i,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===(o=this.extractAttr(e,"dxfId"))||void 0===o?void 0:o.asNum(),stopIfTrue:null===(i=this.extractAttr(e,"stopIfTrue"))||void 0===i?void 0:i.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 o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){var t,o;const i=this.querySelector(e,"iconSet, x14:iconSet");if(i)return{iconSet:this.extractAttr(i,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(i,"showValue",{default:!0}).asBool(),percent:this.extractAttr(i,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(i,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(o=this.extractAttr(i,"custom"))||void 0===o?void 0:o.asBool(),cfvos:this.extractCFVos(i),cfIcons:this.extractCfIcons(i)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,o;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(o=this.extractAttr(e,"val"))||void 0===o?void 0:o.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class af extends nf{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!$p[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),i=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:$p[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:Hp[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===i,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=ef(e.tagName);if(hp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class lf extends nf{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==ef(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),i=new af(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!i)throw new Error("Unable to extract chart definition");return i}}class cf extends nf{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 hf extends nf{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,o,i,n,s;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(o=this.extractAttr(e,"showFirstColumn"))||void 0===o?void 0:o.asBool(),showLastColumn:null===(i=this.extractAttr(e,"showLastColumn"))||void 0===i?void 0:i.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 df extends nf{constructor(e,t,o,i){super(e,t,o),this.theme=i}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=Xp(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=Xp(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new rf(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),i=this.getTargetXmlFile(this.relationships[o]);return new lf(i,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),i=this.getTargetXmlFile(this.relationships[o]);return new hf(i,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 cf(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:Ep.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:wp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,o,i,n,s,r,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(o=this.extractAttr(e,"customWidth"))||void 0===o?void 0:o.asBool(),bestFit:null===(i=this.extractAttr(e,"bestFit"))||void 0===i?void 0:i.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,o,i,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===(o=this.extractAttr(e,"ht"))||void 0===o?void 0:o.asNum(),customHeight:null===(i=this.extractAttr(e,"customHeight"))||void 0===i?void 0:i.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,o,i;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(o=this.extractAttr(e,"s"))||void 0===o?void 0:o.asNum(),type:Pp[null===(i=this.extractAttr(e,"t",{default:"n"}))||void 0===i?void 0:i.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,o;const i=this.querySelector(e,"f");if(i)return{content:this.extractTextContent(i),sharedIndex:null===(t=this.extractAttr(i,"si"))||void 0===t?void 0:t.asNum(),ref:null===(o=this.extractAttr(i,"ref"))||void 0===o?void 0:o.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,o,i,n;const s=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(o=this.extractAttr(e,"ref",{required:!0}))||void 0===o?void 0:o.asString(),location:null===(i=this.extractAttr(e,"location"))||void 0===i?void 0:i.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]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),i=this.extractTextContent(e,{required:!0});o[t]=i}const i=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?i.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),i.push(""));return i}}class uf extends nf{constructor(e,t,o){super(e.styles,e,t),this.theme=o}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,o,i,n;const s=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),r=this.extractChildAttr(e,"sz","val",{default:G.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(o=h.attributes.val)||void 0===o?void 0:o.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(i=u.attributes.val)||void 0===i?void 0:i.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 o=e.children[0];return"patternFill"===o.tagName?{patternType:null===(t=o.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(o,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(o,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(o,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,o;const i={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 i.diagonal&&(i.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),i.diagonalDown=null===(o=this.extractAttr(e,"diagonalDown"))||void 0===o?void 0:o.asBool()),i}extractSingleBorder(e,t,o){const i=this.querySelector(e,t);if(i&&i.attributes.style)return{style:this.extractAttr(i,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(i.children[0],o,"000000")}}extractAlignment(e){var t,o,i,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===(o=this.extractAttr(e,"wrapText"))||void 0===o?void 0:o.asBool(),indent:null===(i=this.extractAttr(e,"indent"))||void 0===i?void 0:i.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"),o=this.querySelector(e,"fill"),i=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),s=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:s?this.extractAlignment(s):void 0,border:i?this.extractBorder(i):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 gf extends nf{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function pf(e,t){const o=function(e,t){const o=t[Ap],i=o.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of i){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const o=[];for(let i of e){const e=mf(i,t);o.push({file:{fileName:i,xml:t[i]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function mf(e,t){if(e===Ap)return"_rels/.rels";let o="";const i=e.split("/");for(let e=0;e<i.length-1;e++)o+=i[e]+"/";return o+="_rels/",o+=i[i.length-1]+".rels",t[o]||(o=void 0),o}class ff{constructor(e){this.warningManager=new Op,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=Ym(new cp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new sf(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new sf(e.sharedStrings,e,this.warningManager).getSharedStrings():[],i=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new df(o,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new gf(t,e,this.warningManager).getExternalBook())),s=new uf(e,this.warningManager,t);return{fonts:s.getFonts(),fills:s.getFills(),borders:s.getBorders(),dxfs:s.getDxfs(),numFmts:s.getNumFormats(),styles:s.getStyles(),sheets:i,sharedStrings:o,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:pf(fp.sheet,this.xmls),workbook:pf(fp.workbook,this.xmls)[0],styles:pf(fp.styles,this.xmls)[0],sharedStrings:pf(fp.sharedStrings,this.xmls)[0],theme:pf(fp.themes,this.xmls)[0],charts:pf(fp.chart,this.xmls),figures:pf(fp.drawing,this.xmls),tables:pf(fp.table,this.xmls),pivots:pf(fp.pivot,this.xmls),externalLinks:pf(fp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(s("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Pm(e,this.warningManager),styles:im(e,this.warningManager),formats:sm(e,this.warningManager),borders:tm(e,this.warningManager),entities:{},revisionId:K};return Wm(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=lt(e.styles[t])})),t}}const vf=Hu.content,bf=["%"],Sf="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(bf);function Cf(e){const t=(e=gt(e)).split(""),o=[];for(;t.length;){let e=Of(t)||yf(t)||If(t)||Tf(t)||Ef(t)||Nf(t)||Rf(t)||Mf(t);e||(e={type:"UNKNOWN",value:t.shift()}),o.push(e)}return o}function Ef(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const wf={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function yf(e){if(e[0]in wf){const t=e.shift();return{type:wf[t],value:t}}return null}function xf(e,t){for(let o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function If(e){for(let t of Sf)if(xf(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Rf(e){const t=it(e).match(qt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Tf(e){if('"'===e[0]){const t=e.shift();let o=t;for(;e[0]&&(e[0]!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e[0]&&(o+=e.shift()),{type:"STRING",value:o}}return null}const Af=/\w|\.|!|\$/;function Mf(e){let t="";if("'"===e[0]){let o=e.shift();for(t+=o;e[0];)if(o=e.shift(),t+=o,"'"===o){if(!e[0]||"'"!==e[0])break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Af);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in vf)return{type:"FUNCTION",value:e};return e.match(_t)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function Of(e){let t=0;for(;e[0]===ce;)t++,e.shift();if(t)return{type:"SPACE",value:ce.repeat(t)};for(;" "===e[0];)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Nf(e){return xf(e,Y)?(e.splice(0,Y.length),{type:"INVALID_REFERENCE",value:Y}):null}var _f;!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"}(_f||(_f={}));const Ff=(e,t=(()=>!0))=>[{goTo:e,guard:t}],Df=(e,t=(()=>!0))=>({goTo:e,guard:t}),kf={[_f.LeftRef]:{REFERENCE:Ff(_f.Separator),NUMBER:Ff(_f.FullRowSeparator),SYMBOL:[Df(_f.FullColumnSeparator,(e=>Ft(e.value))),Df(_f.FullRowSeparator,(e=>Dt(e.value)))]},[_f.FullColumnSeparator]:{SPACE:Ff(_f.FullColumnSeparator),OPERATOR:Ff(_f.RightColumnRef,(e=>":"===e.value))},[_f.FullRowSeparator]:{SPACE:Ff(_f.FullRowSeparator),OPERATOR:Ff(_f.RightRowRef,(e=>":"===e.value))},[_f.Separator]:{SPACE:Ff(_f.Separator),OPERATOR:Ff(_f.RightRef,(e=>":"===e.value))},[_f.RightRef]:{SPACE:Ff(_f.RightRef),NUMBER:Ff(_f.Found),REFERENCE:Ff(_f.Found,(e=>Pt(e.value))),SYMBOL:Ff(_f.Found,(e=>kt(e.value)))},[_f.RightColumnRef]:{SPACE:Ff(_f.RightColumnRef),SYMBOL:Ff(_f.Found,(e=>kt(e.value))),REFERENCE:Ff(_f.Found,(e=>Pt(e.value)))},[_f.RightRowRef]:{SPACE:Ff(_f.RightRowRef),NUMBER:Ff(_f.Found),REFERENCE:Ff(_f.Found,(e=>Pt(e.value)))},[_f.Found]:{}};function Pf(e){var t;let o=0,i=kf[_f.LeftRef];const n=[];for(;void 0!==i;){const s=e[o++];if(!s)return null;const r=null===(t=i[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 _f.Found:return n.push(s),e.splice(0,o),{type:"REFERENCE",value:it(n.map((e=>e.value)))};default:i=kf[a],n.push(s)}}return null}function Lf(e){const t=Cf(e),o=[];for(;t.length;)o.push(Pf(t)||t.shift());return o}function Uf(e){const t=Lf(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Tt.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${re}${o.indexOf(t)}${re}`}return e.value}))),dependencies:o}}const Vf=12,zf="Sheet1";function Bf(e,t){if(!e)return qf();if(e["[Content_Types].xml"]){const o=new ff(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in(e=JSON.parse(JSON.stringify(e)))&&e.version<Vf&&(e=function(e){for(let t=Hf.findIndex((t=>t.from===e.version));t<Hf.length;t++)e=Hf[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new Fo;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(qf(),e,{version:Vf}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(Gf(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(Gf(zf,"Sheet1"));return e}(e),e}(e),e}const Hf=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=Uf(o.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:o,...i}=t.figures[e].data,n=[];for(let e of o)if(e.labelCell){const t=ko(e.dataRange),o=e.labelCell+":"+Bt(t.right,t.bottom);n.push(o)}else n.push(e.dataRange);i.dataSetsHaveTitle=Boolean(o[0].labelCell),i.dataSets=n,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const o=[],i=new RegExp(se,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,s=e.replace(i,"_");let r=1,a=s;for(;o.includes(a);)a=`${s}${r}`,r++;n.name=a,o.push(a);const l=t=>{if(void 0===t)return t;let o=t.replace(e,a),i=t;for(;i!==o;)i=o,o=i.replace(e,a);return i};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),o=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const o of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[o])||void 0===t?void 0:t.type)&&(e.rule[o].value=l(e.rule[o].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,i]of Object.entries(t)){const t=`\\${re}${o}\\${re}`;e=e.replace(new RegExp(t,"g"),i)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const i=o.cells[e];i.format&&(i.format=ot(i.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 $f(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],i=[],n=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:zf};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(n)}):i.push(e);return i}(e,t),t=Wf(t,"SORT_CELLS"),t=function(e,t){var o;const i=[],n={};for(const t of e.sheets||[])null===(o=t.figures)||void 0===o||o.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":n[o.id]=o.definition;break;case"UPDATE_CHART":if(!n[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...n[o.id],...o.definition};e={...o,definition:t},n[o.id]=t}t.push(e)}i.push({...e,commands:t})}else i.push(e);return i}(e,t=Wf(t,"SET_DECIMAL")),t}function Wf(e,t){const o=[];for(const i of e)"REMOTE_REVISION"===i.type?o.push({...i,commands:i.commands.filter((e=>e.type!==t))}):o.push(i);return o}function Gf(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function qf(e="Sheet1"){return{version:Vf,sheets:[Gf(zf,e)],entities:{},styles:{},formats:{},borders:{},revisionId:K,uniqueFigureIds:!0}}function Zf(e,t){return{...Gf(e,t),charts:[],images:[]}}class jf{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 o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}jf.getters=[];class Xf extends jf{constructor({getters:e,stateObserver:t,range:o,dispatch:i,uuidGenerator:n}){super(t,i),this.range=o,o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class Yf extends Xf{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const o=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder({sheetId:e,col:t,row:o}){var i,n,s,r,a,l,c,h,d,u,g,p;const m={top:null===(s=null===(n=null===(i=this.borders[e])||void 0===i?void 0:i[t])||void 0===n?void 0:n[o])||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[o+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[o])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,o){const i=ze(t+1,o);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:o,row:n});if(s&&r){const t=this.getCommonSides(s,r);for(let o of i)this.addBorder(e,o,n,t)}}}ensureRowBorderContinuity(e,t,o){const i=ze(t+1,o);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:o});if(s&&r){const t=this.getCommonSides(s,r);for(let o of i)this.addBorder(e,n,o,t)}}}getCommonSides(e,t){const o={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(o[i]=e[i]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?ze(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((n=>{(n===t&&i||n!==t)&&this.moveBordersOfColumn(e,n,o,"vertical"),this.moveBordersOfColumn(e,n,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((n=>{(n===t&&i||n!==t)&&this.moveBordersOfRow(e,n,o,"horizontal"),this.moveBordersOfRow(e,n,o,"vertical")})))}moveBordersOfRow(e,t,o,i,{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+o])||void 0===l?void 0:l[i],u=null===(h=null===(c=s[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[i];this.history.update("borders",e,r,t+o,i,n?u:u||d),this.history.update("borders",e,r,t,i,void 0)}))}moveBordersOfColumn(e,t,o,i,{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+o])||void 0===a?void 0:a[r])||void 0===l?void 0:l[i],u=null===(h=null===(c=s[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[i];this.history.update("borders",e,t+o,r,i,n?u:u||d),this.history.update("borders",e,t,r,i,void 0)}))}setBorder(e,t,o,i,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[o])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,o,"vertical",null==i?void 0:i.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[o])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,o,"horizontal",null==i?void 0:i.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[o])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,o,"vertical",null==i?void 0:i.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[o+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,o+1,"horizontal",null==i?void 0:i.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let i=o.left;i<=o.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,i){this.setBorder(e,t,o,{...this.getCellBorder({sheetId:e,col:t,row:o}),...i})}setBorders(e,t,o){if("clear"===o)return this.clearBorders(e,t);for(let i of t){if("h"===o||"hv"===o||"all"===o)for(let t=i.top+1;t<=i.bottom;t++)for(let o=i.left;o<=i.right;o++)this.addBorder(e,o,t,{top:Z});if("v"===o||"hv"===o||"all"===o)for(let t=i.top;t<=i.bottom;t++)for(let o=i.left+1;o<=i.right;o++)this.addBorder(e,o,t,{left:Z});if("left"===o||"all"===o||"external"===o)for(let t=i.top;t<=i.bottom;t++)this.addBorder(e,i.left,t,{left:Z});if("right"===o||"all"===o||"external"===o)for(let t=i.top;t<=i.bottom;t++)this.addBorder(e,i.right+1,t,{left:Z});if("top"===o||"all"===o||"external"===o)for(let t=i.left;t<=i.right;t++)this.addBorder(e,t,i.top,{top:Z});if("bottom"===o||"all"===o||"external"===o)for(let t=i.left;t<=i.right;t++)this.addBorder(e,t,i.bottom+1,{top:Z})}}addBordersToMerge(e,t){const{left:o,right:i,top:n,bottom:s}=t,r=this.getCellBorder({sheetId:e,col:o,row:n}),a=this.getCellBorder({sheetId:e,col:i,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:o}],"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:i}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[o,i]of Object.entries(t.cells))if(null==i?void 0:i.border){const n=e.borders[i.border],{col:s,row:r}=zt(o);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,ko(e))}export(e){let t=0;const o={};function i(e){for(let[t,i]of Object.entries(o))if(Ae(i)===Ae(e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const n=this.getCellBorder({sheetId:t.id,col:e,row:o});if(n){const s=Bt(e,o),r=t.cells[s],a=i(n);r?r.border=a:t.cells[s]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}Yf.getters=["getCellBorder"];class Kf{constructor(e=new Jf){this.scope=e,this.code=""}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new Qf(this.scope,this.code,e)}toString(){return ev(this.code)}}class Qf{constructor(e,t,o){this.scope=e,this.returnExpression=o,this.code=ev(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new Kf(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 Kf(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class Jf{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 ev(e){let t="",o=0;const i=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of i)e.startsWith("}")&&o--,t+="\t".repeat(o)+e+"\n",e.endsWith("{")&&o++;return t.trim()}const tv=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,ov=["-","+"],iv=["%"],nv=["*","+","&"],sv={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function rv(e){var t,o,i;const n=e.shift();if(!n)throw new h(ae);switch(n.type){case"DEBUGGER":const r=cv(e,1e3);return r.debug=!0,r;case"NUMBER":return{type:"NUMBER",value:eo(n.value)};case"STRING":return{type:"STRING",value:Me(n.value)};case"FUNCTION":const a=function(e){var t;lv(e,"LEFT_PAREN",s("Missing opening parenthesis"));const o=e[0];if("RIGHT_PAREN"===(null==o?void 0:o.type))return lv(e,"RIGHT_PAREN"),[];const i=[];i.push(av(e));for(;"RIGHT_PAREN"!==(null===(t=e[0])||void 0===t?void 0:t.type);)lv(e,"COMMA",s("Wrong function call")),i.push(av(e));return lv(e,"RIGHT_PAREN"),i}(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===(o=e[1])||void 0===o?void 0:o.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&&tv.test(n.value)&&"LEFT_PAREN"===(null===(i=e[0])||void 0===i?void 0:i.type))throw new p(n.value);throw new h(s("Invalid formula"));case"LEFT_PAREN":const l=cv(e);return lv(e,"RIGHT_PAREN",s("Missing closing parenthesis")),l;case"OPERATOR":const c=n.value;if(ov.includes(c))return{type:"UNARY_OPERATION",value:c,operand:cv(e,sv[c])};throw new h(s("Unexpected token: %s",n.value));default:throw new h(s("Unexpected token: %s",n.value))}}function av(e){const t=e[0];return"COMMA"===(null==t?void 0:t.type)||"RIGHT_PAREN"===(null==t?void 0:t.type)?{type:"EMPTY",value:""}:cv(e)}function lv(e,t,o=ae){const i=e.shift();if(!i||i.type!==t)throw new h(o)}function cv(e,t=0){var o;if(0===e.length)throw new h(ae);let i=rv(e);for(;"OPERATOR"===(null===(o=e[0])||void 0===o?void 0:o.type)&&sv[e[0].value]>t;){const t=e.shift().value;if(iv.includes(t))i={type:"UNARY_OPERATION",value:t,operand:i,postfix:!0};else{i={type:"BIN_OPERATION",value:t,left:i,right:cv(e,sv[t])}}}return i}function hv(e){return dv(Cf(e))}function dv(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=cv(e);if(e.length)throw new h(ae);return t}function uv(e,t,o){switch(t===e.type&&(e=o(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>uv(e,t,o)))};case"UNARY_OPERATION":return{...e,operand:uv(e.operand,t,o)};case"BIN_OPERATION":return{...e,right:uv(e.right,t,o),left:uv(e.left,t,o)};default:return e}}function gv(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>gv(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?pv(e)+e.value:e.value+mv(e);case"BIN_OPERATION":return pv(e)+e.value+mv(e)}}function pv(e){const t=e.value,o="left"in e?e.left:e.operand,i=o.value;return"BIN_OPERATION"===o.type&&sv[i]<sv[t]?`(${gv(o)})`:gv(o)}function mv(e){const t=e.value,o="right"in e?e.right:e.operand,i=sv[o.value],n=sv[t];let s=!1;return"BIN_OPERATION"!==o.type?s=!1:i<n?s=!0:i!==n||nv.includes(t)||(s=!0),s?`(${gv(o)})`:gv(o)}const fv=Hu.content,vv={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},bv={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},Sv={};function Cv(e){const t=Lf(e),{dependencies:o,constantValues:i}=function(e){const t={numbers:[],strings:[]},o=[];for(const i of e)switch(i.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(i.value);break;case"STRING":const e=Me(i.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=eo(i.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:o,constantValues:t}}(t),n=function(e,t,o){return it(e.map((e=>{switch(e.type){case"STRING":const i=Me(e.value);return`|S${o.strings.indexOf(i)}|`;case"NUMBER":return`|N${o.numbers.indexOf(eo(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,o,i);if(!Sv[n]){const r=dv([...t]),a=new Jf;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 Kf;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=fv[e.value.toUpperCase()],o=e.args,i=o.length;if(i<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(),i.toString()));if(i>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(),i.toString()));const n=t.nbrArgRepeating;if(n>1){const o=t.args.length-n;if((i-o)%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(),o.toString(),n.toString()))}let r=[];for(let n=0;n<i;n++){const i=t.getArgToFocus(n+1)-1;if(0<=i&&i<t.args.length){const a=o[n],l=t.args[i],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 Kf(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[${i.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${i.strings.indexOf(e.value)}] }`);case"REFERENCE":const s=o.indexOf(e.value);return n?l.return(`range(deps[${s}])`):l.return(`ref(deps[${s}], ${t?"true":"false"}, "${r.functionName||vv["="]}", ${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=bv[e.value],o=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression})`)}case"BIN_OPERATION":{const t=vv[e.value],o=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),i=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression}, ${i.returnExpression})`)}case"EMPTY":return l.return("undefined")}}Sv[n]={execute:d}}return{execute:Sv[n].execute,dependencies:o,constantValues:i,tokens:t}}function Ev(e){return function(e){let t=[],o="";return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"FUNCTION":o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0}),o="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=1;const o=[];return e.map((e=>("LEFT_PAREN"===e.type?(o.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=o.pop()),e)))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,i=Object.assign({},e,{start:t,end:t+o,length:o});return t=i.end,i}))}(Lf(e))))}class wv extends Xf{constructor(){super(...arguments),this.nextId=1,this.cells={}}adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const i of Object.values(this.cells[o]||{}))if(i.isFormula)for(const n of i.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",o,i.id,"dependencies",i.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,o){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let n=i.left;n<=i.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null,format:""})}handleAddColumnsRows(e,t){let o,i;"before"===e.position?(o=ze(e.base,e.base+e.quantity),i=e.base+e.quantity):(o=ze(e.base+1,e.base+e.quantity+1),i=e.base),t(e.sheetId,i,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const i=t.cells[o],{col:n,row:s}=zt(o);if((null==i?void 0:i.content)||(null==i?void 0:i.format)||(null==i?void 0:i.style)){const o=this.importCell(t.id,i,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:n,row:s,sheetId:t.id})}}}export(e){const t={},o={};for(let i of e.sheets){const e={},n=Object.keys(this.cells[i.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const i of n){const n=this.getters.getCell(i);e[Bt(i.col,i.row)]={style:n.style?ot(n.style,t):void 0,format:n.format?ot(n.format,o):void 0,content:n.content||void 0}}i.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,i){const n=t.style&&o[t.style]||void 0,s=t.format&&i[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 o=this.cells[t][e];if(o)return o}}buildFormulaContent(e,t,o){const i=o||[...t.dependencies];return it(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=i.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,o=[{colFixed:!1,rowFixed:!1}]){const i=Bt((t=this.getters.expandZone(e,t)).left,t.top,o[0]),n=Bt(t.right,t.bottom,o.length>1?o[1]:o[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 i==n||a?i:i+":"+n}setStyle(e,t,o){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let n=i.top;n<=i.bottom;n++){const i=this.getters.getCell({sheetId:e,col:t,row:n});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:o?{...null==i?void 0:i.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let i=0;i<this.getters.getNumberRows(e);i++){const n=this.getFormat(e,t,i);if(n.style||n.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,...n})}}copyRowStyle(e,t,o){for(let i=0;i<this.getters.getNumberCols(e);i++){const n=this.getFormat(e,i,t);if(n.style||n.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,...n})}}getFormat(e,t,o){const i={},n=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),s=this.getters.getCell(n);return s&&(s.style&&(i.style=s.style),s.format&&(i.format=s.format)),i}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,o,i){const n=this.getters.getCell({sheetId:e,col:t,row:o}),s="content"in i||"formula"in i,r=s?gt(null==i?void 0:i.content):(null==n?void 0:n.content)||"";let a;a=void 0!==i.style?i.style||void 0:n?n.style:void 0;let l=("format"in i?i.format:n&&n.format)||Co(r);if((s&&!r&&!i.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:o,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:o,sheetId:e})}createCell(e,t,o,i,n){if(!t.startsWith("="))return this.createLiteralCell(e,t,o,i);try{return this.createFormulaCell(e,t,o,i,n)}catch(n){return this.createErrorFormula(e,t,o,i,n)}}createLiteralCell(e,t,o,i){return{id:e,content:t,style:i,format:o,isFormula:!1}}createFormulaCell(e,t,o,i,n){const s=Cv(t);return s.dependencies.length?this.createFormulaCellWithDependencies(e,s,o,i,n):{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:s,dependencies:[]}}createFormulaCellWithDependencies(e,t,o,i,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:i,format:o,isFormula:!0,compiledFormula:t,dependencies:s}}createErrorFormula(e,t,o,i,n){return{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:{dependencies:[],tokens:Cf(t),execute:function(){throw n}},dependencies:[]}}checkCellOutOfSheet(e,t,o){if(!this.getters.tryGetSheet(e))return 27;return qo(t,o,this.getters.getSheetZone(e))?0:18}}wv.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class yv extends Xf{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=or.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,i,n){const s=t.find((e=>e.match(i.type)));if(!s)throw new Error(`No builder for this chart: ${i.type}`);return s.createChart(i,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const o=or.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,null==o?void 0:o.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const o=this.getters.getFigures(e.sheetId);for(const i of o)if("chart"===i.tag){const o=i.id.split(J).pop(),n=`${e.sheetIdTo}${J}${o}`,s=null===(t=this.charts[i.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:n,position:{x:i.x,y:i.y},size:{width:i.width,height:i.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 o=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!o)throw new Error("Chart not defined.");return o}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const o=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!o)throw new Error(`There is no chart with the given figureId: ${e}`);return o}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let o of e.sheets){const e=this.getters.getFigures(o.id),i=[];for(let o of e){const e=o;if(e&&"chart"===e.tag){const o=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();o&&(e.data=o,i.push(e))}else i.push(e)}o.figures=i}}exportForExcel(e){var t;for(let o of e.sheets){const e=this.getters.getFigures(o.id),i=[];for(let o of e)if(o&&"chart"===o.tag){const e=null===(t=this.charts[o.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&i.push({...o,data:e})}o.charts=i}}addFigure(e,t,o={x:0,y:0},i={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?84:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:85}}function xv(e){return""===e?NaN:Number(e)}yv.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class Iv extends Xf{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const i of o.ranges){const n=t(i);switch(n.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(i),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 o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let i=t.top;i<=t.bottom;i++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,i).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const i=[];for(let n of this.cfRules[e])for(let e of n.ranges)qo(t,o,e.zone)&&i.push(n);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),i=o.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);i>-1?o.splice(i,1,n):o.push(n),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 27;const i=this.cfRules[o].findIndex((t=>t.id===e));if(-1===i)return 71;const n="up"===t?i-1:i+1;return n<0||n>=this.cfRules[o].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 o=>{if(t.includes(o.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(o.values[0])&&t.push(51),e>=2&&i(o.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{Cv(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,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?48:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&xv(t)>=xv(o)?47:0}checkMidBiggerThanMax(e){var t;const o=null===(t=e.midpoint)||void 0===t?void 0:t.value,i=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&xv(o)>=xv(i)?49:0}checkMinBiggerThanMid(e){var t;const o=e.minimum.value,i=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&&xv(o)>=xv(i)?50:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const i=this.cfRules[o].findIndex((t=>t.id===e)),n="up"===t?i-1:i+1;if(!(n<0||n>=this.cfRules[o].length)&&-1!==i&&-1!==n){const e=[...this.cfRules[o]],t=e[i];e[i]=e[n],e[n]=t,this.history.update("cfRules",o,e)}}}Iv.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Rv extends Xf{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:o,...i}=e,n=i;this.updateFigure(o,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[o,i]of Object.entries(t))switch(o){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,o,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,o,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var o;return void 0===(null===(o=this.figures[e])||void 0===o?void 0:o[t])?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(et)}getFigure(e,t){var o;return null===(o=this.figures[e])||void 0===o?void 0:o[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var o;return void 0!==(null===(o=this.figures[t])||void 0===o?void 0:o[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}Rv.getters=["getFigures","getFigure","getFigureSheetId"];class Tv{constructor(e){this.filters=[],this.zone=e;const t=new Fo;this.id=t.uuidv4();for(const o of ze(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new Av(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 Tv(this.zone)}}class Av{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 Mv extends Xf{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!si(...e.target))return 81;const t=Ho(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>Go(e.zone,t)))?78:0,i=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(Go(t,e))return 80;return 0};return this.checkValidations(e,o,i);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(Go(o.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":this.history.update("tables",e.sheetIdTo,Ne(this.tables[e.sheetId]));break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=Ho(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!$o(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(et):[]}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:o}){return this.getFilterTables(e).find((e=>qo(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Zo(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if($o(o,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=Uo(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i=[];for(const o of t.filters){const t=Uo(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);i.push(new Av(o.id,t))}if(i.length<Yo(o).numberOfCols){for(let e=o.left;e<=o.right;e++)i.find((t=>t.col===e))||i.push(new Av(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));i.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=Bo(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(Lo(o)!==Lo(t.zone)){const i=[];for(const o of t.filters){const t=Bo(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&i.push(new Av(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new Tv(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const i=t.filters[o],n={...i.zoneWithHeaders,bottom:i.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:i},n){var s;if(!e)return;const r=n.zone;if(!(r.bottom+1===i&&o>=r.left&&o<=r.right))return!1;for(const e of ze(r.left,r.right+1)){const o={sheetId:t,col:e,row:i};if(null===(s=this.getters.getCell(o))||void 0===s?void 0:s.content)return!1;if(this.getters.getFilter(o))return!1;if(this.getters.isInMerge(o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(ko(e.range));this.history.update("tables",t.id,o.id,o)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:Lo(e.zone)})}exportForExcel(e){this.export(e)}}Mv.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Ov extends Xf{constructor(){super(...arguments),this.sizes={}}handle(e){var t,o,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),o={COL:t.COL.map((e=>({manualSize:void 0,computedSize:nt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:nt(e)})))};this.history.update("sizes",e.sheetId,o);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Ne(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const n={...this.sizes};delete n[e.sheetId],this.history.update("sizes",n);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);const o=Math.min(...e.elements);t=t.map(((t,i)=>"ROW"===e.dimension&&i>=o?{manualSize:t.manualSize,computedSize:nt((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=rt(e.position,e.base),i=t[e.base];t.splice(o,0,...Array(e.quantity).fill(i)),t=t.map(((t,o)=>"ROW"===e.dimension&&o>e.base+e.quantity?{manualSize:t.manualSize,computedSize:nt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const o=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:nt(o)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:nt(e.size||_)});break;case"UPDATE_CELL":if(!(null===(i=null===(o=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[e.row])||void 0===i?void 0:i.manualSize)){const{sheetId:t,row:o}=e;this.history.update("sizes",t,"ROW",o,"computedSize",nt((()=>this.getRowTallestCellSize(t,o))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let o of ze(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,o);t!==this.getRowSize(e.sheetId,o)&&this.history.update("sizes",e.sheetId,"ROW",o,"computedSize",nt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,o){var i,n,s,r;return Math.round((null===(n=null===(i=this.sizes[e])||void 0===i?void 0:i[t][o])||void 0===n?void 0:n.manualSize)||(null===(r=null===(s=this.sizes[e])||void 0===s?void 0:s[t][o])||void 0===r?void 0:r.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,o;const i={COL:[],ROW:[]};for(let t of ze(0,this.getters.getNumberCols(e)))i.COL.push(this.getHeaderSize(e,"COL",t));for(let n of ze(0,this.getters.getNumberRows(e))){let s=null===(o=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[n].manualSize;if(!s){s=this.getRowTallestCellSize(e,n)}i.ROW.push(s)}return i}getDefaultHeaderSize(e){return"COL"===e?_:F}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return F;return function(e){return e&&e.content?ke(Ve(e.style),e.isFormula?1:e.content.split(ce).length)+2*V:F}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const o=this.getters.getRowCells(e,t);let i=0;for(let e=0;e<o.length;e++){const t=this.getters.getCellById(o[e]);if(!t)continue;const n=this.getters.getCellPosition(t.id),s=this.getCellHeight(n);s>i&&s>F&&(i=s)}return i<=F?F:i}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[o,i]of Object.entries(t.rows))i.size&&(e.ROW[o]=i.size);for(let[o,i]of Object.entries(t.cols))i.size&&(e.COL[o]=i.size);const o=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:o.COL.map(((t,o)=>({manualSize:e.COL[o],computedSize:nt(t)}))),ROW:o.ROW.map(((t,o)=>({manualSize:e.ROW[o],computedSize:nt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var o,i;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of ze(0,this.getters.getNumberRows(n.id)))(t||(null===(o=this.sizes[n.id].ROW[e])||void 0===o?void 0:o.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of ze(0,this.getters.getNumberCols(n.id)))(t||(null===(i=this.sizes[n.id].COL[e])||void 0===i?void 0:i.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Ov.getters=["getRowSize","getColSize"];class Nv extends Xf{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){if("HIDE_COLUMNS_ROWS"===e.type){if(!this.hiddenHeaders[e.sheetId])return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return(t||[]).flat().concat(e.elements).length<o?0:66}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,Ne(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=rt(e.position,e.base);t.splice(o,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}import(e){var t,o;for(let i of e.sheets){this.hiddenHeaders[i.id]={COL:[],ROW:[]};for(let e=0;e<i.rowNumber;e++)this.hiddenHeaders[i.id].ROW[e]=Boolean(null===(t=i.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<i.colNumber;e++)this.hiddenHeaders[i.id].COL[e]=Boolean(null===(o=i.cols[e])||void 0===o?void 0:o.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}Nv.getters=["getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class _v extends Xf{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 o of t)if("image"===o.tag){const t=o.id.split(J).pop(),i=`${e.sheetIdTo}${J}${t}`,n=this.getImage(o.id);if(n){const t={width:o.width,height:o.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:i,position:{x:o.x,y:o.y},size:t,definition:Ne(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 o of this.syncedImages)t.has(o)||null===(e=this.fileStore)||void 0===e||e.delete(o)}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,o,i){const n={id:e,x:o.x,y:o.y,width:i.width,height:i.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 o of e)this.history.update("images",t.id,o.id,o.data),this.syncedImages.add(o.data.path)}}export(e){var t;for(const o of e.sheets){const e=o.figures.filter((e=>"image"===e.tag));for(const i of e)i.data=null===(t=this.images[o.id])||void 0===t?void 0:t[i.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(const t of e)if("image"===(null==t?void 0:t.tag)){const e=this.getImage(t.id);e&&o.push({...t,data:Ne(e)})}t.images=o}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(et));return e}}_v.getters=["getImage","getImagePath","getImageSize"];class Fv extends Xf{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const o of Object.values(t).filter(et))this.addMerge(e.sheetIdTo,o.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(et)}getMerge({sheetId:e,col:t,row:o}){var i;const n=this.mergeCellMap[e],s=n?t in n&&(null===(i=n[t])||void 0===i?void 0:i[o]):void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){var o;const i=this.mergeCellMap[e];if(!i)return[];const n=new Set;for(const{col:e,row:s}of Qo(t)){const t=null===(o=i[e])||void 0===o?void 0:o[s];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(et)}doesIntersectMerge(e,t){return Qo(t).some((({col:t,row:o})=>void 0!==this.getMerge({sheetId:e,col:t,row:o})))}doesColumnsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(i.id,t,n,o,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(i.id,n,t,n,o))return!0;return!1}expandZone(e,t){let{left:o,right:i,top:n,bottom:s}=t,r={left:o,right:i,top:n,bottom:s};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&Go(o,r)&&(r=Ho(o,r))}return Wo(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,o,i,n){const s=this.getMerge({sheetId:e,col:t,row:o}),r=this.getMerge({sheetId:e,col:i,row:n});return!(!s||!r)&&Wo(s,r)}isInMerge({sheetId:e,col:t,row:o}){var i;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(i=n[t])||void 0===i?void 0:i[o]))}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:o}=this.getMerge(e);return{sheetId:e.sheetId,col:o,row:t}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge({sheetId:e,col:t.left,row:t.top});if(o)return Wo(t,o);const{numberOfCols:i,numberOfRows:n}=Yo(t);return 1===i&&1===n}isMergeDestructive(e,t){let{left:o,right:i,top:n,bottom:s}=t;i=De(i,0,this.getters.getNumberCols(e)-1),s=De(s,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=s;t++)for(let s=o;s<=i;s++)if(s!==o||t!==n){const o=this.getters.getCell({sheetId:e,col:s,row:t});if(o&&""!==o.content)return!0}return!1}getMergeById(e,t){var o;const i=null===(o=this.merges[e])||void 0===o?void 0:o[t];return void 0!==i?kv(t,i):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const o of e)if(t!==o&&Go(t,o))return 65;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<i&&e.bottom>=i)return 75;return 0}checkMergedContentUpdate(e){const{col:t,row:o,content:i}=e;if(void 0===i)return 0;const{col:n,row:s}=this.getMainCellPosition(e);return n===t&&s===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:i}=e,n=this.getMerge({sheetId:t,col:o,row:i});if(void 0===n||!Wo(e,n))return 5}return 0}addMerge(e,t){let{left:o,right:i,top:n,bottom:s}=t;i=De(i,0,this.getters.getNumberCols(e)-1),s=De(s,0,this.getters.getNumberRows(e)-1);if(Bt(o,n)===Bt(i,s))return;const r=this.getters.getCell({sheetId:e,col:o,row:n});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,Lo({left:o,top:n,right:i,bottom:s})));let l=new Set;for(let t=n;t<=s;t++)for(let s=o;s<=i;s++){s===o&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,style:r?r.style:null,content:""});const i=this.getMerge({sheetId:e,col:s,row:t});i&&l.add(i.id),this.history.update("mergeCellMap",e,s,t,a)}for(let t of l){const{top:o,bottom:i,left:n,right:s}=this.getMergeById(e,t);for(let t=o;t<=i;t++)for(let o=n;o<=s;o++){const i={sheetId:e,col:o,row:t},n=this.getMerge(i);n&&n.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",i))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:i,bottom:n,right:s}=t,r=this.getMerge({sheetId:e,col:o,row:i});if(void 0!==r&&Wo(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=i;t<=n;t++)for(let i=o;i<=s;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[i,n]of o)if(n){const o=n.zone,s=t(n);switch(s.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{numberOfCols:t,numberOfRows:n}=Yo(s.range.zone);1===t&&1===n?this.removeMerge(e,o):this.history.update("merges",e,parseInt(i,10),s.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:i}of Qo(t))this.history.update("mergeCellMap",e,o,i,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let o of t)this.addMerge(e,ko(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...Dv(e))}}exportForExcel(e){this.export(e)}}function Dv(e){return Object.entries(e).map((([e,t])=>t?kv(parseInt(e,10),t):void 0)).filter(et).map((e=>Bt(e.left,e.top)+":"+Bt(e.right,e.bottom)))}function kv(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Fv.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class Pv{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const s=Be(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[o]){const e=Math.min(n.zone[o],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e)}else if(n.zone[t]>=s&&n.zone[o]<=l)a="REMOVE",r=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[o]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e),r=this.createAdaptedRange(r,i,"MOVE",-(n.zone[t]-s))}else s<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,i,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",o="COL"===e.dimension?"right":"bottom",i="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[o])return{changeType:"RESIZE",range:this.createAdaptedRange(n,i,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,i,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(n,i,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:o})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const o=void 0,i=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:i,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!Zo(o.zone,t))return{changeType:"NONE"};const i=e.targetSheetId,n=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(o,"both","MOVE",[n,s]),a=e.sheetId!==i||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:i,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||Po(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,i){const n=Jo(e.unboundedZone,t,o,i);return e.clone({zone:n})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,i){const n=e.map((e=>Ao.fromRange(e,this.getters)));return n.map((e=>{if(!Po(e.zone))return e;const n=e.prefixSheet?e.sheetId:i,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:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return e.clone({sheetId:n,zone:s}).orderZone()}))}getRangeFromSheetXC(e,t){if(!_t.test(t))return new Ao({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,i=t,n=!1;t.includes("!")&&(({xc:i,sheetName:o}=Lt(t)),o&&(n=!0));const s=Do(i),r=Ao.getRangeParts(i,s),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e;return new Ao({prefixSheet:n,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize).orderZone()}getSelectionRangeString(e,t){const o=Ao.fromRange(e,this.getters),i=this.getters.expandZone(o.sheetId,o.zone),n=o.clone({zone:{...i,bottom:o.isFullCol?void 0:i.bottom,right:o.isFullRow?void 0:i.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return Y;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return Y;if(e.zone.left<0||e.zone.top<0)return Y;const o=Ao.fromRange(e,this.getters);let i=o.sheetId!==t||o.invalidSheetName||o.prefixSheet,n="";if(i&&(n=o.invalidSheetName?o.invalidSheetName:Fe(this.getters.getSheetName(o.sheetId))),i&&!n)return Y;let s=this.getRangePartString(o,0);return o.parts&&2===o.parts.length&&(o.zone.top!==o.zone.bottom||o.zone.left!==o.zone.right||o.parts[0].rowFixed||o.parts[0].colFixed||o.parts[1].rowFixed||o.parts[1].colFixed)&&(s+=":",s+=this.getRangePartString(o,1)),`${i?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 Ao(t,this.getters.getSheetSize)}getRangePartString(e,t){const o=e.parts&&e.parts[t].colFixed?"$":"",i=Ut(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?o+i+n+s:o+i:e.isFullRow?0===t&&e.unboundedZone.hasHeader?o+i+n+s:n+s:o+i+n+s,r}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:Y}}}Pv.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Lv extends Xf{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"REMOVE_COLUMNS_ROWS":return("COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId))>e.elements.length?0:8;case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.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,o;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let i of e.sheets){const e=i.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:r}=this.getImportedSheetSize(i),a={id:i.id,name:e,numberOfCols:s,rows:_o(r),areGridLinesVisible:void 0===i.areGridLinesVisible||i.areGridLinesVisible,isVisible:i.isVisible,panes:{xSplit:(null===(t=i.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(o=i.panes)||void 0===o?void 0:o.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(et).map((e=>{const t=this.sheets[e],o={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(o.panes=t.panes),o}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=_e(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell({sheetId:e,col:t,row:o}){var i;const n=this.tryGetSheet(e),s=null===(i=null==n?void 0:n.rows[o])||void 0===i?void 0:i.cells[t];if(void 0!==s)return this.getters.getCellById(s)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){var o;return Object.values(null===(o=this.getSheet(e).rows[t])||void 0===o?void 0:o.cells).filter(et)}getRowsZone(e,t,o){return{top:t,bottom:o,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this));let i=`${e}${t}`;for(;o.includes(i);)i=`${e}${t}`,t++;return i}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,o){const i={...this.getPaneDivisions(e)};"COL"===o?i.xSplit=t:"ROW"===o&&(i.ySplit=t),this.history.update("sheets",e,"panes",i)}isEmpty(e,t){return Qo(t).map((({col:t,row:o})=>this.getCell({sheetId:e,col:t,row:o}))).every((e=>!e||""===e.content))}updateCellPosition(e){const{sheetId:t,cellId:o,col:i,row:n}=e;o?this.setNewPosition(o,t,i,n):this.clearPosition(t,i,n)}setNewPosition(e,t,o,i){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:i,col:o,sheetId:t}),this.history.update("sheets",t,"rows",i,"cells",o,e)}clearPosition(e,t,o){var i;const n=null===(i=this.sheets[e])||void 0===i?void 0:i.rows[o].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,o,i,n){const s={id:e,name:t,numberOfCols:o,rows:_o(i),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 o=this.orderedSheetIds.slice(),i=o.findIndex((t=>t===e)),n=o.splice(i,1);let s=this.findIndexOfTargetSheet(i,t);o.splice(s,0,n[0]),this.history.update("orderedSheetIds",o)}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:o}=this,i=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=o[e])||void 0===t?void 0:t.name.toLowerCase())===i}))?11:se.test(i)?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 o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 65;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 65;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIdsMapName);i[t]=e.id,delete i[o],this.history.update("sheetIdsMapName",i)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),i=this.getDuplicateSheetName(o.name),n=JSON.parse(JSON.stringify(o));n.id=t,n.name=i;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:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:o,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 o=this.orderedSheetIds.map(this.getSheetName.bind(this)),i=s("Copy of %s",e);let n=i.toString();for(;o.includes(n);)n=`${i} (${t})`,t++;return n}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const i=this.orderedSheetIds.slice(),n=i.indexOf(e.id);i.splice(n,1),this.history.update("orderedSheetIds",i);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 o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const i=t.filter((t=>t<e.panes.xSplit)).length;i&&this.setPaneDivisions(e.id,e.panes.xSplit-i,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of Be(t))this.moveCellOnRowsDeletion(e,o[o.length-1],o[0]),o.map((t=>this.updateRowsStructureOnDeletion(t,e)));const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,i){const n="before"===o?t:t+1;this.moveCellsOnAddition(e,n,i,"columns");const s=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",s+i),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+i,"COL")}addRows(e,t,o,i){const n="before"===o?t:t+1;this.addEmptyRows(e,i),this.moveCellsOnAddition(e,n,i,"rows"),this.updateRowsStructureOnAddition(e,t,i),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+i,"ROW")}moveCellOnColumnsDeletion(e,t){for(let[o,i]of Object.entries(e.rows)){const n=parseInt(o,10);for(let o in i.cells){const s=parseInt(o,10),r=i.cells[o];r&&(s===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:n}),s>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:s-1,row:n}))}}}moveCellsOnAddition(e,t,o,i){const n=[];for(const[s,r]of Object.entries(e.rows)){const a=parseInt(s,10);if("rows"!==i||a>=t)for(let s in r.cells){const l=parseInt(s,10),c=r.cells[s];c&&("rows"===i||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===i?o:0),row:a+("rows"===i?o:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const i=o-t+1;for(let[n,s]of Object.entries(e.rows)){const r=parseInt(n,10);if(r>=t&&r<=o)for(let t in s.cells){const o=parseInt(t,10);s.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:r})}if(r>o)for(let t in s.cells){const o=parseInt(t,10),n=s.cells[t];n&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:n,col:o,row:r-i})}}}updateRowsStructureOnDeletion(e,t){const o=[],i=t.rows.map((e=>e.cells));for(let n in t.rows)parseInt(n,10)!==e&&o.push({cells:i.shift()});this.history.update("sheets",t.id,"rows",o)}updateRowsStructureOnAddition(e,t,o){const i=[],n=e.rows.map((e=>e.cells));e.rows.forEach((()=>i.push({cells:n.shift()}))),this.history.update("sheets",e.id,"rows",i)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(zt);let o=e.rowNumber,i=e.colNumber;for(let{col:e,row:n}of t)o=Math.max(o,n+1),i=Math.max(i,e+1);return{rowNumber:o,colNumber:i}}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(Po))return 25;if(t.length&&"sheetId"in e){const o=this.getSheetZone(e.sheetId);return t.every((e=>Zo(e,o)))?0:18}return 0}}Lv.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"];class Uv extends jf{constructor({getters:e,stateObserver:t,dispatch:o,uiActions:i,selection:n}){super(t,o),this.getters=e,this.ui=i,this.selection=n}drawGrid(e,t){}}Uv.layers=[];class Vv extends Uv{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const o=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(o),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:Et(255,0,0),colors:[]},{leadColor:Et(255,128,0),colors:[]},{leadColor:Et(128,128,0),colors:[]},{leadColor:Et(128,255,0),colors:[]},{leadColor:Et(0,255,0),colors:[]},{leadColor:Et(0,255,128),colors:[]},{leadColor:Et(0,255,255),colors:[]},{leadColor:Et(0,127,255),colors:[]},{leadColor:Et(0,0,255),colors:[]},{leadColor:Et(127,0,255),colors:[]},{leadColor:Et(128,0,128),colors:[]},{leadColor:Et(255,0,128),colors:[]}];for(const o of e.map(xt)){let e=500,i=0;t.forEach(((t,n)=>{const s=(r=o,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,i=n)})),t[i].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>Rt(e).s-Rt(t).s)))).flat().map(yt)}([...new Set([...new Set([...e,...this.customColors])].filter(St).map(bt))]).filter((e=>!M.includes(e)))}getColorsFromCells(e){var t,o;const i=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&i.add(n.style.textColor),(null===(o=n.style)||void 0===o?void 0:o.fillColor)&&i.add(n.style.fillColor);return[...i]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(vt(t.minimum.color)),o.push(t.midpoint?vt(t.midpoint.color):void 0),o.push(vt(t.maximum.color)))}return o.filter(et)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const i=e;o.add(i.baselineColorDown),o.add(i.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=bt(e);e&&!M.includes(t)&&this.customColors.add(t)}}Vv.getters=["getCustomColors"];const zv=Hu.mapping;class Bv extends Uv{constructor(e){super(e),this.isUpToDate=!1,this.evaluatedCells={},this.evalContext=e.custom,this.lazyEvaluation=e.lazyEvaluation}handle(e){switch(tn.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 o=Cv(e),i=this.getCompilationParameters((e=>this.getEvaluatedCell(this.getters.getCellPosition(e.id)))),n=[];for(let e of o.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return o.execute(n,...i).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:o}){var i,n,s;return void 0===this.getters.getCell({sheetId:e,col:t,row:o})?gn(""):(null===(s=null===(n=null===(i=this.evaluatedCells[e])||void 0===i?void 0:i[t])||void 0===n?void 0:n[o])||void 0===s?void 0:s.call(n))||gn("")}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},o={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);o[e]=this.getEvaluatedCell(t)}return o}getColEvaluatedCells(e,t){var o;return Object.values((null===(o=this.evaluatedCells[e])||void 0===o?void 0:o[t])||[]).filter(et).map((e=>e()))}getEvaluatedCellsInZone(e,t){return Qo(t).map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o})))}setEvaluatedCell(e,t){const{col:o,row:i,sheetId:n}=this.getters.getCellPosition(e);this.evaluatedCells[n]||(this.evaluatedCells[n]={}),this.evaluatedCells[n][o]||(this.evaluatedCells[n][o]={}),this.evaluatedCells[n][o][i]=t,this.lazyEvaluation||this.evaluatedCells[n][o][i]()}*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||nt((()=>{try{switch(e.isFormula){case!0:return i(e);case!1:return dn(e.content,e.format)}}catch(t){return o(t,e)}}))},o=(e,t)=>{e instanceof Error||(e=new Error(e));const o=(null==e?void 0:e.errorType)||a.GenericError,i=n[2].__lastFnCalled||"",s=new c(o,e.message.replace("[[FUNCTION_NAME]]",i),void 0!==e.logLevel?e.logLevel:l.error);return vn(t.content,s)},i=t=>{const o=t.id;if(e.has(o))throw new d;n[2].__originCellXC=()=>{const e=n[2].getters.getCellPosition(o);return Bt(e.col,e.row)},e.add(o);const i=t.compiledFormula.execute(t.dependencies,...n);if(e.delete(o),Array.isArray(i.value))throw new Error(s("This formula depends on invalid values"));return gn(i.value,t.format||i.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}),o=this.getters;const i=t=>{const o=e(t);if(o.type===Ji.error)throw o.error;return o};return[function(e,t,n,r){if(t)return{value:Lo(e.zone)};if(!Po(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(!o.tryGetSheet(e.sheetId))throw new Error(s("Invalid sheet name"));return t=o.getCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}),t&&""!==t.content?i(t):{value:null}}(e)},function(e){const n=e.sheetId;if(!Po(e.zone))throw new u;const s=o.getSheetZone(n),r=[],a=$o(e.zone,s);if(!a)return r.push([]),r;for(let o=a.left;o<=a.right;o++){const n=[];for(let s=a.top;s<=a.bottom;s++){const r=t.getters.getCell({sheetId:e.sheetId,col:o,row:s});n.push(r?i(r):void 0)}r.push(n)}return r},t]}exportForExcel(e){for(let t of e.sheets)for(const e in t.cells){const o={sheetId:t.id,...zt(e)},i=this.getters.getCell(o);if(i){const n=t.cells[e];n.value=this.getEvaluatedCell(o).value,n.isFormula=i.isFormula&&!this.isBadExpression(i.content)}}}isBadExpression(e){try{return Cv(e),!1}catch(e){return!0}}}Bv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getColEvaluatedCells","getEvaluatedCellsInZone"];class Hv extends Uv{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=or.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const i=t.find((e=>e.match(o.type)));if(!i)throw new Error("No runtime builder for this chart.");return i.getChartRuntime(o,e)}}(this.getters)}handle(e){if(tn.has(e.type)||on.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const o=t.zone.left,i=t.zone.top,n=t.sheetId;return this.getters.getCellComputedStyle({sheetId:n,col:o,row:i}).fillColor||w}}Hv.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class $v extends Uv{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.rulePredicate={CellIsRule:(e,t)=>{if(e.type===Ji.error)return!1;const o=t.values.map(un);switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==o[0]&&e.value.toString().startsWith(o[0].toString());case"EndsWith":return""!==o[0]&&e.value.toString().endsWith(o[0].toString());case"Between":return e.value>=o[0]&&e.value<=o[1];case"NotBetween":return!(e.value>=o[0]&&e.value<=o[1]);case"ContainsText":return e.value.toString().indexOf(o[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(o[0].toString());case"GreaterThan":return e.value>o[0];case"GreaterThanOrEqual":return e.value>=o[0];case"LessThan":return e.value<o[0];case"LessThanOrEqual":return e.value<=o[0];case"NotEqual":return""!==o[0]&&e.value!==o[0];case"Equal":return""===o[0]||e.value===o[0];default:console.warn(s("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((on.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const o=this.getters.getActiveSheetId(),i=this.getters.getRulesByCell(o,e.originCol,e.originRow);for(const t of i)this.adaptRules(o,t,[Bt(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:o,col:i,row:n}=e,s=this.getters.getCell(e),r=this.computedStyles[o],a=r&&(null===(t=r[i])||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=x),this.getters.isFilterHeader(e)&&(l.bold=!0),l}getConditionalIcon({col:e,row:t}){var o;const i=this.getters.getActiveSheetId(),n=this.computedIcons[i];return n&&(null===(o=n[e])||void 0===o?void 0:o[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const o=this.computedStyles[t];for(let i of this.getters.getConditionalFormats(t).reverse())try{switch(i.rule.type){case"ColorScaleRule":for(let e of i.ranges)this.applyColorScale(e,i.rule);break;case"IconSetRule":for(let e of i.ranges)this.applyIcon(e,i.rule);break;default:for(let n of i.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[i.rule.type];let a=this.getters.getEvaluatedCell({sheetId:t,col:r,row:n});s&&s(a,i.rule)&&(o[r]||(o[r]=[]),o[r][n]=Object.assign((null===(e=o[r])||void 0===e?void 0:e[n])||{},i.rule.style))}}}}catch(e){}}parsePoint(e,t,o){const i=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCellsInZone(i,this.getters.getRangeFromSheetXC(i,e).zone).filter((e=>e.type===Ji.number)).map((e=>e.value));switch(t.type){case"value":return"max"===o?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 to(n,Number(t.value)/100,!0);case"formula":const i=t.value&&this.getters.evaluateFormula(t.value);return i instanceof Promise?null:i;default:return null}}applyIcon(e,t){const o=this.parsePoint(e,t.lowerInflectionPoint),i=this.parsePoint(e,t.upperInflectionPoint);if(null===o||null===i||o>i)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!==Ji.number)continue;const c=this.computeIcon(s.value,i,t.upperInflectionPoint.operator,o,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,o,i,n,s){return"ge"===o&&e>=t||"gt"===o&&e>t?s[0]:"ge"===n&&e>=i||"gt"===n&&e>i?s[1]:s[2]}applyColorScale(e,t){var o;const i=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,s=this.parsePoint(e,t.maximum,"max");if(null===i||null===s||i>=s||n&&(i>=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:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,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:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,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===Ji.number){const r=De(a.value,i,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===(o=l[t])||void 0===o?void 0:o[e])||{},l[t][e].fillColor=vt(h)}}}computeColorDiffUnits(e,t,o,i){const n=t-e;return[((o>>16)%256-(i>>16)%256)/n,((o>>8)%256-(i>>8)%256)/n,(o%256-i%256)/n]}colorCell(e,t,o,i){const[n,s,r]=i;return Math.round((o>>16)%256-n*(e-t))<<16|Math.round((o>>8)%256-s*(e-t))<<8|Math.round(o%256-r*(e-t))}adaptRules(e,t,o,i){if(0===o.length&&0===i.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(o);const a=jo(r,i);this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}pasteCf(e,t,o){const i=Bt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let s of n.ranges)if(qo(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=n,r=[];"CUT"===o&&r.push(Bt(e.col,e.row)),e.sheetId===t.sheetId?this.adaptRules(e.sheetId,s,[i],r):(this.adaptRules(t.sheetId,s,[i],[]),this.adaptRules(e.sheetId,s,[],r))}}}$v.getters=["getConditionalIcon","getCellComputedStyle"];class Wv extends Uv{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":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const o of this.getters.getFilters(e.sheetIdTo)){const i=o.zoneWithHeaders;t[o.id]=this.getFilterValues({sheetId:e.sheetId,col:i.left,row:i.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:o,row:i}=e;let n;for(let e of this.getters.getFilterTables(t)){const s=e.zone;if(qo(o,i,s)){const e=this.intersectZoneWithViewport(t,s);n={top:i===e.top?j:void 0,bottom:i===e.bottom?j:void 0,left:o===e.left?j:void 0,right:o===e.right?j:void 0}}}const s=this.getters.getCellBorder(e),r={...n,...lt(s||{})};return tt(r)?null:r}getFilterHeaders(e){const t=[];for(let o of this.getters.getFilterTables(e)){const i=o.zone;if(!i)continue;const n=i.top;for(let o=i.left;o<=i.right;o++)this.getters.isColHidden(e,o)||this.getters.isRowHidden(e,n)||t.push({col:o,row:n})}return t}getFilterValues(e){const t=this.getters.getFilterId(e),o=e.sheetId;return t&&this.filterValues[o]&&this.filterValues[o][t]||[]}isFilterHeader({sheetId:e,col:t,row:o}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}isFilterActive(e){var t,o;const i=this.getters.getFilterId(e),n=e.sheetId;return Boolean(i&&(null===(o=null===(t=this.filterValues[n])||void 0===t?void 0:t[i])||void 0===o?void 0:o.length))}intersectZoneWithViewport(e,t){const o=ze(t.left,t.right+1),i=ze(t.top,t.bottom+1);return{left:this.getters.findVisibleHeader(e,"COL",o),right:this.getters.findVisibleHeader(e,"COL",o.reverse()),top:this.getters.findVisibleHeader(e,"ROW",i),bottom:this.getters.findVisibleHeader(e,"ROW",i.reverse())}}updateFilter({col:e,row:t,values:o,sheetId:i}){const n=this.getters.getFilterId({sheetId:i,col:e,row:t});n&&(this.filterValues[i]||(this.filterValues[i]={}),this.filterValues[i][n]=o)}updateHiddenRows(){var e,t;const o=this.getters.getActiveSheetId(),i=this.getters.getFilters(o).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let s of i){if(this.getters.isRowHiddenByUser(o,s.zoneWithHeaders.top))continue;if(n.has(s.zoneWithHeaders.top))continue;const i=null===(t=null===(e=this.filterValues[o])||void 0===e?void 0:e[s.id])||void 0===t?void 0:t.map(ct);if(i&&s.filteredZone)for(let e=s.filteredZone.top;e<=s.filteredZone.bottom;e++){const t=this.getCellValueAsString(o,s.col,e);i.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,o){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets)for(const e of t.filterTables){const o=ko(e.range),i=[],n=[];for(const e of ze(0,Yo(o).numberOfCols)){const s={sheetId:t.id,col:o.left+e,row:o.top},r=this.getFilterValues(s),a=this.getters.getFilter(s);if(!a)continue;const l=(a.filteredZone?Qo(a.filteredZone).map((({col:e,row:o})=>this.getters.getEvaluatedCell({sheetId:t.id,col:e,row:o}))).filter((e=>e.type!==Ji.empty)).map((e=>e.formattedValue)):[]).filter((e=>!r.includes(e)));i.push({colId:e,filteredValues:[...new Set(l)]});const c={col:a.col,row:a.zoneWithHeaders.top,sheetId:t.id},h=this.getters.getEvaluatedCell(c).formattedValue,d=this.getUniqueColNameForExcel(e,h,n);n.push(d),t.cells[Bt(c.col,c.row)]={...t.cells[Bt(c.col,c.row)],content:d,value:d,isFormula:!1}}e.filters=i}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let i=t,n=2;for(;o.includes(i);)i=t+String(n),n++;return i}}Wv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];class Gv{constructor(e,t,o,i,n,s){this.getters=e,this.sheetId=t,this.boundaries=o,this.viewportWidth=i.width,this.viewportHeight=i.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:o,size:i}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:s}=this.getters.getRowDimensions(this.sheetId,t),r=this.searchHeaderIndex("COL",o-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=o-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(_,Math.min(a,this.viewportWidth-i)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(F+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 o=this.getters.getMainCellPosition({sheetId:t,...e}),{col:i,row:n}=this.getters.getNextVisibleCellPosition(o);qo(i,this.boundaries.top,this.boundaries)&&this.adjustPositionX(i),qo(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{start:o,end:i}=this.getters.getColDimensions(t,e);for(;i>this.offsetX+this.offsetCorrectionX+this.viewportWidth&&this.offsetX+this.offsetCorrectionX<o;)this.offsetX=this.getters.getColDimensions(t,this.left).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX();for(;e<this.left;){let e;for(e=this.left;e>=0&&this.getters.isColHidden(t,e);e--);this.offsetX=this.getters.getColDimensions(t,e-1).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId;for(;this.getters.getRowDimensions(t,e).end>this.offsetY+this.viewportHeight+this.offsetCorrectionY&&this.offsetY+this.offsetCorrectionY<this.getters.getRowDimensions(t,e).start;)this.offsetY=this.getters.getRowDimensions(t,this.top).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY();for(;e<this.top;){let e;for(e=this.top;e>=0&&this.getters.isRowHidden(t,e);e--);this.offsetY=this.getters.getRowDimensions(t,e-1).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=$o(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,o=0,i=!1){let n=0;const s=this.sheetId,r=this.getters.getNumberHeaders(s,e);for(let a=o;a<=r-1;a++){const o=i||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(s,e,a)&&!o&&(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.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.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 qv extends Uv{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:o}=ei(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const i=e.previousAnchor.zone,n=e.anchor.zone,{top:s,bottom:r,left:a,right:l}=this.getters.getActiveMainViewport();i.left===n.left&&i.right===n.right&&(t=a>t||t>l?a:t),i.top===n.top&&i.bottom===n.bottom&&(o=s>o||o>r?s:o)}const i=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(i)-1),o=Math.min(o,this.getters.getNumberRows(i)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:o})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:o}=this.getActiveMainViewport(),i=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(i,o).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),o=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(o);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"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 o of t)(null===(e=this.viewports[o])||void 0===e?void 0:e.bottomRight)||this.resetViewports(o)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ze(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=>ze(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);let{width:n,height:s}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,i).start,width:n,height:s}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),i=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-i.viewportWidth+1),maxOffsetY:Math.max(0,o-i.viewportHeight+1)}}getColRowOffsetInViewport(e,t,o){const i=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),s=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let r=0;const a="COL"===e?n:s;for(let n=t;n<o;n++)a.includes(n)&&(r+="COL"===e?this.getters.getColSize(i,n):this.getters.getRowSize(i,n));return r}isVisibleInViewport({sheetId:e,col:t,row:o}){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let i=!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?(i=!0,s=Gt(e-a),n=1):e<l&&o>=l&&c>0?(i=!0,s=Gt(l-e),n=-1):r&&t<l&&e>l&&(i=!0,s=Gt(e),n="reset"),{canEdgeScroll:i,direction:n,delay:s}}getEdgeScrollRow(e,t,o){let i=!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?(i=!0,s=Gt(e-a),n=1):e<l&&o>=l&&c>0?(i=!0,s=Gt(l-e),n=-1):r&&t<l&&e>l&&(i=!0,s=Gt(e),n="reset"),{canEdgeScroll:i,direction:n,delay:s}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(et);if(0===o.length)return{x:0,y:0,width:0,height:0};const i=Math.min(...o.map((e=>e.x))),n=Math.min(...o.map((e=>e.y))),s=Math.max(...o.map((e=>e.x+e.width)))-i,r=Math.max(...o.map((e=>e.y+e.height)))-n;return{x:i+this.gridOffsetX,y:n+this.gridOffsetY,width:s,height:r}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(et)}checkPositiveDimension(e){return e.width<0||e.height<0?68:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?76:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.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 o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,i=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=i,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:i,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(De(e,0,i),De(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),o=t-this.sheetViewHeight;return e=Math.min(e,o),e=Math.max(e,0)}getViewportOffset(e){var t,o;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(o=this.viewports[e])||void 0===o?void 0:o.bottomRight.offsetScrollbarY)||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),s=this.getters.getColRowOffset("COL",0,t,e),r=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new Gv(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:s,height:r},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new Gv(this.getters,e,{left:t,right:i-1,top:0,bottom:o-1},{width:this.sheetViewWidth-s,height:r},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new Gv(this.getters,e,{left:0,right:t-1,top:o,bottom:n-1},{width:s,height:this.sheetViewHeight-r},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new Gv(this.getters,e,{left:t,right:i-1,top:o,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:o}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(o,e);const{anchor:i}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(i.cell.col,i.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:i,scrollY:n}=this.getActiveSheetScrollInfo(),{x:s,y:r}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=s&&(e.x+e.width<=s+i||e.x>=a+i+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:o}=this.getters.getPaneDivisions(e),i=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,o).start;return{xRatio:i/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}qv.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class Zv{constructor(e,t,o){this.index=0,this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:i}=Sn.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class jv extends Uv{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:De(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:De(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:45;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),o=this.autofillZone;switch(this.direction){case"down":for(let i=t.left;i<=t.right;i++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(Bt(i,e));const s=this.createGenerator(n);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(s,i,t,e)}break;case"up":for(let i=t.left;i<=t.right;i++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(Bt(i,e));const s=this.createGenerator(n);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(s,i,t,e)}break;case"left":for(let i=t.top;i<=t.bottom;i++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(Bt(e,i));const s=this.createGenerator(n);for(let t=o.right;t>=o.left;t--)this.computeNewCell(s,t,i,e)}break;case"right":for(let i=t.top;i<=t.bottom;i++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(Bt(e,i));const s=this.createGenerator(n);for(let t=o.left;t<=o.right;t++)this.computeNewCell(s,t,i,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const o=this.getters.getSelectedZone();if(qo(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,i=e.bottom;if(o>0){let e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i});for(;e.type!==Ji.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i})}if(i===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i});for(;e.type!==Ji.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i})}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,o,i){const{cellData:n,tooltip:s,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=s,i&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=Cn.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],i=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=zt(t),s=this.getters.getCell({sheetId:i,col:e,row:n});o.push({col:e,row:n,cell:s,sheetId:i})}const n=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,n)||o}const i=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:i},rule:o})}return new Zv(t,this.getters,this.direction)}saveZone(e,t,o,i){this.autofillZone={top:e,bottom:t,left:o,right:i}}getDirection(e,t){const o=this.getters.getSelectedZone(),i={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const n=i.up.number>0?"up":"down",s=i.left.number>0?"left":"right";return Math.abs(i[n].number)>=Math.abs(i[s].number)?i[n].value:i[s].value}autoFillMerge(e,t,o,i){const n=this.getters.getActiveSheetId(),s={sheetId:n,col:o,row:i},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:i,bottom:i+a.bottom-a.top,left:o,right:o+a.right-a.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:i,y:n,width:s,height:r}=this.getters.getVisibleRect(this.autofillZone);s>0&&r>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(i,n,s,r),t.setLineDash([]))}}jv.layers=[5],jv.getters=["getAutofillTooltip"];class Xv extends Uv{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,o){const{col:i,row:n}=qo(o.col,o.row,t)?o:{col:t.left,row:t.top},s=this.findAdjacentData(e,i,n);return s?this.getters.isSingleCellOrMerge(e,t)||Ko(Ho(s,t))?[{position:{col:i,row:n},zone:s}]:this.sumDimensions(e,Ho(s,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const i=this.getters.getSheet(e),n=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),s=this.findSuitableZoneToSum(i,n.col,n.row);if(s)return this.getters.expandZone(e,s)}findSuitableZoneToSum(e,t,o){const i=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:o-1}),n=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:o});if(this.isNumber(n)&&!this.isNumber(i))return this.findHorizontalZone(e,t,o);const s=this.findVerticalZone(e,t,o);if(this.isZoneValid(s))return s;const r=this.findHorizontalZone(e,t,o);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,o){const i={top:0,bottom:o-1,left:t,right:t},n=this.reduceZoneStart(e,i,i.bottom);return{...i,top:n}}findHorizontalZone(e,t,o){const i={top:o,bottom:o,left:0,right:t-1},n=this.reduceZoneStart(e,i,i.right);return{...i,left:n}}reduceZoneStart(e,t,o){const i=this.getters.getEvaluatedCellsInZone(e.id,t),n=ze(o,-1,-1),s=n.filter((e=>i[e]&&!i[e].isAutoSummable)),r=Math.max(...s),a=Be(n.filter((e=>this.isNumber(i[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===Ji.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(X))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const o=new Set;return Ko(t)?(o.add(1===Yo(t).numberOfCols?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},Qo(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},Qo(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:i}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:i,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:i,right:n});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:i,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:i,bottom:n});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}Xv.getters=["getAutomaticSums"];class Yv extends Uv{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{es.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 o,i;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=null===(i=(o=es.get(this.persistentPopover.type)).onOpen)||void 0===i?void 0:i.call(o,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=es.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 o=this.getters.getActiveSheetId(),i=this.getters.getMerge({sheetId:o,col:e,row:t});return i?this.getters.getVisibleRect(i):this.getters.getVisibleRect(oi({col:e,row:t}))}}Yv.getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];var Kv;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(Kv||(Kv={}));class Qv extends Uv{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(Kv.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(Kv.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(Kv.current)}updateRegex(){let e=Oe(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),o=[];if(this.toSearch)for(const i of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(i.id);if(i&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:n}))){const e={col:t,row:n,selected:!1};o.push(e)}}return o.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId(),i=this.getters.getCell({sheetId:o,...t});if((null==i?void 0:i.isFormula)&&!this.searchOptions.searchFormulas)this.selectNextCell(Kv.next);else{const i=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),n=this.getSearchableString({sheetId:o,col:t.col,row:t.row}).replace(i,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:n}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(Kv.current)}}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replace(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,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge({sheetId:o,col:e.col,row:e.row}),n=i?i.left:e.col,s=i?i.right:e.col,r=i?i.top:e.row,a=i?i.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)))}}}Qv.layers=[3],Qv.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class Jv extends Uv{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition({sheetId:e,col:t,row:o}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",ze(t,this.getters.getNumberCols(e))),row:this.findVisibleHeader(e,"ROW",ze(o,this.getters.getNumberRows(e)))}}findVisibleHeader(e,t,o){return o.find((o=>this.getters.doesHeaderExist(e,t,o)&&!this.isHeaderHidden(e,t,o)))}findLastVisibleColRowIndex(e,t,{last:o,first:i}){return ze(o,i,-1).find((o=>!this.isHeaderHidden(e,t,o)))||i}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let i=0;i<o-1;i++){if("COL"===t&&!this.isColHidden(e,i))return i;if("ROW"===t&&!this.isRowHidden(e,i))return i}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const i=this.isRowHidden(t.id,Number(e));o.isHidden=i}}}Jv.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class eb extends Uv{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:o}=Yo(e.zone),i=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:i}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),n=3*o;t.lineWidth=n;const s=this.getHighlights();for(let e of s.filter(((e,t)=>s.findIndex((t=>Wo(t.zone,e.zone)&&t.sheetId===i))===t))){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e.zone);s>0&&r>0&&(t.strokeStyle=e.color,t.strokeRect(o+n/2,i+n/2,s-n,r-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+n,i+n,s-2*n,r-2*n))}}}eb.layers=[1],eb.getters=["getHighlights"];class tb extends Uv{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleCols()),i=this.getters.getColRowOffsetInViewport("COL",o,t),n=this.getters.getColSize(e,t);return{start:i,size:n,end:i+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleRows()),i=this.getters.getColRowOffsetInViewport("ROW",o,t),n=this.getters.getRowSize(e,t);return{start:i,size:n,end:i+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,o){let i=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(i+="ROW"===e?O:N),i}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:o}=e,{width:i,height:n}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,i+m,n+m);const s=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),r=s?.1*o:0;if(s)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=o,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 o=e.style;o.fillColor&&"#ffffff"!==o.fillColor&&(t.fillStyle=o.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,o;const{ctx:i,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===(o=e.clipRect)||void 0===o?void 0:o.x)||e.x+e.width/2-e.content.width/2)+n/2,a=h-2*n),i.fillStyle="#ffffff",i.fillRect(r,l,a,c)}}drawBorders(e){const{ctx:t,thinLineWidth:o}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:o,y:n,width:s,height:r}=e;t.left&&i(t.left,o,n,o,n+r),t.top&&i(t.top,o,n,o+s,n),t.right&&i(t.right,o+s,n,o+s,n+r),t.bottom&&i(t.bottom,o,n+r,o+s,n+r)}}function i([e,i],n,s,r,a){t.strokeStyle=i,t.lineWidth=("thin"===e?2:3)*o,t.beginPath(),t.moveTo(n,s),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let i;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},s=e.content.align||"left",r=Ue(n);r!==i&&(i=r,t.font=r),t.fillStyle=n.textColor||"#000";let a=e.x;if(a+="left"===s?U+(e.image?e.image.size+L:0):"right"===s?e.width-U-(e.isFilterHeader?20:0):e.width/2,t.textAlign=s,e.clipRect){t.save(),t.beginPath();const{x:o,y:i,width:n,height:s}=e.clipRect;t.rect(o,i,n,s),t.clip()}const l=Ve(n),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let i of e.content.textLines){if(t.fillText(i,Math.round(a),Math.round(h)),n.strikethrough||n.underline){const e=Pe(t,i,n);let r=a;"right"===s?r-=e:"center"===s&&(r-=e/2),n.strikethrough&&t.fillRect(r,h+l/2,e,2.6*o),n.underline&&t.fillRect(r,h+l+1,e,1.3*o)}h+=U+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:i,width:n,height:s}=e.image.clipIcon;t.rect(o,i,n,s),t.clip()}const i=e.image.size,n=this.computeTextYCoordinate(e,i);t.drawImage(o,e.x+L,n,i,i),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,o=1){const i=e.y+1,n=ke(t,o),s=e.height>n+2*U,r=e.verticalAlign||"middle";if(s){if("middle"===r)return i+(e.height-n)/2;if("bottom"===r)return i+e.height-n-U}return i+U}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getSheetViewVisibleCols(),n=i[0],s=i[i.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 o of e)for(let e of ze(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of ze(o.top,o.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 ${q}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=n;e<=s;e++){const o={left:e,right:e,top:0,bottom:f-1},{x:i,width:n}=this.getters.getVisibleRect(o),s=this.getters.doesZonesContainFilter(p,[o]),r=E.has(e),a=u.has(e);t.fillStyle=r?s?I:S:a?s?T:b:s?R:v,t.fillRect(i,0,n,O)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:m-1},{y:i,height:n}=this.getters.getVisibleRect(o),s=this.getters.doesZonesContainFilter(p,[o]),r=w.has(e),a=g.has(e);t.fillStyle=r?s?I:S:a?s?T:b:s?R:v,t.fillRect(0,i,N,n)}t.beginPath(),t.moveTo(N,0),t.lineTo(N,h),t.moveTo(0,O),t.lineTo(c,O),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of i){const o=this.getters.getColSize(p,e),i=Ut(e);t.fillStyle=E.has(e)?"#fff":C;let s=this.getHeaderOffset("COL",n,e);t.fillText(i,s+o/2,13),t.moveTo(s+o,0),t.lineTo(s+o,O)}for(const e of r){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let i=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,i+o/2),t.moveTo(0,i+o),t.lineTo(N,i+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.isDashboard()?0:N,r=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),i&&(t.moveTo(s+i,0),t.lineTo(s+i,r)),n&&(t.moveTo(0,r+n),t.lineTo(s,r+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:i,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:N,u=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),i&&(t.moveTo(d+i,u),t.lineTo(d+i,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}findNextEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let n=e;for(;n<t;){const e={sheetId:i,col:n+1,row:o},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==Ji.empty||this.getters.isInMerge(e)||(null==s?void 0:s.left))return n;n++}return n}findPreviousEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let n=e;for(;n>t;){const e={sheetId:i,col:n-1,row:o},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==Ji.empty||this.getters.isInMerge(e)||(null==s?void 0:s.right))return n;n--}return n}computeCellAlignment(e,t){const o=this.getters.getCell(e);if((null==o?void 0:o.isFormula)&&this.getters.shouldShowFormulas())return"left";const{align:i}=this.getters.getCellStyle(e),n=this.getters.getEvaluatedCell(e);return t&&n.type===Ji.number?"center"!==i?"left":i:i||n.defaultAlign}createZoneBox(e,t,o){const{left:i,right:n}=o,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===Ji.empty)return f;const v=this.getters.getConditionalIcon(a),b=Ve(f.style),S=v?L+b:0;v&&(f.image={type:"icon",size:b,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:mg[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*U,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+U))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===Ji.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,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=s):(e=this.findNextEmptyCol(s,n,r),o=this.findPreviousEmptyCol(s,i,r),f.isOverflow=!0),T){case"left":{const o=oi({col:e,row:r}),{x:i,y:n,width:s,height:a}=this.getters.getVisibleRect(Ho(t,o));(s<R||b>a||x.length>1)&&(f.clipRect={x:i,y:n,width:s,height:a});break}case"right":{const e=oi({col:o,row:r}),{x:i,y:n,width:s,height:a}=this.getters.getVisibleRect(Ho(t,e));(s<R||b>a||x.length>1)&&(f.clipRect={x:i,y:n,width:s,height:a});break}case"center":{const i={...t,left:o,right:e},{x:n,y:s,height:r,width:a}=this.getters.getVisibleRect(i),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(),o=t[0],i=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),s={left:o,right:i,top:n[0],bottom:n[n.length-1]},r=this.getters.getActiveSheetId();for(const o of n)for(const i of t){const t={sheetId:r,col:i,row:o};this.getters.isInMerge(t)||e.push(this.createZoneBox(r,oi(t),s))}for(const t of this.getters.getMerges(r))if(!this.getters.isMergeHidden(r,t)&&Go(t,s)){const o=this.createZoneBox(r,t,s),i=this.getters.getCellBorder({sheetId:r,col:t.right,row:t.bottom});o.border={...o.border,bottom:i?i.bottom:void 0,right:i?i.right:void 0},o.isMerge=!0,e.push(o)}return e}}tb.layers=[0,7],tb.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];class ob extends Uv{constructor(e,t,o){super(e),this.inputHasSingleRange=o,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){if("ADD_EMPTY_RANGE"===e.type)if(this.inputHasSingleRange&&1===this.ranges.length)return 30;return 0}handleEvent(e){const t=Lo(e.anchor.zone),o=this.activeSheet,i=this.getters.getActiveSheetId(),n=this.getters.getSheetName(i);this.add([i===o?t:`${Fe(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 o=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),i=this.getters.expandZone(e.sheetIdTo,oi({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:i})}}}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 o=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:o+t+1,color:ft[(o+t)%ft.length]}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=Lt(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:o}=Lt(t),i=this.getters.getSheetIdByName(o),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(i===n||void 0===i&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}ob.layers=[1],ob.getters=[];class ib extends Uv{constructor(e){super(e),this.config=e,this.inputs={},this.focusedInputId=null}get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}allowDispatch(e){var t,o;if("FOCUS_RANGE"===e.type){const i=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(o=this.currentInput)||void 0===o?void 0:o.focusedRangeIndex)===i)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:oi({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],o=t.ranges.find((t=>t.id===e.rangeId)),i=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(i,(null==o?void 0:o.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,o)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=Lt(e);return null!==t.match(_t)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]=new ob(this.config,t,o),0===t.length){const t=this.inputs[e],o={zone:oi({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}ib.layers=[1],ib.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class nb{constructor(){this.subscriptions={}}on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,i=o.length;e<i;e++){const i=o[e];i.callback.call(i.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function sb(e,t){return{...e,definition:pr(e.definition,t)}}function rb(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}qu.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],sb),qu.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],sb),qu.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)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 o;if(e.name===t.name)return{...e,name:(null===(o=e.name)||void 0===o?void 0:o.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),qu.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const i of e.target)for(const e of t.target)Go(i,e)||o.push({...i});if(o.length)return{...e,target:o};return})),qu.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],rb),qu.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],rb),qu.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(Go(e,o))return;return e}));const ab=[{match:function(e){return"sheetId"in e},fn:hb},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=hb(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const i=[];for(const o of e.target){const e=is(o,t);e&&i.push(e)}if(!i.length)return"IGNORE_COMMAND";return{...e,target:i}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=hb(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let i=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[o]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&qo(e.col,e.row,o))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const o=hb(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,i=o?"base":"elements";let n=o?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(et)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((o=>o>e?o+t.quantity:o))}if(n.length){let t=n;return o&&(t=n[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const o=[],i="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)o.push({...n,_zone:n._zone});else{const e=is(n._zone,t);e&&i!==n._sheetId&&o.push({...n,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function lb(e,t){const o=qu.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:i}of ab)if(o(e)){const o=i(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function cb(e,t){let o=[...e];for(const e of t)o=o.map((t=>lb(t,e))).filter(et);return o}function hb(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class db{constructor(e,t,o,i){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...o],this._changes=i?[...i]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class ub extends Error{}class gb extends nb{constructor(e,t,o=K){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Fo,this.debouncedMove=function(e,t,o){let i;return function(){const n=this,s=arguments,r=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||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 o=new db(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(o.id,o),this.trigger("new-local-state-update",{id:o.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:o.id,clientId:o.clientId,commands:o.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0,this.on("unexpected-revision-id",this,(({revisionId:e})=>{throw new Error(`The spreadsheet could not be loaded. Revision ${e} is corrupted.`)}));for(const t of e)this.onMessageReceived(t);this.off("unexpected-revision-id",this),this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new ub("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(et))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const o=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==o?void 0:o.col)===e.col&&o.row===e.row&&o.sheetId===e.sheetId)return;const i=o?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:i,version:1,client:{...n,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e)){switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":if(e.serverRevisionId!==this.serverRevisionId)return void this.trigger("unexpected-revision-id",{revisionId:e.serverRevisionId});const{clientId:t,commands:o}=e,i=new db(e.nextRevisionId,t,o);if(i.clientId!==this.clientId){this.revisions.insert(i.id,i,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:cb(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new db(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const pb=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class mb extends Uv{constructor(){super(...arguments),this.availableColors=new Set(pb),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(pb));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 ub)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const i=this.colors[o.id];t.push({...o,position:e,color:i})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:s}=e.position,r=this.getters.expandZone(i,{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*o,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${G+1}px ${q}`}}}mb.getters=["getClientsToDisplay"],mb.layers=[6];class fb extends Uv{allowDispatch(e){if("SORT_CELLS"===e.type){if(!qo(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 Qo(t).some((({col:t,row:o})=>!this.getters.isInMerge({sheetId:e,col:t,row:o})))?63:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>Go(e,t))),i=Yo(o[0]);let[n,s]=[i.numberOfCols,i.numberOfRows];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&o===s}))?0:63}expand(e,t){const{left:o,right:i,top:n,bottom:s}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,i),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,s)}}checkExpandedValues(e,t){const o=this.expand(e,t);let i;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:n,top:s,bottom:r}=o;for(let o=t;o<=n;o++)for(let t=s;t<=r;t++){const{col:n,row:s}=this.getters.getMainCellPosition({sheetId:e,col:o,row:t});if(i=this.getters.getEvaluatedCell({sheetId:e,col:n,row:s}),i.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,o))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:i,bottom:n,left:s,right:r}=t,a=!1;for(;!a;)a=!0,i>0&&(o=this.checkExpandedValues(e,{left:s-1,right:r+1,top:i-1,bottom:i-1}),o&&(a=!1,i--)),s>0&&(o=this.checkExpandedValues(e,{left:s-1,right:s-1,top:i-1,bottom:n+1}),o&&(a=!1,s--)),r<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:r+1,right:r+1,top:i-1,bottom:n+1}),o&&(a=!1,r++)),n<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:s-1,right:r+1,top:n+1,bottom:n+1}),o&&(a=!1,n++));return{left:s,right:r,top:i,bottom:n}}hasHeader(e,t){if(1===t[0].length)return!1;let o=t.map((t=>t.map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).type))));return o[0][0]===Ji.empty&&(o=o.slice(1)),!o.some((e=>e[0]===Ji.empty))&&!!o.some((e=>e[1]!==Ji.empty&&e[0]!==e[1]))}sortZone(e,t,o,i,n){const[s,r]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},o),c=this.mainCells(e,o);!n.sortHeaders&&this.hasHeader(e,c)&&(l.top+=r),c=this.mainCells(e,l);const h=function(e,t,o){const i=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let n=i.filter((e=>e.type===Ji.empty)),s=i.filter((e=>e.type!==Ji.empty));o&&(s.push(...n.map((e=>({...e,type:Ji.number,value:0})))),n=[]);const r="descending"===t?-1:1;return s.sort(((e,t)=>{let o=fr.indexOf(e.type)-fr.indexOf(t.type);return 0===o&&(o=e.type===Ji.text||e.type===Ji.error?e.value.localeCompare(t.value):e.value-t.value),r*o})).concat(n)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),i,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:o,row:i,sheetId:n}=c[e][d[t]];const a=this.getters.getCell({sheetId:n,col:o,row:i});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,o=this.getters.createAdaptedRanges(a.dependencies,0,t,n);e=this.getters.buildFormulaContent(n,a,o)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}for(const e of p)this.dispatch("UPDATE_CELL",e)}}mainCellsSteps(e,t){const o=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,i]=this.mainCellsSteps(e,t),n=[],s=ze(t.left,t.right+1,o),r=ze(t.top,t.bottom+1,i);for(const t of s){const o=[];n.push(o);for(const i of r)o.push({sheetId:e,col:t,row:i})}return n}}fb.getters=["getContiguousZone"];class vb extends Uv{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}vb.getters=["shouldShowFormulas"];class bb extends Uv{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e){const t=this.getCellText(e),o=this.getters.getCellComputedStyle(e);let i=this.getTextWidth(t,o);this.getters.getConditionalIcon(e)&&(i+=function(e){return Ve(e)+2*L}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(i+=20),i>0&&(i+=2*z,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,i)}return i}getTextWidth(e,t){return Pe(this.ctx,e,t)}getCellText(e,t=!1){const o=this.getters.getCell(e);return t&&(null==o?void 0:o.isFormula)?o.content:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),i=this.getters.getCellText(e,this.getters.shouldShowFormulas()),n=[];for(const e of i.split("\n")){const i=e.split(" ");if(!t){n.push(e);continue}let s="",r=t;for(let e of i){const i=this.splitWordToSpecificWidth(this.ctx,e,t,o),a=i.pop(),l=Pe(this.ctx,a,o);if(i.length)""!==s&&(n.push(s),s="",r=t),i.forEach((e=>{n.push(e)})),s=a,r=t-l;else{const e=""===s?a:" "+a,i=Pe(this.ctx,e,o);i<=r?(s+=e,r-=i):(n.push(s),s=a,r=t-l)}}""!==s&&n.push(s)}return n}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),i=this.getters.getColSize(e,t);return{start:o,size:i,end:o+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),i=this.getters.getRowSize(e,t);return{start:o,size:i,end:o+(this.getters.isRowHidden(e,t)?0:i)}}getColRowOffset(e,t,o,i=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let n=0;for(let s=t;s<o;s++)this.getters.isHeaderHidden(i,e,s)||(n+="COL"===e?this.getters.getColSize(i,s):this.getters.getRowSize(i,s));return n}getColMaxWidth(e,t){const o=Qo(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...o)}splitWordToSpecificWidth(e,t,o,i){if(Pe(e,t,i)<=o)return[t];const n=[];let s="";for(let r of t){Pe(e,s+r,i)>o?(n.push(s),s=r):s+=r}return n.push(s),n}}bb.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];class Sb{constructor(e,t,o,i){this.getters=t,this.dispatch=o,this.selection=i,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,i){const n=this.getters.getActiveSheetId(),s=t+i-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+o-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 Cb extends Sb{constructor(e,t,o,i,n){if(super(t,o,i,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 o=e.length;for(let i=0;i<o;i++)if(Go(e[i],t))return e[i]=Ho(e[i],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>Qo(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=o.getActiveSheetId();for(let e of u){let t=[];for(let i of d){const n={col:i,row:e,sheetId:p};t.push({cell:o.getCell(n),style:o.getCellComputedStyle(n),evaluatedCell:o.getEvaluatedCell(n),border:o.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 o of ze(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:o,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 o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const i=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||i*n!=1))return 2;const{xSplit:s,ySplit:r}=this.getters.getPaneDivisions(o);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 o=this.cells.length,i=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(i,o,n,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,i=this.cells[0].length,n=this.pastedZones(e,i,o);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,i,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,o){const i=e[0],n=Math.max(1,Math.floor((i.right+1-i.left)/t)),s=Math.max(1,Math.floor((i.bottom+1-i.top)/o)),r=[];for(let e=0;e<n;e++)for(let n=0;n<s;n++){const s=i.top+n*o,a=i.left+e*t;r.push({left:a,top:s,bottom:s+o-1,right:a+t-1})}return r}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],i=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)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:r,top:a,right:r-1+e*n,bottom:a-1+t*i});return o}selectPastedZone(e,t,o,i){const n=i[0],s=n.left,r=n.top;if(t>1||e>1||o){const n=this.pastedZones(i,e,t),a=o?n[0]:Ho(...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,o){const i=this.cells.length,n=this.cells[0].length,s="onlyValue"!==(null==o?void 0:o.pasteOption)&&(null==o?void 0:o.shouldPasteCF),r=this.getters.getActiveSheetId();this.addMissingDimensions(n,i,e,t);for(let a=0;a<i;a++){const i=this.cells[a];for(let l=0;l<n;l++){const n=i[l],c={col:e+l,row:t+a,sheetId:r};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,o),s&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,o,i){const{sheetId:n,col:s,row:r}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==(null==i?void 0:i.pasteOption)){const o=this.getters.getCellBorder(t),i=e.border,a={top:(null==o?void 0:o.top)||(null==i?void 0:i.top),bottom:(null==o?void 0:o.bottom)||(null==i?void 0:i.bottom),left:(null==o?void 0:o.left)||(null==i?void 0:i.left),right:(null==o?void 0:o.right)||(null==i?void 0:i.right)};this.dispatch("SET_BORDER",{sheetId:n,col:s,row:r,border:a})}if(e.cell){if("onlyFormat"===(null==i?void 0:i.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===(null==i?void 0:i.pasteOption)){const o=ho(e.evaluatedCell.value);return void this.dispatch("UPDATE_CELL",{...t,content:o})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===o){const t=s-e.position.col,i=r-e.position.row;a=this.getUpdatedContent(n,e.cell,t,i,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==i?void 0:i.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==i?void 0:i.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,i,n){const s=this.getters.createAdaptedRanges(t.dependencies,o,i,e);return this.getters.buildFormulaContent(e,t,s)}pasteMergeIfExist(e,t){let{sheetId:o,col:i,row:n}=e;const{col:s,row:r}=this.getters.getMainCellPosition(e);if(s===i&&r===n){const s=this.getters.getMerge(e);if(!s)return;({sheetId:o,col:i,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:i,top:n,right:i+s.right-s.left,bottom:n+s.bottom-s.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],i=this.zones[0],n=[o.left-i.left,o.top-i.top];for(const e of this.copiedTables){const o=Jo(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const i of ze(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+i,row:o.top,values:e.filtersValues[i]})}}getClipboardContent(){return{[en.PlainText]:this.getPlainTextContent(),[en.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 o of t){e+=`<td style="${gi(di(o.style))}">`+jm(this.getters.getCellText(o.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:i,width:n,height:s}=this.getters.getVisibleRect(e);n>0&&s>0&&t.strokeRect(o,i,n,s)}}}}class Eb{constructor(e,t,o){this.operation=e,this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const i=t.getSelectedFigureId();if(!i)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,i);if(!n)throw new Error(`No figure for the given id: ${i}`);switch(this.copiedFigure={...n},n.tag){case"chart":this.copiedFigureContent=new wb(o,t,this.sheetId,i);break;case"image":this.copiedFigureContent=new yb(o,t,this.sheetId,i);break;default:throw new Error(`Unknow tag '${n.tag}' for the given figure id: ${i}`)}}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(),o={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},i={height:this.copiedFigure.height,width:this.copiedFigure.width},n=(new Fo).uuidv4();this.copiedFigureContent.paste(t,n,o,i),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return{[en.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class wb{constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const n=t.getChart(i);if(!n)throw new Error(`No chart for the given id: ${i}`);this.copiedChart=n.copyInSheetId(o)}paste(e,t,o,i){const n=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:o,size:i,definition:n.getDefinition()})}}class yb{constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const n=t.getImage(i);this.copiedImage=Ne(n)}paste(e,t,o,i){const n=Ne(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:o,size:i,definition:n})}}class xb extends Sb{constructor(e,t,o,i){super("COPY",t,o,i),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),i=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,i)?2:0}paste(e){const t=this.values,o=this.getPasteZone(e),{left:i,top:n}=o,{numberOfCols:s,numberOfRows:r}=Yo(o),a=this.getters.getActiveSheetId();this.addMissingDimensions(s,r,i,n);for(let e=0;e<t.length;e++)for(let o=0;o<t[e].length;o++)this.dispatch("UPDATE_CELL",{row:n+e,col:i+o,content:t[e][o],sheetId:a});const l={left:i,top:n,right:i+s-1,bottom:n+r-1};this.selection.selectZone({cell:{col:i,row:n},zone:l})}getClipboardContent(){return{[en.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,o=Math.max(...this.values.map((e=>e.length))),{left:i,top:n}=e[0];return{top:n,left:i,bottom:n+t-1,right:i+o-1}}}class Ib extends Uv{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=e.target||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new xb(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}}return 0}handle(e){var t,o;switch(e.type){case"COPY":case"CUT":const i="target"in e&&e.target||this.getters.getSelectedZones();this.state=this.getClipboardState(i,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:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Po(t[0])){for(const{col:t,row:o}of Qo(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(o=this.state)||void 0===o?void 0:o.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new xb(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:rn(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||{[en.PlainText]:"\t"}}getClipboardTextContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent()[en.PlainText])||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i;return i="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i,n;return"COL"===t?(i={...e,right:this.getters.getNumberCols(o)-1},n={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:this.getters.getNumberRows(o)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[i],paste:[n]}}getClipboardStateForCopyCells(e,t){return new Cb(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new Eb(t,this.getters,this.dispatch):new Cb(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}function Rb(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Lt(e.value),[i,n]=t.split(":"),s=o?`${Fe(o)}!`:"",r=Tb(i),a=n?`:${Tb(n)}`:"";return{...e,value:s+r+a}}function Tb(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=Ab(e,"colrow");break;case"colrow":e=Ab(e,"row");break;case"row":e=Ab(e,"col");break;case"col":e=Ab(e,"none")}return e}function Ab(e,t){let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}Ib.layers=[2],Ib.getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];const Mb=s("The cell you are trying to edit has been deleted.");class Ob extends Uv{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),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:i}=Lt(e.value),n=i||this.getters.getSheetName(this.sheetId),s=this.getters.getActiveSheetId();if(this.getters.getSheetName(s)!==n)return!1;const r=this.getters.getRangeFromSheetXC(s,o);return Wo(this.getters.expandZone(s,r.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const i=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(i,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:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),n=this.getters.expandZone(e.sheetIdTo,oi({col:o,row:i}));this.selection.resetAnchor(this,{cell:{col:o,row:i},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:Mb}));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((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(Rb).map((e=>e.value)).join(""),i=this.currentContent,n=e[0].start,s=e[e.length-1].end,r=i.slice(0,n)+o+i.slice(s),a=r.length-i.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,o){return t>=0&&t<=e&&o>=0&&o<=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:Mb});const{top:t,left:o}=zo({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Mb});const{top:t,left:o}=zo({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=Vo({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=oi({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var o;const i=this.getters.getActiveCell();e&&(null===(o=i.format)||void 0===o?void 0:o.includes("%"))&&Qt(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=oi({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 o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const i=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCell({sheetId:i,col:this.col,row:this.row});if(o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,i=e-t;i>0&&(o+=it(new Array(i).fill(")")))}else n.link&&(o=je(o,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}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:o,value:i,type:n,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(n){case Ji.text:case Ji.empty:return i;case Ji.boolean:return s;case Ji.error:return(null==t?void 0:t.content)||"";case Ji.number:return o&&mo(o)?s:this.numberComposerContent(i,o)}}numberComposerContent(e,t){return(null==t?void 0:t.includes("%"))?100*e+"%":function(e){const{integerDigits:t,decimalDigits:o}=po(e,20);return o?`${t}.${o}`:t}(e)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const i=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(i||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?Ev(e):[],this.currentTokens.length>100&&o&&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),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const o=this.getters.getActiveSheetId();let i=this.getters.zoneToXC(o,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){i=`${Fe(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${i}`}return i}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let o=[...t];1===t.length&&ni(e.zone)>1?o.push({...t[0]}):2===t.length&&1===ni(e.zone)&&o.pop();const i=e.clone({parts:o});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:i,end:i}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const i=new Set(Object.values(o));let n=0;const s=()=>{for(;i.has(n);)n++;return i.add(n),n};for(const e of t){const t=e in o?o[e]:s();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ft[t%ft.length]};return this.getReferencedRanges().map((o=>{const i=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(i),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,i=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(i.type)||bf.includes(i.value);){if("SPACE"!==i.type||o<1)return!1;o--,i=this.currentTokens[o]}for(o=t+1,i=this.currentTokens[o];i&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;o++,i=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}Ob.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];const Nb=[{name:s("Sum"),types:[Ji.number],compute:e=>sl.compute([e])},{name:s("Avg"),types:[Ji.number],compute:e=>fl.compute([e])},{name:s("Min"),types:[Ji.number],compute:e=>Fl.compute([e])},{name:s("Max"),types:[Ji.number],compute:e=>Ml.compute([e])},{name:s("Count"),types:[Ji.number,Ji.text,Ji.boolean,Ji.error],compute:e=>xl.compute([e])},{name:s("Count Numbers"),types:[Ji.number,Ji.text,Ji.boolean,Ji.error],compute:e=>yl.compute([e])}];class _b extends Uv{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 o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const i=o.findIndex((t=>Wo(t,e.previousAnchor.zone)));i>=0&&(o[i]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Ne(this.gridSelection.anchor));const{col:i,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:i,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:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(o,i),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:Ne(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Ne(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,o)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}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:Ne(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}const 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,Ne(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 o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Ne(this.gridSelection.zones)}getSelectedZone(){return Ne(this.gridSelection.anchor.zone)}getSelection(){return Ne(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!==Ji.empty)));let t=new Set,o=[];for(let i of e)t.add(i.type),o.push(i.value);let i={};for(let e of Nb){let n;e.types.some((e=>t.has(e)))&&(n=e.compute(o)),i[e.name]=n}return i}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),i=this.gridSelection.zones.map(Qo).flat();for(const{col:n,row:s}of i){const i=this.getters.getEvaluatedCell({sheetId:o,col:n,row:s});i.type===Ji.number&&(t++,e+=i.value)}return t<2?null:ho(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Wo(t,e)))}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let o=[];const i="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[i]+1},((t,o)=>e[i]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:i}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(i)}selectCell(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:i,cell:{col:e,row:t}},[i])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=zo(o,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=zo(n,"left",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:i};this.setSelectionMixin(s,[i])}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=zo(o,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=zo(n,"top",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:i};this.setSelectionMixin(s,[i])}onAddElements(e){const t=Vo(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(o,[t])}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const o="COL"===e.dimension,i=e.elements[0],n=e.elements[t-1],s=e.base<i,r=s&&o?t:0,a=s&&!o?t:0;this.dispatch("CUT",{target:[{left:o?i+r:0,right:o?n+r:this.getters.getNumberCols(e.sheetId)-1,top:o?0:i+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:n+a}]}),this.dispatch("PASTE",{target:[{left:o?e.base:0,right:o?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:e.base,bottom:o?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=s?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const o="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:o,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],i=e.elements[e.elements.length-1],n=e.sheetId,s=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return s(n,o-1,o)||s(n,i,i+1)||s(n,e.base-1,e.base)?2:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,i=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:De(e.left,0,o),right:De(e.right,0,o),top:De(e.top,0,i),bottom:De(e.bottom,0,i)}))),anchor:{cell:{col:De(t.anchor.cell.col,0,o),row:De(t.anchor.cell.row,0,i)},zone:{left:De(t.anchor.zone.left,0,o),right:De(t.anchor.zone.right,0,o),top:De(t.anchor.zone.top,0,i),bottom:De(t.anchor.zone.bottom,0,i)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o;for(const e of i){const{x:o,y:i,width:n,height:s}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(o,i,n,s),t.globalCompositeOperation="source-over",t.strokeRect(o,i,n,s)}t.globalCompositeOperation="source-over";const s=this.getActivePosition();let r;t.strokeStyle=E,t.lineWidth=3*o,r=this.getters.isInMerge(s)?this.getters.getMerge(s):oi(s);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);c>0&&h>0&&t.strokeRect(a,l,c,h)}}_b.layers=[6],_b.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","getElementsFromSelection"];const Fb=(new bi).add("sheet",Lv).add("header visibility",Nv).add("filters",Mv).add("cell",wv).add("merge",Fv).add("headerSize",Ov).add("borders",Yf).add("conditional formatting",Iv).add("figures",Rv).add("chart",yv).add("image",_v),Db=(new bi).add("ui_sheet",bb).add("header_visibility_ui",Jv).add("ui_options",vb).add("selectionInputManager",ib).add("highlight",eb).add("grid renderer",tb).add("autofill",jv).add("find_and_replace",Qv).add("sort",fb).add("automatic_sum",Xv).add("format",class extends Uv{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){for(const i of t)for(const t of Qo(i)){const i=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==i){const n=wo(i,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:[oi(t)],format:n})}}}getCellNumberFormat(e){var t;for(const o of[e]){const e=this.getters.getEvaluatedCell(o);if(e.type===Ji.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(X)))return e.format||So(e.value)}}}).add("cell_popovers",Yv).add("selection_multiuser",mb),kb=(new bi).add("selection",_b).add("clipboard",Ib).add("edition",Ob),Pb=(new bi).add("evaluation",Bv).add("evaluation_filter",Wv).add("evaluation_chart",Hv).add("evaluation_cf",$v).add("viewport",qv).add("custom_colors",Vv),Lb=new bi;Lb.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,action:(e,t)=>Ii(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Ub{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)}}getImageFromUser(){return new Promise(((e,t)=>{const o=document.createElement("input");o.setAttribute("type","file"),o.setAttribute("accept","image/*"),o.addEventListener("change",(async()=>{null===o.files||1!=o.files.length?t():e(o.files[0])})),o.click()}))}getImageSize(e){return new Promise(((t,o)=>{const i=new Image;i.src=e,i.addEventListener("load",(()=>{const e={width:i.width,height:i.height};t(e)})),i.addEventListener("error",o)}))}}const Vb=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];ci`
|
|
1380
|
+
`}function Jm(e){return new hp(e.join("\n"))}function ef(e,...t){let o=[e[0]];for(let i=0;i<t.length;i++){const n=t[i]instanceof hp?t[i]:Xm(t[i]);o.push(n+e[i+1])}return new hp(it(o))}function tf(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function of(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class nf{constructor(e){this.value=e}asString(){return Jp(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class sf{constructor(e,t,o){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=o,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(et)}mapOnElements(e,t){var o;const i=[],n=this.currentFile;let s;if(e.children){const t=null===(o=this.querySelector(e.parent,e.query))||void 0===o?void 0:o.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{i.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,i}catchErrorOnElement(e,t){const o=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([o,e.message].join("\n"))}extractAttr(e,t,o){const i=e.attributes[t];i||this.handleMissingValue(e,`attribute "${t}"`,o);const n=(null==i?void 0:i.value)?i.value:null==o?void 0:o.default;return void 0===n?void 0:new nf(n)}extractTextContent(e,t){var o;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const i="preserve"===(null===(o=null==e?void 0:e.attributes["xml:space"])||void 0===o?void 0:o.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=i?n:n.trim()),n?Jp(n):null==t?void 0:t.default}extractChildAttr(e,t,o,i){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}>`,i);const r=s?null===(n=this.extractAttr(s,o,i))||void 0===n?void 0:n.asString():null==i?void 0:i.default;return void 0!==r?new nf(r):void 0}extractChildTextContent(e,t,o){if(void 0!==(null==o?void 0:o.default)&&"string"!=typeof o.default)throw new Error("extractTextContent default value should be a string");let i=this.querySelector(e,t);return i||this.handleMissingValue(e,`child <${t}>`,o),i?this.extractTextContent(i,o):null==o?void 0:o.default}handleMissingValue(e,t,o){if(null==o?void 0:o.required){if(!(null==o?void 0:o.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${o.default}`)}}extractColor(e,t,o){var i,n,s,r,a;if(!e)return o?{rgb:o}:void 0;const l=null===(i=this.extractAttr(e,"theme"))||void 0===i?void 0:i.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 o=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!o||!o.file)throw new Error("Cannot find target file");return o}querySelector(e,t){return t=this.areNamespaceIgnored?tf(t):of(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?tf(t):of(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 rf extends sf{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:up}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:up}).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 af extends sf{constructor(e,t,o,i){super(e,t,o),this.theme=i}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var o,i,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===(o=this.extractAttr(e,"dxfId"))||void 0===o?void 0:o.asNum(),stopIfTrue:null===(i=this.extractAttr(e,"stopIfTrue"))||void 0===i?void 0:i.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 o=this.querySelector(e,"colorScale");if(o)return{colors:this.mapOnElements({parent:o,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(o)}}extractCfIconSet(e){var t,o;const i=this.querySelector(e,"iconSet, x14:iconSet");if(i)return{iconSet:this.extractAttr(i,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(i,"showValue",{default:!0}).asBool(),percent:this.extractAttr(i,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(i,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(o=this.extractAttr(i,"custom"))||void 0===o?void 0:o.asBool(),cfvos:this.extractCFVos(i),cfIcons:this.extractCfIcons(i)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,o;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(o=this.extractAttr(e,"val"))||void 0===o?void 0:o.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class lf extends sf{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!Wp[t])throw new Error(`Unsupported chart type ${t}`);const o=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),i=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:o,type:Wp[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:$p[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===i,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=tf(e.tagName);if(dp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class cf extends sf{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==tf(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const o=this.querySelector(t,e);if(!o)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(o,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(o,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(o,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(o,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),o=this.getTargetXmlFile(this.relationships[t]),i=new lf(o,this.xlsxFileStructure,this.warningManager).extractChart();if(!i)throw new Error("Unable to extract chart definition");return i}}class hf extends sf{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 df extends sf{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,o,i,n,s;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(o=this.extractAttr(e,"showFirstColumn"))||void 0===o?void 0:o.asBool(),showLastColumn:null===(i=this.extractAttr(e,"showLastColumn"))||void 0===i?void 0:i.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 uf extends sf{constructor(e,t,o,i){super(e,t,o),this.theme=i}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=Yp(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=Yp(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,o=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!o)throw new Error("Cannot find corresponding workbook sheet");return o}extractConditionalFormats(){return new af(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),i=this.getTargetXmlFile(this.relationships[o]);return new cf(i,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const o=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),i=this.getTargetXmlFile(this.relationships[o]);return new df(i,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 hf(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:wp.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:yp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,o,i,n,s,r,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(o=this.extractAttr(e,"customWidth"))||void 0===o?void 0:o.asBool(),bestFit:null===(i=this.extractAttr(e,"bestFit"))||void 0===i?void 0:i.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,o,i,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===(o=this.extractAttr(e,"ht"))||void 0===o?void 0:o.asNum(),customHeight:null===(i=this.extractAttr(e,"customHeight"))||void 0===i?void 0:i.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,o,i;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(o=this.extractAttr(e,"s"))||void 0===o?void 0:o.asNum(),type:Lp[null===(i=this.extractAttr(e,"t",{default:"n"}))||void 0===i?void 0:i.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,o;const i=this.querySelector(e,"f");if(i)return{content:this.extractTextContent(i),sharedIndex:null===(t=this.extractAttr(i,"si"))||void 0===t?void 0:t.asNum(),ref:null===(o=this.extractAttr(i,"ref"))||void 0===o?void 0:o.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,o,i,n;const s=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(o=this.extractAttr(e,"ref",{required:!0}))||void 0===o?void 0:o.asString(),location:null===(i=this.extractAttr(e,"location"))||void 0===i?void 0:i.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]"),o={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),i=this.extractTextContent(e,{required:!0});o[t]=i}const i=[];for(let e=0;e<Object.keys(o).length;e++)o[e]?i.push(o[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),i.push(""));return i}}class gf extends sf{constructor(e,t,o){super(e.styles,e,t),this.theme=o}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,o,i,n;const s=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),r=this.extractChildAttr(e,"sz","val",{default:G.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(o=h.attributes.val)||void 0===o?void 0:o.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(i=u.attributes.val)||void 0===i?void 0:i.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 o=e.children[0];return"patternFill"===o.tagName?{patternType:null===(t=o.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(o,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(o,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(o,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,o;const i={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 i.diagonal&&(i.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),i.diagonalDown=null===(o=this.extractAttr(e,"diagonalDown"))||void 0===o?void 0:o.asBool()),i}extractSingleBorder(e,t,o){const i=this.querySelector(e,t);if(i&&i.attributes.style)return{style:this.extractAttr(i,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(i.children[0],o,"000000")}}extractAlignment(e){var t,o,i,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===(o=this.extractAttr(e,"wrapText"))||void 0===o?void 0:o.asBool(),indent:null===(i=this.extractAttr(e,"indent"))||void 0===i?void 0:i.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"),o=this.querySelector(e,"fill"),i=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),s=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:o?this.extractFill(o):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:s?this.extractAlignment(s):void 0,border:i?this.extractBorder(i):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 pf extends sf{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),o={};for(let e of t)o[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:o}}))}}function mf(e,t){const o=function(e,t){const o=t[Mp],i=o.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of i){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const o=[];for(let i of e){const e=ff(i,t);o.push({file:{fileName:i,xml:t[i]},rels:e?{fileName:e,xml:t[e]}:void 0})}return o}(o,t)}function ff(e,t){if(e===Mp)return"_rels/.rels";let o="";const i=e.split("/");for(let e=0;e<i.length-1;e++)o+=i[e]+"/";return o+="_rels/",o+=i[i.length-1]+".rels",t[o]||(o=void 0),o}class vf{constructor(e){this.warningManager=new Np,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=Km(new hp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new rf(e.theme,e,this.warningManager).getTheme():void 0,o=e.sharedStrings?new rf(e.sharedStrings,e,this.warningManager).getSharedStrings():[],i=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((o=>new uf(o,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new pf(t,e,this.warningManager).getExternalBook())),s=new gf(e,this.warningManager,t);return{fonts:s.getFonts(),fills:s.getFills(),borders:s.getBorders(),dxfs:s.getDxfs(),numFmts:s.getNumFormats(),styles:s.getStyles(),sheets:i,sharedStrings:o,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:mf(vp.sheet,this.xmls),workbook:mf(vp.workbook,this.xmls)[0],styles:mf(vp.styles,this.xmls)[0],sharedStrings:mf(vp.sharedStrings,this.xmls)[0],theme:mf(vp.themes,this.xmls)[0],charts:mf(vp.chart,this.xmls),figures:mf(vp.drawing,this.xmls),tables:mf(vp.table,this.xmls),pivots:mf(vp.pivot,this.xmls),externalLinks:mf(vp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(s("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Lm(e,this.warningManager),styles:nm(e,this.warningManager),formats:rm(e,this.warningManager),borders:om(e,this.warningManager),entities:{},revisionId:K};return Gm(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=lt(e.styles[t])})),t}}const bf=$u.content,Sf=["%"],Cf="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Sf);function Ef(e){const t=(e=gt(e)).split(""),o=[];for(;t.length;){let e=Nf(t)||xf(t)||Rf(t)||Af(t)||wf(t)||_f(t)||Tf(t)||Of(t);e||(e={type:"UNKNOWN",value:t.shift()}),o.push(e)}return o}function wf(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const yf={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function xf(e){if(e[0]in yf){const t=e.shift();return{type:yf[t],value:t}}return null}function If(e,t){for(let o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function Rf(e){for(let t of Cf)if(If(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Tf(e){const t=it(e).match(qt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Af(e){if('"'===e[0]){const t=e.shift();let o=t;for(;e[0]&&(e[0]!==t||"\\"===o[o.length-1]);)o+=e.shift();return'"'===e[0]&&(o+=e.shift()),{type:"STRING",value:o}}return null}const Mf=/\w|\.|!|\$/;function Of(e){let t="";if("'"===e[0]){let o=e.shift();for(t+=o;e[0];)if(o=e.shift(),t+=o,"'"===o){if(!e[0]||"'"!==e[0])break;o=e.shift(),t+=o}if("'"!==o)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Mf);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in bf)return{type:"FUNCTION",value:e};return e.match(_t)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function Nf(e){let t=0;for(;e[0]===ce;)t++,e.shift();if(t)return{type:"SPACE",value:ce.repeat(t)};for(;" "===e[0];)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function _f(e){return If(e,Y)?(e.splice(0,Y.length),{type:"INVALID_REFERENCE",value:Y}):null}var Ff;!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"}(Ff||(Ff={}));const Df=(e,t=(()=>!0))=>[{goTo:e,guard:t}],kf=(e,t=(()=>!0))=>({goTo:e,guard:t}),Pf={[Ff.LeftRef]:{REFERENCE:Df(Ff.Separator),NUMBER:Df(Ff.FullRowSeparator),SYMBOL:[kf(Ff.FullColumnSeparator,(e=>Ft(e.value))),kf(Ff.FullRowSeparator,(e=>Dt(e.value)))]},[Ff.FullColumnSeparator]:{SPACE:Df(Ff.FullColumnSeparator),OPERATOR:Df(Ff.RightColumnRef,(e=>":"===e.value))},[Ff.FullRowSeparator]:{SPACE:Df(Ff.FullRowSeparator),OPERATOR:Df(Ff.RightRowRef,(e=>":"===e.value))},[Ff.Separator]:{SPACE:Df(Ff.Separator),OPERATOR:Df(Ff.RightRef,(e=>":"===e.value))},[Ff.RightRef]:{SPACE:Df(Ff.RightRef),NUMBER:Df(Ff.Found),REFERENCE:Df(Ff.Found,(e=>Pt(e.value))),SYMBOL:Df(Ff.Found,(e=>kt(e.value)))},[Ff.RightColumnRef]:{SPACE:Df(Ff.RightColumnRef),SYMBOL:Df(Ff.Found,(e=>kt(e.value))),REFERENCE:Df(Ff.Found,(e=>Pt(e.value)))},[Ff.RightRowRef]:{SPACE:Df(Ff.RightRowRef),NUMBER:Df(Ff.Found),REFERENCE:Df(Ff.Found,(e=>Pt(e.value)))},[Ff.Found]:{}};function Lf(e){var t;let o=0,i=Pf[Ff.LeftRef];const n=[];for(;void 0!==i;){const s=e[o++];if(!s)return null;const r=null===(t=i[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 Ff.Found:return n.push(s),e.splice(0,o),{type:"REFERENCE",value:it(n.map((e=>e.value)))};default:i=Pf[a],n.push(s)}}return null}function Uf(e){const t=Ef(e),o=[];for(;t.length;)o.push(Lf(t)||t.shift());return o}function Vf(e){const t=Uf(e);let o=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Tt.test(e.value)){const t=e.value.trim();return o.includes(t)||o.push(t),`${re}${o.indexOf(t)}${re}`}return e.value}))),dependencies:o}}const zf=12,Bf="Sheet1";function Hf(e,t){if(!e)return Zf();if(e["[Content_Types].xml"]){const o=new vf(e);if(e=o.convertXlsx(),t)for(let e of o.warningManager.warnings.sort())console.warn(e)}return"version"in(e=Ne(e))&&e.version<zf&&(e=function(e){for(let t=$f.findIndex((t=>t.from===e.version));t<$f.length;t++)e=$f[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,o=new Do;for(const i of e.sheets||[])for(const e of i.figures||[])t.has(e.id)&&(e.id+=o.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Zf(),e,{version:zf}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(qf(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(qf(Bf,"Sheet1"));return e}(e),e}(e),e}const $f=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];o.content&&o.content.startsWith("=")&&(o.formula=Vf(o.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:o,...i}=t.figures[e].data,n=[];for(let e of o)if(e.labelCell){const t=Po(e.dataRange),o=e.labelCell+":"+Bt(t.right,t.bottom);n.push(o)}else n.push(e.dataRange);i.dataSetsHaveTitle=Boolean(o[0].labelCell),i.dataSets=n,t.figures[e].data=i}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const o=[],i=new RegExp(se,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,s=e.replace(i,"_");let r=1,a=s;for(;o.includes(a);)a=`${s}${r}`,r++;n.name=a,o.push(a);const l=t=>{if(void 0===t)return t;let o=t.replace(e,a),i=t;for(;i!==o;)i=o,o=i.replace(e,a);return i};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),o=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:o}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const o of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[o])||void 0===t?void 0:t.type)&&(e.rule[o].value=l(e.rule[o].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const o=t.cells[e];if(o.formula){let{text:e,dependencies:t}=o.formula;for(let[o,i]of Object.entries(t)){const t=`\\${re}${o}\\${re}`;e=e.replace(new RegExp(t,"g"),i)}o.content=e,delete o.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let o of e.sheets||[])for(let e in o.cells||[]){const i=o.cells[e];i.format&&(i.format=ot(i.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 Wf(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const o=[],i=[],n=e=>{if("CREATE_SHEET"===e.type)o.push(e.sheetId);else if("sheetId"in e&&!o.includes(e.sheetId))return{...e,sheetId:Bf};return e};for(const e of t)"REMOTE_REVISION"===e.type?i.push({...e,commands:e.commands.map(n)}):i.push(e);return i}(e,t),t=Gf(t,"SORT_CELLS"),t=function(e,t){var o;const i=[],n={};for(const t of e.sheets||[])null===(o=t.figures)||void 0===o||o.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const o of e.commands){let e=o;switch(o.type){case"CREATE_CHART":n[o.id]=o.definition;break;case"UPDATE_CHART":if(!n[o.id]){console.log(`Fix chart definition: chart with id ${o.id} not found.`);continue}const t={...n[o.id],...o.definition};e={...o,definition:t},n[o.id]=t}t.push(e)}i.push({...e,commands:t})}else i.push(e);return i}(e,t=Gf(t,"SET_DECIMAL")),t}function Gf(e,t){const o=[];for(const i of e)"REMOTE_REVISION"===i.type?o.push({...i,commands:i.commands.filter((e=>e.type!==t))}):o.push(i);return o}function qf(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Zf(e="Sheet1"){return{version:zf,sheets:[qf(Bf,e)],entities:{},styles:{},formats:{},borders:{},revisionId:K,uniqueFigureIds:!0}}function jf(e,t){return{...qf(e,t),charts:[],images:[]}}class Xf{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 o of e){let e=o.call(this,t);Array.isArray(e)||(e=[e]);const i=e.filter((e=>0!==e));if(i.length)return i}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Xf.getters=[];class Yf extends Xf{constructor({getters:e,stateObserver:t,range:o,dispatch:i,uuidGenerator:n}){super(t,i),this.range=o,o.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class Kf extends Yf{constructor(){super(...arguments),this.borders={}}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const o=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,o)}break;case"DELETE_SHEET":const o={...this.borders};delete o[e.sheetId],this.history.update("borders",o);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,o;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,o)}handleAddRows(e){let t,o;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,o=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,o=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,o)}getCellBorder({sheetId:e,col:t,row:o}){var i,n,s,r,a,l,c,h,d,u,g,p;const m={top:null===(s=null===(n=null===(i=this.borders[e])||void 0===i?void 0:i[t])||void 0===n?void 0:n[o])||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[o+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[o])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,o){const i=ze(t+1,o);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:o,row:n});if(s&&r){const t=this.getCommonSides(s,r);for(let o of i)this.addBorder(e,o,n,t)}}}ensureRowBorderContinuity(e,t,o){const i=ze(t+1,o);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:o});if(s&&r){const t=this.getCommonSides(s,r);for(let o of i)this.addBorder(e,n,o,t)}}}getCommonSides(e,t){const o={};for(let i of["top","bottom","left","right"])e[i]&&e[i]===t[i]&&(o[i]=e[i]);return o}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?ze(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,o,{moveFirstLeftBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfColumn(e,t,o,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((n=>{(n===t&&i||n!==t)&&this.moveBordersOfColumn(e,n,o,"vertical"),this.moveBordersOfColumn(e,n,o,"horizontal")})))}shiftBordersVertically(e,t,o,{moveFirstTopBorder:i}={}){this.borders[e]&&(o<0&&this.moveBordersOfRow(e,t,o,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>o<0?e-t:t-e)).forEach((n=>{(n===t&&i||n!==t)&&this.moveBordersOfRow(e,n,o,"horizontal"),this.moveBordersOfRow(e,n,o,"vertical")})))}moveBordersOfRow(e,t,o,i,{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+o])||void 0===l?void 0:l[i],u=null===(h=null===(c=s[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[i];this.history.update("borders",e,r,t+o,i,n?u:u||d),this.history.update("borders",e,r,t,i,void 0)}))}moveBordersOfColumn(e,t,o,i,{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+o])||void 0===a?void 0:a[r])||void 0===l?void 0:l[i],u=null===(h=null===(c=s[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[i];this.history.update("borders",e,t+o,r,i,n?u:u||d),this.history.update("borders",e,t,r,i,void 0)}))}setBorder(e,t,o,i,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[o])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,o,"vertical",null==i?void 0:i.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[o])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,o,"horizontal",null==i?void 0:i.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[o])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,o,"vertical",null==i?void 0:i.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[o+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,o+1,"horizontal",null==i?void 0:i.bottom)}clearBorders(e,t){for(let o of t){for(let t=o.top;t<=o.bottom;t++){this.history.update("borders",e,o.right+1,t,"vertical",void 0);for(let i=o.left;i<=o.right;i++)this.history.update("borders",e,i,t,void 0)}for(let t=o.left;t<=o.right;t++)this.history.update("borders",e,t,o.bottom+1,"horizontal",void 0)}}addBorder(e,t,o,i){this.setBorder(e,t,o,{...this.getCellBorder({sheetId:e,col:t,row:o}),...i})}setBorders(e,t,o){if("clear"===o)return this.clearBorders(e,t);for(let i of t){if("h"===o||"hv"===o||"all"===o)for(let t=i.top+1;t<=i.bottom;t++)for(let o=i.left;o<=i.right;o++)this.addBorder(e,o,t,{top:Z});if("v"===o||"hv"===o||"all"===o)for(let t=i.top;t<=i.bottom;t++)for(let o=i.left+1;o<=i.right;o++)this.addBorder(e,o,t,{left:Z});if("left"===o||"all"===o||"external"===o)for(let t=i.top;t<=i.bottom;t++)this.addBorder(e,i.left,t,{left:Z});if("right"===o||"all"===o||"external"===o)for(let t=i.top;t<=i.bottom;t++)this.addBorder(e,i.right+1,t,{left:Z});if("top"===o||"all"===o||"external"===o)for(let t=i.left;t<=i.right;t++)this.addBorder(e,t,i.top,{top:Z});if("bottom"===o||"all"===o||"external"===o)for(let t=i.left;t<=i.right;t++)this.addBorder(e,t,i.bottom+1,{top:Z})}}addBordersToMerge(e,t){const{left:o,right:i,top:n,bottom:s}=t,r=this.getCellBorder({sheetId:e,col:o,row:n}),a=this.getCellBorder({sheetId:e,col:i,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:o}],"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:i}],"right")}import(e){if(e.borders)for(let t of e.sheets)for(let[o,i]of Object.entries(t.cells))if(null==i?void 0:i.border){const n=e.borders[i.border],{col:s,row:r}=zt(o);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,Po(e))}export(e){let t=0;const o={};function i(e){for(let[t,i]of Object.entries(o))if(Ae(i)===Ae(e))return parseInt(t,10);return o[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let o=0;o<t.rowNumber;o++){const n=this.getCellBorder({sheetId:t.id,col:e,row:o});if(n){const s=Bt(e,o),r=t.cells[s],a=i(n);r?r.border=a:t.cells[s]={border:a}}}e.borders=o}exportForExcel(e){this.export(e)}}Kf.getters=["getCellBorder"];class Qf{constructor(e=new ev){this.scope=e,this.code=""}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new Jf(this.scope,this.code,e)}toString(){return tv(this.code)}}class Jf{constructor(e,t,o){this.scope=e,this.returnExpression=o,this.code=tv(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new Qf(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 Qf(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class ev{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 tv(e){let t="",o=0;const i=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of i)e.startsWith("}")&&o--,t+="\t".repeat(o)+e+"\n",e.endsWith("{")&&o++;return t.trim()}const ov=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,iv=["-","+"],nv=["%"],sv=["*","+","&"],rv={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function av(e){var t,o,i;const n=e.shift();if(!n)throw new h(ae);switch(n.type){case"DEBUGGER":const r=hv(e,1e3);return r.debug=!0,r;case"NUMBER":return{type:"NUMBER",value:eo(n.value)};case"STRING":return{type:"STRING",value:Me(n.value)};case"FUNCTION":const a=function(e){var t;cv(e,"LEFT_PAREN",s("Missing opening parenthesis"));const o=e[0];if("RIGHT_PAREN"===(null==o?void 0:o.type))return cv(e,"RIGHT_PAREN"),[];const i=[];i.push(lv(e));for(;"RIGHT_PAREN"!==(null===(t=e[0])||void 0===t?void 0:t.type);)cv(e,"COMMA",s("Wrong function call")),i.push(lv(e));return cv(e,"RIGHT_PAREN"),i}(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===(o=e[1])||void 0===o?void 0:o.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&&ov.test(n.value)&&"LEFT_PAREN"===(null===(i=e[0])||void 0===i?void 0:i.type))throw new p(n.value);throw new h(s("Invalid formula"));case"LEFT_PAREN":const l=hv(e);return cv(e,"RIGHT_PAREN",s("Missing closing parenthesis")),l;case"OPERATOR":const c=n.value;if(iv.includes(c))return{type:"UNARY_OPERATION",value:c,operand:hv(e,rv[c])};throw new h(s("Unexpected token: %s",n.value));default:throw new h(s("Unexpected token: %s",n.value))}}function lv(e){const t=e[0];return"COMMA"===(null==t?void 0:t.type)||"RIGHT_PAREN"===(null==t?void 0:t.type)?{type:"EMPTY",value:""}:hv(e)}function cv(e,t,o=ae){const i=e.shift();if(!i||i.type!==t)throw new h(o)}function hv(e,t=0){var o;if(0===e.length)throw new h(ae);let i=av(e);for(;"OPERATOR"===(null===(o=e[0])||void 0===o?void 0:o.type)&&rv[e[0].value]>t;){const t=e.shift().value;if(nv.includes(t))i={type:"UNARY_OPERATION",value:t,operand:i,postfix:!0};else{i={type:"BIN_OPERATION",value:t,left:i,right:hv(e,rv[t])}}}return i}function dv(e){return uv(Ef(e))}function uv(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=hv(e);if(e.length)throw new h(ae);return t}function gv(e,t,o){switch(t===e.type&&(e=o(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>gv(e,t,o)))};case"UNARY_OPERATION":return{...e,operand:gv(e.operand,t,o)};case"BIN_OPERATION":return{...e,right:gv(e.right,t,o),left:gv(e.left,t,o)};default:return e}}function pv(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>pv(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?mv(e)+e.value:e.value+fv(e);case"BIN_OPERATION":return mv(e)+e.value+fv(e)}}function mv(e){const t=e.value,o="left"in e?e.left:e.operand,i=o.value;return"BIN_OPERATION"===o.type&&rv[i]<rv[t]?`(${pv(o)})`:pv(o)}function fv(e){const t=e.value,o="right"in e?e.right:e.operand,i=rv[o.value],n=rv[t];let s=!1;return"BIN_OPERATION"!==o.type?s=!1:i<n?s=!0:i!==n||sv.includes(t)||(s=!0),s?`(${pv(o)})`:pv(o)}const vv=$u.content,bv={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},Sv={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},Cv={};function Ev(e){const t=Uf(e),{dependencies:o,constantValues:i}=function(e){const t={numbers:[],strings:[]},o=[];for(const i of e)switch(i.type){case"INVALID_REFERENCE":case"REFERENCE":o.push(i.value);break;case"STRING":const e=Me(i.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=eo(i.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:o,constantValues:t}}(t),n=function(e,t,o){return it(e.map((e=>{switch(e.type){case"STRING":const i=Me(e.value);return`|S${o.strings.indexOf(i)}|`;case"NUMBER":return`|N${o.numbers.indexOf(eo(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,o,i);if(!Cv[n]){const r=uv([...t]),a=new ev;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 Qf;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=vv[e.value.toUpperCase()],o=e.args,i=o.length;if(i<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(),i.toString()));if(i>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(),i.toString()));const n=t.nbrArgRepeating;if(n>1){const o=t.args.length-n;if((i-o)%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(),o.toString(),n.toString()))}let r=[];for(let n=0;n<i;n++){const i=t.getArgToFocus(n+1)-1;if(0<=i&&i<t.args.length){const a=o[n],l=t.args[i],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 Qf(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[${i.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${i.strings.indexOf(e.value)}] }`);case"REFERENCE":const s=o.indexOf(e.value);return n?l.return(`range(deps[${s}])`):l.return(`ref(deps[${s}], ${t?"true":"false"}, "${r.functionName||bv["="]}", ${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=Sv[e.value],o=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression})`)}case"BIN_OPERATION":{const t=bv[e.value],o=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),i=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(o),l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${o.returnExpression}, ${i.returnExpression})`)}case"EMPTY":return l.return("undefined")}}Cv[n]={execute:d}}return{execute:Cv[n].execute,dependencies:o,constantValues:i,tokens:t}}function wv(e){return function(e){let t=[],o="";return e.map(((e,i)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(o=""),e.type){case"FUNCTION":o=e.value;break;case"LEFT_PAREN":t.push({parent:o,argPosition:0}),o="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const o=t[t.length-1];o.parent&&(e.functionContext=Object.assign({},o))}return e}))}(function(e){let t=1;const o=[];return e.map((e=>("LEFT_PAREN"===e.type?(o.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=o.pop()),e)))}(function(e){let t=0;return e.map((e=>{const o=e.value.toString().length,i=Object.assign({},e,{start:t,end:t+o,length:o});return t=i.end,i}))}(Uf(e))))}class yv extends Yf{constructor(){super(...arguments),this.nextId=1,this.cells={}}adaptRanges(e,t){for(const o of Object.keys(this.cells))for(const i of Object.values(this.cells[o]||{}))if(i.isFormula)for(const n of i.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",o,i.id,"dependencies",i.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,o){for(let i of t)for(let t=i.top;t<=i.bottom;t++)for(let n=i.left;n<=i.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:o})}clearFormatting(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,style:null,format:""})}handleAddColumnsRows(e,t){let o,i;"before"===e.position?(o=ze(e.base,e.base+e.quantity),i=e.base+e.quantity):(o=ze(e.base+1,e.base+e.quantity+1),i=e.base),t(e.sheetId,i,o)}import(e){for(let t of e.sheets)for(let o in t.cells){const i=t.cells[o],{col:n,row:s}=zt(o);if((null==i?void 0:i.content)||(null==i?void 0:i.format)||(null==i?void 0:i.style)){const o=this.importCell(t.id,i,e.styles,e.formats);this.history.update("cells",t.id,o.id,o),this.dispatch("UPDATE_CELL_POSITION",{cellId:o.id,col:n,row:s,sheetId:t.id})}}}export(e){const t={},o={};for(let i of e.sheets){const e={},n=Object.keys(this.cells[i.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const i of n){const n=this.getters.getCell(i);e[Bt(i.col,i.row)]={style:n.style?ot(n.style,t):void 0,format:n.format?ot(n.format,o):void 0,content:n.content||void 0}}i.cells=e}e.styles=t,e.formats=o}importCell(e,t,o,i){const n=t.style&&o[t.style]||void 0,s=t.format&&i[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 o=this.cells[t][e];if(o)return o}}buildFormulaContent(e,t,o){const i=o||[...t.dependencies];return it(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=i.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,o=[{colFixed:!1,rowFixed:!1}]){const i=Bt((t=this.getters.expandZone(e,t)).left,t.top,o[0]),n=Bt(t.right,t.bottom,o.length>1?o[1]:o[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 i==n||a?i:i+":"+n}setStyle(e,t,o){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let n=i.top;n<=i.bottom;n++){const i=this.getters.getCell({sheetId:e,col:t,row:n});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:o?{...null==i?void 0:i.style,...o}:void 0})}}copyColumnStyle(e,t,o){for(let i=0;i<this.getters.getNumberRows(e);i++){const n=this.getFormat(e,t,i);if(n.style||n.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,...n})}}copyRowStyle(e,t,o){for(let i=0;i<this.getters.getNumberCols(e);i++){const n=this.getFormat(e,i,t);if(n.style||n.format)for(let t of o)this.dispatch("UPDATE_CELL",{sheetId:e,col:i,row:t,...n})}}getFormat(e,t,o){const i={},n=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),s=this.getters.getCell(n);return s&&(s.style&&(i.style=s.style),s.format&&(i.format=s.format)),i}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,o,i){const n=this.getters.getCell({sheetId:e,col:t,row:o}),s="content"in i||"formula"in i,r=s?gt(null==i?void 0:i.content):(null==n?void 0:n.content)||"";let a;a=void 0!==i.style?i.style||void 0:n?n.style:void 0;let l=("format"in i?i.format:n&&n.format)||Eo(r);if((s&&!r&&!i.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:o,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:o,sheetId:e})}createCell(e,t,o,i,n){if(!t.startsWith("="))return this.createLiteralCell(e,t,o,i);try{return this.createFormulaCell(e,t,o,i,n)}catch(n){return this.createErrorFormula(e,t,o,i,n)}}createLiteralCell(e,t,o,i){return{id:e,content:t,style:i,format:o,isFormula:!1}}createFormulaCell(e,t,o,i,n){const s=Ev(t);return s.dependencies.length?this.createFormulaCellWithDependencies(e,s,o,i,n):{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:s,dependencies:[]}}createFormulaCellWithDependencies(e,t,o,i,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:i,format:o,isFormula:!0,compiledFormula:t,dependencies:s}}createErrorFormula(e,t,o,i,n){return{id:e,content:t,style:i,format:o,isFormula:!0,compiledFormula:{dependencies:[],tokens:Ef(t),execute:function(){throw n}},dependencies:[]}}checkCellOutOfSheet(e,t,o){if(!this.getters.tryGetSheet(e))return 27;return Zo(t,o,this.getters.getSheetZone(e))?0:18}}yv.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class xv extends Yf{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=ir.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,i,n){const s=t.find((e=>e.match(i.type)));if(!s)throw new Error(`No builder for this chart: ${i.type}`);return s.createChart(i,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const o=ir.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,o]of Object.entries(this.charts))this.history.update("charts",t,null==o?void 0:o.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const o=this.getters.getFigures(e.sheetId);for(const i of o)if("chart"===i.tag){const o=i.id.split(J).pop(),n=`${e.sheetIdTo}${J}${o}`,s=null===(t=this.charts[i.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:n,position:{x:i.x,y:i.y},size:{width:i.width,height:i.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 o=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!o)throw new Error("Chart not defined.");return o}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const o=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!o)throw new Error(`There is no chart with the given figureId: ${e}`);return o}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let o of e.sheets){const e=this.getters.getFigures(o.id),i=[];for(let o of e){const e=o;if(e&&"chart"===e.tag){const o=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();o&&(e.data=o,i.push(e))}else i.push(e)}o.figures=i}}exportForExcel(e){var t;for(let o of e.sheets){const e=this.getters.getFigures(o.id),i=[];for(let o of e)if(o&&"chart"===o.tag){const e=null===(t=this.charts[o.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&i.push({...o,data:e})}o.charts=i}}addFigure(e,t,o={x:0,y:0},i={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:o.x,y:o.y,width:i.width,height:i.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const o=this.getters.getFigureSheetId(e);o&&this.history.update("charts",e,this.createChart(e,t,o))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?84:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:85}}function Iv(e){return""===e?NaN:Number(e)}xv.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class Rv extends Yf{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const o of this.cfRules[e])for(const i of o.ranges){const n=t(i);switch(n.changeType){case"REMOVE":let t=o.ranges.slice();t.splice(o.ranges.indexOf(i),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",t):this.removeConditionalFormatting(o.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(o),"ranges",o.ranges.indexOf(i),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 o={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(o,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const o=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{o.add(e)}))})),Array.from(o)}getRulesByZone(e,t){const o=new Set;for(let i=t.top;i<=t.bottom;i++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,i).forEach((e=>{o.add(e.id)}))}return o}getRulesByCell(e,t,o){const i=[];for(let n of this.cfRules[e])for(let e of n.ranges)Zo(t,o,e.zone)&&i.push(n);return new Set(i.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const o={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return o}addConditionalFormatting(e,t){const o=this.cfRules[t].slice(),i=o.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);i>-1?o.splice(i,1,n):o.push(n),this.history.update("cfRules",t,o)}checkValidReordering(e,t,o){if(!this.cfRules[o])return 27;const i=this.cfRules[o].findIndex((t=>t.id===e));if(-1===i)return 71;const n="up"===t?i-1:i+1;return n<0||n>=this.cfRules[o].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 o=>{if(t.includes(o.operator)){const t=[],i=e=>void 0===e||""===e;return e>=1&&i(o.values[0])&&t.push(51),e>=2&&i(o.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{Ev(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,o=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(o)?48:0}checkMinBiggerThanMax(e){const t=e.minimum.value,o=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&Iv(t)>=Iv(o)?47:0}checkMidBiggerThanMax(e){var t;const o=null===(t=e.midpoint)||void 0===t?void 0:t.value,i=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&Iv(o)>=Iv(i)?49:0}checkMinBiggerThanMid(e){var t;const o=e.minimum.value,i=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&&Iv(o)>=Iv(i)?50:0}removeConditionalFormatting(e,t){const o=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==o){const e=this.cfRules[t].slice();e.splice(o,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,o){const i=this.cfRules[o].findIndex((t=>t.id===e)),n="up"===t?i-1:i+1;if(!(n<0||n>=this.cfRules[o].length)&&-1!==i&&-1!==n){const e=[...this.cfRules[o]],t=e[i];e[i]=e[n],e[n]=t,this.history.update("cfRules",o,e)}}}Rv.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Tv extends Yf{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:o,...i}=e,n=i;this.updateFigure(o,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[o,i]of Object.entries(t))switch(o){case"x":case"y":void 0!==i&&this.history.update("figures",e,t.id,o,Math.max(i,0));break;case"width":case"height":void 0!==i&&this.history.update("figures",e,t.id,o,i)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var o;return void 0===(null===(o=this.figures[e])||void 0===o?void 0:o[t])?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(et)}getFigure(e,t){var o;return null===(o=this.figures[e])||void 0===o?void 0:o[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var o;return void 0!==(null===(o=this.figures[t])||void 0===o?void 0:o[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const o=void 0;t.figures.push({...e,data:o})}}exportForExcel(e){this.export(e)}}Tv.getters=["getFigures","getFigure","getFigureSheetId"];class Av{constructor(e){this.filters=[],this.zone=e;const t=new Do;this.id=t.uuidv4();for(const o of ze(e.left,e.right+1)){const e={...this.zone,left:o,right:o};this.filters.push(new Mv(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 Av(this.zone)}}class Mv{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 Ov extends Yf{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!ri(...e.target))return 81;const t=$o(...e.target),o=()=>this.getFilterTables(e.sheetId).some((e=>qo(e.zone,t)))?78:0,i=()=>{const o=this.getters.getMergesInZone(e.sheetId,t);for(let e of o)if(qo(t,e))return 80;return 0};return this.checkValidations(e,o,i);case"ADD_MERGE":for(let t of e.target)for(let o of this.getFilterTables(e.sheetId))if(qo(o.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":this.history.update("tables",e.sheetIdTo,Ne(this.tables[e.sheetId]));break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=$o(...e.target),o=this.createFilterTable(t);this.history.update("tables",e.sheetId,o.id,o);break}case"REMOVE_FILTER_TABLE":{const t={};for(const o of this.getFilterTables(e.sheetId))e.target.every((e=>!Wo(e,o.zone)))&&(t[o.id]=o);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let o of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,o)&&this.extendTableDown(t,o);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(et):[]}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:o}){return this.getFilterTables(e).find((e=>Zo(t,o,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>jo(e.zone,t)))}doesZonesContainFilter(e,t){for(const o of t)for(const t of this.getFilterTables(e))if(Wo(o,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=Vo(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i=[];for(const o of t.filters){const t=Vo(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);i.push(new Mv(o.id,t))}if(i.length<Ko(o).numberOfCols){for(let e=o.left;e<=o.right;e++)i.find((t=>t.col===e))||i.push(new Mv(this.uuidGenerator.uuidv4(),{...o,left:e,right:e}));i.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const o=Ho(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(o){if(Uo(o)!==Uo(t.zone)){const i=[];for(const o of t.filters){const t=Ho(o.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&i.push(new Mv(o.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",o),this.history.update("tables",e.sheetId,t.id,"filters",i)}}else{const o={...this.tables[e.sheetId]};delete o[t.id],this.history.update("tables",e.sheetId,o)}}}createFilterTable(e){return new Av(e)}extendTableDown(e,t){const o={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",o);for(let o=0;o<t.filters.length;o++){const i=t.filters[o],n={...i.zoneWithHeaders,bottom:i.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",o,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:o,row:i},n){var s;if(!e)return;const r=n.zone;if(!(r.bottom+1===i&&o>=r.left&&o<=r.right))return!1;for(const e of ze(r.left,r.right+1)){const o={sheetId:t,col:e,row:i};if(null===(s=this.getters.getCell(o))||void 0===s?void 0:s.content)return!1;if(this.getters.getFilter(o))return!1;if(this.getters.isInMerge(o))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const o=this.createFilterTable(Po(e.range));this.history.update("tables",t.id,o.id,o)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:Uo(e.zone)})}exportForExcel(e){this.export(e)}}Ov.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Nv extends Yf{constructor(){super(...arguments),this.sizes={}}handle(e){var t,o,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),o={COL:t.COL.map((e=>({manualSize:void 0,computedSize:nt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:nt(e)})))};this.history.update("sizes",e.sheetId,o);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,Ne(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const n={...this.sizes};delete n[e.sheetId],this.history.update("sizes",n);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);const o=Math.min(...e.elements);t=t.map(((t,i)=>"ROW"===e.dimension&&i>=o?{manualSize:t.manualSize,computedSize:nt((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const o=rt(e.position,e.base),i=t[e.base];t.splice(o,0,...Array(e.quantity).fill(i)),t=t.map(((t,o)=>"ROW"===e.dimension&&o>e.base+e.quantity?{manualSize:t.manualSize,computedSize:nt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const o=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:nt(o)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:nt(e.size||_)});break;case"UPDATE_CELL":if(!(null===(i=null===(o=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[e.row])||void 0===i?void 0:i.manualSize)){const{sheetId:t,row:o}=e;this.history.update("sizes",t,"ROW",o,"computedSize",nt((()=>this.getRowTallestCellSize(t,o))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let o of ze(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,o);t!==this.getRowSize(e.sheetId,o)&&this.history.update("sizes",e.sheetId,"ROW",o,"computedSize",nt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,o){var i,n,s,r;return Math.round((null===(n=null===(i=this.sizes[e])||void 0===i?void 0:i[t][o])||void 0===n?void 0:n.manualSize)||(null===(r=null===(s=this.sizes[e])||void 0===s?void 0:s[t][o])||void 0===r?void 0:r.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,o;const i={COL:[],ROW:[]};for(let t of ze(0,this.getters.getNumberCols(e)))i.COL.push(this.getHeaderSize(e,"COL",t));for(let n of ze(0,this.getters.getNumberRows(e))){let s=null===(o=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===o?void 0:o[n].manualSize;if(!s){s=this.getRowTallestCellSize(e,n)}i.ROW.push(s)}return i}getDefaultHeaderSize(e){return"COL"===e?_:F}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return F;return function(e){return e&&e.content?ke(Ve(e.style),e.isFormula?1:e.content.split(ce).length)+2*V:F}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const o=this.getters.getRowCells(e,t);let i=0;for(let e=0;e<o.length;e++){const t=this.getters.getCellById(o[e]);if(!t)continue;const n=this.getters.getCellPosition(t.id),s=this.getCellHeight(n);s>i&&s>F&&(i=s)}return i<=F?F:i}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[o,i]of Object.entries(t.rows))i.size&&(e.ROW[o]=i.size);for(let[o,i]of Object.entries(t.cols))i.size&&(e.COL[o]=i.size);const o=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:o.COL.map(((t,o)=>({manualSize:e.COL[o],computedSize:nt(t)}))),ROW:o.ROW.map(((t,o)=>({manualSize:e.ROW[o],computedSize:nt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var o,i;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of ze(0,this.getters.getNumberRows(n.id)))(t||(null===(o=this.sizes[n.id].ROW[e])||void 0===o?void 0:o.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of ze(0,this.getters.getNumberCols(n.id)))(t||(null===(i=this.sizes[n.id].COL[e])||void 0===i?void 0:i.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Nv.getters=["getRowSize","getColSize"];class _v extends Yf{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),o="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return(t||[]).flat().concat(e.elements).length<o?0:66}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.canRemoveHeaders(e.sheetId,e.dimension,e.elements)?0:8: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,Ne(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let o of[...e.elements].sort(((e,t)=>t-e)))t.splice(o,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],o=rt(e.position,e.base);t.splice(o,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}canRemoveHeaders(e,t,o){const i=this.getAllVisibleHeaders(e,t);return n=o,!i.every((e=>n.includes(e)));var n}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],o=this.hiddenHeaders[e].COL;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],o=this.hiddenHeaders[e].ROW;for(let e=0;e<o.length;e++){o[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getAllVisibleHeaders(e,t){return ze(0,this.hiddenHeaders[e][t].length).filter((o=>!this.hiddenHeaders[e][t][o]))}import(e){var t,o;for(let i of e.sheets){this.hiddenHeaders[i.id]={COL:[],ROW:[]};for(let e=0;e<i.rowNumber;e++)this.hiddenHeaders[i.id].ROW[e]=Boolean(null===(t=i.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<i.colNumber;e++)this.hiddenHeaders[i.id].COL[e]=Boolean(null===(o=i.cols[e])||void 0===o?void 0:o.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let o of e.sheets){void 0===o.rows&&(o.rows={});for(let e=0;e<this.getters.getNumberRows(o.id);e++)(t||this.hiddenHeaders[o.id].ROW[e])&&(void 0===o.rows[e]&&(o.rows[e]={}),o.rows[e].isHidden=this.hiddenHeaders[o.id].ROW[e]);void 0===o.cols&&(o.cols={});for(let e=0;e<this.getters.getNumberCols(o.id);e++)(t||this.hiddenHeaders[o.id].COL[e])&&(void 0===o.cols[e]&&(o.cols[e]={}),o.cols[e].isHidden=this.hiddenHeaders[o.id].COL[e])}}}_v.getters=["canRemoveHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class Fv extends Yf{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 o of t)if("image"===o.tag){const t=o.id.split(J).pop(),i=`${e.sheetIdTo}${J}${t}`,n=this.getImage(o.id);if(n){const t={width:o.width,height:o.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:i,position:{x:o.x,y:o.y},size:t,definition:Ne(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 o of this.syncedImages)t.has(o)||null===(e=this.fileStore)||void 0===e||e.delete(o)}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,o,i){const n={id:e,x:o.x,y:o.y,width:i.width,height:i.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 o of e)this.history.update("images",t.id,o.id,o.data),this.syncedImages.add(o.data.path)}}export(e){var t;for(const o of e.sheets){const e=o.figures.filter((e=>"image"===e.tag));for(const i of e)i.data=null===(t=this.images[o.id])||void 0===t?void 0:t[i.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),o=[];for(const t of e)if("image"===(null==t?void 0:t.tag)){const e=this.getImage(t.id);e&&o.push({...t,data:Ne(e)})}t.images=o}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(et));return e}}Fv.getters=["getImage","getImagePath","getImageSize"];class Dv extends Yf{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const o of Object.values(t).filter(et))this.addMerge(e.sheetIdTo,o.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const o=t?[t]:Object.keys(this.merges);for(const t of o)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(et)}getMerge({sheetId:e,col:t,row:o}){var i;const n=this.mergeCellMap[e],s=n?t in n&&(null===(i=n[t])||void 0===i?void 0:i[o]):void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){var o;const i=this.mergeCellMap[e];if(!i)return[];const n=new Set;for(const{col:e,row:s}of Jo(t)){const t=null===(o=i[e])||void 0===o?void 0:o[s];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(et)}doesIntersectMerge(e,t){return Jo(t).some((({col:t,row:o})=>void 0!==this.getMerge({sheetId:e,col:t,row:o})))}doesColumnsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(i.id,t,n,o,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,o){const i=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(i.id,n,t,n,o))return!0;return!1}expandZone(e,t){let{left:o,right:i,top:n,bottom:s}=t,r={left:o,right:i,top:n,bottom:s};for(let t in this.merges[e]){const o=this.getMergeById(e,parseInt(t));o&&qo(o,r)&&(r=$o(o,r))}return Go(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,o,i,n){const s=this.getMerge({sheetId:e,col:t,row:o}),r=this.getMerge({sheetId:e,col:i,row:n});return!(!s||!r)&&Go(s,r)}isInMerge({sheetId:e,col:t,row:o}){var i;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(i=n[t])||void 0===i?void 0:i[o]))}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:o}=this.getMerge(e);return{sheetId:e.sheetId,col:o,row:t}}isMergeHidden(e,t){const o=this.getters.getHiddenColsGroups(e),i=this.getters.getHiddenRowsGroups(e);for(let e of o)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of i)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const o=this.getMerge({sheetId:e,col:t.left,row:t.top});if(o)return Go(t,o);const{numberOfCols:i,numberOfRows:n}=Ko(t);return 1===i&&1===n}isMergeDestructive(e,t){let{left:o,right:i,top:n,bottom:s}=t;i=De(i,0,this.getters.getNumberCols(e)-1),s=De(s,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=s;t++)for(let s=o;s<=i;s++)if(s!==o||t!==n){const o=this.getters.getCell({sheetId:e,col:s,row:t});if(o&&""!==o.content)return!0}return!1}getMergeById(e,t){var o;const i=null===(o=this.merges[e])||void 0===o?void 0:o[t];return void 0!==i?Pv(t,i):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const o of e)if(t!==o&&qo(t,o))return 65;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<o&&e.right>=o||e.top<i&&e.bottom>=i)return 75;return 0}checkMergedContentUpdate(e){const{col:t,row:o,content:i}=e;if(void 0===i)return 0;const{col:n,row:s}=this.getMainCellPosition(e);return n===t&&s===o?0:4}checkMergeExists(e){const{sheetId:t,target:o}=e;for(const e of o){const{left:o,top:i}=e,n=this.getMerge({sheetId:t,col:o,row:i});if(void 0===n||!Go(e,n))return 5}return 0}addMerge(e,t){let{left:o,right:i,top:n,bottom:s}=t;i=De(i,0,this.getters.getNumberCols(e)-1),s=De(s,0,this.getters.getNumberRows(e)-1);if(Bt(o,n)===Bt(i,s))return;const r=this.getters.getCell({sheetId:e,col:o,row:n});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,Uo({left:o,top:n,right:i,bottom:s})));let l=new Set;for(let t=n;t<=s;t++)for(let s=o;s<=i;s++){s===o&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,style:r?r.style:null,content:""});const i=this.getMerge({sheetId:e,col:s,row:t});i&&l.add(i.id),this.history.update("mergeCellMap",e,s,t,a)}for(let t of l){const{top:o,bottom:i,left:n,right:s}=this.getMergeById(e,t);for(let t=o;t<=i;t++)for(let o=n;o<=s;o++){const i={sheetId:e,col:o,row:t},n=this.getMerge(i);n&&n.id===a||(this.history.update("mergeCellMap",e,o,t,void 0),this.dispatch("CLEAR_CELL",i))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:o,top:i,bottom:n,right:s}=t,r=this.getMerge({sheetId:e,col:o,row:i});if(void 0!==r&&Go(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=i;t<=n;t++)for(let i=o;i<=s;i++)this.history.update("mergeCellMap",e,i,t,void 0)}}applyRangeChangeOnSheet(e,t){const o=Object.entries(this.merges[e]||{});for(const[i,n]of o)if(n){const o=n.zone,s=t(n);switch(s.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,o);break;default:const{numberOfCols:t,numberOfRows:n}=Ko(s.range.zone);1===t&&1===n?this.removeMerge(e,o):this.history.update("merges",e,parseInt(i,10),s.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:o,row:i}of Jo(t))this.history.update("mergeCellMap",e,o,i,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let o of t)this.addMerge(e,Po(o))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...kv(e))}}exportForExcel(e){this.export(e)}}function kv(e){return Object.entries(e).map((([e,t])=>t?Pv(parseInt(e,10),t):void 0)).filter(et).map((e=>Bt(e.left,e.top)+":"+Bt(e.right,e.bottom)))}function Pv(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Dv.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class Lv{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",o="COL"===e.dimension?"right":"bottom",i="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const s=Be(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[o]){const e=Math.min(n.zone[o],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e)}else if(n.zone[t]>=s&&n.zone[o]<=l)a="REMOVE",r=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[o]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,i,a,-e),r=this.createAdaptedRange(r,i,"MOVE",-(n.zone[t]-s))}else s<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,i,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",o="COL"===e.dimension?"right":"bottom",i="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[o])return{changeType:"RESIZE",range:this.createAdaptedRange(n,i,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,i,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[o])return{changeType:"RESIZE",range:this.createAdaptedRange(n,i,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,i,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const o=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:o})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const o=void 0,i=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:i,invalidSheetName:o})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((o=>{if(o.sheetId!==e.sheetId||!jo(o.zone,t))return{changeType:"NONE"};const i=e.targetSheetId,n=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(o,"both","MOVE",[n,s]),a=e.sheetId!==i||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:i,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const o=e(t);return"NONE"===o.changeType||Lo(o.range.zone)?o:{range:o.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,o,i){const n=ei(e.unboundedZone,t,o,i);return e.clone({zone:n})}executeOnAllRanges(e,t){const o=this.verifyRangeRemoved(e);for(const e of this.providers)e(o,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,o,i){const n=e.map((e=>Mo.fromRange(e,this.getters)));return n.map((e=>{if(!Lo(e.zone))return e;const n=e.prefixSheet?e.sheetId:i,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:o),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:o)};return e.clone({sheetId:n,zone:s}).orderZone()}))}getRangeFromSheetXC(e,t){if(!_t.test(t))return new Mo({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let o,i=t,n=!1;t.includes("!")&&(({xc:i,sheetName:o}=Lt(t)),o&&(n=!0));const s=ko(i),r=Mo.getRangeParts(i,s),a=o&&!this.getters.getSheetIdByName(o)?o:void 0,l=this.getters.getSheetIdByName(o)||e;return new Mo({prefixSheet:n,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize).orderZone()}getSelectionRangeString(e,t){const o=Mo.fromRange(e,this.getters),i=this.getters.expandZone(o.sheetId,o.zone),n=o.clone({zone:{...i,bottom:o.isFullCol?void 0:i.bottom,right:o.isFullRow?void 0:i.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return Y;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return Y;if(e.zone.left<0||e.zone.top<0)return Y;const o=Mo.fromRange(e,this.getters);let i=o.sheetId!==t||o.invalidSheetName||o.prefixSheet,n="";if(i&&(n=o.invalidSheetName?o.invalidSheetName:Fe(this.getters.getSheetName(o.sheetId))),i&&!n)return Y;let s=this.getRangePartString(o,0);return o.parts&&2===o.parts.length&&(o.zone.top!==o.zone.bottom||o.zone.left!==o.zone.right||o.parts[0].rowFixed||o.parts[0].colFixed||o.parts[1].rowFixed||o.parts[1].colFixed)&&(s+=":",s+=this.getRangePartString(o,1)),`${i?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 Mo(t,this.getters.getSheetSize)}getRangePartString(e,t){const o=e.parts&&e.parts[t].colFixed?"$":"",i=Ut(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?o+i+n+s:o+i:e.isFullRow?0===t&&e.unboundedZone.hasHeader?o+i+n+s:n+s:o+i+n+s,r}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:Y}}}Lv.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Uv extends Yf{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"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,o;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let i of e.sheets){const e=i.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:r}=this.getImportedSheetSize(i),a={id:i.id,name:e,numberOfCols:s,rows:Fo(r),areGridLinesVisible:void 0===i.areGridLinesVisible||i.areGridLinesVisible,isVisible:i.isVisible,panes:{xSplit:(null===(t=i.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(o=i.panes)||void 0===o?void 0:o.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(et).map((e=>{const t=this.sheets[e],o={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(o.panes=t.panes),o}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=_e(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,o){return"COL"===t?o>=0&&o<this.getNumberCols(e):o>=0&&o<this.getNumberRows(e)}getRow(e,t){const o=this.getSheet(e).rows[t];if(!o)throw new Error(`Row ${o} not found.`);return o}getCell({sheetId:e,col:t,row:o}){var i;const n=this.tryGetSheet(e),s=null===(i=null==n?void 0:n.rows[o])||void 0===i?void 0:i.cells[t];if(void 0!==s)return this.getters.getCellById(s)}getColsZone(e,t,o){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:o}}getRowCells(e,t){var o;return Object.values(null===(o=this.getSheet(e).rows[t])||void 0===o?void 0:o.cells).filter(et)}getRowsZone(e,t,o){return{top:t,bottom:o,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const o=this.orderedSheetIds.map(this.getSheetName.bind(this));let i=`${e}${t}`;for(;o.includes(i);)i=`${e}${t}`,t++;return i}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,o){const i={...this.getPaneDivisions(e)};"COL"===o?i.xSplit=t:"ROW"===o&&(i.ySplit=t),this.history.update("sheets",e,"panes",i)}isEmpty(e,t){return Jo(t).map((({col:t,row:o})=>this.getCell({sheetId:e,col:t,row:o}))).every((e=>!e||""===e.content))}updateCellPosition(e){const{sheetId:t,cellId:o,col:i,row:n}=e;o?this.setNewPosition(o,t,i,n):this.clearPosition(t,i,n)}setNewPosition(e,t,o,i){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:i,col:o,sheetId:t}),this.history.update("sheets",t,"rows",i,"cells",o,e)}clearPosition(e,t,o){var i;const n=null===(i=this.sheets[e])||void 0===i?void 0:i.rows[o].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",o,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let i=o.top;i<=o.bottom;i++){this.sheets[e].rows[i].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:i})}}createSheet(e,t,o,i,n){const s={id:e,name:t,numberOfCols:o,rows:Fo(i),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 o=this.orderedSheetIds.slice(),i=o.findIndex((t=>t===e)),n=o.splice(i,1);let s=this.findIndexOfTargetSheet(i,t);o.splice(s,0,n[0]),this.history.update("orderedSheetIds",o)}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:o}=this,i=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=o[e])||void 0===t?void 0:t.name.toLowerCase())===i}))?11:se.test(i)?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 o of t)if(o.top<e.quantity&&e.quantity<=o.bottom)return 65;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let o of t)if(o.left<e.quantity&&e.quantity<=o.right)return 65;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const o=e.name;this.history.update("sheets",e.id,"name",t.trim());const i=Object.assign({},this.sheetIdsMapName);i[t]=e.id,delete i[o],this.history.update("sheetIdsMapName",i)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const o=this.getSheet(e),i=this.getDuplicateSheetName(o.name),n=Ne(o);n.id=t,n.name=i;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:o}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:o,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 o=this.orderedSheetIds.map(this.getSheetName.bind(this)),i=s("Copy of %s",e);let n=i.toString();for(;o.includes(n);)n=`${i} (${t})`,t++;return n}deleteSheet(e){const t=e.name,o=Object.assign({},this.sheets);delete o[e.id],this.history.update("sheets",o);const i=this.orderedSheetIds.slice(),n=i.indexOf(e.id);i.splice(n,1),this.history.update("orderedSheetIds",i);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 o of t)this.moveCellOnColumnsDeletion(e,o);const o=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",o-t.length);const i=t.filter((t=>t<e.panes.xSplit)).length;i&&this.setPaneDivisions(e.id,e.panes.xSplit-i,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let o of Be(t))this.moveCellOnRowsDeletion(e,o[o.length-1],o[0]),o.map((t=>this.updateRowsStructureOnDeletion(t,e)));const o=t.filter((t=>t<e.panes.ySplit)).length;o&&this.setPaneDivisions(e.id,e.panes.ySplit-o,"ROW")}addColumns(e,t,o,i){const n="before"===o?t:t+1;this.moveCellsOnAddition(e,n,i,"columns");const s=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",s+i),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+i,"COL")}addRows(e,t,o,i){const n="before"===o?t:t+1;this.addEmptyRows(e,i),this.moveCellsOnAddition(e,n,i,"rows"),this.updateRowsStructureOnAddition(e,t,i),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+i,"ROW")}moveCellOnColumnsDeletion(e,t){for(let o=0;o<e.rows.length;o++){const i=e.rows[o];for(let n in i.cells){const s=Number(n),r=i.cells[n];r&&(s===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:o}),s>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:s-1,row:o}))}}}moveCellsOnAddition(e,t,o,i){const n=[];for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if("rows"!==i||s>=t)for(let a in r.cells){const l=Number(a),c=r.cells[a];c&&("rows"===i||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===i?o:0),row:s+("rows"===i?o:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,o){const i=o-t+1;for(let n=0;n<e.rows.length;n++){const s=e.rows[n];if(n>=t&&n<=o)for(let t in s.cells){const o=Number(t);s.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:o,row:n})}if(n>o)for(let t in s.cells){const o=Number(t),r=s.cells[t];r&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:o,row:n-i})}}}updateRowsStructureOnDeletion(e,t){const o=[],i=t.rows.map((e=>e.cells));for(let n in t.rows)Number(n)!==e&&o.push({cells:i.shift()});this.history.update("sheets",t.id,"rows",o)}updateRowsStructureOnAddition(e,t,o){const i=[],n=e.rows.map((e=>e.cells));e.rows.forEach((()=>i.push({cells:n.shift()}))),this.history.update("sheets",e.id,"rows",i)}addEmptyRows(e,t){const o=e.rows.slice();for(let e=0;e<t;e++)o.push({cells:{}});this.history.update("sheets",e.id,"rows",o)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(zt);let o=e.rowNumber,i=e.colNumber;for(let{col:e,row:n}of t)o=Math.max(o,n+1),i=Math.max(i,e+1);return{rowNumber:o,colNumber:i}}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(Lo))return 25;if(t.length&&"sheetId"in e){const o=this.getSheetZone(e.sheetId);return t.every((e=>jo(e,o)))?0:18}return 0}}Uv.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"];class Vv extends Xf{constructor({getters:e,stateObserver:t,dispatch:o,uiActions:i,selection:n}){super(t,o),this.getters=e,this.ui=i,this.selection=n}drawGrid(e,t){}}Vv.layers=[];class zv extends Vv{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const o=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(o),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:Et(255,0,0),colors:[]},{leadColor:Et(255,128,0),colors:[]},{leadColor:Et(128,128,0),colors:[]},{leadColor:Et(128,255,0),colors:[]},{leadColor:Et(0,255,0),colors:[]},{leadColor:Et(0,255,128),colors:[]},{leadColor:Et(0,255,255),colors:[]},{leadColor:Et(0,127,255),colors:[]},{leadColor:Et(0,0,255),colors:[]},{leadColor:Et(127,0,255),colors:[]},{leadColor:Et(128,0,128),colors:[]},{leadColor:Et(255,0,128),colors:[]}];for(const o of e.map(xt)){let e=500,i=0;t.forEach(((t,n)=>{const s=(r=o,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,i=n)})),t[i].colors.push(o)}return t.map((e=>e.colors.sort(((e,t)=>Rt(e).s-Rt(t).s)))).flat().map(yt)}([...new Set([...new Set([...e,...this.customColors])].filter(St).map(bt))]).filter((e=>!M.includes(e)))}getColorsFromCells(e){var t,o;const i=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&i.add(n.style.textColor),(null===(o=n.style)||void 0===o?void 0:o.fillColor)&&i.add(n.style.fillColor);return[...i]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),o=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(o.push(t.style.textColor),o.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(o.push(vt(t.minimum.color)),o.push(t.midpoint?vt(t.midpoint.color):void 0),o.push(vt(t.maximum.color)))}return o.filter(et)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let o=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&o.add(t),e.type){case"gauge":const t=e.sectionRule.colors;o.add(t.lowerColor),o.add(t.middleColor),o.add(t.upperColor);break;case"scorecard":const i=e;o.add(i.baselineColorDown),o.add(i.baselineColorUp)}}return[...o]}tryToAddColor(e){const t=bt(e);e&&!M.includes(t)&&this.customColors.add(t)}}zv.getters=["getCustomColors"];const Bv=$u.mapping;class Hv extends Vv{constructor(e){super(e),this.isUpToDate=!1,this.evaluatedCells={},this.evalContext=e.custom,this.lazyEvaluation=e.lazyEvaluation}handle(e){switch(on.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 o=Ev(e),i=this.getCompilationParameters((e=>this.getEvaluatedCell(this.getters.getCellPosition(e.id)))),n=[];for(let e of o.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return o.execute(n,...i).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:o}){var i,n,s;return void 0===this.getters.getCell({sheetId:e,col:t,row:o})?pn(""):(null===(s=null===(n=null===(i=this.evaluatedCells[e])||void 0===i?void 0:i[t])||void 0===n?void 0:n[o])||void 0===s?void 0:s.call(n))||pn("")}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},o={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);o[e]=this.getEvaluatedCell(t)}return o}getColEvaluatedCells(e,t){var o;return Object.values((null===(o=this.evaluatedCells[e])||void 0===o?void 0:o[t])||[]).filter(et).map((e=>e()))}getEvaluatedCellsInZone(e,t){return Jo(t).map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o})))}setEvaluatedCell(e,t){const{col:o,row:i,sheetId:n}=this.getters.getCellPosition(e);this.evaluatedCells[n]||(this.evaluatedCells[n]={}),this.evaluatedCells[n][o]||(this.evaluatedCells[n][o]={}),this.evaluatedCells[n][o][i]=t,this.lazyEvaluation||this.evaluatedCells[n][o][i]()}*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||nt((()=>{try{switch(e.isFormula){case!0:return i(e);case!1:return un(e.content,e.format)}}catch(t){return o(t,e)}}))},o=(e,t)=>{e instanceof Error||(e=new Error(e));const o=(null==e?void 0:e.errorType)||a.GenericError,i=n[2].__lastFnCalled||"",s=new c(o,e.message.replace("[[FUNCTION_NAME]]",i),void 0!==e.logLevel?e.logLevel:l.error);return bn(t.content,s)},i=t=>{const o=t.id;if(e.has(o))throw new d;n[2].__originCellXC=()=>{const e=n[2].getters.getCellPosition(o);return Bt(e.col,e.row)},e.add(o);const i=t.compiledFormula.execute(t.dependencies,...n);if(e.delete(o),Array.isArray(i.value))throw new Error(s("This formula depends on invalid values"));return pn(i.value,t.format||i.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(Bv),this.evalContext,{getters:this.getters}),o=this.getters;const i=t=>{const o=e(t);if(o.type===en.error)throw o.error;return o};return[function(e,t,n,r){if(t)return{value:Uo(e.zone)};if(!Lo(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(!o.tryGetSheet(e.sheetId))throw new Error(s("Invalid sheet name"));return t=o.getCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}),t&&""!==t.content?i(t):{value:null}}(e)},function(e){const n=e.sheetId;if(!Lo(e.zone))throw new u;const s=o.getSheetZone(n),r=[],a=Wo(e.zone,s);if(!a)return r.push([]),r;for(let o=a.left;o<=a.right;o++){const n=[];for(let s=a.top;s<=a.bottom;s++){const r=t.getters.getCell({sheetId:e.sheetId,col:o,row:s});n.push(r?i(r):void 0)}r.push(n)}return r},t]}exportForExcel(e){for(let t of e.sheets)for(const e in t.cells){const o={sheetId:t.id,...zt(e)},i=this.getters.getCell(o);if(i){const n=t.cells[e];n.value=this.getEvaluatedCell(o).value,n.isFormula=i.isFormula&&!this.isBadExpression(i.content)}}}isBadExpression(e){try{return Ev(e),!1}catch(e){return!0}}}Hv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getColEvaluatedCells","getEvaluatedCellsInZone"];class $v extends Vv{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=ir.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const i=t.find((e=>e.match(o.type)));if(!i)throw new Error("No runtime builder for this chart.");return i.getChartRuntime(o,e)}}(this.getters)}handle(e){if(on.has(e.type)||nn.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getBackgroundOfSingleCellChart(e,t){if(e)return e;if(!t)return w;const o=t.zone.left,i=t.zone.top,n=t.sheetId;return this.getters.getCellComputedStyle({sheetId:n,col:o,row:i}).fillColor||w}}$v.getters=["getChartRuntime","getBackgroundOfSingleCellChart"];class Wv extends Vv{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.rulePredicate={CellIsRule:(e,t)=>{if(e.type===en.error)return!1;const o=t.values.map(gn);switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==o[0]&&e.value.toString().startsWith(o[0].toString());case"EndsWith":return""!==o[0]&&e.value.toString().endsWith(o[0].toString());case"Between":return e.value>=o[0]&&e.value<=o[1];case"NotBetween":return!(e.value>=o[0]&&e.value<=o[1]);case"ContainsText":return e.value.toString().indexOf(o[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(o[0].toString());case"GreaterThan":return e.value>o[0];case"GreaterThanOrEqual":return e.value>=o[0];case"LessThan":return e.value<o[0];case"LessThanOrEqual":return e.value<=o[0];case"NotEqual":return""!==o[0]&&e.value!==o[0];case"Equal":return""===o[0]||e.value===o[0];default:console.warn(s("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((nn.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const o=this.getters.getActiveSheetId(),i=this.getters.getRulesByCell(o,e.originCol,e.originRow);for(const t of i)this.adaptRules(o,t,[Bt(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:o,col:i,row:n}=e,s=this.getters.getCell(e),r=this.computedStyles[o],a=r&&(null===(t=r[i])||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=x),this.getters.isFilterHeader(e)&&(l.bold=!0),l}getConditionalIcon({col:e,row:t}){var o;const i=this.getters.getActiveSheetId(),n=this.computedIcons[i];return n&&(null===(o=n[e])||void 0===o?void 0:o[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const o=this.computedStyles[t];for(let i of this.getters.getConditionalFormats(t).reverse())try{switch(i.rule.type){case"ColorScaleRule":for(let e of i.ranges)this.applyColorScale(e,i.rule);break;case"IconSetRule":for(let e of i.ranges)this.applyIcon(e,i.rule);break;default:for(let n of i.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[i.rule.type];let a=this.getters.getEvaluatedCell({sheetId:t,col:r,row:n});s&&s(a,i.rule)&&(o[r]||(o[r]=[]),o[r][n]=Object.assign((null===(e=o[r])||void 0===e?void 0:e[n])||{},i.rule.style))}}}}catch(e){}}parsePoint(e,t,o){const i=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCellsInZone(i,this.getters.getRangeFromSheetXC(i,e).zone).filter((e=>e.type===en.number)).map((e=>e.value));switch(t.type){case"value":return"max"===o?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 to(n,Number(t.value)/100,!0);case"formula":const i=t.value&&this.getters.evaluateFormula(t.value);return i instanceof Promise?null:i;default:return null}}applyIcon(e,t){const o=this.parsePoint(e,t.lowerInflectionPoint),i=this.parsePoint(e,t.upperInflectionPoint);if(null===o||null===i||o>i)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!==en.number)continue;const c=this.computeIcon(s.value,i,t.upperInflectionPoint.operator,o,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,o,i,n,s){return"ge"===o&&e>=t||"gt"===o&&e>t?s[0]:"ge"===n&&e>=i||"gt"===n&&e>i?s[1]:s[2]}applyColorScale(e,t){var o;const i=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,s=this.parsePoint(e,t.maximum,"max");if(null===i||null===s||i>=s||n&&(i>=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:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,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:i,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(i,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===en.number){const r=De(a.value,i,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===(o=l[t])||void 0===o?void 0:o[e])||{},l[t][e].fillColor=vt(h)}}}computeColorDiffUnits(e,t,o,i){const n=t-e;return[((o>>16)%256-(i>>16)%256)/n,((o>>8)%256-(i>>8)%256)/n,(o%256-i%256)/n]}colorCell(e,t,o,i){const[n,s,r]=i;return Math.round((o>>16)%256-n*(e-t))<<16|Math.round((o>>8)%256-s*(e-t))<<8|Math.round(o%256-r*(e-t))}adaptRules(e,t,o,i){if(0===o.length&&0===i.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(o);const a=Xo(r,i);this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e})}pasteCf(e,t,o){const i=Bt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let s of n.ranges)if(Zo(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=n,r=[];"CUT"===o&&r.push(Bt(e.col,e.row)),e.sheetId===t.sheetId?this.adaptRules(e.sheetId,s,[i],r):(this.adaptRules(t.sheetId,s,[i],[]),this.adaptRules(e.sheetId,s,[],r))}}}Wv.getters=["getConditionalIcon","getCellComputedStyle"];class Gv extends Vv{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":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const o of this.getters.getFilters(e.sheetIdTo)){const i=o.zoneWithHeaders;t[o.id]=this.getFilterValues({sheetId:e.sheetId,col:i.left,row:i.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:o,row:i}=e;let n;for(let e of this.getters.getFilterTables(t)){const s=e.zone;if(Zo(o,i,s)){const e=this.intersectZoneWithViewport(t,s);n={top:i===e.top?j:void 0,bottom:i===e.bottom?j:void 0,left:o===e.left?j:void 0,right:o===e.right?j:void 0}}}const s=this.getters.getCellBorder(e),r={...n,...lt(s||{})};return tt(r)?null:r}getFilterHeaders(e){const t=[];for(let o of this.getters.getFilterTables(e)){const i=o.zone;if(!i)continue;const n=i.top;for(let o=i.left;o<=i.right;o++)this.getters.isColHidden(e,o)||this.getters.isRowHidden(e,n)||t.push({col:o,row:n})}return t}getFilterValues(e){const t=this.getters.getFilterId(e),o=e.sheetId;return t&&this.filterValues[o]&&this.filterValues[o][t]||[]}isFilterHeader({sheetId:e,col:t,row:o}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===o))}isFilterActive(e){var t,o;const i=this.getters.getFilterId(e),n=e.sheetId;return Boolean(i&&(null===(o=null===(t=this.filterValues[n])||void 0===t?void 0:t[i])||void 0===o?void 0:o.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:o,sheetId:i}){const n=this.getters.getFilterId({sheetId:i,col:e,row:t});n&&(this.filterValues[i]||(this.filterValues[i]={}),this.filterValues[i][n]=o)}updateHiddenRows(){var e,t;const o=this.getters.getActiveSheetId(),i=this.getters.getFilters(o).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let s of i){if(this.getters.isRowHiddenByUser(o,s.zoneWithHeaders.top))continue;if(n.has(s.zoneWithHeaders.top))continue;const i=null===(t=null===(e=this.filterValues[o])||void 0===e?void 0:e[s.id])||void 0===t?void 0:t.map(ct);if(i&&s.filteredZone)for(let e=s.filteredZone.top;e<=s.filteredZone.bottom;e++){const t=this.getCellValueAsString(o,s.col,e);i.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,o){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets)for(const e of t.filterTables){const o=Po(e.range),i=[],n=[];for(const e of ze(0,Ko(o).numberOfCols)){const s={sheetId:t.id,col:o.left+e,row:o.top},r=this.getFilterValues(s),a=this.getters.getFilter(s);if(!a)continue;const l=(a.filteredZone?Jo(a.filteredZone).map((({col:e,row:o})=>this.getters.getEvaluatedCell({sheetId:t.id,col:e,row:o}))).filter((e=>e.type!==en.empty)).map((e=>e.formattedValue)):[]).filter((e=>!r.includes(e)));i.push({colId:e,filteredValues:[...new Set(l)]});const c={col:a.col,row:a.zoneWithHeaders.top,sheetId:t.id},h=this.getters.getEvaluatedCell(c).formattedValue,d=this.getUniqueColNameForExcel(e,h,n);n.push(d),t.cells[Bt(c.col,c.row)]={...t.cells[Bt(c.col,c.row)],content:d,value:d,isFormula:!1}}e.filters=i}}getUniqueColNameForExcel(e,t,o){t||(t=`Column${e}`);let i=t,n=2;for(;o.includes(i);)i=t+String(n),n++;return i}}Gv.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];class qv{constructor(e,t,o,i,n,s){this.getters=e,this.sheetId=t,this.boundaries=o,this.viewportWidth=i.width,this.viewportHeight=i.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:o,size:i}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:s}=this.getters.getRowDimensions(this.sheetId,t),r=this.searchHeaderIndex("COL",o-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=o-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(_,Math.min(a,this.viewportWidth-i)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(F+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 o=this.getters.getMainCellPosition({sheetId:t,...e}),{col:i,row:n}=this.getters.getNextVisibleCellPosition(o);Zo(i,this.boundaries.top,this.boundaries)&&this.adjustPositionX(i),Zo(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{end:o}=this.getters.getColDimensions(t,e),i=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<o)for(let e=this.left;this.offsetX+this.offsetCorrectionX+this.viewportWidth<o&&!(e>i);e++)this.getters.isColHidden(t,e)||(this.offsetX=this.getters.getColDimensions(t,e).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX());else if(this.left>e)for(let o=this.left;o>=e&&!(o<0);o--)this.getters.isColHidden(t,o)||(this.offsetX=this.getters.getColDimensions(t,o).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX())}adjustPositionY(e){const t=this.sheetId,{end:o}=this.getters.getRowDimensions(t,e),i=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<o)for(let e=this.top;this.offsetY+this.viewportHeight+this.offsetCorrectionY<o&&!(e>i);e++)this.getters.isRowHidden(t,e)||(this.offsetY=this.getters.getRowDimensions(t,e).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY());else if(this.top>e)for(let o=this.top;o>=e&&!(o<0);o--)this.getters.isRowHidden(t,o)||(this.offsetY=this.getters.getRowDimensions(t,o).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=Wo(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,o=0,i=!1){let n=0;const s=this.sheetId,r=this.getters.getNumberHeaders(s,e);for(let a=o;a<=r-1;a++){const o=i||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(s,e,a)&&!o&&(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.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.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 Zv extends Vv{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:o}=ti(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const i=e.previousAnchor.zone,n=e.anchor.zone,{top:s,bottom:r,left:a,right:l}=this.getters.getActiveMainViewport();i.left===n.left&&i.right===n.right&&(t=a>t||t>l?a:t),i.top===n.top&&i.bottom===n.bottom&&(o=s>o||o>r?s:o)}const i=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(i)-1),o=Math.min(o,this.getters.getNumberRows(i)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:o})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:o}=this.getActiveMainViewport(),i=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(i,o).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),o=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(o);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"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 o of t)(null===(e=this.viewports[o])||void 0===e?void 0:e.bottomRight)||this.resetViewports(o)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>ze(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=>ze(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:o,ySplit:i}=this.getters.getPaneDivisions(e);let{width:n,height:s}=t.getMaxSize();return{x:this.getters.getColDimensions(e,o).start,y:this.getters.getRowDimensions(e,i).start,width:n,height:s}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:o}=this.getMainViewportRect(),i=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-i.viewportWidth+1),maxOffsetY:Math.max(0,o-i.viewportHeight+1)}}getColRowOffsetInViewport(e,t,o){const i=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),s=this.getters.getSheetViewVisibleRows();if(o<t)return-this.getColRowOffsetInViewport(e,o,t);let r=0;const a="COL"===e?n:s;for(let n=t;n<o;n++)a.includes(n)&&(r+="COL"===e?this.getters.getColSize(i,n):this.getters.getRowSize(i,n));return r}isVisibleInViewport({sheetId:e,col:t,row:o}){return this.getSubViewports(e).some((e=>e.isVisible(t,o)))}getEdgeScrollCol(e,t,o){let i=!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?(i=!0,s=Gt(e-a),n=1):e<l&&o>=l&&c>0?(i=!0,s=Gt(l-e),n=-1):r&&t<l&&e>l&&(i=!0,s=Gt(e),n="reset"),{canEdgeScroll:i,direction:n,delay:s}}getEdgeScrollRow(e,t,o){let i=!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?(i=!0,s=Gt(e-a),n=1):e<l&&o>=l&&c>0?(i=!0,s=Gt(l-e),n=-1):r&&t<l&&e>l&&(i=!0,s=Gt(e),n="reset"),{canEdgeScroll:i,direction:n,delay:s}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),o=this.getSubViewports(t).map((t=>t.getRect(e))).filter(et);if(0===o.length)return{x:0,y:0,width:0,height:0};const i=Math.min(...o.map((e=>e.x))),n=Math.min(...o.map((e=>e.y))),s=Math.max(...o.map((e=>e.x+e.width)))-i,r=Math.max(...o.map((e=>e.y+e.height)))-n;return{x:i+this.gridOffsetX,y:n+this.gridOffsetY,width:s,height:r}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,o).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(et)}checkPositiveDimension(e){return e.width<0||e.height<0?68:0}checkValuesAreDifferent(e){const{height:t,width:o}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===o&&e.height===t?76:0}checkScrollingDirection({offsetX:e,offsetY:t}){const o=this.getMainInternalViewport(this.getters.getActiveSheetId());return!o.canScrollHorizontally&&e>0||!o.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 o=this.getSubViewports(e);Object.values(o).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,o=0,i=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=o,this.gridOffsetY=i,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const o=this.getters.getActiveSheetId(),{maxOffsetX:i,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(o)).forEach((o=>o.setViewportOffset(De(e,0,i),De(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),o=t-this.sheetViewHeight;return e=Math.min(e,o),e=Math.max(e,0)}getViewportOffset(e){var t,o;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(o=this.viewports[e])||void 0===o?void 0:o.bottomRight.offsetScrollbarY)||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:o}=this.getters.getPaneDivisions(e),i=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),s=this.getters.getColRowOffset("COL",0,t,e),r=this.getters.getColRowOffset("ROW",0,o,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:o&&t&&new qv(this.getters,e,{left:0,right:t-1,top:0,bottom:o-1},{width:s,height:r},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:o&&new qv(this.getters,e,{left:t,right:i-1,top:0,bottom:o-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:o,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:i-1,top:o,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:o}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(o,e);const{anchor:i}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(i.cell.col,i.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],o=this.getters.getFigures(e),{scrollX:i,scrollY:n}=this.getActiveSheetScrollInfo(),{x:s,y:r}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of o)e.x>=s&&(e.x+e.width<=s+i||e.x>=a+i+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:o}=this.getters.getPaneDivisions(e),i=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,o).start;return{xRatio:i/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}Zv.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class jv{constructor(e,t,o){this.index=0,this.cells=e,this.getters=t,this.direction=o}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:o,tooltip:i}=Cn.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:o,tooltip:i,origin:{col:e.data.col,row:e.data.row}}}}class Xv extends Vv{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:De(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:De(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:45;case"AUTOFILL_AUTO":const o=this.getters.getSelectedZone();return o.top===o.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),o=this.autofillZone;switch(this.direction){case"down":for(let i=t.left;i<=t.right;i++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(Bt(i,e));const s=this.createGenerator(n);for(let t=o.top;t<=o.bottom;t++)this.computeNewCell(s,i,t,e)}break;case"up":for(let i=t.left;i<=t.right;i++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(Bt(i,e));const s=this.createGenerator(n);for(let t=o.bottom;t>=o.top;t--)this.computeNewCell(s,i,t,e)}break;case"left":for(let i=t.top;i<=t.bottom;i++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(Bt(e,i));const s=this.createGenerator(n);for(let t=o.right;t>=o.left;t--)this.computeNewCell(s,t,i,e)}break;case"right":for(let i=t.top;i<=t.bottom;i++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(Bt(e,i));const s=this.createGenerator(n);for(let t=o.left;t<=o.right;t++)this.computeNewCell(s,t,i,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const o=this.getters.getSelectedZone();if(Zo(e,t,o))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,o.top-1,o.left,o.right),this.steps=o.top-t;break;case"down":this.saveZone(o.bottom+1,t,o.left,o.right),this.steps=t-o.bottom;break;case"left":this.saveZone(o.top,o.bottom,e,o.left-1),this.steps=o.left-e;break;case"right":this.saveZone(o.top,o.bottom,o.right+1,e),this.steps=e-o.right}this.autofill(!1)}}autofillAuto(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();let o=e.left,i=e.bottom;if(o>0){let e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i});for(;e.type!==en.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o-1,row:i})}if(i===e.bottom&&(o=e.right,o<=this.getters.getNumberCols(t))){let e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i});for(;e.type!==en.empty;)i+=1,e=this.getters.getEvaluatedCell({sheetId:t,col:o+1,row:i})}i!==e.bottom&&(this.select(e.left,i-1),this.autofill(!0))}computeNewCell(e,t,o,i){const{cellData:n,tooltip:s,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=s,i&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:o,content:a,style:l,border:c,format:h})}getRule(e,t){const o=En.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((o=>o.condition(e,t)));return o&&o.generateRule(e,t)}createGenerator(e){const t=[],o=[],i=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=zt(t),s=this.getters.getCell({sheetId:i,col:e,row:n});o.push({col:e,row:n,cell:s,sheetId:i})}const n=o.map((e=>e.cell));for(let e of o){let o={type:"COPY_MODIFIER"};if(e&&e.cell){o=this.getRule(e.cell,n)||o}const i=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:i},rule:o})}return new jv(t,this.getters,this.direction)}saveZone(e,t,o,i){this.autofillZone={top:e,bottom:t,left:o,right:i}}getDirection(e,t){const o=this.getters.getSelectedZone(),i={up:{number:o.top-t,value:"up"},down:{number:t-o.bottom,value:"down"},left:{number:o.left-e,value:"left"},right:{number:e-o.right,value:"right"}};if(1===Object.values(i).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(i).find((e=>e.number>0?1:0)).value;const n=i.up.number>0?"up":"down",s=i.left.number>0?"left":"right";return Math.abs(i[n].number)>=Math.abs(i[s].number)?i[n].value:i[s].value}autoFillMerge(e,t,o,i){const n=this.getters.getActiveSheetId(),s={sheetId:n,col:o,row:i},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:i,bottom:i+a.bottom-a.top,left:o,right:o+a.right-a.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:o}=e,{x:i,y:n,width:s,height:r}=this.getters.getVisibleRect(this.autofillZone);s>0&&r>0&&(t.strokeStyle="black",t.lineWidth=o,t.setLineDash([3]),t.strokeRect(i,n,s,r),t.setLineDash([]))}}Xv.layers=[5],Xv.getters=["getAutofillTooltip"];class Yv extends Vv{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:o}=this.getters.getSelection();for(const i of t){const t=this.getAutomaticSums(e,i,o.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,o){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,o):this.sumData(e,t)}sumData(e,t){const o=this.dimensionsToSum(e,t),i=this.sumDimensions(e,t,o).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return o.has("ROW")&&o.has("COL")&&i.push(this.sumTotal(t)),i}sumAdjacentData(e,t,o){const{col:i,row:n}=Zo(o.col,o.row,t)?o:{col:t.left,row:t.top},s=this.findAdjacentData(e,i,n);return s?this.getters.isSingleCellOrMerge(e,t)||Qo($o(s,t))?[{position:{col:i,row:n},zone:s}]:this.sumDimensions(e,$o(s,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,o){const i=this.getters.getSheet(e),n=this.getters.getMainCellPosition({sheetId:e,col:t,row:o}),s=this.findSuitableZoneToSum(i,n.col,n.row);if(s)return this.getters.expandZone(e,s)}findSuitableZoneToSum(e,t,o){const i=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:o-1}),n=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:o});if(this.isNumber(n)&&!this.isNumber(i))return this.findHorizontalZone(e,t,o);const s=this.findVerticalZone(e,t,o);if(this.isZoneValid(s))return s;const r=this.findHorizontalZone(e,t,o);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,o){const i={top:0,bottom:o-1,left:t,right:t},n=this.reduceZoneStart(e,i,i.bottom);return{...i,top:n}}findHorizontalZone(e,t,o){const i={top:o,bottom:o,left:0,right:t-1},n=this.reduceZoneStart(e,i,i.right);return{...i,left:n}}reduceZoneStart(e,t,o){const i=this.getters.getEvaluatedCellsInZone(e.id,t),n=ze(o,-1,-1),s=n.filter((e=>i[e]&&!i[e].isAutoSummable)),r=Math.max(...s),a=Be(n.filter((e=>this.isNumber(i[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===en.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(X))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const o=new Set;return Qo(t)?(o.add(1===Ko(t).numberOfCols?"COL":"ROW"),o):(this.lastColIsEmpty(e,t)&&o.add("ROW"),this.lastRowIsEmpty(e,t)&&o.add("COL"),0===o.size&&o.add("COL"),o)}sumDimensions(e,t,o){return[...o.has("COL")?this.sumColumns(t,e):[],...o.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:o}=e;return{position:{col:o,row:t},zone:{...e,top:t,right:o-1}}}sumColumns(e,t){const o=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,o.bottom-1)},Jo(o).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const o=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,o.right-1)},Jo(o).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const o of t){const{col:t,row:i}=o.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:i,content:`=SUM(${this.getters.zoneToXC(e,o.zone)})`})}}nextEmptyRow(e,t){let o=t.bottom+1;const{left:i,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:o,top:o,left:i,right:n});)o++;return{...t,top:o,bottom:o}}nextEmptyCol(e,t){let o=t.right+1;const{top:i,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:o,right:o,top:i,bottom:n});)o++;return{...t,left:o,right:o}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}Yv.getters=["getAutomaticSums"];class Kv extends Vv{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{ts.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 o,i;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=null===(i=(o=ts.get(this.persistentPopover.type)).onOpen)||void 0===i?void 0:i.call(o,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=ts.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 o=this.getters.getActiveSheetId(),i=this.getters.getMerge({sheetId:o,col:e,row:t});return i?this.getters.getVisibleRect(i):this.getters.getVisibleRect(ii({col:e,row:t}))}}Kv.getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];var Qv;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(Qv||(Qv={}));class Jv extends Vv{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch=""}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":case"UNDO":case"REDO":case"REMOVE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(Qv.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(Qv.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"ACTIVATE_SHEET":case"REFRESH_SEARCH":this.refreshSearch()}}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(Qv.current)}updateRegex(){let e=Oe(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),o=[];if(this.toSearch)for(const i of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(i.id);if(i&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:n}))){const e={col:t,row:n,selected:!1};o.push(e)}}return o.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let o;o=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,o=(o%t.length+t.length)%t.length,this.selectedMatchIndex=o,this.selection.selectCell(t[o].col,t[o].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replace(e){if(null===this.selectedMatchIndex||!this.currentSearchRegex)return;const t=this.searchMatches[this.selectedMatchIndex],o=this.getters.getActiveSheetId(),i=this.getters.getCell({sheetId:o,...t});if((null==i?void 0:i.isFormula)&&!this.searchOptions.searchFormulas)this.selectNextCell(Qv.next);else{const i=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),n=this.getSearchableString({sheetId:o,col:t.col,row:t.row}).replace(i,e);this.dispatch("UPDATE_CELL",{sheetId:this.getters.getActiveSheetId(),col:t.col,row:t.row,content:n}),this.searchMatches.splice(this.selectedMatchIndex,1),this.selectNextCell(Qv.current)}}replaceAll(e){const t=this.searchMatches.length;for(let o=0;o<t;o++)this.replace(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,o=this.getters.getActiveSheetId();for(const e of this.searchMatches){const i=this.getters.getMerge({sheetId:o,col:e.col,row:e.row}),n=i?i.left:e.col,s=i?i.right:e.col,r=i?i.top:e.row,a=i?i.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)))}}}Jv.layers=[3],Jv.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class eb extends Vv{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,o){return"COL"===t?this.isColHidden(e,o):this.isRowHidden(e,o)}getNextVisibleCellPosition({sheetId:e,col:t,row:o}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",o,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,o,i){if(o<=i)for(let n=o;n<=i;n++)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n;if(o>i)for(let n=o;n>=i;n--)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n}findLastVisibleColRowIndex(e,t,{last:o,first:i}){return ze(o,i,-1).find((o=>!this.isHeaderHidden(e,t,o)))||i}findFirstVisibleColRowIndex(e,t){const o=this.getters.getNumberHeaders(e,t);for(let i=0;i<o;i++){if("COL"===t&&!this.isColHidden(e,i))return i;if("ROW"===t&&!this.isRowHidden(e,i))return i}}exportForExcel(e){for(const t of e.sheets)for(const[e,o]of Object.entries(t.rows)){const i=this.isRowHidden(t.id,Number(e));o.isHidden=i}}}eb.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class tb extends Vv{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:o}=Ko(e.zone),i=t*o==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:i}}))}drawGrid(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId(),n=3*o;t.lineWidth=n;const s=this.getHighlights();for(let e of s.filter(((e,t)=>s.findIndex((t=>Go(t.zone,e.zone)&&t.sheetId===i))===t))){const{x:o,y:i,width:s,height:r}=this.getters.getVisibleRect(e.zone);s>0&&r>0&&(t.strokeStyle=e.color,t.strokeRect(o+n/2,i+n/2,s-n,r-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(o+n,i+n,s-2*n,r-2*n))}}}tb.layers=[1],tb.getters=["getHighlights"];class ob extends Vv{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleCols()),i=this.getters.getColRowOffsetInViewport("COL",o,t),n=this.getters.getColSize(e,t);return{start:i,size:n,end:i+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const o=Math.min(...this.getters.getSheetViewVisibleRows()),i=this.getters.getColRowOffsetInViewport("ROW",o,t),n=this.getters.getRowSize(e,t);return{start:i,size:n,end:i+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,o){let i=this.getters.getColRowOffsetInViewport(e,t,o);return this.getters.isDashboard()||(i+="ROW"===e?O:N),i}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:o}=e,{width:i,height:n}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,i+m,n+m);const s=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),r=s?.1*o:0;if(s)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=o,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 o=e.style;o.fillColor&&"#ffffff"!==o.fillColor&&(t.fillStyle=o.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,o;const{ctx:i,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===(o=e.clipRect)||void 0===o?void 0:o.x)||e.x+e.width/2-e.content.width/2)+n/2,a=h-2*n),i.fillStyle="#ffffff",i.fillRect(r,l,a,c)}}drawBorders(e){const{ctx:t,thinLineWidth:o}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:o,y:n,width:s,height:r}=e;t.left&&i(t.left,o,n,o,n+r),t.top&&i(t.top,o,n,o+s,n),t.right&&i(t.right,o+s,n,o+s,n+r),t.bottom&&i(t.bottom,o,n+r,o+s,n+r)}}function i([e,i],n,s,r,a){t.strokeStyle=i,t.lineWidth=("thin"===e?2:3)*o,t.beginPath(),t.moveTo(n,s),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:o}=e;let i;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},s=e.content.align||"left",r=Ue(n);r!==i&&(i=r,t.font=r),t.fillStyle=n.textColor||"#000";let a=e.x;if(a+="left"===s?U+(e.image?e.image.size+L:0):"right"===s?e.width-U-(e.isFilterHeader?20:0):e.width/2,t.textAlign=s,e.clipRect){t.save(),t.beginPath();const{x:o,y:i,width:n,height:s}=e.clipRect;t.rect(o,i,n,s),t.clip()}const l=Ve(n),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let i of e.content.textLines){if(t.fillText(i,Math.round(a),Math.round(h)),n.strikethrough||n.underline){const e=Pe(t,i,n);let r=a;"right"===s?r-=e:"center"===s&&(r-=e/2),n.strikethrough&&t.fillRect(r,h+l/2,e,2.6*o),n.underline&&t.fillRect(r,h+l+1,e,1.3*o)}h+=U+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const o=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:o,y:i,width:n,height:s}=e.image.clipIcon;t.rect(o,i,n,s),t.clip()}const i=e.image.size,n=this.computeTextYCoordinate(e,i);t.drawImage(o,e.x+L,n,i,i),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,o=1){const i=e.y+1,n=ke(t,o),s=e.height>n+2*U,r=e.verticalAlign||"middle";if(s){if("middle"===r)return i+(e.height-n)/2;if("bottom"===r)return i+e.height-n-U}return i+U}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,i=this.getters.getSheetViewVisibleCols(),n=i[0],s=i[i.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 o of e)for(let e of ze(o.left,o.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let o of e)for(let e of ze(o.top,o.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 ${q}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(let e=n;e<=s;e++){const o={left:e,right:e,top:0,bottom:f-1},{x:i,width:n}=this.getters.getVisibleRect(o),s=this.getters.doesZonesContainFilter(p,[o]),r=E.has(e),a=u.has(e);t.fillStyle=r?s?I:S:a?s?T:b:s?R:v,t.fillRect(i,0,n,O)}for(let e=a;e<=l;e++){const o={top:e,bottom:e,left:0,right:m-1},{y:i,height:n}=this.getters.getVisibleRect(o),s=this.getters.doesZonesContainFilter(p,[o]),r=w.has(e),a=g.has(e);t.fillStyle=r?s?I:S:a?s?T:b:s?R:v,t.fillRect(0,i,N,n)}t.beginPath(),t.moveTo(N,0),t.lineTo(N,h),t.moveTo(0,O),t.lineTo(c,O),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of i){const o=this.getters.getColSize(p,e),i=Ut(e);t.fillStyle=E.has(e)?"#fff":C;let s=this.getHeaderOffset("COL",n,e);t.fillText(i,s+o/2,13),t.moveTo(s+o,0),t.lineTo(s+o,O)}for(const e of r){const o=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let i=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,i+o/2),t.moveTo(0,i+o),t.lineTo(N,i+o)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:i,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.isDashboard()?0:N,r=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#BCBCBC",t.beginPath(),i&&(t.moveTo(s+i,0),t.lineTo(s+i,r)),n&&(t.moveTo(0,r+n),t.lineTo(s,r+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:i,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:N,u=this.getters.isDashboard()?0:O;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),i&&(t.moveTo(d+i,u),t.lineTo(d+i,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}findNextEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let n=e;for(;n<t;){const e={sheetId:i,col:n+1,row:o},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==en.empty||this.getters.isInMerge(e)||(null==s?void 0:s.left))return n;n++}return n}findPreviousEmptyCol(e,t,o){const i=this.getters.getActiveSheetId();let n=e;for(;n>t;){const e={sheetId:i,col:n-1,row:o},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==en.empty||this.getters.isInMerge(e)||(null==s?void 0:s.right))return n;n--}return n}computeCellAlignment(e,t){const o=this.getters.getCell(e);if((null==o?void 0:o.isFormula)&&this.getters.shouldShowFormulas())return"left";const{align:i}=this.getters.getCellStyle(e),n=this.getters.getEvaluatedCell(e);return t&&n.type===en.number?"center"!==i?"left":i:i||n.defaultAlign}createZoneBox(e,t,o){const{left:i,right:n}=o,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===en.empty)return f;const v=this.getters.getConditionalIcon(a),b=Ve(f.style),S=v?L+b:0;v&&(f.image={type:"icon",size:b,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:fg[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*U,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+U))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===en.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,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=s):(e=this.findNextEmptyCol(s,n,r),o=this.findPreviousEmptyCol(s,i,r),f.isOverflow=!0),T){case"left":{const o=ii({col:e,row:r}),{x:i,y:n,width:s,height:a}=this.getters.getVisibleRect($o(t,o));(s<R||b>a||x.length>1)&&(f.clipRect={x:i,y:n,width:s,height:a});break}case"right":{const e=ii({col:o,row:r}),{x:i,y:n,width:s,height:a}=this.getters.getVisibleRect($o(t,e));(s<R||b>a||x.length>1)&&(f.clipRect={x:i,y:n,width:s,height:a});break}case"center":{const i={...t,left:o,right:e},{x:n,y:s,height:r,width:a}=this.getters.getVisibleRect(i),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(),o=t[0],i=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),s={left:o,right:i,top:n[0],bottom:n[n.length-1]},r=this.getters.getActiveSheetId();for(const o of n)for(const i of t){const t={sheetId:r,col:i,row:o};this.getters.isInMerge(t)||e.push(this.createZoneBox(r,ii(t),s))}for(const t of this.getters.getMerges(r))if(!this.getters.isMergeHidden(r,t)&&qo(t,s)){const o=this.createZoneBox(r,t,s),i=this.getters.getCellBorder({sheetId:r,col:t.right,row:t.bottom});o.border={...o.border,bottom:i?i.bottom:void 0,right:i?i.right:void 0},o.isMerge=!0,e.push(o)}return e}}ob.layers=[0,7],ob.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];class ib extends Vv{constructor(e,t,o){super(e),this.inputHasSingleRange=o,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){if("ADD_EMPTY_RANGE"===e.type)if(this.inputHasSingleRange&&1===this.ranges.length)return 30;return 0}handleEvent(e){const t=Uo(e.anchor.zone),o=this.activeSheet,i=this.getters.getActiveSheetId(),n=this.getters.getSheetName(i);this.add([i===o?t:`${Fe(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 o=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,o)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),i=this.getters.expandZone(e.sheetIdTo,ii({col:t,row:o}));this.selection.resetAnchor(this,{cell:{col:t,row:o},zone:i})}}}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 o=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:o+t+1,color:ft[(o+t)%ft.length]}))))}setRange(e,t){const[,...o]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,o),o.length&&this.focus(e+o.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const o=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return o.map((e=>{const{sheetName:o}=Lt(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:o&&this.getters.getSheetIdByName(o)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:o}=Lt(t),i=this.getters.getSheetIdByName(o),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(i===n||void 0===i&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}ib.layers=[1],ib.getters=[];class nb extends Vv{constructor(e){super(e),this.config=e,this.inputs={},this.focusedInputId=null}get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}allowDispatch(e){var t,o;if("FOCUS_RANGE"===e.type){const i=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(o=this.currentInput)||void 0===o?void 0:o.focusedRangeIndex)===i)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:ii({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],o=t.ranges.find((t=>t.id===e.rangeId)),i=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(i,(null==o?void 0:o.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,o)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===o}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:o}=Lt(e);return null!==t.match(_t)&&(!o||void 0!==this.getters.getSheetIdByName(o))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,o=!1){if(this.inputs[e]=new ib(this.config,t,o),0===t.length){const t=this.inputs[e],o={zone:ii({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,o,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}nb.layers=[1],nb.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class sb{constructor(){this.subscriptions={}}on(e,t,o){if(!o)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:o})}trigger(e,t){const o=this.subscriptions[e]||[];for(let e=0,i=o.length;e<i;e++){const i=o[e];i.callback.call(i.owner,t)}}off(e,t){const o=this.subscriptions[e];o&&(this.subscriptions[e]=o.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function rb(e,t){return{...e,definition:mr(e.definition,t)}}function ab(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let o=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)o>t&&o--}if("ADD_COLUMNS_ROWS"===t.type){o=o>("before"===t.position?t.base-1:t.base)?o+t.quantity:o}return o>0?{...e,quantity:o}:void 0}Zu.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],rb),Zu.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],rb),Zu.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const o=t.sheetId;if(e.targetSheetId===o||e.sheetId===o)return;return e})),Zu.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),Zu.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var o;if(e.name===t.name)return{...e,name:(null===(o=e.name)||void 0===o?void 0:o.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),Zu.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const o=[];for(const i of e.target)for(const e of t.target)qo(i,e)||o.push({...i});if(o.length)return{...e,target:o};return})),Zu.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],ab),Zu.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],ab),Zu.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const o of e.target)for(const e of t.target)if(qo(e,o))return;return e}));const lb=[{match:function(e){return"sheetId"in e},fn:db},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const o=db(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;const i=[];for(const o of e.target){const e=ns(o,t);e&&i.push(e)}if(!i.length)return"IGNORE_COMMAND";return{...e,target:i}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const o=db(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const o="COL"===t.dimension?"col":"row";let i=e[o];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(i))return"IGNORE_COMMAND";for(let t of e)i>=t&&i--}"ADD_COLUMNS_ROWS"===t.type&&(i>t.base||i===t.base&&"before"===t.position)&&(i+=t.quantity);return{...e,[o]:i}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const o of t.target){if(!(e.col===o.left&&e.row===o.top)&&Zo(e.col,e.row,o))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const o=db(e,t);if("SKIP_TRANSFORMATION"!==o)return"IGNORE_COMMAND"===o?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const o="ADD_COLUMNS_ROWS"===e.type,i=o?"base":"elements";let n=o?[e[i]]:e[i];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const o=t.elements.sort(((e,t)=>t-e));for(let t of o)e>t&&e--;return e})).filter(et)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((o=>o>e?o+t.quantity:o))}if(n.length){let t=n;return o&&(t=n[0]),{...e,[i]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const o=[],i="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)o.push({...n,_zone:n._zone});else{const e=ns(n._zone,t);e&&i!==n._sheetId&&o.push({...n,_zone:e})}if(!o.length)return"IGNORE_COMMAND";return{...e,ranges:o}}}];function cb(e,t){const o=Zu.getTransformation(e.type,t.type);return o?o(e,t):function(e,t){for(const{match:o,fn:i}of lb)if(o(e)){const o=i(e,t);if("SKIP_TRANSFORMATION"===o)continue;if("IGNORE_COMMAND"===o)return;e=o}return e}(e,t)}function hb(e,t){let o=[...e];for(const e of t)o=o.map((t=>cb(t,e))).filter(et);return o}function db(e,t){const o="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===o?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class ub{constructor(e,t,o,i){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...o],this._changes=i?[...i]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class gb extends Error{}class pb extends sb{constructor(e,t,o=K){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=o,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Do,this.debouncedMove=function(e,t,o){let i;return function(){const n=this,s=arguments,r=o&&!i;clearTimeout(i),i=setTimeout((function(){i=null,o||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 o=new ub(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(o.id,o),this.trigger("new-local-state-update",{id:o.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:o.id,clientId:o.clientId,commands:o.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0,this.on("unexpected-revision-id",this,(({revisionId:e})=>{throw new Error(`The spreadsheet could not be loaded. Revision ${e} is corrupted.`)}));for(const t of e)this.onMessageReceived(t);this.off("unexpected-revision-id",this),this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new gb("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(et))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const o=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==o?void 0:o.col)===e.col&&o.row===e.row&&o.sheetId===e.sheetId)return;const i=o?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:i,version:1,client:{...n,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e)){switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":if(e.serverRevisionId!==this.serverRevisionId)return void this.trigger("unexpected-revision-id",{revisionId:e.serverRevisionId});const{clientId:t,commands:o}=e,i=new ub(e.nextRevisionId,t,o);if(i.clientId!==this.clientId){this.revisions.insert(i.id,i,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:hb(o,t)})}break;case"SNAPSHOT_CREATED":{const t=new ub(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const mb=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class fb extends Vv{constructor(){super(...arguments),this.availableColors=new Set(mb),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(mb));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 gb)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const o of this.getters.getConnectedClients())if(o.id!==this.getters.getClient().id&&o.position&&o.position.sheetId===e&&this.isPositionValid(o.position)){const e=o.position;this.colors[o.id]||(this.colors[o.id]=this.chooseNewColor());const i=this.colors[o.id];t.push({...o,position:e,color:i})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:s}=e.position,r=this.getters.expandZone(i,{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*o,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${G+1}px ${q}`}}}fb.getters=["getClientsToDisplay"],fb.layers=[6];class vb extends Vv{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Zo(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 Jo(t).some((({col:t,row:o})=>!this.getters.isInMerge({sheetId:e,col:t,row:o})))?63:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const o=this.getters.getMerges(e).filter((e=>qo(e,t))),i=Ko(o[0]);let[n,s]=[i.numberOfCols,i.numberOfRows];return o.every((e=>{let[t,o]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&o===s}))?0:63}expand(e,t){const{left:o,right:i,top:n,bottom:s}=this.getters.expandZone(e,t);return{left:Math.max(0,o),right:Math.min(this.getters.getNumberCols(e)-1,i),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,s)}}checkExpandedValues(e,t){const o=this.expand(e,t);let i;if(this.getters.doesIntersectMerge(e,o)){const{left:t,right:n,top:s,bottom:r}=o;for(let o=t;o<=n;o++)for(let t=s;t<=r;t++){const{col:n,row:s}=this.getters.getMainCellPosition({sheetId:e,col:o,row:t});if(i=this.getters.getEvaluatedCell({sheetId:e,col:n,row:s}),i.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,o))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let o,{top:i,bottom:n,left:s,right:r}=t,a=!1;for(;!a;)a=!0,i>0&&(o=this.checkExpandedValues(e,{left:s-1,right:r+1,top:i-1,bottom:i-1}),o&&(a=!1,i--)),s>0&&(o=this.checkExpandedValues(e,{left:s-1,right:s-1,top:i-1,bottom:n+1}),o&&(a=!1,s--)),r<this.getters.getNumberCols(e)-1&&(o=this.checkExpandedValues(e,{left:r+1,right:r+1,top:i-1,bottom:n+1}),o&&(a=!1,r++)),n<this.getters.getNumberRows(e)-1&&(o=this.checkExpandedValues(e,{left:s-1,right:r+1,top:n+1,bottom:n+1}),o&&(a=!1,n++));return{left:s,right:r,top:i,bottom:n}}hasHeader(e,t){if(1===t[0].length)return!1;let o=t.map((t=>t.map((({col:t,row:o})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:o}).type))));return o[0][0]===en.empty&&(o=o.slice(1)),!o.some((e=>e[0]===en.empty))&&!!o.some((e=>e[1]!==en.empty&&e[0]!==e[1]))}sortZone(e,t,o,i,n){const[s,r]=this.mainCellsSteps(e,o);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},o),c=this.mainCells(e,o);!n.sortHeaders&&this.hasHeader(e,c)&&(l.top+=r),c=this.mainCells(e,l);const h=function(e,t,o){const i=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let n=i.filter((e=>e.type===en.empty)),s=i.filter((e=>e.type!==en.empty));o&&(s.push(...n.map((e=>({...e,type:en.number,value:0})))),n=[]);const r="descending"===t?-1:1;return s.sort(((e,t)=>{let o=vr.indexOf(e.type)-vr.indexOf(t.type);return 0===o&&(o=e.type===en.text||e.type===en.error?e.value.localeCompare(t.value):e.value-t.value),r*o})).concat(n)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),i,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:o,row:i,sheetId:n}=c[e][d[t]];const a=this.getters.getCell({sheetId:n,col:o,row:i});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,o=this.getters.createAdaptedRanges(a.dependencies,0,t,n);e=this.getters.buildFormulaContent(n,a,o)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}for(const e of p)this.dispatch("UPDATE_CELL",e)}}mainCellsSteps(e,t){const o=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[o?o.right-o.left+1:1,o?o.bottom-o.top+1:1]}mainCells(e,t){const[o,i]=this.mainCellsSteps(e,t),n=[],s=ze(t.left,t.right+1,o),r=ze(t.top,t.bottom+1,i);for(const t of s){const o=[];n.push(o);for(const i of r)o.push({sheetId:e,col:t,row:i})}return n}}vb.getters=["getContiguousZone"];class bb extends Vv{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}bb.getters=["shouldShowFormulas"];class Sb extends Vv{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const o=this.getColMaxWidth(e.sheetId,t);0!==o&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:o,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e){const t=this.getCellText(e),o=this.getters.getCellComputedStyle(e);let i=this.getTextWidth(t,o);this.getters.getConditionalIcon(e)&&(i+=function(e){return Ve(e)+2*L}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(i+=20),i>0&&(i+=2*z,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,i)}return i}getTextWidth(e,t){return Pe(this.ctx,e,t)}getCellText(e,t=!1){const o=this.getters.getCell(e);return t&&(null==o?void 0:o.isFormula)?o.content:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const o=this.getters.getCellStyle(e),i=this.getters.getCellText(e,this.getters.shouldShowFormulas()),n=[];for(const e of i.split("\n")){const i=e.split(" ");if(!t){n.push(e);continue}let s="",r=t;for(let e of i){const i=this.splitWordToSpecificWidth(this.ctx,e,t,o),a=i.pop(),l=Pe(this.ctx,a,o);if(i.length)""!==s&&(n.push(s),s="",r=t),i.forEach((e=>{n.push(e)})),s=a,r=t-l;else{const e=""===s?a:" "+a,i=Pe(this.ctx,e,o);i<=r?(s+=e,r-=i):(n.push(s),s=a,r=t-l)}}""!==s&&n.push(s)}return n}getColDimensions(e,t){const o=this.getColRowOffset("COL",0,t,e),i=this.getters.getColSize(e,t);return{start:o,size:i,end:o+(this.getters.isColHidden(e,t)?0:i)}}getRowDimensions(e,t){const o=this.getColRowOffset("ROW",0,t,e),i=this.getters.getRowSize(e,t);return{start:o,size:i,end:o+(this.getters.isRowHidden(e,t)?0:i)}}getColRowOffset(e,t,o,i=this.getters.getActiveSheetId()){if(o<t)return-this.getColRowOffset(e,o,t);let n=0;for(let s=t;s<o;s++)this.getters.isHeaderHidden(i,e,s)||(n+="COL"===e?this.getters.getColSize(i,s):this.getters.getRowSize(i,s));return n}getColMaxWidth(e,t){const o=Jo(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...o)}splitWordToSpecificWidth(e,t,o,i){if(Pe(e,t,i)<=o)return[t];const n=[];let s="";for(let r of t){Pe(e,s+r,i)>o?(n.push(s),s=r):s+=r}return n.push(s),n}}Sb.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];class Cb{constructor(e,t,o,i){this.getters=t,this.dispatch=o,this.selection=i,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,o,i){const n=this.getters.getActiveSheetId(),s=t+i-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+o-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 Eb extends Cb{constructor(e,t,o,i,n){if(super(t,o,i,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 o=e.length;for(let i=0;i<o;i++)if(qo(e[i],t))return e[i]=$o(e[i],t),e;return e[o]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>Jo(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=o.getActiveSheetId();for(let e of u){let t=[];for(let i of d){const n={col:i,row:e,sheetId:p};t.push({cell:o.getCell(n),style:o.getCellComputedStyle(n),evaluatedCell:o.getEvaluatedCell(n),border:o.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 o of ze(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:o,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 o=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const i=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(o,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(o,e[0])||i*n!=1))return 2;const{xSplit:s,ySplit:r}=this.getters.getPaneDivisions(o);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 o=this.cells.length,i=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(i,o,n,e)}pasteFromCopy(e,t){if(1===e.length){const o=this.cells.length,i=this.cells[0].length,n=this.pastedZones(e,i,o);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const o of e)for(let e=o.left;e<=o.right;e++)for(let i=o.top;i<=o.bottom;i++)this.pasteZone(e,i,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const o=e[0];this.pasteZone(o.left,o.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:o.left,row:o.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.getters.getActiveSheetId(),target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,o){const i=e[0],n=Math.max(1,Math.floor((i.right+1-i.left)/t)),s=Math.max(1,Math.floor((i.bottom+1-i.top)/o)),r=[];for(let e=0;e<n;e++)for(let n=0;n<s;n++){const s=i.top+n*o,a=i.left+e*t;r.push({left:a,top:s,bottom:s+o-1,right:a+t-1})}return r}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const o=[],i=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)/i));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)o.push({left:r,top:a,right:r-1+e*n,bottom:a-1+t*i});return o}selectPastedZone(e,t,o,i){const n=i[0],s=n.left,r=n.top;if(t>1||e>1||o){const n=this.pastedZones(i,e,t),a=o?n[0]:$o(...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,o){const i=this.cells.length,n=this.cells[0].length,s="onlyValue"!==(null==o?void 0:o.pasteOption)&&(null==o?void 0:o.shouldPasteCF),r=this.getters.getActiveSheetId();this.addMissingDimensions(n,i,e,t);for(let a=0;a<i;a++){const i=this.cells[a];for(let l=0;l<n;l++){const n=i[l],c={col:e+l,row:t+a,sheetId:r};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,o),s&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,o,i){const{sheetId:n,col:s,row:r}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==(null==i?void 0:i.pasteOption)){const o=this.getters.getCellBorder(t),i=e.border,a={top:(null==o?void 0:o.top)||(null==i?void 0:i.top),bottom:(null==o?void 0:o.bottom)||(null==i?void 0:i.bottom),left:(null==o?void 0:o.left)||(null==i?void 0:i.left),right:(null==o?void 0:o.right)||(null==i?void 0:i.right)};this.dispatch("SET_BORDER",{sheetId:n,col:s,row:r,border:a})}if(e.cell){if("onlyFormat"===(null==i?void 0:i.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===(null==i?void 0:i.pasteOption)){const o=ho(e.evaluatedCell.value);return void this.dispatch("UPDATE_CELL",{...t,content:o})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===o){const t=s-e.position.col,i=r-e.position.row;a=this.getUpdatedContent(n,e.cell,t,i,o)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==i?void 0:i.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==i?void 0:i.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,o,i,n){const s=this.getters.createAdaptedRanges(t.dependencies,o,i,e);return this.getters.buildFormulaContent(e,t,s)}pasteMergeIfExist(e,t){let{sheetId:o,col:i,row:n}=e;const{col:s,row:r}=this.getters.getMainCellPosition(e);if(s===i&&r===n){const s=this.getters.getMerge(e);if(!s)return;({sheetId:o,col:i,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:o,force:!0,target:[{left:i,top:n,right:i+s.right-s.left,bottom:n+s.bottom-s.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),o=e[0],i=this.zones[0],n=[o.left-i.left,o.top-i.top];for(const e of this.copiedTables){const o=ei(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[o]});for(const i of ze(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:o.left+i,row:o.top,values:e.filtersValues[i]})}}getClipboardContent(){return{[tn.PlainText]:this.getPlainTextContent(),[tn.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 o of t){e+=`<td style="${pi(ui(o.style))}">`+Xm(this.getters.getCellText(o.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let o of this.zones){if("COL"===t&&e<=o.right)return!0;if("ROW"===t&&e<=o.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:o}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*o;for(const e of this.zones){const{x:o,y:i,width:n,height:s}=this.getters.getVisibleRect(e);n>0&&s>0&&t.strokeRect(o,i,n,s)}}}}class wb{constructor(e,t,o){this.operation=e,this.getters=t,this.dispatch=o,this.sheetId=t.getActiveSheetId();const i=t.getSelectedFigureId();if(!i)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,i);if(!n)throw new Error(`No figure for the given id: ${i}`);switch(this.copiedFigure={...n},n.tag){case"chart":this.copiedFigureContent=new yb(o,t,this.sheetId,i);break;case"image":this.copiedFigureContent=new xb(o,t,this.sheetId,i);break;default:throw new Error(`Unknow tag '${n.tag}' for the given figure id: ${i}`)}}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(),o={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},i={height:this.copiedFigure.height,width:this.copiedFigure.width},n=(new Do).uuidv4();this.copiedFigureContent.paste(t,n,o,i),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return{[tn.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class yb{constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const n=t.getChart(i);if(!n)throw new Error(`No chart for the given id: ${i}`);this.copiedChart=n.copyInSheetId(o)}paste(e,t,o,i){const n=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:o,size:i,definition:n.getDefinition()})}}class xb{constructor(e,t,o,i){this.dispatch=e,this.sheetId=o;const n=t.getImage(i);this.copiedImage=Ne(n)}paste(e,t,o,i){const n=Ne(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:o,size:i,definition:n})}}class Ib extends Cb{constructor(e,t,o,i){super("COPY",t,o,i),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const o=this.getters.getActiveSheetId(),i=this.getPasteZone(e);return this.getters.doesIntersectMerge(o,i)?2:0}paste(e){const t=this.values,o=this.getPasteZone(e),{left:i,top:n}=o,{numberOfCols:s,numberOfRows:r}=Ko(o),a=this.getters.getActiveSheetId();this.addMissingDimensions(s,r,i,n);for(let e=0;e<t.length;e++)for(let o=0;o<t[e].length;o++)this.dispatch("UPDATE_CELL",{row:n+e,col:i+o,content:t[e][o],sheetId:a});const l={left:i,top:n,right:i+s-1,bottom:n+r-1};this.selection.selectZone({cell:{col:i,row:n},zone:l})}getClipboardContent(){return{[tn.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,o=Math.max(...this.values.map((e=>e.length))),{left:i,top:n}=e[0];return{top:n,left:i,bottom:n+t-1,right:i+o-1}}}class Rb extends Vv{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=e.target||this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const o=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:o});case"PASTE_FROM_OS_CLIPBOARD":return new Ib(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}case"DELETE_CELL":{const{cut:t,paste:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(o)}}return 0}handle(e){var t,o;switch(e.type){case"COPY":case"CUT":const i="target"in e&&e.target||this.getters.getSelectedZones();this.state=this.getClipboardState(i,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:o}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Lo(t[0])){for(const{col:t,row:o}of Jo(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:o,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"INSERT_CELL":{const{cut:t,paste:o}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(o);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(o=this.state)||void 0===o?void 0:o.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new Ib(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:an(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||{[tn.PlainText]:"\t"}}getClipboardTextContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent()[tn.PlainText])||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i;return i="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(o)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1},{cut:[i],paste:[e]}}getInsertCellsTargets(e,t){const o=this.getters.getActiveSheetId();let i,n;return"COL"===t?(i={...e,right:this.getters.getNumberCols(o)-1},n={...e,left:e.right+1,right:e.right+1}):(i={...e,bottom:this.getters.getNumberRows(o)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(o)-1}),{cut:[i],paste:[n]}}getClipboardStateForCopyCells(e,t){return new Eb(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new wb(t,this.getters,this.dispatch):new Eb(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}function Tb(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:o}=Lt(e.value),[i,n]=t.split(":"),s=o?`${Fe(o)}!`:"",r=Ab(i),a=n?`:${Ab(n)}`:"";return{...e,value:s+r+a}}function Ab(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=Mb(e,"colrow");break;case"colrow":e=Mb(e,"row");break;case"row":e=Mb(e,"col");break;case"col":e=Mb(e,"none")}return e}function Mb(e,t){let o;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return o=e.search(/[0-9]/),e.slice(0,o)+"$"+e.slice(o);case"colrow":return o=e.search(/[0-9]/),"$"+(e=e.slice(0,o)+"$"+e.slice(o));case"none":return e}}Rb.layers=[2],Rb.getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];const Ob=s("The cell you are trying to edit has been deleted.");class Nb extends Vv{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),o=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:o,sheetName:i}=Lt(e.value),n=i||this.getters.getSheetName(this.sheetId),s=this.getters.getActiveSheetId();if(this.getters.getSheetName(s)!==n)return!1;const r=this.getters.getRangeFromSheetXC(s,o);return Go(this.getters.expandZone(s,r.zone),t.zone)}));this.previousRef=o.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=o.start;break;case"CHANGE_HIGHLIGHT":const i=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(i,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:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),n=this.getters.expandZone(e.sheetIdTo,ii({col:o,row:i}));this.selection.resetAnchor(this,{cell:{col:o,row:i},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:Ob}));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((o=>o.start<=e&&o.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const o=e.map(Tb).map((e=>e.value)).join(""),i=this.currentContent,n=e[0].start,s=e[e.length-1].end,r=i.slice(0,n)+o+i.slice(s),a=r.length-i.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,o){return t>=0&&t<=e&&o>=0&&o<=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:Ob});const{top:t,left:o}=Bo({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=o,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Ob});const{top:t,left:o}=Bo({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=o,this.row=t}onAddElements(e){const{top:t,left:o}=zo({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=o,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=ii({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var o;const i=this.getters.getActiveCell();e&&(null===(o=i.format)||void 0===o?void 0:o.includes("%"))&&Qt(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=ii({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 o=this.currentContent;if(!(this.initialContent!==o))return;if(o){const i=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCell({sheetId:i,col:this.col,row:this.row});if(o.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,i=e-t;i>0&&(o+=it(new Array(i).fill(")")))}else n.link&&(o=je(o,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:o})}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:o,value:i,type:n,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(n){case en.text:case en.empty:return i;case en.boolean:return s;case en.error:return(null==t?void 0:t.content)||"";case en.number:return o&&fo(o)?s:this.numberComposerContent(i,o)}}numberComposerContent(e,t){return(null==t?void 0:t.includes("%"))?100*e+"%":function(e){const{integerDigits:t,decimalDigits:o}=po(e,20);return o?`${t}.${o}`:t}(e)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const i=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(i||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?wv(e):[],this.currentTokens.length>100&&o&&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),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(o,t),this.selectionInitialStart=t):(this.insertText(","+o,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const o=this.getters.getActiveSheetId();let i=this.getters.zoneToXC(o,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){i=`${Fe(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${i}`}return i}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let o=[...t];1===t.length&&si(e.zone)>1?o.push({...t[0]}):2===t.length&&1===si(e.zone)&&o.pop();const i=e.clone({parts:o});return this.getters.getSelectionRangeString(i,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(o,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),i=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:o,selection:{start:i,end:i}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const i=new Set(Object.values(o));let n=0;const s=()=>{for(;i.has(n);)n++;return i.add(n),n};for(const e of t){const t=e in o?o[e]:s();o[e]=t}this.colorIndexByRange=o}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return ft[t%ft.length]};return this.getReferencedRanges().map((o=>{const i=this.getters.getRangeString(o,e);return{zone:o.zone,color:t(i),sheetId:o.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,i=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(i.type)||Sf.includes(i.value);){if("SPACE"!==i.type||o<1)return!1;o--,i=this.currentTokens[o]}for(o=t+1,i=this.currentTokens[o];i&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(i.type);){if("SPACE"!==i.type)return!1;o++,i=this.currentTokens[o]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((o=>o.start<=e&&o.end>=e||o.start>=e&&o.start<t))}}Nb.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];const _b=[{name:s("Sum"),types:[en.number],compute:e=>rl.compute([e])},{name:s("Avg"),types:[en.number],compute:e=>vl.compute([e])},{name:s("Min"),types:[en.number],compute:e=>Dl.compute([e])},{name:s("Max"),types:[en.number],compute:e=>Ol.compute([e])},{name:s("Count"),types:[en.number,en.text,en.boolean,en.error],compute:e=>Il.compute([e])},{name:s("Count Numbers"),types:[en.number,en.text,en.boolean,en.error],compute:e=>xl.compute([e])}];class Fb extends Vv{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 o=[];switch(e.mode){case"overrideSelection":o=[t.zone];break;case"updateAnchor":o=[...this.gridSelection.zones];const i=o.findIndex((t=>Go(t,e.previousAnchor.zone)));i>=0&&(o[i]=t.zone);break;case"newAnchor":o=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,o),this.selection.resetDefaultAnchor(this,Ne(this.gridSelection.anchor));const{col:i,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:i,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:o,row:i}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(o,i),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:Ne(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,Ne(this.gridSelection.anchor));else{const{col:t,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,o)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:o,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:o,row:i})}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:Ne(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:o})}const 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,Ne(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 o=t.left;o<=t.right;o++)e.add(o);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let o of this.gridSelection.zones)if(0===o.left&&o.right===this.getters.getNumberCols(t)-1)for(let t=o.top;t<=o.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return Ne(this.gridSelection.zones)}getSelectedZone(){return Ne(this.gridSelection.anchor.zone)}getSelection(){return Ne(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!==en.empty)));let t=new Set,o=[];for(let i of e)t.add(i.type),o.push(i.value);let i={};for(let e of _b){let n;e.types.some((e=>t.has(e)))&&(n=e.compute(o)),i[e.name]=n}return i}getAggregate(){let e=0,t=0;const o=this.getters.getActiveSheetId(),i=this.gridSelection.zones.map(Jo).flat();for(const{col:n,row:s}of i){const i=this.getters.getEvaluatedCell({sheetId:o,col:n,row:s});i.type===en.number&&(t++,e+=i.value)}return t<2?null:ho(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Go(t,e)))}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let o=[];const i="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[i]+1},((t,o)=>e[i]+o));o=o.concat(t)}return[...new Set(o)].sort()}setSelectionMixin(e,t){const{anchor:o,zones:i}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=o,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,o)=>t===o.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(i)}selectCell(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.expandZone(o,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:i,cell:{col:e,row:t}},[i])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),o=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[o]})}onColumnsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=Bo(o,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Bo(n,"left",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:i};this.setSelectionMixin(s,[i])}onRowsRemoved(e){const{cell:t,zone:o}=this.gridSelection.anchor,i=Bo(o,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=Bo(n,"top",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:i};this.setSelectionMixin(s,[i])}onAddElements(e){const t=zo(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(o,[t])}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:"before"});const o="COL"===e.dimension,i=e.elements[0],n=e.elements[t-1],s=e.base<i,r=s&&o?t:0,a=s&&!o?t:0;this.dispatch("CUT",{target:[{left:o?i+r:0,right:o?n+r:this.getters.getNumberCols(e.sheetId)-1,top:o?0:i+a,bottom:o?this.getters.getNumberRows(e.sheetId)-1:n+a}]}),this.dispatch("PASTE",{target:[{left:o?e.base:0,right:o?e.base+t-1:this.getters.getNumberCols(e.sheetId)-1,top:o?0:e.base,bottom:o?this.getters.getNumberRows(e.sheetId)-1:e.base+t-1}]});const l=s?e.elements.map((e=>e+t)):e.elements;let c=e.base;for(const t of l){const o="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:o,elements:[c]}),c+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:l})}isMoveElementAllowed(e){const t="COL"===e.dimension,o=e.elements[0],i=e.elements[e.elements.length-1],n=e.sheetId,s=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;return s(n,o-1,o)||s(n,i,i+1)||s(n,e.base-1,e.base)?2:0}clipSelection(e,t){const o=this.getters.getNumberCols(e)-1,i=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:De(e.left,0,o),right:De(e.right,0,o),top:De(e.top,0,i),bottom:De(e.bottom,0,i)}))),anchor:{cell:{col:De(t.anchor.cell.col,0,o),row:De(t.anchor.cell.row,0,i)},zone:{left:De(t.anchor.zone.left,0,o),right:De(t.anchor.zone.right,0,o),top:De(t.anchor.zone.top,0,i),bottom:De(t.anchor.zone.bottom,0,i)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:o}=e,i=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===i.length&&i[0].left===i[0].right&&i[0].top===i[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*o;for(const e of i){const{x:o,y:i,width:n,height:s}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(o,i,n,s),t.globalCompositeOperation="source-over",t.strokeRect(o,i,n,s)}t.globalCompositeOperation="source-over";const s=this.getActivePosition();let r;t.strokeStyle=E,t.lineWidth=3*o,r=this.getters.isInMerge(s)?this.getters.getMerge(s):ii(s);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);c>0&&h>0&&t.strokeRect(a,l,c,h)}}Fb.layers=[6],Fb.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","getElementsFromSelection"];const Db=(new Si).add("sheet",Uv).add("header visibility",_v).add("filters",Ov).add("cell",yv).add("merge",Dv).add("headerSize",Nv).add("borders",Kf).add("conditional formatting",Rv).add("figures",Tv).add("chart",xv).add("image",Fv),kb=(new Si).add("ui_sheet",Sb).add("header_visibility_ui",eb).add("ui_options",bb).add("selectionInputManager",nb).add("highlight",tb).add("grid renderer",ob).add("autofill",Xv).add("find_and_replace",Jv).add("sort",vb).add("automatic_sum",Yv).add("format",class extends Vv{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,o){for(const i of t)for(const t of Jo(i)){const i=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==i){const n=yo(i,o);this.dispatch("SET_FORMATTING",{sheetId:e,target:[ii(t)],format:n})}}}getCellNumberFormat(e){var t;for(const o of[e]){const e=this.getters.getEvaluatedCell(o);if(e.type===en.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(X)))return e.format||Co(e.value)}}}).add("cell_popovers",Kv).add("selection_multiuser",fb),Pb=(new Si).add("selection",Fb).add("clipboard",Rb).add("edition",Nb),Lb=(new Si).add("evaluation",Hv).add("evaluation_filter",Gv).add("evaluation_chart",$v).add("evaluation_cf",Wv).add("viewport",Zv).add("custom_colors",zv),Ub=new Si;Ub.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,action:(e,t)=>Ri(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Vb{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)}}getImageFromUser(){return new Promise(((e,t)=>{const o=document.createElement("input");o.setAttribute("type","file"),o.setAttribute("accept","image/*"),o.addEventListener("change",(async()=>{null===o.files||1!=o.files.length?t():e(o.files[0])})),o.click()}))}getImageSize(e){return new Promise(((t,o)=>{const i=new Image;i.src=e,i.addEventListener("load",(()=>{const e={width:i.width,height:i.height};t(e)})),i.addEventListener("error",o)}))}}const zb=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];hi`
|
|
1381
1381
|
.o-ripple {
|
|
1382
1382
|
z-index: 1;
|
|
1383
1383
|
}
|
|
1384
|
-
`;class
|
|
1384
|
+
`;class Bb 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:o,height:i}=this.props;return pi({transform:"scale(0)",left:e,top:t,"margin-left":`${-o/2+(this.props.offsetX||0)}px`,"margin-top":`${-i/2+(this.props.offsetY||0)}px`,width:`${o}px`,height:`${i}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}Bb.template="o-spreadsheet-RippleEffect",Bb.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 Hb 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:o,y:i,width:n,height:s}=t,r=Math.max(n,s),a={x:e.clientX-o,y:e.clientY-i,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 pi({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{...kn(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,o=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{...kn(t),marginLeft:o.left,marginTop:o.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 o=null===(t=this.state.ripples.find((t=>t.id===e)))||void 0===t?void 0:t.rippleRect;if(!o)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%":o.x+"px",y:this.props.ignoreClickPosition?"50%":o.y+"px",width:o.width,height:o.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}Hb.template="o-spreadsheet-Ripple",Hb.components={RippleEffect:Bb},Hb.defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""},Hb.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}},hi`
|
|
1385
1385
|
.o-sheet {
|
|
1386
1386
|
color: #666;
|
|
1387
1387
|
padding: 0 15px;
|
|
@@ -1422,7 +1422,7 @@
|
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
1424
|
}
|
|
1425
|
-
`;class
|
|
1425
|
+
`;class $b 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,o,i){const n=e.model.getters.getSheetName(t);if(null===o||o===n)return;const r=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:o});r.reasons.includes(10)?e.raiseError(s("The sheet name cannot be empty."),i):r.reasons.includes(11)?e.raiseError(s("A sheet with the name %s already exists. Please select another name.",o),i):r.reasons.includes(13)&&e.raiseError(s("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",ne.join(" ")),i)}(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 Kn;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(),o=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:o}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}}).add("rename",{name:s("Rename"),sequence:30,action:()=>e.renameSheetCallback()}).add("move_right",{name:s("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),o=e.model.getters.getVisibleSheetIds();return o.indexOf(t)!==o.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),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)}}$b.template="o-spreadsheet-BottomBarSheet",$b.components={Ripple:Hb},$b.defaultProps={onMouseDown:()=>{},style:""},$b.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},hi`
|
|
1426
1426
|
.o-selection-statistic {
|
|
1427
1427
|
margin-right: 20px;
|
|
1428
1428
|
padding: 4px 4px 4px 8px;
|
|
@@ -1432,7 +1432,7 @@
|
|
|
1432
1432
|
background-color: rgba(0, 0, 0, 0.08) !important;
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
|
-
`;class
|
|
1435
|
+
`;class Wb 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();at(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 Kn;let o=0;for(let[e,i]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,i),sequence:o,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),o++;const i=e.currentTarget,{top:n,left:s,width:r}=i.getBoundingClientRect();this.props.openContextMenu(s+r,n,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?ho(t):"__")}}Wb.template="o-spreadsheet-BottomBarStatisic",Wb.components={Ripple:Hb},Wb.props={openContextMenu:Function,closeContextMenu:Function};class Gb{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,Ig(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),o=this.items.findIndex((e=>e.id===this.draggedItemId)),i=this.items[o];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:i.position,end:i.position+i.size})&&(this.deadZone=void 0),o===t)return void this.onChange(this.getItemsPositions());const n=Math.min(o,t),s=Math.max(o,t),r=Math.sign(t-o);let a=0;for(let e=n;e<=s;e++)e!==o&&(this.items[e].position-=r*i.size,a+=this.items[e].size);i.position+=r*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=r>0?{start:e,end:i.position}:{start:i.position+i.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 o=this.currentMousePosition+t;o<this.minPosition?o=this.minPosition:o>this.maxPosition&&(o=this.maxPosition),this.edgeScrollOffset+=o-this.currentMousePosition,this.moveDraggedItemToPosition(o),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 o=this.currentMousePosition-this.initialMousePosition;o=Math.max(this.minPosition-t.positionAtStart,o),o=Math.min(this.maxPosition-t.positionAtStart-t.size,o),e[t.id]=o}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}hi`
|
|
1436
1436
|
.o-spreadsheet-bottom-bar {
|
|
1437
1437
|
background-color: ${f};
|
|
1438
1438
|
padding-left: ${N}px;
|
|
@@ -1481,12 +1481,12 @@
|
|
|
1481
1481
|
}
|
|
1482
1482
|
}
|
|
1483
1483
|
}
|
|
1484
|
-
`;class
|
|
1484
|
+
`;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&&!at(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(),o=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,i=this.env.model.uuidGenerator.uuidv4(),n=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:i,position:o,name:n}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}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 Kn,o=this.env.model.getters.getActiveSheetId();let i=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:i,isReadonlyAllowed:!0,textColor:n.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:e})}}),i++}const n=e.currentTarget,{left:s}=n.getBoundingClientRect(),r=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(s,r,"listSheets",t)}openContextMenu(e,t,o,i){this.menuState.isOpen=!0,this.menuState.menuId=o,this.menuState.menuItems=i.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,o){const i=o.currentTarget,{top:n,left:s}=i.getBoundingClientRect();o.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 o=t.clientX;document.body.style.cursor="move";const i=this.getVisibleSheets(),n=this.getSheetItemRects(),s=i.map(((e,t)=>({id:e.id,size:n[t].width,position:n[t].x})));this.dndHelper=new Gb({draggedItemId:e,mouseX:o,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 o=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==o&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:o}),this.stopDragging()}getSheetStyle(e){var t;const o={};return this.sheetState.isDnd&&(o.position="relative",o.left=((null===(t=this.sheetState.sheetDndPositions)||void 0===t?void 0:t[e])||0)+"px",o.transition="left 0.5s",o.cursor="move"),this.isDragged(e)&&(o.transition="left 0s",o["z-index"]="1000"),pi(o)}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:Gn,Ripple:Hb,BottomBarSheet:$b,BottomBarStatistic:Wb},qb.props={onClick:Function},hi`
|
|
1485
1485
|
.o-dashboard-clickable-cell {
|
|
1486
1486
|
position: absolute;
|
|
1487
1487
|
cursor: pointer;
|
|
1488
1488
|
}
|
|
1489
|
-
`;let
|
|
1489
|
+
`;let Zb=1;class jb extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=Un(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),Jg("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=ep(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:o}=this.env.model.getters.getColDimensions(e,t);return pi({"max-width":`${o}px`})}get gridOverlayDimensions(){return pi({height:"100%",width:"100%"})}getCellClickableStyle(e){return pi({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 o of this.env.model.getters.getSheetViewVisibleCols())for(const i of this.env.model.getters.getSheetViewVisibleRows()){const n={sheetId:t,col:o,row:i},s=this.getClickableAction(n);if(!s)continue;let r;r=this.env.model.getters.isInMerge(n)?this.env.model.getters.getMerge(n):ii({col:o,row:i});const a=this.env.model.getters.getVisibleRect(r);e.push({coordinates:a,position:{col:o,row:i},action:s,tKey:`${Zb}-${o}-${i}`})}return Zb++,e}getClickableAction(e){for(const t of Ub.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:o}=e;o({...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:o,scrollY:i}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:o+e,offsetY:i+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}jb.template="o-spreadsheet-SpreadsheetDashboard",jb.components={GridOverlay:Zg,GridPopover:jg,Popover:Bn,VerticalScrollBar:ap,HorizontalScrollBar:rp,FilterIconsOverlay:Wg},jb.props={},hi`
|
|
1490
1490
|
.o-sidePanel {
|
|
1491
1491
|
display: flex;
|
|
1492
1492
|
flex-direction: column;
|
|
@@ -1651,14 +1651,14 @@
|
|
|
1651
1651
|
}
|
|
1652
1652
|
}
|
|
1653
1653
|
}
|
|
1654
|
-
`;class
|
|
1654
|
+
`;class Xb extends t.Component{setup(){this.state=t.useState({panel:wg.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=wg.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}Xb.template="o-spreadsheet-SidePanel",Xb.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function};const Yb={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.")};hi`
|
|
1655
1655
|
.o-topbar-composer {
|
|
1656
1656
|
height: fit-content;
|
|
1657
1657
|
margin-top: -1px;
|
|
1658
1658
|
border: 1px solid;
|
|
1659
1659
|
z-index: ${le.TopBarComposer};
|
|
1660
1660
|
}
|
|
1661
|
-
`;class
|
|
1661
|
+
`;class Kb 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",pi(e)}get containerStyle(){return"inactive"===this.props.focus?pi({"border-color":A,"border-right":"none"}):pi({"border-color":E})}}Kb.template="o-spreadsheet-TopBarComposer",Kb.components={Composer:Ug},Kb.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},hi`
|
|
1662
1662
|
.o-font-size-editor {
|
|
1663
1663
|
input.o-font-size {
|
|
1664
1664
|
height: 20px;
|
|
@@ -1672,7 +1672,7 @@
|
|
|
1672
1672
|
-webkit-appearance: none;
|
|
1673
1673
|
}
|
|
1674
1674
|
}
|
|
1675
|
-
`;class
|
|
1675
|
+
`;class Qb extends t.Component{constructor(){super(...arguments),this.fontSizes=he,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){Fn(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||G}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=De(Math.floor(parseFloat(e)),1,400);Mr(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()}}}Qb.template="o-spreadsheet-FontSizeEditor",Qb.components={},Qb.props={onToggle:Function,dropdownStyle:String};const Jb=[{name:"automatic",text:xs.Automatic},{name:"number",text:xs.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:xs.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:xs.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:xs.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:xs.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:xs.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:xs.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:xs.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],eS=[{name:"custom_currency",text:xs.CustomCurrency,sidePanel:"CustomCurrency"}],tS="#4a4f59";hi`
|
|
1676
1676
|
.o-spreadsheet-topbar {
|
|
1677
1677
|
background-color: white;
|
|
1678
1678
|
line-height: 1.2;
|
|
@@ -1682,7 +1682,7 @@
|
|
|
1682
1682
|
line-height: 1.2;
|
|
1683
1683
|
user-select: none;
|
|
1684
1684
|
font-weight: 500;
|
|
1685
|
-
color: ${
|
|
1685
|
+
color: ${tS};
|
|
1686
1686
|
|
|
1687
1687
|
.o-topbar-top {
|
|
1688
1688
|
border-bottom: 1px solid ${A};
|
|
@@ -1749,7 +1749,7 @@
|
|
|
1749
1749
|
svg path,
|
|
1750
1750
|
polygon,
|
|
1751
1751
|
rect {
|
|
1752
|
-
fill: ${
|
|
1752
|
+
fill: ${tS};
|
|
1753
1753
|
}
|
|
1754
1754
|
}
|
|
1755
1755
|
|
|
@@ -1874,7 +1874,7 @@
|
|
|
1874
1874
|
}
|
|
1875
1875
|
}
|
|
1876
1876
|
}
|
|
1877
|
-
`;class
|
|
1877
|
+
`;class oS extends t.Component{constructor(){super(...arguments),this.commonFormats=Jb,this.customFormats=eS,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 yg.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){Mr(this.env,{[e]:!this.style[e]})}toggleFormat(e){const t=Jb.find((t=>t.name===e)),o=t&&t.value||"";Ar(this.env,o)}toggleHorizontalAlign(e){Mr(this.env,{align:e}),this.onClick()}toggleVerticalAlign(e){Mr(this.env,{verticalAlign:e}),this.onClick()}toggleTextWrapping(e){Mr(this.env,{wrapping:e}),this.onClick()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const o=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=o?"":e,this.openedEl=o?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen?this.closeMenus():this.openMenu(e,t)}openMenu(e,t){const{left:o,top:i,height:n}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:o,y:i+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:o,sheetId:i}=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(i);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(i,ii({col:t,row:o}));this.inMerge=Go(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=Gu.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]],o=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:o,target:t}):function(e,t,o){const i=e.model.dispatch("ADD_MERGE",{sheetId:t,target:o});i.isCancelledBecause(80)?e.raiseError(Yb.MergeInFilter):i.isCancelledBecause(3)&&e.askConfirmation(Yb.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:o,force:!0})}))}(this.env,o,t)}setColor(e,t){Mr(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=eS.find((t=>t.name===e)),o=t&&t.sidePanel||"";this.env.openSidePanel(o)}setDecimal(e){this.env.model.dispatch("SET_DECIMAL",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),step:e})}paintFormat(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.env.model.getters.getSelectedZones()})}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}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!ri(...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();Er(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}oS.template="o-spreadsheet-TopBar",oS.components={ColorPickerWidget:ng,Menu:Gn,TopBarComposer:Kb,FontSizeEditor:Qb},oS.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class iS{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({[tn.PlainText]:this.getBlob(e,tn.PlainText),[tn.Html]:this.getBlob(e,tn.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}hi`
|
|
1878
1878
|
.o-spreadsheet {
|
|
1879
1879
|
position: relative;
|
|
1880
1880
|
display: grid;
|
|
@@ -1918,7 +1918,7 @@
|
|
|
1918
1918
|
height: ${15}px;
|
|
1919
1919
|
vertical-align: sub;
|
|
1920
1920
|
}
|
|
1921
|
-
`,
|
|
1921
|
+
`,hi`
|
|
1922
1922
|
.o-grid {
|
|
1923
1923
|
position: relative;
|
|
1924
1924
|
overflow: hidden;
|
|
@@ -1947,23 +1947,23 @@
|
|
|
1947
1947
|
outline: none;
|
|
1948
1948
|
}
|
|
1949
1949
|
}
|
|
1950
|
-
`;class iS 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 Ub(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:iS._t,clipboard:this.env.clipboard||new oS(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 o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}iS.template="o-spreadsheet-Spreadsheet",iS.components={TopBar:tS,Grid:lp,BottomBar:Gb,SidePanel:jb,SpreadsheetDashboard:Zb},iS._t=e=>e,iS.props={model:Object};class nS{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 sS(e){return ur.get(e.type)(e)}function rS(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class aS{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:i,operation:n,after:s}=this.locateOperation(t);this.operations=[...i,n,e,...s.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new aS(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class lS{constructor(e,t){this.id=e,this.data=t}transformed(e){return new cS(this.id,nt((()=>e(this.data))))}}class cS{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new cS(this.id,this.lazyData.map(e))}}class hS{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new hS(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new hS(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new hS(function*(e,t){let o=!0;for(const i of e)o||(yield i),i.operation.id===t&&(o=!1)}(this.operations,e))}}class dS{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 hS(He(this._execution(e),this._execution(e)))}revertedExecution(e){return new hS(He(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var o;const i=e.getLastOperationId()||(null===(o=this.previousBranch(e))||void 0===o?void 0:o.getLastOperationId());e.append(t),i&&this.insertPrevious(e,t,i)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);i&&this.branchingOperationIds.set(n,i),this.insertBranchAfter(e,n),this.transform(n,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const i=this.buildTransformation.without(o.data),n=t.fork(o.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(i);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 o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const i=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(i&&n)if(e.getFirstOperationAmong(o,i)===i){const s=this.addToNextBranch(e,n,i,t,o);this.updateNextWith(n,s,o)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,o,i,n){let s=i;return n===o?(s=this.getTransformedOperation(e,o,i),t.prepend(s)):t.contains(n)?(s=this.getTransformedOperation(e,o,i),t.insert(s,n)):t.append(i),s}getTransformedOperation(e,t,o){const i=e.getOperation(t),n=this.buildTransformation.without(i.data);return o.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:i,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!i||!n)return;const s=this.buildTransformation.with(n.data),r=e.fork(o);r.transform(s),i.cutAfter(o),i.appendBranch(r);const a=t.transformed(s);this.insertPrevious(i,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const i=e.getOperations();for(let n=i.length-1;n>=0;n--){const s=i[n];s.id===t&&(o=!1),o||(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 uS{constructor(e,t,o,i,n){this.applyOperation=t,this.revertOperation=o,this.buildEmpty=i,this.buildTransformation=n,this.HEAD_BRANCH=new aS(this.buildTransformation),this.tree=new dS(n,this.HEAD_BRANCH);const s=new lS(e,i(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 o=new lS(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,o),this.HEAD_BRANCH=i,this.HEAD_OPERATION=o}insert(e,t,o){const i=new lS(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,o),this.fastForward()}undo(e,t,o){const{branch:i,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,n),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:i}of e)i||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function gS(e,t,o){return new uS(e,(e=>{const i=e.commands.slice(),{changes:n}=t((()=>{for(const e of i)o(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){pS(t.changes[e],"before")}}([e])),(e=>new db(e,"empty",[],[])),{with:e=>t=>new db(t.id,t.clientId,cb(t.commands,e.commands)),without:e=>t=>new db(t.id,t.clientId,cb(t.commands,e.commands.map(sS).flat()))})}function pS(e,t){let o=e.root,i=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===o[i]){const n=e.path[t+1];o[i]=rS(n)}o=o[i]}void 0===e[t]?delete o[i]:o[i]=e[t]}class mS 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 fS{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var o,i,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(o=this.mainSubscription)||void 0===o?void 0:o.owner)&&this.mainSubscription.owner!==e&&(null===(n=(i=this.mainSubscription.callbacks).release)||void 0===n||n.call(i)),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,o;this.mainSubscription!==this.defaultSubscription&&(null===(o=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===o||o.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class vS{constructor(e){this.getters=e,this.stream=new fS,this.anchor={cell:{col:0,row:0},zone:oi({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){return this.modifyAnchor(e,"overrideSelection","ZonesSelected")}modifyAnchor(e,t,o){const i=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(i,e.zone)},this.processEvent({type:o,anchor:e,mode:t})}selectCell(e,t){const o=oi({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new an(83);const{col:o,row:i}=this.getNextAvailablePosition(e,t);return this.selectCell(o,i)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:i,row:n}=this.anchor.cell,s={left:Math.min(i,e),top:Math.min(n,t),right:Math.max(i,e),bottom:Math.max(n,t)},r={zone:this.getters.expandZone(o,s),cell:{col:i,row:n}};return this.processEvent({type:"AlterZone",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const i=this.getters.expandZone(o,oi({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:i,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new an(83);const o=this.getters.getActiveSheetId(),i=this.anchor,{col:n,row:s}=i.cell,{left:r,right:a,top:l,bottom:c}=i.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return an.Success;let g=i.zone;const p=e=>{e=ti(e);const{left:t,right:i,top:n,bottom:s}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,i),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(o)-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?ti(g):g,g&&!Wo(g,i.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:s}}})}g=p(Ho({top:s,bottom:s,left:n,right:n},ti({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 o=this.getters.getActiveSheetId(),i=this.getters.getNumberRows(o)-1;let n={left:e,right:e,top:0,bottom:i};const s=this.getters.findFirstVisibleColRowIndex(o,"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=Ho(n,{left:r,right:r,top:s,bottom:i})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberCols(o)-1;let n={top:e,bottom:e,left:0,right:i};const s=this.getters.findFirstVisibleColRowIndex(o,"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=Ho(n,{left:s,right:i,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(Wo(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:oi(t.cell)},"updateAnchor","AlterZone");const o=this.expandZoneToTable(t.zone);return at(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"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:Ne(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new an(o):(this.anchor=t.anchor,this.stream.send(t),an.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!qo(t.col,t.row,o))return 16;const{left:i,right:n,top:s,bottom:r}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",ze(i,n+1));return void 0===this.getters.findVisibleHeader(a,"ROW",ze(s,r+1))||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:o,row:i}=this.anchor.cell,n=this.deltaToTarget({col:o,row:i},e,t);return{col:this.getNextAvailableCol(n[0],o,i),row:this.getNextAvailableRow(n[1],o,i)}}getNextAvailableCol(e,t,o){const i=this.getters.getActiveSheetId(),n={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(i,t,o,e,o)))}getNextAvailableRow(e,t,o){const i=this.getters.getActiveSheetId(),n={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,n,(e=>this.getters.isInSameMerge(i,t,o,t,e)))}getNextAvailableHeader(e,t,o,i,n){const s=this.getters.getActiveSheetId();if(0===e)return o;const r=Math.sign(e);let a=o+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,o)?this.getNextAvailableHeader(-r,t,o,i,n):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:i,top:n,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",ze(o,i+1))||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",ze(n,s+1))||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const i=this.anchor.zone;switch(e){case"down":case"up":o=o===i.top?i.bottom:i.top;break;case"left":case"right":t=t===i.right?i.left:i.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const i=this.getters.getActiveSheet();let n=e;const s=this.getNextCellPosition(e,t,o);let r=this.isCellEmpty(n,i.id)||this.isCellEmpty(s,i.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,o);if(n.col===e.col&&n.row===e.row)break;const s=this.isCellEmpty(e,i.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},o=this.getters.getActiveSheetId()){const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return this.getters.getEvaluatedCell(i).type===Ji.empty}getNextCellPosition(e,t,o){const i="cols"===t?"col":"row",n={...e},s="cols"===t?this.getNextAvailableCol(o,n.col,n.row):this.getNextAvailableRow(o,n.col,n.row);return n[i]=s,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of ze(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 ze(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 o=!1,i=e;do{o=!1;const e=t(i);Wo(i,e)||(o=!0,i=e)}while(o);return i}}class bS{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop(),[o,...i]=e;let n=o,s=i[i.length-1];for(let e=0;e<=i.length-2;e++){const t=i[e];if(void 0===n[t]){const o=i[e+1];n[t]=rS(o)}n=n[t]}n[s]!==t&&(this.changes.push({root:o,path:i,before:n[s],after:t}),void 0===t?delete n[s]:n[s]=t)}}const SS=17781237,CS=88853993;function ES(e,t,o){const i=[["xmlns:r",bp],["xmlns:a",pp],["xmlns:c",mp]],n=wS({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=Jm``;e.data.title&&(s=Jm`
|
|
1950
|
+
`;class nS 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 Vb(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:nS._t,clipboard:this.env.clipboard||new iS(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 o=this.keyDownMapping[t];if(o)return e.preventDefault(),e.stopPropagation(),void o()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}nS.template="o-spreadsheet-Spreadsheet",nS.components={TopBar:oS,Grid:cp,BottomBar:qb,SidePanel:Xb,SpreadsheetDashboard:jb},nS._t=e=>e,nS.props={model:Object};class sS{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 rS(e){return gr.get(e.type)(e)}function aS(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class lS{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:i,operation:n,after:s}=this.locateOperation(t);this.operations=[...i,n,e,...s.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new lS(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class cS{constructor(e,t){this.id=e,this.data=t}transformed(e){return new hS(this.id,nt((()=>e(this.data))))}}class hS{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new hS(this.id,this.lazyData.map(e))}}class dS{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new dS(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new dS(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new dS(function*(e,t){let o=!0;for(const i of e)o||(yield i),i.operation.id===t&&(o=!1)}(this.operations,e))}}class uS{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 dS(He(this._execution(e),this._execution(e)))}revertedExecution(e){return new dS(He(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var o;const i=e.getLastOperationId()||(null===(o=this.previousBranch(e))||void 0===o?void 0:o.getLastOperationId());e.append(t),i&&this.insertPrevious(e,t,i)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),i=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);i&&this.branchingOperationIds.set(n,i),this.insertBranchAfter(e,n),this.transform(n,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const i=this.branchingOperationIds.get(t);i?this.branchingOperationIds.set(e,i):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const i=this.buildTransformation.without(o.data),n=t.fork(o.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(i);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 o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const i=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(i&&n)if(e.getFirstOperationAmong(o,i)===i){const s=this.addToNextBranch(e,n,i,t,o);this.updateNextWith(n,s,o)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,o,i,n){let s=i;return n===o?(s=this.getTransformedOperation(e,o,i),t.prepend(s)):t.contains(n)?(s=this.getTransformedOperation(e,o,i),t.insert(s,n)):t.append(i),s}getTransformedOperation(e,t,o){const i=e.getOperation(t),n=this.buildTransformation.without(i.data);return o.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:i,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!i||!n)return;const s=this.buildTransformation.with(n.data),r=e.fork(o);r.transform(s),i.cutAfter(o),i.appendBranch(r);const a=t.transformed(s);this.insertPrevious(i,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const i=e.getOperations();for(let n=i.length-1;n>=0;n--){const s=i[n];s.id===t&&(o=!1),o||(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 gS{constructor(e,t,o,i,n){this.applyOperation=t,this.revertOperation=o,this.buildEmpty=i,this.buildTransformation=n,this.HEAD_BRANCH=new lS(this.buildTransformation),this.tree=new uS(n,this.HEAD_BRANCH);const s=new cS(e,i(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 o=new cS(e,t),i=this.tree.getLastBranch();this.tree.insertOperationLast(i,o),this.HEAD_BRANCH=i,this.HEAD_OPERATION=o}insert(e,t,o){const i=new cS(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,i,o),this.fastForward()}undo(e,t,o){const{branch:i,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(i,n),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:i}of e)i||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:i}of e)i||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function pS(e,t,o){return new gS(e,(e=>{const i=e.commands.slice(),{changes:n}=t((()=>{for(const e of i)o(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){mS(t.changes[e],"before")}}([e])),(e=>new ub(e,"empty",[],[])),{with:e=>t=>new ub(t.id,t.clientId,hb(t.commands,e.commands)),without:e=>t=>new ub(t.id,t.clientId,hb(t.commands,e.commands.map(rS).flat()))})}function mS(e,t){let o=e.root,i=e.path[e.path.length-1];for(let t=0;t<e.path.slice(0,-1).length;t++){const i=e.path[t];if(void 0===o[i]){const n=e.path[t+1];o[i]=aS(n)}o=o[i]}void 0===e[t]?delete o[i]:o[i]=e[t]}class fS 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 vS{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var o,i,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(o=this.mainSubscription)||void 0===o?void 0:o.owner)&&this.mainSubscription.owner!==e&&(null===(n=(i=this.mainSubscription.callbacks).release)||void 0===n||n.call(i)),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,o;this.mainSubscription!==this.defaultSubscription&&(null===(o=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===o||o.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class bS{constructor(e){this.getters=e,this.stream=new vS,this.anchor={cell:{col:0,row:0},zone:ii({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){return this.modifyAnchor(e,"overrideSelection","ZonesSelected")}modifyAnchor(e,t,o){const i=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(i,e.zone)},this.processEvent({type:o,anchor:e,mode:t})}selectCell(e,t){const o=ii({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new ln(83);const{col:o,row:i}=this.getNextAvailablePosition(e,t);return this.selectCell(o,i)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:i,row:n}=this.anchor.cell,s={left:Math.min(i,e),top:Math.min(n,t),right:Math.max(i,e),bottom:Math.max(n,t)},r={zone:this.getters.expandZone(o,s),cell:{col:i,row:n}};return this.processEvent({type:"AlterZone",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const i=this.getters.expandZone(o,ii({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:i,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new ln(83);const o=this.getters.getActiveSheetId(),i=this.anchor,{col:n,row:s}=i.cell,{left:r,right:a,top:l,bottom:c}=i.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return ln.Success;let g=i.zone;const p=e=>{e=oi(e);const{left:t,right:i,top:n,bottom:s}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,i),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(o)-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?oi(g):g,g&&!Go(g,i.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:s}}})}g=p($o({top:s,bottom:s,left:n,right:n},oi({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 o=this.getters.getActiveSheetId(),i=this.getters.getNumberRows(o)-1;let n={left:e,right:e,top:0,bottom:i};const s=this.getters.findFirstVisibleColRowIndex(o,"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=$o(n,{left:r,right:r,top:s,bottom:i})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),i=this.getters.getNumberCols(o)-1;let n={top:e,bottom:e,left:0,right:i};const s=this.getters.findFirstVisibleColRowIndex(o,"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=$o(n,{left:s,right:i,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(Go(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:ii(t.cell)},"updateAnchor","AlterZone");const o=this.expandZoneToTable(t.zone);return at(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"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:Ne(this.anchor)},o=this.checkEventAnchorZone(t);return 0!==o?new ln(o):(this.anchor=t.anchor,this.stream.send(t),ln.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!Zo(t.col,t.row,o))return 16;const{left:i,right:n,top:s,bottom:r}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",i,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:o,row:i}=this.anchor.cell,n=this.deltaToTarget({col:o,row:i},e,t);return{col:this.getNextAvailableCol(n[0],o,i),row:this.getNextAvailableRow(n[1],o,i)}}getNextAvailableCol(e,t,o){const i=this.getters.getActiveSheetId(),n={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(i,t,o,e,o)))}getNextAvailableRow(e,t,o){const i=this.getters.getActiveSheetId(),n={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,n,(e=>this.getters.isInSameMerge(i,t,o,t,e)))}getNextAvailableHeader(e,t,o,i,n){const s=this.getters.getActiveSheetId();if(0===e)return o;const r=Math.sign(e);let a=o+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,o)?this.getNextAvailableHeader(-r,t,o,i,n):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:i,top:n,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",o,i)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",n,s)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const i=this.anchor.zone;switch(e){case"down":case"up":o=o===i.top?i.bottom:i.top;break;case"left":case"right":t=t===i.right?i.left:i.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const i=this.getters.getActiveSheet();let n=e;const s=this.getNextCellPosition(e,t,o);let r=this.isCellEmpty(n,i.id)||this.isCellEmpty(s,i.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,o);if(n.col===e.col&&n.row===e.row)break;const s=this.isCellEmpty(e,i.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},o=this.getters.getActiveSheetId()){const i=this.getters.getMainCellPosition({sheetId:o,col:e,row:t});return this.getters.getEvaluatedCell(i).type===en.empty}getNextCellPosition(e,t,o){const i="cols"===t?"col":"row",n={...e},s="cols"===t?this.getNextAvailableCol(o,n.col,n.row):this.getNextAvailableRow(o,n.col,n.row);return n[i]=s,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of ze(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 ze(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 o=!1,i=e;do{o=!1;const e=t(i);Go(i,e)||(o=!0,i=e)}while(o);return i}}class SS{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop(),[o,...i]=e;let n=o,s=i[i.length-1];for(let e=0;e<=i.length-2;e++){const t=i[e];if(void 0===n[t]){const o=i[e+1];n[t]=aS(o)}n=n[t]}n[s]!==t&&(this.changes.push({root:o,path:i,before:n[s],after:t}),void 0===t?delete n[s]:n[s]=t)}}const CS=17781237,ES=88853993;function wS(e,t,o){const i=[["xmlns:r",Sp],["xmlns:a",mp],["xmlns:c",fp]],n=yS({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=ef``;e.data.title&&(s=ef`
|
|
1951
1951
|
<c:title>
|
|
1952
|
-
${
|
|
1952
|
+
${IS(e.data.title,e.data.fontColor)}
|
|
1953
1953
|
<c:overlay val="0" />
|
|
1954
1954
|
</c:title>
|
|
1955
|
-
`);let r=
|
|
1955
|
+
`);let r=ef``;switch(e.data.type){case"bar":r=function(e){const t=new ps,o=[];for(const[i,n]of Object.entries(e.dataSets)){const s=os(t.next()),r=yS({backgroundColor:s,line:{color:s}});o.push(ef`
|
|
1956
1956
|
<c:ser>
|
|
1957
1957
|
<c:idx val="${i}"/>
|
|
1958
1958
|
<c:order val="${i}"/>
|
|
1959
|
-
${n.label?
|
|
1959
|
+
${n.label?ef`<c:tx>${MS(n.label)}</c:tx>`:""}
|
|
1960
1960
|
${r}
|
|
1961
|
-
${e.labelRange?
|
|
1961
|
+
${e.labelRange?ef`<c:cat>${MS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
1962
1962
|
<c:val> <!-- x-coordinate values -->
|
|
1963
|
-
${
|
|
1963
|
+
${OS(n.range)}
|
|
1964
1964
|
</c:val>
|
|
1965
1965
|
</c:ser>
|
|
1966
|
-
`)}const i="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",s=e.stacked?100:-20;return
|
|
1966
|
+
`)}const i="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",s=e.stacked?100:-20;return ef`
|
|
1967
1967
|
<c:barChart>
|
|
1968
1968
|
<c:barDir val="col"/>
|
|
1969
1969
|
<c:grouping val="${n}"/>
|
|
@@ -1971,13 +1971,13 @@
|
|
|
1971
1971
|
<c:gapWidth val="70"/>
|
|
1972
1972
|
<!-- each data marker in the series does not have a different color -->
|
|
1973
1973
|
<c:varyColors val="0"/>
|
|
1974
|
-
${
|
|
1975
|
-
<c:axId val="${SS}" />
|
|
1974
|
+
${Jm(o)}
|
|
1976
1975
|
<c:axId val="${CS}" />
|
|
1976
|
+
<c:axId val="${ES}" />
|
|
1977
1977
|
</c:barChart>
|
|
1978
|
-
${
|
|
1979
|
-
${
|
|
1980
|
-
`}(e.data);break;case"line":r=function(e){const t=new
|
|
1978
|
+
${AS("b","c:catAx",CS,ES,{fontColor:e.fontColor})}
|
|
1979
|
+
${AS(i,"c:valAx",ES,CS,{fontColor:e.fontColor})}
|
|
1980
|
+
`}(e.data);break;case"line":r=function(e){const t=new ps,o=[];for(const[i,n]of Object.entries(e.dataSets)){const s=yS({line:{width:2.5,style:"solid",color:os(t.next())}});o.push(ef`
|
|
1981
1981
|
<c:ser>
|
|
1982
1982
|
<c:idx val="${i}"/>
|
|
1983
1983
|
<c:order val="${i}"/>
|
|
@@ -1986,50 +1986,50 @@
|
|
|
1986
1986
|
<c:symbol val="circle" />
|
|
1987
1987
|
<c:size val="5"/>
|
|
1988
1988
|
</c:marker>
|
|
1989
|
-
${n.label?
|
|
1989
|
+
${n.label?ef`<c:tx>${MS(n.label)}</c:tx>`:""}
|
|
1990
1990
|
${s}
|
|
1991
|
-
${e.labelRange?
|
|
1991
|
+
${e.labelRange?ef`<c:cat>${MS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
1992
1992
|
<c:val> <!-- x-coordinate values -->
|
|
1993
|
-
${
|
|
1993
|
+
${OS(n.range)}
|
|
1994
1994
|
</c:val>
|
|
1995
1995
|
</c:ser>
|
|
1996
|
-
`)}const i="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return
|
|
1996
|
+
`)}const i="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return ef`
|
|
1997
1997
|
<c:lineChart>
|
|
1998
1998
|
<c:grouping val="${n}"/>
|
|
1999
1999
|
<!-- each data marker in the series does not have a different color -->
|
|
2000
2000
|
<c:varyColors val="0"/>
|
|
2001
|
-
${
|
|
2002
|
-
<c:axId val="${SS}" />
|
|
2001
|
+
${Jm(o)}
|
|
2003
2002
|
<c:axId val="${CS}" />
|
|
2003
|
+
<c:axId val="${ES}" />
|
|
2004
2004
|
</c:lineChart>
|
|
2005
|
-
${
|
|
2006
|
-
${
|
|
2007
|
-
`}(e.data);break;case"pie":r=function(e,t,o,{holeSize:i}={holeSize:50}){const n=new
|
|
2005
|
+
${AS("b","c:catAx",CS,ES,{fontColor:e.fontColor})}
|
|
2006
|
+
${AS(i,"c:valAx",ES,CS,{fontColor:e.fontColor})}
|
|
2007
|
+
`}(e.data);break;case"pie":r=function(e,t,o,{holeSize:i}={holeSize:50}){const n=new ps,s=Math.max(...e.dataSets.map((e=>Im(e.range,t,o)))),r=ze(0,s).map((()=>os(n.next()))),a=[];for(const[i,n]of Object.entries(e.dataSets).reverse()){const s=Im(n.range,t,o),l=[];for(const e of ze(0,s)){const t=yS({backgroundColor:r[e],line:{color:"FFFFFF",width:1.5}});l.push(ef`
|
|
2008
2008
|
<c:dPt>
|
|
2009
2009
|
<c:idx val="${e}"/>
|
|
2010
2010
|
${t}
|
|
2011
2011
|
</c:dPt>
|
|
2012
|
-
`)}a.push(
|
|
2012
|
+
`)}a.push(ef`
|
|
2013
2013
|
<c:ser>
|
|
2014
2014
|
<c:idx val="${i}"/>
|
|
2015
2015
|
<c:order val="${i}"/>
|
|
2016
|
-
${n.label?
|
|
2017
|
-
${
|
|
2018
|
-
${
|
|
2019
|
-
${e.labelRange?
|
|
2016
|
+
${n.label?ef`<c:tx>${MS(n.label)}</c:tx>`:""}
|
|
2017
|
+
${Jm(l)}
|
|
2018
|
+
${TS({showLeaderLines:!0})}
|
|
2019
|
+
${e.labelRange?ef`<c:cat>${MS(e.labelRange)}</c:cat>`:""}
|
|
2020
2020
|
<c:val>
|
|
2021
|
-
${
|
|
2021
|
+
${OS(n.range)}
|
|
2022
2022
|
</c:val>
|
|
2023
2023
|
</c:ser>
|
|
2024
|
-
`)}return
|
|
2024
|
+
`)}return ef`
|
|
2025
2025
|
<c:doughnutChart>
|
|
2026
2026
|
<c:varyColors val="1" />
|
|
2027
2027
|
<c:holeSize val="${i}" />
|
|
2028
|
-
${
|
|
2029
|
-
${
|
|
2028
|
+
${TS()}
|
|
2029
|
+
${Jm(a)}
|
|
2030
2030
|
</c:doughnutChart>
|
|
2031
|
-
`}(e.data,t,o,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=
|
|
2032
|
-
<c:chartSpace ${
|
|
2031
|
+
`}(e.data,t,o,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=ef`
|
|
2032
|
+
<c:chartSpace ${Ym(i)}>
|
|
2033
2033
|
<c:roundedCorners val="0" />
|
|
2034
2034
|
<!-- <manualLayout/> to manually position the chart in the figure container -->
|
|
2035
2035
|
${n}
|
|
@@ -2040,32 +2040,32 @@
|
|
|
2040
2040
|
<!-- how the chart element is placed on the chart -->
|
|
2041
2041
|
<c:layout />
|
|
2042
2042
|
${r}
|
|
2043
|
-
${
|
|
2043
|
+
${yS({backgroundColor:e.data.backgroundColor})}
|
|
2044
2044
|
</c:plotArea>
|
|
2045
|
-
${function(e,t){return
|
|
2045
|
+
${function(e,t){return ef`
|
|
2046
2046
|
<c:legend>
|
|
2047
2047
|
<c:legendPos val="${e}"/>
|
|
2048
2048
|
<c:overlay val="0"/>
|
|
2049
|
-
${
|
|
2049
|
+
${RS(10,t)}
|
|
2050
2050
|
</c:legend>
|
|
2051
2051
|
`}(a,l)}
|
|
2052
2052
|
</c:chart>
|
|
2053
2053
|
</c:chartSpace>
|
|
2054
|
-
`;return
|
|
2054
|
+
`;return Km(c)}function yS(e){return ef`
|
|
2055
2055
|
<c:spPr>
|
|
2056
|
-
${e.backgroundColor?
|
|
2057
|
-
${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",
|
|
2058
|
-
<a:ln ${
|
|
2059
|
-
${
|
|
2056
|
+
${e.backgroundColor?xS(e.backgroundColor):""}
|
|
2057
|
+
${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",xm(e.width)]);const o=e.style?ef`<a:prstDash val="${e.style}"/>`:"";return ef`
|
|
2058
|
+
<a:ln ${Ym(t)}>
|
|
2059
|
+
${xS(e.color)}
|
|
2060
2060
|
${o}
|
|
2061
2061
|
</a:ln>
|
|
2062
2062
|
`}(e.line):""}
|
|
2063
2063
|
</c:spPr>
|
|
2064
|
-
`}function
|
|
2064
|
+
`}function xS(e){return ef`
|
|
2065
2065
|
<a:solidFill>
|
|
2066
2066
|
<a:srgbClr val="${e}"/>
|
|
2067
2067
|
</a:solidFill>
|
|
2068
|
-
`}function
|
|
2068
|
+
`}function IS(e,t="000000",o=22){return ef`
|
|
2069
2069
|
<c:tx>
|
|
2070
2070
|
<c:rich>
|
|
2071
2071
|
<a:bodyPr />
|
|
@@ -2073,7 +2073,7 @@
|
|
|
2073
2073
|
<a:p>
|
|
2074
2074
|
<a:pPr lvl="0">
|
|
2075
2075
|
<a:defRPr b="0">
|
|
2076
|
-
${
|
|
2076
|
+
${xS(t)}
|
|
2077
2077
|
<a:latin typeface="+mn-lt"/>
|
|
2078
2078
|
</a:defRPr>
|
|
2079
2079
|
</a:pPr>
|
|
@@ -2084,20 +2084,20 @@
|
|
|
2084
2084
|
</a:p>
|
|
2085
2085
|
</c:rich>
|
|
2086
2086
|
</c:tx>
|
|
2087
|
-
`}function
|
|
2087
|
+
`}function RS(e=12,t="000000",o=!1,i=!1){return ef`
|
|
2088
2088
|
<c:txPr>
|
|
2089
2089
|
<a:bodyPr/>
|
|
2090
2090
|
<a:lstStyle/>
|
|
2091
2091
|
<a:p>
|
|
2092
2092
|
<a:pPr lvl="0">
|
|
2093
|
-
<a:defRPr ${
|
|
2094
|
-
${
|
|
2093
|
+
<a:defRPr ${Ym([["b",o?"1":"0"],["i",i?"1":"0"],["sz",100*e]])}>
|
|
2094
|
+
${xS(t)}
|
|
2095
2095
|
<a:latin typeface="+mn-lt"/>
|
|
2096
2096
|
</a:defRPr>
|
|
2097
2097
|
</a:pPr>
|
|
2098
2098
|
</a:p>
|
|
2099
2099
|
</c:txPr>
|
|
2100
|
-
`}function
|
|
2100
|
+
`}function TS({showLeaderLines:e}={showLeaderLines:!1}){return ef`
|
|
2101
2101
|
<dLbls>
|
|
2102
2102
|
<c:showLegendKey val="0"/>
|
|
2103
2103
|
<c:showVal val="0"/>
|
|
@@ -2107,7 +2107,7 @@
|
|
|
2107
2107
|
<c:showBubbleSize val="0"/>
|
|
2108
2108
|
<c:showLeaderLines val="${e?"1":"0"}"/>
|
|
2109
2109
|
</dLbls>
|
|
2110
|
-
`}function
|
|
2110
|
+
`}function AS(e,t,o,i,{fontColor:n}){return ef`
|
|
2111
2111
|
<${t}>
|
|
2112
2112
|
<c:axId val="${o}"/>
|
|
2113
2113
|
<c:crossAx val="${i}"/> <!-- reference to the other axe of the chart -->
|
|
@@ -2116,62 +2116,62 @@
|
|
|
2116
2116
|
<c:orientation val="minMax" />
|
|
2117
2117
|
</c:scaling>
|
|
2118
2118
|
<c:axPos val="${e}" />
|
|
2119
|
-
${function(e="B7B7B7"){return
|
|
2119
|
+
${function(e="B7B7B7"){return ef`
|
|
2120
2120
|
<c:majorGridlines>
|
|
2121
|
-
${
|
|
2121
|
+
${yS({line:{color:e}})}
|
|
2122
2122
|
</c:majorGridlines>
|
|
2123
2123
|
`}()}
|
|
2124
2124
|
<c:majorTickMark val="out" />
|
|
2125
2125
|
<c:minorTickMark val="none" />
|
|
2126
2126
|
<c:numFmt formatCode="General" sourceLinked="1" />
|
|
2127
2127
|
<c:title>
|
|
2128
|
-
${
|
|
2128
|
+
${IS("")}
|
|
2129
2129
|
</c:title>
|
|
2130
|
-
${
|
|
2130
|
+
${RS(10,n)}
|
|
2131
2131
|
</${t}>
|
|
2132
2132
|
<!-- <tickLblPos/> omitted -->
|
|
2133
|
-
`}function
|
|
2133
|
+
`}function MS(e){return ef`
|
|
2134
2134
|
<c:strRef>
|
|
2135
2135
|
<c:f>${e}</c:f>
|
|
2136
2136
|
</c:strRef>
|
|
2137
|
-
`}function
|
|
2137
|
+
`}function OS(e){return ef`
|
|
2138
2138
|
<c:numRef>
|
|
2139
2139
|
<c:f>${e}</c:f>
|
|
2140
2140
|
<c:numCache />
|
|
2141
2141
|
</c:numRef>
|
|
2142
|
-
`}function
|
|
2142
|
+
`}function NS(e){const t=e.content,o=$u.content,i=[];let n=ef``;if(Ef(t).filter((e=>"FUNCTION"===e.type)).every((e=>o[e.value.toUpperCase()].isExported))){let o=ef``;const s=FS(t);return e.value===a.CircularDependency&&(i.push(["t","str"]),o=ef`<v>${e.value}</v>`),n=ef`
|
|
2143
2143
|
<f>
|
|
2144
2144
|
${s}
|
|
2145
2145
|
</f>
|
|
2146
2146
|
${o}
|
|
2147
|
-
`,{attrs:i,node:n}}{const t=e.value;if(t){const e=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);i.push(["t",e]),n=
|
|
2147
|
+
`,{attrs:i,node:n}}{const t=e.value;if(t){const e=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);i.push(["t",e]),n=ef`<v>${t}</v>`}return{attrs:i,node:n}}}function _S(e,t,o=!1){let i=e;const n=[];if(!o&&["TRUE","FALSE"].includes(i.trim()))i="TRUE"===i?"1":"0",n.push(["t","b"]);else if(o||!Qt(i)){const{id:o}=Sm(e,t);i=o.toString(),n.push(["t","s"])}return{attrs:n,node:ef`<v>${i}</v>`}}function FS(e){let t;"="===e[0]&&(e=e.slice(1));try{t=dv(e)}catch(t){return e}return t=gv(t,"STRING",DS),t=gv(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),o=e.args,i=Tp[t];if(i){const n=$u.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=i[t-s];o.push({type:e.type,value:e.value})}}return{...e,args:o}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:Ap.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?pv(t):e}function DS(e){const t=e.value.replace(new RegExp('"',"g"),""),o=Se(t);if(o){let i=[];return(t.match(fe)||t.match(ve))&&i.push("yyyy-mm-dd"),t.match(be)&&i.push("hh:mm:ss"),{...e,value:ho(o.value,i.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function kS(e,t){const o=[];for(const i of t)switch(i.rule.type){case"CellIsRule":o.push(PS(i,i.rule,e));break;case"ColorScaleRule":o.push(LS(i,i.rule));break;case"IconSetRule":o.push(US(i,i.rule));break;default:console.warn(`Conditional formatting ${i.rule.type} not implemented`)}return o}function PS(e,t,o){const i=VS(e),n=um(t.operator);i.push(...function(e){const t=um(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 o=e[0].split(":")[0],i=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${i[0]}",${o})))`];case"NotContains":return[`ISERROR(SEARCH("${i[0]}",${o}))`];case"BeginsWith":return[`LEFT(${o},LEN("${i[0]}"))="${i[0]}"`];case"EndsWith":return[`RIGHT(${o},LEN("${i[0]}"))="${i[0]}"`];case"IsEmpty":return[`LEN(TRIM(${o}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${o}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[i[0]];case"Between":case"NotBetween":return[i[0],i[1]]}}(e.ranges,t).map((e=>ef`<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}=Sm(r,o);return i.push(["dxfId",a]),ef`
|
|
2148
2148
|
<conditionalFormatting sqref="${e.ranges.join(" ")}">
|
|
2149
|
-
<cfRule ${
|
|
2150
|
-
${
|
|
2149
|
+
<cfRule ${Ym(i)}>
|
|
2150
|
+
${Jm(s)}
|
|
2151
2151
|
</cfRule>
|
|
2152
2152
|
</conditionalFormatting>
|
|
2153
|
-
`}function
|
|
2153
|
+
`}function LS(e,t){const o=VS(e);o.push(["type","colorScale"]);const i=[];for(const n of e.ranges){const e=[],s=[];let r=!0;for(let o of["minimum","midpoint","maximum"]){const i=t[o];i&&("formula"!==i.type?(e.push(BS(i,o)),s.push([["rgb",os(vt(i.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=>ef`<cfvo ${Ym(e)}/>`)),l=s.map((e=>ef`<color ${Ym(e)}/>`));i.push(ef`
|
|
2154
2154
|
<conditionalFormatting sqref="${n}">
|
|
2155
|
-
<cfRule ${
|
|
2155
|
+
<cfRule ${Ym(o)}>
|
|
2156
2156
|
<colorScale>
|
|
2157
|
-
${
|
|
2158
|
-
${
|
|
2157
|
+
${Jm(a)}
|
|
2158
|
+
${Jm(l)}
|
|
2159
2159
|
</colorScale>
|
|
2160
2160
|
</cfRule>
|
|
2161
2161
|
</conditionalFormatting>
|
|
2162
|
-
`)}return
|
|
2162
|
+
`)}return Jm(i)}function US(e,t){const o=VS(e);o.push(["type","iconSet"]);const i=[];for(const n of e.ranges){const e=[[["type","percent"],["val",0]]];let s=!0;for(let o of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[o].type){s=!1;continue}const i=t[o];e.push([...BS(i,o),["gte","ge"===i.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=>ef`<cfvo ${Ym(e)} />`));i.push(ef`
|
|
2163
2163
|
<conditionalFormatting sqref="${n}">
|
|
2164
|
-
<cfRule ${
|
|
2165
|
-
<iconSet iconSet="${
|
|
2166
|
-
${
|
|
2164
|
+
<cfRule ${Ym(o)}>
|
|
2165
|
+
<iconSet iconSet="${zS(t.icons)}">
|
|
2166
|
+
${Jm(r)}
|
|
2167
2167
|
</iconSet>
|
|
2168
2168
|
</cfRule>
|
|
2169
2169
|
</conditionalFormatting>
|
|
2170
|
-
`)}return
|
|
2171
|
-
<xdr:wsDr ${
|
|
2172
|
-
${
|
|
2170
|
+
`)}return Jm(i)}function VS(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function zS(e){return gp[Object.keys(gp).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function BS(e,t){const o=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),i=[["type",o]];if("min"!==o&&"max"!==o){let t=e.value;if("formula"===o)try{t=FS(e.value)}catch(o){t=e.value}i.push(["val",t])}return i}function HS(e,t,o){const i=[["xmlns:xdr",pp.drawing],["xmlns:r",Sp],["xmlns:a",mp],["xmlns:c",fp]],n=[];for(const[i,s]of Object.entries(o))switch(null==s?void 0:s.tag){case"chart":n.push(GS(s,t,e[i]));break;case"image":n.push(qS(s,t,e[i]))}return Km(ef`
|
|
2171
|
+
<xdr:wsDr ${Ym(i)}>
|
|
2172
|
+
${Jm(n)}
|
|
2173
2173
|
</xdr:wsDr>
|
|
2174
|
-
`)}function
|
|
2174
|
+
`)}function $S(e,t){const{x:o,y:i,height:n,width:s}=e,r=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=WS(r,o),{index:h,offset:d}=WS(r,o+s),{index:u,offset:g}=WS(a,i),{index:p,offset:m}=WS(a,i+n);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function WS(e,t){let o=0;for(const[i,n]of Object.entries(e)){if(o<=t&&t<o+n.size)return{index:parseInt(i),offset:xm(t-o+$)};o+=n.size}return{index:e.length-1,offset:xm(t-o+$)}}function GS(e,t,o){const{from:i,to:n}=$S(e,t),s=Em(e.id),r=[["id",s],["name",`Chart ${s}`],["title","Chart"]];return ef`
|
|
2175
2175
|
<xdr:twoCellAnchor>
|
|
2176
2176
|
<xdr:from>
|
|
2177
2177
|
<xdr:col>${i.col}</xdr:col>
|
|
@@ -2187,7 +2187,7 @@
|
|
|
2187
2187
|
</xdr:to>
|
|
2188
2188
|
<xdr:graphicFrame>
|
|
2189
2189
|
<xdr:nvGraphicFramePr>
|
|
2190
|
-
<xdr:cNvPr ${
|
|
2190
|
+
<xdr:cNvPr ${Ym(r)} />
|
|
2191
2191
|
<xdr:cNvGraphicFramePr />
|
|
2192
2192
|
</xdr:nvGraphicFramePr>
|
|
2193
2193
|
<xdr:xfrm>
|
|
@@ -2195,14 +2195,14 @@
|
|
|
2195
2195
|
<a:ext cx="0" cy="0"/>
|
|
2196
2196
|
</xdr:xfrm>
|
|
2197
2197
|
<a:graphic>
|
|
2198
|
-
<a:graphicData uri="${
|
|
2198
|
+
<a:graphicData uri="${fp}">
|
|
2199
2199
|
<c:chart r:id="${o}" />
|
|
2200
2200
|
</a:graphicData>
|
|
2201
2201
|
</a:graphic>
|
|
2202
2202
|
</xdr:graphicFrame>
|
|
2203
2203
|
<xdr:clientData fLocksWithSheet="0"/>
|
|
2204
2204
|
</xdr:twoCellAnchor>
|
|
2205
|
-
`}function
|
|
2205
|
+
`}function qS(e,t,o){const{from:i,to:n}=$S(e,t),s=ym(e.id),r=[["id",s],["name",`Image ${s}`],["title","Image"]];return ef`
|
|
2206
2206
|
<xdr:twoCellAnchor editAs="oneCell">
|
|
2207
2207
|
<xdr:from>
|
|
2208
2208
|
<xdr:col>${i.col}</xdr:col>
|
|
@@ -2218,7 +2218,7 @@
|
|
|
2218
2218
|
</xdr:to>
|
|
2219
2219
|
<xdr:pic>
|
|
2220
2220
|
<xdr:nvPicPr>
|
|
2221
|
-
<xdr:cNvPr ${
|
|
2221
|
+
<xdr:cNvPr ${Ym(r)}/>
|
|
2222
2222
|
<xdr:cNvPicPr preferRelativeResize="0"/>
|
|
2223
2223
|
</xdr:nvPicPr>
|
|
2224
2224
|
<xdr:blipFill>
|
|
@@ -2236,69 +2236,69 @@
|
|
|
2236
2236
|
</xdr:pic>
|
|
2237
2237
|
<xdr:clientData fLocksWithSheet="0"/>
|
|
2238
2238
|
</xdr:twoCellAnchor>
|
|
2239
|
-
`}function
|
|
2239
|
+
`}function ZS(e){return tt(e)?ef``:ef`
|
|
2240
2240
|
<font>
|
|
2241
|
-
${e.bold?
|
|
2242
|
-
${e.italic?
|
|
2243
|
-
${e.underline?
|
|
2244
|
-
${e.strike?
|
|
2245
|
-
${e.size?
|
|
2246
|
-
${e.color&&e.color.rgb?
|
|
2247
|
-
${e.name?
|
|
2241
|
+
${e.bold?ef`<b />`:""}
|
|
2242
|
+
${e.italic?ef`<i />`:""}
|
|
2243
|
+
${e.underline?ef`<u />`:""}
|
|
2244
|
+
${e.strike?ef`<strike />`:""}
|
|
2245
|
+
${e.size?ef`<sz val="${e.size}" />`:""}
|
|
2246
|
+
${e.color&&e.color.rgb?ef`<color rgb="${os(e.color.rgb)}" />`:""}
|
|
2247
|
+
${e.name?ef`<name val="${e.name}" />`:""}
|
|
2248
2248
|
</font>
|
|
2249
|
-
`}function
|
|
2250
|
-
<table ${
|
|
2251
|
-
${function(e){const t=[["ref",e.range]];return
|
|
2252
|
-
<autoFilter ${
|
|
2253
|
-
${
|
|
2254
|
-
<filterColumn ${
|
|
2255
|
-
${
|
|
2249
|
+
`}function jS(e){return e?Ym([["style",e.style],["color",os(e.color.rgb)]]):ef``}const XS=ef`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function YS(e,t,o){const i=ef`
|
|
2250
|
+
<table ${Ym([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",pp.table],["xmlns:xr",pp.revision],["xmlns:xr3",pp.revision3],["xmlns:mc",pp.markupCompatibility]])}>
|
|
2251
|
+
${function(e){const t=[["ref",e.range]];return ef`
|
|
2252
|
+
<autoFilter ${Ym(t)}>
|
|
2253
|
+
${Jm(function(e){const t=Po(e.range),o=[];for(const i of ze(0,Ko(t).numberOfCols)){const t=e.filters[i];if(!t||!t.filteredValues.length)continue;const n=ef`
|
|
2254
|
+
<filterColumn ${Ym([["colId",i]])}>
|
|
2255
|
+
${KS(t)}
|
|
2256
2256
|
</filterColumn>
|
|
2257
2257
|
`;o.push(n)}return o}(e))}
|
|
2258
2258
|
</autoFilter>
|
|
2259
2259
|
`}(e)}
|
|
2260
|
-
${function(e,t){var o;const i=
|
|
2261
|
-
<tableColumns ${
|
|
2262
|
-
${
|
|
2260
|
+
${function(e,t){var o;const i=Po(e.range),n=[];for(const e of ze(0,Ko(i).numberOfCols)){const s=Bt(i.left+e,i.top),r=[["id",e+1],["name",(null===(o=t.cells[s])||void 0===o?void 0:o.content)||`col${e}`]];n.push(ef`<tableColumn ${Ym(r)}/>`)}return ef`
|
|
2261
|
+
<tableColumns ${Ym([["count",n.length]])}>
|
|
2262
|
+
${Jm(n)}
|
|
2263
2263
|
</tableColumns>
|
|
2264
2264
|
`}(e,o)}
|
|
2265
|
-
${
|
|
2265
|
+
${XS}
|
|
2266
2266
|
</table>
|
|
2267
|
-
`;return
|
|
2267
|
+
`;return Km(i)}function KS(e){return ef`
|
|
2268
2268
|
<filters>
|
|
2269
|
-
${
|
|
2269
|
+
${Jm(e.filteredValues.map((e=>ef`<filter ${Ym([["val",e]])}/>`)))}
|
|
2270
2270
|
</filters>
|
|
2271
|
-
`}function
|
|
2272
|
-
<col ${
|
|
2273
|
-
`)}return
|
|
2271
|
+
`}function QS(e){if(!Object.values(e).length)return ef``;const t=[];for(let[o,i]of Object.entries(e)){const e=[["min",parseInt(o)+1],["max",parseInt(o)+1],["width",pm(i.size||_)],["customWidth",1],["hidden",i.isHidden?1:0]];t.push(ef`
|
|
2272
|
+
<col ${Ym(e)}/>
|
|
2273
|
+
`)}return ef`
|
|
2274
2274
|
<cols>
|
|
2275
|
-
${
|
|
2275
|
+
${Jm(t)}
|
|
2276
2276
|
</cols>
|
|
2277
|
-
`}function
|
|
2278
|
-
<c ${
|
|
2277
|
+
`}function JS(e,t,o){const i=[];for(let n=0;n<o.rowNumber;n++){const s=[["r",n+1]],r=o.rows[n]||{};s.push(["ht",gm(r.size||F)],["customHeight",1],["hidden",r.isHidden?1:0]);const a=[];for(let i=0;i<o.colNumber;i++){const s=Bt(i,n),r=o.cells[s];if(r){const l=[["r",s]],c=vm(e,fm(r,t));l.push(["s",c]);let h=[],d=ef``;if(r.isFormula)({attrs:h,node:d}=NS(r));else if(r.content&&qe(r.content)){const{label:t}=Xe(r.content);({attrs:h,node:d}=_S(t,e.sharedStrings))}else if(r.content&&""!==r.content){const t=eC(i,n,o);({attrs:h,node:d}=_S(r.content,e.sharedStrings,t))}l.push(...h),a.push(ef`
|
|
2278
|
+
<c ${Ym(l)}>
|
|
2279
2279
|
${d}
|
|
2280
2280
|
</c>
|
|
2281
|
-
`)}}(a.length||r.size!==F||r.isHidden)&&i.push(
|
|
2282
|
-
<row ${
|
|
2283
|
-
${
|
|
2281
|
+
`)}}(a.length||r.size!==F||r.isHidden)&&i.push(ef`
|
|
2282
|
+
<row ${Ym(s)}>
|
|
2283
|
+
${Jm(a)}
|
|
2284
2284
|
</row>
|
|
2285
|
-
`)}return
|
|
2285
|
+
`)}return ef`
|
|
2286
2286
|
<sheetData>
|
|
2287
|
-
${
|
|
2287
|
+
${Jm(i)}
|
|
2288
2288
|
</sheetData>
|
|
2289
|
-
`}function
|
|
2289
|
+
`}function eC(e,t,o){return o.filterTables.some((o=>{const i=Po(o.range),n={...i,bottom:i.top};return Zo(e,t,n)}))}function tC(e,t,o){var i;const n=t.sheets[o].cells,s=[];for(const r in n){const a=null===(i=n[r])||void 0===i?void 0:i.content;if(a&&qe(a)){const{label:i,url:n}=Xe(a);if(Ke(n)){const e=Je(n),o=t.sheets.find((t=>t.id===e)),a=o?`${o.name}!A1`:Y;s.push(ef`
|
|
2290
2290
|
<hyperlink display="${i}" location="${a}" ref="${r}"/>
|
|
2291
|
-
`)}else{const t=
|
|
2291
|
+
`)}else{const t=bm(e.relsFiles,`xl/worksheets/_rels/sheet${o}.xml.rels`,{target:Ci(n),type:bp.hyperlink,targetMode:"External"});s.push(ef`
|
|
2292
2292
|
<hyperlink r:id="${t}" ref="${r}"/>
|
|
2293
|
-
`)}}}return s.length?
|
|
2293
|
+
`)}}}return s.length?ef`
|
|
2294
2294
|
<hyperlinks>
|
|
2295
|
-
${
|
|
2295
|
+
${Jm(s)}
|
|
2296
2296
|
</hyperlinks>
|
|
2297
|
-
`:
|
|
2297
|
+
`:ef``}function oC(e){if(e.length){const t=e.map((e=>ef`<mergeCell ref="${e}" />`));return ef`
|
|
2298
2298
|
<mergeCells count="${e.length}">
|
|
2299
|
-
${
|
|
2299
|
+
${Jm(t)}
|
|
2300
2300
|
</mergeCells>
|
|
2301
|
-
`}return
|
|
2301
|
+
`}return ef``}function iC(e){const t=e.panes;let o=ef``;if(t&&(t.xSplit||t.ySplit)){const e=Bt(t.xSplit,t.ySplit),i=t.xSplit?ef`xSplit="${t.xSplit}"`:"",n=t.ySplit?ef`ySplit="${t.ySplit}"`:"",s=t.xSplit?ef`<selection pane="topRight"/>`:"",r=t.ySplit?ef`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?ef`<selection pane="bottomRight"/>`:"";o=ef`
|
|
2302
2302
|
<pane
|
|
2303
2303
|
${i}
|
|
2304
2304
|
${n}
|
|
@@ -2308,123 +2308,123 @@
|
|
|
2308
2308
|
${s}
|
|
2309
2309
|
${r}
|
|
2310
2310
|
${a}
|
|
2311
|
-
`}return
|
|
2311
|
+
`}return ef`
|
|
2312
2312
|
<sheetViews>
|
|
2313
2313
|
<sheetView showGridLines="${e.areGridLinesVisible?1:0}" workbookViewId="0">
|
|
2314
2314
|
${o}
|
|
2315
2315
|
</sheetView>
|
|
2316
2316
|
</sheetViews>
|
|
2317
|
-
`}function
|
|
2318
|
-
<sheet ${
|
|
2319
|
-
`),
|
|
2320
|
-
<workbook ${
|
|
2317
|
+
`}function nC(e){const t=[],o={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:G,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const o=[["xmlns",pp.workbook],["xmlns:r",Sp]],i=[];for(const[o,n]of Object.entries(e.sheets)){const e=[["state",n.isVisible?"visible":"hidden"],["name",n.name],["sheetId",parseInt(o)+1],["r:id",`rId${parseInt(o)+1}`]];i.push(ef`
|
|
2318
|
+
<sheet ${Ym(e)} />
|
|
2319
|
+
`),bm(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:bp.sheet,target:`worksheets/sheet${o}.xml`})}return jm(Km(ef`
|
|
2320
|
+
<workbook ${Ym(o)}>
|
|
2321
2321
|
<sheets>
|
|
2322
|
-
${
|
|
2322
|
+
${Jm(i)}
|
|
2323
2323
|
</sheets>
|
|
2324
2324
|
</workbook>
|
|
2325
|
-
`),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let i=1;for(const[n,s]of Object.entries(e.sheets)){const r=[["xmlns",
|
|
2326
|
-
<worksheet ${
|
|
2327
|
-
${
|
|
2328
|
-
<sheetFormatPr ${
|
|
2329
|
-
${
|
|
2330
|
-
${
|
|
2331
|
-
${
|
|
2332
|
-
${
|
|
2333
|
-
${
|
|
2325
|
+
`),"xl/workbook.xml","workbook")}(e,o)),t.push(...function(e,t){const o=[];let i=1;for(const[n,s]of Object.entries(e.sheets)){const r=[["xmlns",pp.worksheet],["xmlns:r",Sp]],a=[["defaultRowHeight",gm(F)],["defaultColWidth",pm(_)]],l=sC(s,n,i,t,o);i+=s.filterTables.length;let c=ef``;const h=[],d=s.charts;for(const i of d){const s=Em(i.id),r=bm(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../charts/chart${s}.xml`,type:bp.chart});h.push(r),o.push(jm(wS(i,n,e),`xl/charts/chart${s}.xml`,"chart"))}const u=s.images;for(const e of u){const i=ym(e.id),s=bm(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../media/image${i}`,type:bp.image});h.push(s),o.push({path:`xl/media/image${i}`,imagePath:e.data.path})}const g=[...d,...u];if(g.length){const e=bm(t.relsFiles,`xl/worksheets/_rels/sheet${n}.xml.rels`,{target:`../drawings/drawing${n}.xml`,type:bp.drawing});o.push(jm(HS(h,s,g),`xl/drawings/drawing${n}.xml`,"drawing")),c=ef`<drawing r:id="${e}" />`}const p=ef`
|
|
2326
|
+
<worksheet ${Ym(r)}>
|
|
2327
|
+
${iC(s)}
|
|
2328
|
+
<sheetFormatPr ${Ym(a)} />
|
|
2329
|
+
${QS(s.cols)}
|
|
2330
|
+
${JS(t,e,s)}
|
|
2331
|
+
${oC(s.merges)}
|
|
2332
|
+
${Jm(kS(t.dxfs,s.conditionalFormats))}
|
|
2333
|
+
${tC(t,e,n)}
|
|
2334
2334
|
${c}
|
|
2335
2335
|
${l}
|
|
2336
2336
|
</worksheet>
|
|
2337
|
-
`;o.push(
|
|
2338
|
-
<styleSheet ${
|
|
2339
|
-
${function(e){const t=[];for(let[o,i]of Object.entries(e)){const e=[["numFmtId",parseInt(o)+
|
|
2340
|
-
<numFmt ${
|
|
2341
|
-
`)}return
|
|
2337
|
+
`;o.push(jm(Km(p),`xl/worksheets/sheet${n}.xml`,"sheet"))}return bm(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:bp.sharedStrings,target:"sharedStrings.xml"}),bm(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:bp.styles,target:"styles.xml"}),o}(e,o)),t.push(function(e){const t=ef`
|
|
2338
|
+
<styleSheet ${Ym([["xmlns",pp.styleSheet],["xmlns:r",Sp]])}>
|
|
2339
|
+
${function(e){const t=[];for(let[o,i]of Object.entries(e)){const e=[["numFmtId",parseInt(o)+Rp],["formatCode",i.format]];t.push(ef`
|
|
2340
|
+
<numFmt ${Ym(e)}/>
|
|
2341
|
+
`)}return ef`
|
|
2342
2342
|
<numFmts count="${e.length}">
|
|
2343
|
-
${
|
|
2343
|
+
${Jm(t)}
|
|
2344
2344
|
</numFmts>
|
|
2345
2345
|
`}(e.numFmts)}
|
|
2346
|
-
${o=e.fonts,
|
|
2346
|
+
${o=e.fonts,ef`
|
|
2347
2347
|
<fonts count="${o.length}">
|
|
2348
|
-
${
|
|
2348
|
+
${Jm(Object.values(o).map(ZS))}
|
|
2349
2349
|
</fonts>
|
|
2350
2350
|
`}
|
|
2351
|
-
${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(
|
|
2351
|
+
${function(e){const t=[];for(let o of Object.values(e))void 0!==o.reservedAttribute?t.push(ef`
|
|
2352
2352
|
<fill>
|
|
2353
2353
|
<patternFill patternType="${o.reservedAttribute}" />
|
|
2354
2354
|
</fill>
|
|
2355
|
-
`):t.push(
|
|
2355
|
+
`):t.push(ef`
|
|
2356
2356
|
<fill>
|
|
2357
2357
|
<patternFill patternType="solid">
|
|
2358
|
-
<fgColor rgb="${
|
|
2358
|
+
<fgColor rgb="${os(o.fgColor.rgb)}" />
|
|
2359
2359
|
<bgColor indexed="64" />
|
|
2360
2360
|
</patternFill>
|
|
2361
2361
|
</fill>
|
|
2362
|
-
`);return
|
|
2362
|
+
`);return ef`
|
|
2363
2363
|
<fills count="${e.length}">
|
|
2364
|
-
${
|
|
2364
|
+
${Jm(t)}
|
|
2365
2365
|
</fills>
|
|
2366
2366
|
`}(e.fills)}
|
|
2367
|
-
${function(e){const t=[];for(let o of Object.values(e))t.push(
|
|
2367
|
+
${function(e){const t=[];for(let o of Object.values(e))t.push(ef`
|
|
2368
2368
|
<border>
|
|
2369
|
-
<left ${
|
|
2370
|
-
<right ${
|
|
2371
|
-
<top ${
|
|
2372
|
-
<bottom ${
|
|
2373
|
-
<diagonal ${
|
|
2369
|
+
<left ${jS(o.left)} />
|
|
2370
|
+
<right ${jS(o.right)} />
|
|
2371
|
+
<top ${jS(o.top)} />
|
|
2372
|
+
<bottom ${jS(o.bottom)} />
|
|
2373
|
+
<diagonal ${jS(o.diagonal)} />
|
|
2374
2374
|
</border>
|
|
2375
|
-
`);return
|
|
2375
|
+
`);return ef`
|
|
2376
2376
|
<borders count="${e.length}">
|
|
2377
|
-
${
|
|
2377
|
+
${Jm(t)}
|
|
2378
2378
|
</borders>
|
|
2379
2379
|
`}(e.borders)}
|
|
2380
|
-
${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],i=[];o.alignment&&o.alignment.vertical&&i.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&i.push(["horizontal",o.alignment.horizontal]),t.push(
|
|
2381
|
-
<xf ${
|
|
2382
|
-
${i?
|
|
2380
|
+
${function(e){const t=[];for(let o of e){const e=[["numFmtId",o.numFmtId],["fillId",o.fillId],["fontId",o.fontId],["borderId",o.borderId]],i=[];o.alignment&&o.alignment.vertical&&i.push(["vertical",o.alignment.vertical]),o.alignment&&o.alignment.horizontal&&i.push(["horizontal",o.alignment.horizontal]),t.push(ef`
|
|
2381
|
+
<xf ${Ym(e)}>
|
|
2382
|
+
${i?ef`<alignment ${Ym(i)} />`:""}
|
|
2383
2383
|
</xf>
|
|
2384
|
-
`)}return
|
|
2384
|
+
`)}return ef`
|
|
2385
2385
|
<cellXfs count="${e.length}">
|
|
2386
|
-
${
|
|
2386
|
+
${Jm(t)}
|
|
2387
2387
|
</cellXfs>
|
|
2388
2388
|
`}(e.styles)}
|
|
2389
|
-
${function(e){const t=[];for(const o of e){let e=
|
|
2389
|
+
${function(e){const t=[];for(const o of e){let e=ef``;o.font&&(e=ZS(o.font));let i=ef``;o.fill&&(i=ef`
|
|
2390
2390
|
<fill>
|
|
2391
2391
|
<patternFill>
|
|
2392
|
-
<bgColor rgb="${
|
|
2392
|
+
<bgColor rgb="${os(o.fill.fgColor.rgb)}" />
|
|
2393
2393
|
</patternFill>
|
|
2394
2394
|
</fill>
|
|
2395
|
-
`),t.push(
|
|
2395
|
+
`),t.push(ef`
|
|
2396
2396
|
<dxf>
|
|
2397
2397
|
${e}
|
|
2398
2398
|
${i}
|
|
2399
2399
|
</dxf>
|
|
2400
|
-
`)}return
|
|
2400
|
+
`)}return ef`
|
|
2401
2401
|
<dxfs count="${e.length}">
|
|
2402
|
-
${
|
|
2402
|
+
${Jm(t)}
|
|
2403
2403
|
</dxfs>
|
|
2404
2404
|
`}(e.dxfs)}
|
|
2405
2405
|
</styleSheet>
|
|
2406
|
-
`;var o;return
|
|
2407
|
-
<sst ${
|
|
2408
|
-
${
|
|
2406
|
+
`;var o;return jm(Km(t),"xl/styles.xml","styles")}(o)),t.push(function(e){const t=[["xmlns",pp.sst],["count",e.length],["uniqueCount",e.length]],o=e.map((e=>ef`<si><t>${e}</t></si>`));return jm(Km(ef`
|
|
2407
|
+
<sst ${Ym(t)}>
|
|
2408
|
+
${Jm(o)}
|
|
2409
2409
|
</sst>
|
|
2410
|
-
`),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(
|
|
2411
|
-
<Relationship ${
|
|
2412
|
-
`)}const i=
|
|
2413
|
-
<Relationships xmlns="${
|
|
2414
|
-
${
|
|
2410
|
+
`),"xl/sharedStrings.xml","sharedStrings")}(o.sharedStrings)),t.push(...function(e){const t=[];for(const o of e){const e=[];for(const t of o.rels){const o=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&o.push(["TargetMode",t.targetMode]),e.push(ef`
|
|
2411
|
+
<Relationship ${Ym(o)} />
|
|
2412
|
+
`)}const i=ef`
|
|
2413
|
+
<Relationships xmlns="${pp.Relationships}">
|
|
2414
|
+
${Jm(e)}
|
|
2415
2415
|
</Relationships>
|
|
2416
|
-
`;t.push(
|
|
2417
|
-
<Types xmlns="${
|
|
2416
|
+
`;t.push(jm(Km(i),o.path))}return t}(o.relsFiles)),t.push(function(e){const t=[];for(const o of e)"contentType"in o&&o.contentType&&t.push(Qm("/"+o.path,vp[o.contentType]));return jm(Km(ef`
|
|
2417
|
+
<Types xmlns="${pp.Types}">
|
|
2418
2418
|
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
|
|
2419
2419
|
<Default Extension="xml" ContentType="application/xml" />
|
|
2420
|
-
${
|
|
2420
|
+
${Jm(t)}
|
|
2421
2421
|
</Types>
|
|
2422
|
-
`),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",
|
|
2423
|
-
<Relationships xmlns="${
|
|
2424
|
-
<Relationship ${
|
|
2422
|
+
`),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",bp.document],["Target","xl/workbook.xml"]];return jm(Km(ef`
|
|
2423
|
+
<Relationships xmlns="${pp.Relationships}">
|
|
2424
|
+
<Relationship ${Ym(e)} />
|
|
2425
2425
|
</Relationships>
|
|
2426
|
-
`),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function
|
|
2426
|
+
`),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function sC(e,t,o,i,n){let s=o;if(!e.filterTables.length)return new hp("");const r=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const o=bm(i.relsFiles,r,{target:`../tables/table${s}.xml`,type:bp.table});n.push(jm(YS(t,s,e),`xl/tables/table${s}.xml`,"table")),a.push(ef`<tablePart r:id="${o}" />`),s++}return ef`
|
|
2427
2427
|
<tableParts count="${e.filterTables.length}">
|
|
2428
|
-
${
|
|
2428
|
+
${Jm(a)}
|
|
2429
2429
|
</tableParts>
|
|
2430
|
-
`}var
|
|
2430
|
+
`}var rC;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(rC||(rC={}));const aC={},lC={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:O,HEADER_WIDTH:N,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:_,DEFAULT_CELL_HEIGHT:F,SCROLLBAR_WIDTH:D},cC={autofillModifiersRegistry:Cn,autofillRulesRegistry:En,cellMenuRegistry:ta,colMenuRegistry:oa,linkMenuRegistry:Qn,functionRegistry:$u,featurePluginRegistry:kb,statefulUIPluginRegistry:Pb,coreViewsPluginRegistry:Lb,corePluginRegistry:Db,rowMenuRegistry:ia,sidePanelRegistry:wg,figureRegistry:cr,chartSidePanelComponentRegistry:gg,chartComponentRegistry:nr,chartRegistry:ir,topbarMenuRegistry:Gu,topbarComponentRegistry:yg,clickableCellRegistry:Ub,otRegistry:Zu,inverseCommandRegistry:gr,urlRegistry:Ei,cellPopoverRegistry:ts},hC={arg:ra,toBoolean:Pi,toJsDate:Li,toNumber:Ni,toString:Fi,toXC:Bt,toZone:Po,toCartesian:zt,numberToLetters:Ut,UuidGenerator:Do,formatValue:ho,computeTextWidth:Pe,createEmptyWorkbookData:Zf,createEmptySheet:qf,createEmptyExcelSheet:jf,getDefaultChartJsRuntime:Ns,chartFontColor:ms,ChartColors:ps,EvaluationError:c,CellErrorLevel:l,getFillingMode:ks,rgbaToHex:yt,colorToRGBA:xt,positionToZone:ii,isDefined:et,lazy:nt},dC={isMarkdownLink:qe,parseMarkdownLink:Xe,markdownLink:je,openLink:Ri,urlRepresentation:Ii},uC={ChartPanel:pg,ChartFigure:rr,ChartJsComponent:ai,Grid:cp,GridOverlay:Zg,ScorecardChart:fi,LineConfigPanel:cg,LineBarPieDesignPanel:sg,BarConfigPanel:Ju,LineBarPieConfigPanel:Qu,GaugeChartConfigPanel:ag,GaugeChartDesignPanel:lg,ScorecardChartConfigPanel:dg,ScorecardChartDesignPanel:ug,FigureComponent:xg};e.AbstractChart=is,e.CorePlugin=Yf,e.DATETIME_FORMAT=X,e.DispatchResult=ln,e.EvaluationError=c,e.Model=class extends sb{constructor(e={},o={},i=[],n=new Do,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 o={...t,type:e};let i=this.status;if(this.getters.isReadonly()&&(n=o,!sn.has(n.type)))return new ln(67);var n;if(!this.session.canApplyOptimisticUpdate())return new ln(64);switch(i){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return t;this.status=1;const{changes:i,commands:n}=this.state.recordChanges((()=>{an(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize()}));this.session.save(n,i),this.status=0,this.trigger("update");break;case 1:if(an(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(an(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return ln.Success},this.dispatchFromCorePlugin=(e,t)=>{const o={...t,type:e},i=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,o),this.status=i,ln.Success},i=Wf(e,i);const r=Hf(e,s);this.state=new SS,this.uuidGenerator=n,this.config=this.setupConfig(o),this.session=this.setupSession(r.revisionId),this.history=new fS(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Lv(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 bS(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Db.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of Pb.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t)}for(let e of Lb.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.coreHandlers.push(t)}for(let e of kb.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(i),this.joinSession(),o.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 o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}const o=e.layers.map((e=>[t,e]));return this.renderers.push(...o),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new pb(pS(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()},o=e.transportService||new sS;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:o,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 ln(t.flat())}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=Ne(t);for(const o of e)o.beforeHandle(t);for(const o of e)o.handle(t)}drawGrid(e){for(let[t,o]of this.renderers)e.ctx.save(),t.drawGrid(e,o),e.ctx.restore()}exportData(){let e=Zf();for(let t of this.handlers)t instanceof Yf&&t.export(e);return e.revisionId=this.session.getRevisionId()||K,e=Ne(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={...Zf(),sheets:[jf(Bf,"Sheet1")]};for(let t of this.handlers)t instanceof Xf&&t.exportForExcel(e);return e=Ne(e),nC(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Si,e.Revision=ub,e.SPREADSHEET_DIMENSIONS=lC,e.Spreadsheet=nS,e.UIPlugin=Vv,e.__info__=aC,e.addFunction=function(e,t){$u.add(e,t)},e.astToFormula=pv,e.compile=Ev,e.components=uC,e.convertAstNodes=gv,e.coreTypes=rn,e.findCellInNewZone=ti,e.functionCache=Cv,e.helpers=hC,e.invalidateEvaluationCommands=on,e.links=dC,e.load=Hf,e.parse=dv,e.readonlyAllowedCommands=sn,e.registries=cC,e.setTranslationMethod=function(e){o=e},e.tokenize=Ef,Object.defineProperty(e,"__esModule",{value:!0}),aC.version="16.2.4",aC.date="2023-04-21T07:30:02.765Z",aC.hash="7169d69"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|