UNPKG

@odoo/o-spreadsheet

Version:
1 lines 1.3 MB
!function(e,t){"use strict";function o(e){return e.map(i).sort(((e,t)=>e.sequence-t.sequence))}let s=1;function i(e){const t=e.name,o=e.children,n=e.description,r=e.icon,a=e.secondaryIcon;return{id:(e.id||s++).toString(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,isActive:e.isActive,execute:e.execute,children:o?e=>o.map((t=>"function"==typeof t?t(e):t)).flat().map(i):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:"function"==typeof r?r:()=>r||"",iconColor:e.iconColor,secondaryIcon:"function"==typeof a?a:()=>a||"",description:"function"==typeof n?n:()=>n||"",textColor:e.textColor,sequence:e.sequence||0,onStartHover:e.onStartHover,onStopHover:e.onStopHover}}class n{content={};add(e,t){return this.content[e]=t,this}get(e){const t=this.content[e];if(!t&&!(e in this.content))throw new Error(`Cannot find ${e} in this registry!`);return t}contains(e){return e in this.content}getAll(){return Object.values(this.content)}getKeys(){return Object.keys(this.content)}remove(e){delete this.content[e]}}const r=.5,a="#37A850",l="#f5f5f5",c="#F8F9FA",h="#E8EAED",d="#595959",u="#666666",g="#c9ccd2",p="#3266ca",m="#FFFFFF",f="#CACACA",v=11982760,b="#017E84",S="#188038",y="#E0E2E4",C="#4A4F59",w="#999",x="#E2E3E3",E="#BCBCBC",I="#9B359B",R="#4EA7F2",T="#EA6175",A="#AAAAAA",_="#111827",D="#D8DADD",O="#E7E9ED",F="#F9FAFB",M="#374151",P=M+"C2",N="#111827",k="#714B67",L=O,V=D,U="#111827",H="#e6f2f3",B="#111827",z="#017E84",$="#D44C591A",W="#C34A41",G="#98DBE2",q="#E6F2F3",Z=20,j=10,Y=15,X=16,K=12,J="#F28C28",Q=["#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"],ee=26,te=48,oe=96,se=23,ie=15,ne=4,re=3,ae=ne,le=21,ce=17,he=2*se,de=250,ue={align:"left",verticalAlign:"bottom",wrapping:"overflow",bold:!1,italic:!1,strikethrough:!1,underline:!1,fontSize:10,fillColor:"",textColor:""},ge=ue.verticalAlign,pe=ue.wrapping,me="400",fe=ue.fontSize,ve="'Roboto', arial",be="thin",Se="#000000",ye="START_REVISION",Ce=1,we=20,xe="??",Ee="difference",Ie="#43C5B1",Re="#EA6175",Te=.4,Ae=2,_e=["'","*","?","/","\\","[","]"],De=/'|\*|\?|\/|\\|\[|\]/,Oe="|";var Fe;!function(e){e[e.Grid=0]="Grid",e[e.Highlight=5]="Highlight",e[e.HeaderGroupingButton=6]="HeaderGroupingButton",e[e.Figure=10]="Figure",e[e.ScrollBar=15]="ScrollBar",e[e.GridPopover=19]="GridPopover",e[e.GridComposer=20]="GridComposer",e[e.Dropdown=21]="Dropdown",e[e.IconPicker=25]="IconPicker",e[e.TopBarComposer=30]="TopBarComposer",e[e.Popover=35]="Popover",e[e.FigureAnchor=1e3]="FigureAnchor",e[e.FigureSnapLine=1001]="FigureSnapLine",e[e.FigureTooltip=1002]="FigureTooltip"}(Fe||(Fe={}));let Me=0;function Pe(){return Me}const Ne="\n",ke=[6,7,8,9,10,11,12,14,18,24,36],Le={hasFilters:!1,totalRow:!1,firstColumn:!0,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,styleId:"TableStyleMedium5",automaticAutofill:!1},Ve={symbol:"$",position:"before",decimalPlaces:2,code:"",name:"Dollar"},Ue=new RegExp(De,"g");function He(e){return'"'===e[0]&&(e=e.slice(1)),'"'===e[e.length-1]&&"\\"!==e[e.length-2]?e.slice(0,e.length-1):e}function Be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ze(e){switch(typeof e){case"object":{if(null===e)return e;if(function(e){return"clone"in e&&e.clone instanceof Function}(e))return e.clone();if(!(function(e){return"object"==typeof e&&null!==e&&(e?.constructor===Object||void 0===e?.constructor)}(e)||e instanceof Array))throw new Error("Unsupported type: only objects and arrays are supported");const t=Array.isArray(e)?new Array(e.length):{};if(Array.isArray(e))for(let o=0,s=e.length;o<s;o++)o in e&&(t[o]=ze(e[o]));else for(const o in e)t[o]=ze(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 We(e,"'")}function We(e,t='"'){return e.startsWith(t)&&(e=e.slice(1)),e.endsWith(t)&&(e=e.slice(0,-1)),e}function Ge(e){return e.match(/\w/g)?.length!==e.length&&(e=`'${e}'`),e}function qe(e,t=" "){return e.replace(Ue,t)}function Ze(e,t,o){return e<t?t:e>o?o:e}function je(e,t,o=1){if(t<=e&&o>0)return[];if(0===o)throw new Error("range() step must not be zero");const s=Math.ceil(Math.abs((t-e)/o)),i=Array(s);for(let t=0;t<s;t++)i[t]=e+t*o;return i}function Ye(e){return e.reduce(((e,t,o,s)=>{if(1===Math.abs(t-s[o-1])){e[e.length-1].push(t)}else e.push([t]);return e}),[])}function*Xe(e,t){t.next();for(const o of e){const e=t.next();yield{...o,next:e.done?void 0:e.value}}}function Ke(e){const t=e.toUpperCase();return"TRUE"===t||"FALSE"===t}const Je=/^\[(.+)\]\((.+)\)$/,Qe=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/;function et(e){return Je.test(e)}function tt(e){return Qe.test(e)}function ot(e,t){return`[${e}](${t})`}function st(e){const t=e.match(Je)||[],o=t[1],s=t[2];if(!o||!s)throw new Error(`Could not parse markdown link ${e}.`);return{label:o,url:s}}const it="o-spreadsheet://";function nt(e){return e.startsWith(it)}function rt(e){return`${it}${e}`}function at(e){if(e.startsWith(it))return e.slice(it.length);throw new Error(`${e} is not a valid sheet link`)}function lt(e){return void 0!==e}function ct(e){return null!==e}function ht(e){return void 0===e||Object.values(e).every((e=>"object"==typeof e?ht(e):!e))}function dt(e,t,o){let s;const i=function(){const i=this,n=Array.from(arguments);const r=o&&!s;clearTimeout(s),s=setTimeout((function(){s=void 0,o||e.apply(i,n)}),t),r&&e.apply(i,n)};return i.isDebouncePending=()=>void 0!==s,i.stopDebounce=()=>{clearTimeout(s)},i}function ut(e){let t="";for(let o=0,s=e.length;o<s;o++)t+=e[o];return t}function gt(e){let t,o=!1;const s=()=>(o||(t=e instanceof Function?e():e,o=!0),t);return s.map=e=>gt((()=>e(s()))),s}function pt(e,t){let o=e.slice(t).find((e=>e));return o||(o=e.slice(0,t).reverse().find((e=>e))),o||""}function mt(e,t){return"after"===e?t+1:t}function ft(e,t){if(e===t)return!0;if(e&&!t||t&&!e)return!1;if(typeof e!=typeof t)return!1;if("object"!=typeof e)return!1;for(const o in t)if(!(o in e)&&void 0!==t[o])return!1;for(const o in e){if(typeof e[o]!=typeof t[o])return!1;if("object"==typeof e[o]){if(!ft(e[o],t[o]))return!1}else if(e[o]!==t[o])return!1}return!0}function vt(e,t){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!ft(e[o],t[o]))return!1;return!0}function bt(e,t){if(e.length<t.length)return!1;const o=new Set(e);return t.every((e=>o.has(e)))}function St(e){if(!e)return e;const t={...e};return Object.keys(t).forEach((e=>!t[e]&&delete t[e])),t}const yt=["\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))],Ct=new RegExp(yt.join("|"),"g"),wt=/(\r\n|\r)/g;function xt(e){return e?e.replace(wt,Ne):""}function Et(e){const t=Array.from(e).sort(((e,t)=>e-t));for(let e=1;e<t.length;e++)if(t[e]-t[e-1]!=1)return!1;return!0}function It(e){const t=new Map,o=e.name?e.name+" (memoized)":"memoized";return{[o]:(...o)=>(t.has(o[0])||t.set(o[0],e(...o)),t.get(o[0]))}[o]}function Rt(e,t){return e.filter(((e,o)=>!t.includes(o)))}function Tt(e,t,o){const s=[...e];return s.splice(o,0,...t),s}function At(e){return e.split("\n").map((e=>e.replace(/\s+/g," ").trim())).join("\n")}function _t(e,t,o){return t>o?_t(e,o,t):e>=t&&e<=o}function Dt(e,t){let o=Be(e);const s=t.matchCase?"":"i";return t.exactMatch&&(o=`^${o}$`),RegExp(o,s)}function Ot(e){let t=e.length;if(t<1e5)return Math.max(...e);let o=-1/0;for(;t--;)o=e[t]>o?e[t]:o;return o}function Ft(e){let t=e.length;if(t<1e5)return Math.min(...e);let o=1/0;for(;t--;)o=e[t]<o?e[t]:o;return o}class Mt{text;currentIndex=0;current;constructor(e){this.text=e,this.current=e[0]}shift(){const e=this.current,t=this.text[++this.currentIndex];return this.current=t,e}advanceBy(e){this.currentIndex+=e,this.current=this.text[this.currentIndex]}isOver(){return this.currentIndex>=this.text.length}remaining(){return this.text.substring(this.currentIndex)}currentStartsWith(e){if(this.current!==e[0])return!1;for(let t=1;t<e.length;t++)if(this.text[this.currentIndex+t]!==e[t])return!1;return!0}}function Pt(e,t=(e=>e)){const o=new Set;return e.filter((e=>{const s=t(e);return!o.has(s)&&(o.add(s),!0)}))}function Nt(e){const t={};for(const o in e)for(const s in e[o])t[s]||(t[s]={}),t[s][o]=e[o][s];return t}function kt(e,t,o={}){const s=o.compute??((e,t)=>`${e} (${t})`),i=o.computeFirstOne??!1;let n=o.start??1,r=i?s(e,n):e;for(;t.includes(r);)r=s(e,n++);return r}const Lt=/rgba?\(|\s+|\)/gi,Vt=/^#([A-F\d]{2}){3,4}$/,Ut=["#eb6d00","#0074d9","#ad8e00","#169ed4","#b10dc9","#00a82d","#00a3a3","#f012be","#3d9970","#111111","#62A300","#ff4136","#949494","#85144b","#001f3f"];function Ht(e){return zt(e.toString(16).padStart(6,"0"))}function Bt(e){return"number"==typeof e?e:Number.parseInt(zt(e).slice(1),16)}function zt(e){let t=e;if(e.startsWith("rgb")?t=function(e){const t=e.replace(Lt,"").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");if(isNaN(e))throw new Error("invalid alpha value");o=Math.round(255*e)}const s=t.map((e=>parseInt(e,10)));255!==o&&s.push(o);return"#"+ut(s.map((e=>e.toString(16).padStart(2,"0")))).toUpperCase()}(e):(t=e.replace("#","").toUpperCase(),3!==t.length&&4!==t.length||(t=t.split("").reduce(((e,t)=>e+t+t),"")),t=`#${t}`),!Vt.test(t))throw new Error(`invalid color input: ${e}`);return t}function $t(e){try{return zt(e),!0}catch(e){return!1}}const Wt=e=>e>=0&&e<=255;function Gt(e,t,o,s=1){if(!Wt(e)||!Wt(t)||!Wt(o)||s<0||s>1)throw new Error(`Invalid RGBA values ${[e,t,o,s]}`);return{a:s,b:o,g:t,r:e}}function qt(e){let{r:t,g:o,b:s}=jt(e);t/=255,o/=255,s/=255;const i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*i(t)+.7152*i(o)+.0722*i(s)}function Zt(e){let t=e.r.toString(16),o=e.g.toString(16),s=e.b.toString(16),i=Math.round(255*e.a).toString(16);return 1===t.length&&(t="0"+t),1===o.length&&(o="0"+o),1===s.length&&(s="0"+s),1===i.length&&(i="0"+i),"ff"===i&&(i=""),("#"+t+o+s+i).toUpperCase()}function jt(e){let t,o,s,i;if(7===(e=zt(e)).length)t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),i=255;else{if(9!==e.length)throw new Error("Invalid color");t=parseInt(e[1]+e[2],16),o=parseInt(e[3]+e[4],16),s=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16)}return i=+(i/255).toFixed(3),{a:i,r:t,g:o,b:s}}function Yt(e){(e={...e}).s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,o=t*(1-Math.abs(e.h/60%2-1)),s=e.l-t/2,i=0,n=0,r=0;return 0<=e.h&&e.h<60?(i=t,n=o,r=0):60<=e.h&&e.h<120?(i=o,n=t,r=0):120<=e.h&&e.h<180?(i=0,n=t,r=o):180<=e.h&&e.h<240?(i=0,n=o,r=t):240<=e.h&&e.h<300?(i=o,n=0,r=t):300<=e.h&&e.h<360&&(i=t,n=0,r=o),i=Math.round(255*(i+s)),n=Math.round(255*(n+s)),r=Math.round(255*(r+s)),{a:e.a,r:i,g:n,b:r}}function Xt(e){const t=e.r/255,o=e.g/255,s=e.b/255;let i=Math.min(t,o,s),n=Math.max(t,o,s),r=n-i,a=0,l=0,c=0;return a=0===r?0:n===t?(o-s)/r%6:n===o?(s-t)/r+2:(t-o)/r+4,a=Math.round(60*a),a<0&&(a+=360),c=(n+i)/2,l=0===r?0:r/(1-Math.abs(2*c-1)),l=+(100*l).toFixed(1),c=+(100*c).toFixed(1),{a:e.a,h:a,s:l,l:c}}function Kt(e){return Zt(Yt(e))}function Jt(e){return Xt(jt(e))}function Qt(e,t){return 1===t?zt(e).slice(0,7):Zt({...jt(e),a:t})}function eo(e,t){const o=Jt(e);return 1===t?"#fff":(o.l=t*(100-o.l)+o.l,Kt(o))}function to(e,t){const o=Jt(e);return 1===t?"#000":(o.l=o.l-t*o.l,Kt(o))}const oo=["#4EA7F2","#EA6175","#43C5B1","#F4A261","#8481DD","#FFD86D"],so=["#4EA7F2","#3188E6","#43C5B1","#00A78D","#EA6175","#CE4257","#F4A261","#F48935","#8481DD","#5752D1","#FFD86D","#FFBC2C"],io=["#4EA7F2","#3188E6","#056BD9","#A76DBC","#7F4295","#6D2387","#EA6175","#CE4257","#982738","#43C5B1","#00A78D","#0E8270","#F4A261","#F48935","#BE5D10","#8481DD","#5752D1","#3A3580","#A4A8B6","#7E8290","#545B70","#FFD86D","#FFBC2C","#C08A16"],no=["#4EA7F2","#3188E6","#056BD9","#155193","#A76DBC","#7F4295","#6D2387","#4F1565","#EA6175","#CE4257","#982738","#791B29","#43C5B1","#00A78D","#0E8270","#105F53","#F4A261","#F48935","#BE5D10","#7D380D","#8481DD","#5752D1","#3A3580","#26235F","#A4A8B6","#7E8290","#545B70","#3F4250","#FFD86D","#FFBC2C","#C08A16","#936A12"],ro=["#4EA7F2","#43C5B1","#EA6175","#F4A261","#8481DD","#FFD86D","#3188E6","#00A78D","#CE4257","#F48935","#5752D1","#FFBC2C"],ao=["#4EA7F2","#A76DBC","#EA6175","#43C5B1","#F4A261","#8481DD","#A4A8B6","#FFD86D","#3188E6","#7F4295","#CE4257","#00A78D","#F48935","#5752D1","#7E8290","#FFBC2C","#056BD9","#6D2387","#982738","#0E8270","#BE5D10","#3A3580","#545B70","#C08A16"],lo=["#4EA7F2","#A76DBC","#EA6175","#43C5B1","#F4A261","#8481DD","#A4A8B6","#FFD86D","#3188E6","#7F4295","#CE4257","#00A78D","#F48935","#5752D1","#7E8290","#FFBC2C","#056BD9","#6D2387","#982738","#0E8270","#BE5D10","#3A3580","#545B70","#C08A16","#155193","#4F1565","#791B29","#105F53","#7D380D","#26235F","#3F4250","#936A12"];function co(e,t){return t[e%t.length]}function ho(e){return e<=6?oo:e<=12?so:e<=24?io:no}class uo{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=ho(e).filter((e=>!t.includes(e)))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:co(this.currentColorIndex++,this.palette)}}class go extends uo{constructor(e,t=[]){var o;super(e,t),this.palette=(o=e,o<=6?oo:o<=12?ro:o<=24?ao:lo).filter((e=>!t.includes(e)))}}function po(e){if(e.length<2)throw new Error("Color scale must have at least 2 points");const t=[...e.sort(((e,t)=>e.value-t.value))],o=[];for(let e=1;e<t.length;e++){const s=Bt(t[e-1].color),i=Bt(t[e].color);o.push({min:t[e-1].value,max:t[e].value,minColor:s,maxColor:i,colorDiff:mo(t[e-1].value,t[e].value,s,i)})}return e=>{if(e<o[0].min)return Ht(o[0].minColor);for(const t of o)if(e>=t.min&&e<=t.max)return Ht(fo(e,t.min,t.minColor,t.colorDiff));return Ht(o[o.length-1].maxColor)}}function mo(e,t,o,s){const i=t-e;return[((o>>16)%256-(s>>16)%256)/i,((o>>8)%256-(s>>8)%256)/i,(o%256-s%256)/i]}function fo(e,t,o,s){const[i,n,r]=s;return Math.round((o>>16)%256-i*(e-t))<<16|Math.round((o>>8)%256-n*(e-t))<<8|Math.round(o%256-r*(e-t))}function vo(e){if(e<0)throw new Error(`number must be positive. Got ${e}`);return e<26?String.fromCharCode(65+e):vo(Math.floor(e/26)-1)+vo(e%26)}function bo(e){let t=0;const o=e.length;for(let s=0;s<o;s++){const o=e.charCodeAt(s);t=26*t+(o>=65&&o<=90?o-64:o-96)}return t-1}function So(e){return e>="0"&&e<="9"}function yo(e){let t="",o="",s=0;for("$"===(e=e.trim())[s]&&s++;s<e.length&&((i=e[s])>="A"&&i<="Z"||i>="a"&&i<="z");)t+=e[s++];var i;if(0===t.length||t.length>3)throw new Error(`Invalid cell description: ${e}`);for("$"===e[s]&&s++;s<e.length&&So(e[s]);)o+=e[s++];if(s!==e.length||0===o.length||o.length>7)throw new Error(`Invalid cell description: ${e}`);const n=bo(t),r=Number(o)-1;if(isNaN(r))throw new Error(`Invalid cell description: ${e}`);return{col:n,row:r}}function Co(e,t,o={colFixed:!1,rowFixed:!1}){return(o.colFixed?"$":"")+vo(e)+(o.rowFixed?"$":"")+String(t+1)}function wo(e,t=[]){if(e.length<=1&&0===t.length)return e;const o=[0],s=new Map([[0,[]]]);return xo(o,s,e,!1),xo(o,s,t,!0),function(e,t){const o=[];let s=[];for(let i=0;i<e.length;i++){const n=e[i],r=t.get(n);if(!r||0===r.length){o.push(...s),s=[];continue}let a=e[i+1];void 0!==a&&a--;const l=[];for(let e=0;e<r.length;e+=2){const t=r[e];let o=r[e+1];void 0!==o&&o--;const i={top:t,left:n,bottom:o,right:a,hasHeader:void 0===o&&0!==t||void 0===a&&0!==n};let c=!1;for(let e=s.length-1;e>=0;e--){const t=s[e];if(t.top===i.top&&t.bottom===i.bottom){t.right=i.right,s.splice(e,1),l.push(t),c=!0;break}}c||l.push(i)}o.push(...s),s=l}return o.push(...s),o}(o,s)}function xo(e,t,o,s=!1){for(const i of o){const o=i.left,n=void 0===i.right?void 0:i.right+1,r=Eo(e,t,o,!0,0),a=Eo(e,t,n,!1,r);for(let o=r;o<=a;o++){Io(t.get(e[o]),i,s)}Ro(e,t,r,a)}}function Eo(e,t,o,s,i){if(void 0===o)return e.length-1;const n=To(e,o,i);return o!=e[n]?(e.splice(n+1,0,o),t.set(o,[...t.get(e[n])]),s?n+1:n):s?n:n-1}function Io(e,t,o=!1){const s=t.top,i=void 0===t.bottom?void 0:t.bottom+1,n=[],r=To(e,s,0,!1);if((r%2!=0&&!o||r%2==0&&o)&&n.push(s),void 0===i)return e.splice(r+1),void e.push(...n);const a=function(e,t,o=0,s=!0){let i=e.length-1,n=e.length;for(;o<=i;){const r=Math.floor((o+i)/2);if(e[r]===t&&s)return r;e[r]>t?(n=r,i=r-1):o=r+1}return n}(e,i,0,!1);(a%2==0&&!o||a%2!=0&&o)&&n.push(i),e.splice(r+1,a-r-1,...n)}function Ro(e,t,o,s){const i=o-1==-1?0:o-1;for(let o=s===e.length-1?s:s+1;o>i;o--)vt(t.get(e[o]),t.get(e[o-1]))&&(t.delete(e[o]),e.splice(o,1))}function To(e,t,o=0,s=!0){let i=e.length-1,n=-1;for(;o<=i;){const r=Math.floor((o+i)/2);if(e[r]===t&&s)return r;e[r]<t?(n=r,o=r+1):i=r-1}return n}const Ao=e=>e,_o=()=>!1;let Do=Ao,Oo=_o;function Fo(e,...t){if(1!==t.length||"object"!=typeof t[0]||t[0]instanceof String)t.length>0&&(e=e.replace(/\%s/g,(()=>t.shift())));else{const o=t[0];e=e.replace(/\%\(([^\)]+)\)s/g,((e,t)=>o[t]))}return e}const Mo=function(e,...t){return Oo()?Fo(Do(e),...t):new Po(e,t)};class Po extends String{values;constructor(e,t){super(e),this.values=t}valueOf(){const e=super.valueOf();return Oo()?Fo(Do(e),...this.values):Fo(e,...this.values)}toString(){return this.valueOf()}}const No=new RegExp(/\$?([A-Z]{1,3})\$?([0-9]{1,7})/,"i"),ko=new RegExp(/^\$?([A-Z]{1,3})\$?([0-9]{1,7})$/,"i"),Lo=new RegExp(/^\$?([A-Z]{1,3})+$/,"i"),Vo=new RegExp(/^\$?([0-9]{1,7})+$/,"i"),Uo=new RegExp(/^\s*('.+'!|[^']+!)?\$?([A-Z]{1,3})$/,"i"),Ho=new RegExp(/^\s*('.+'!|[^']+!)?\$?([0-9]{1,7})$/,"i"),Bo=new RegExp(/^\s*('.+'!|[^']+!)?/.source+"("+[No.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 zo(e){return Uo.test(e)}function $o(e){return Ho.test(e)}function Wo(e){return Lo.test(e)}function Go(e){return Vo.test(e)}function qo(e){return ko.test(e)}function Zo(e){if(!e.includes("!"))return{xc:e};const t=e.split("!"),o=t.pop();return{sheetName:$e(t.join("!"))||void 0,xc:o}}function jo(e,t){return void 0!==e?`${Ge(e)}!${t}`:t}function Yo(e){const t=function(e){e.includes("!")&&(e=e.split("!").at(-1)),e.includes("$")&&(e=e.replaceAll("$",""));let t,o,s,i,n,r="";e.includes(":")?([r,t]=e.split(":"),r=r.trim(),t=t.trim()):r=e.trim();let a=!1,l=!1,c=!1;if(zo(r))i=n=bo(r),o=s=0,a=!0;else if($o(r))o=s=parseInt(r,10)-1,i=n=0,l=!0;else{const e=yo(r);i=n=e.col,o=s=e.row,c=!0}if(t)if(zo(t))n=bo(t),a=!0;else if($o(t))s=parseInt(t,10)-1,l=!0;else{const e=yo(t);n=e.col,s=e.row,o=a?s:o,i=l?n:i,c=!0}if(a&&l)throw new Error("Wrong zone xc. The zone cannot be at the same time a full column and a full row");const h={top:o,left:i,bottom:a?void 0:s,right:l?void 0:n};return c=c&&(l||a),c&&(h.hasHeader=c),h}(e);return ps(t)}function Xo(e){const t=Yo(e);if(void 0===t.bottom||void 0===t.right)throw new Error("This does not support unbounded ranges");return t}function Ko(e){const{bottom:t,top:o,left:s,right:i}=e;return!(void 0!==t&&isNaN(t)||isNaN(o)||isNaN(s)||void 0!==i&&isNaN(i))&&(Jo(e)&&e.top>=0&&e.left>=0)}function Jo(e){return(void 0===e.bottom||e.bottom>=e.top&&e.bottom>=0)&&(void 0===e.right||e.right>=e.left&&e.right>=0)}function Qo(e){const{top:t,bottom:o,left:s,right:i}=e,n="hasHeader"in e&&e.hasHeader,r=t===o&&s===i;if(void 0===o&&void 0!==i)return 0!==t||n?`${Co(s,t)}:${vo(i)}`:`${vo(s)}:${vo(i)}`;if(void 0===i&&void 0!==o)return 0!==s||n?`${Co(s,t)}:${o+1}`:`${t+1}:${o+1}`;if(void 0!==o&&void 0!==i)return r?Co(s,t):`${Co(s,t)}:${Co(i,o)}`;throw new Error(Mo("Bad zone format"))}function es(e,t,o,s,i){const n="left"===t?"columns":"rows",r="before"===s?o-1:o,a=e["left"===t?"right":"bottom"];return e[t]<=r&&a&&a>r?ms(e,n,"RESIZE",i):r<e[t]?ms(e,n,"MOVE",i):{...e}}function ts(e,t,o,s,i){const n="left"===t?"columns":"rows",r="before"===s?o-1:o,a="left"===t?"right":"bottom";return e[t]<=r&&e[a]>r?ms(e,n,"RESIZE",i):r<e[t]?ms(e,n,"MOVE",i):{...e}}function os(e,t,o){const s="left"===t?"right":"bottom";let i=e[t],n=e[s];for(let r of o.sort(((e,t)=>t-e)))e[t]>r&&(i--,n--),e[t]<r&&e[s]>=r&&n--;return{...e,[t]:i,[s]:n}}function ss(e,t,o){const s="left"===t?"right":"bottom";let i=e[t],n=e[s];const r=e[s];for(let s of o.sort(((e,t)=>t-e)))e[t]>s&&(i--,void 0!==n&&n--),void 0!==r&&void 0!==n&&e[t]<=s&&r>=s&&n--;if(!(void 0!==n&&i>n))return{...e,[t]:i,[s]:n}}function is(...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 ns(e,t){if(as(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 rs(e,t){return e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom}function as(e,t){return!(e.bottom<t.top||t.bottom<e.top)&&!(e.right<t.left||t.right<e.left)}function ls(e,t,o){const{left:s,right:i,top:n,bottom:r}=o;return e>=s&&e<=i&&t>=n&&t<=r}function cs(e,t){return rs(is(t,e),t)}function hs(e){return{numberOfRows:e.bottom-e.top+1,numberOfCols:e.right-e.left+1}}function ds(e){const{numberOfCols:t,numberOfRows:o}=hs(e);return 1===t||1===o}function us(e){const t={};for(const o of e)t[o.sheetId]??=[],t[o.sheetId].push(vs(o));for(const e in t)t[e]=wo(t[e]);return t}function gs(e){const t=[],{left:o,right:s,top:i,bottom:n}=ps(e);for(const e of je(o,s+1))for(const o of je(i,n+1))t.push({col:e,row:o});return t}function ps(e){return void 0!==e.right&&e.left>e.right&&(e={...e,left:e.right,right:e.left}),void 0!==e.bottom&&e.top>e.bottom&&(e={...e,top:e.bottom,bottom:e.top}),e}function ms(e,t,o,s){const i="both"===t?s[0]:"columns"===t?s:0,n="both"===t?s[1]:"rows"===t?s:0,r="hasHeader"in e&&e.hasHeader;let a;a=!function(e){return void 0===e.bottom}(e)||r?!(Ss(e)&&!r)||"columns"!==t:"rows"!==t;const l={...e};return a&&"MOVE"===o&&(l.left+=i,l.top+=n),void 0!==l.right&&(l.right+=i),void 0!==l.bottom&&(l.bottom+=n),l}function fs(e,t){let o,s;const{left:i,right:n,top:r,bottom:a}=e,{left:l,right:c,top:h,bottom:d}=t;return o=l!=i?l:c!=n?c:l,s=h!=r?h:d!=a?d:h,{col:o,row:s}}function vs(e){return{left:e.col,right:e.col,top:e.row,bottom:e.row}}function bs(e){return{...e,right:e.left,bottom:e.top}}function Ss(e){return void 0===e.right}function ys(e){return(e.bottom-e.top+1)*(e.right-e.left+1)}function Cs(e){return e.length<2||1===wo(e).length}function ws(e){const t=[...e];let o=!0;for(;o;){o=!1;for(let e=0;e<t.length;e++){const s=t[e],i=t.findIndex(((t,o)=>{return e!==o&&(n=s,((i=t).right+1===n.left||i.left===n.right+1?i.top<=n.bottom&&i.top>=n.top||n.top<=i.bottom&&n.top>=i.top:(i.bottom+1===n.top||i.top===n.bottom+1)&&(i.left<=n.right&&i.left>=n.left||n.left<=i.right&&n.left>=i.left))||as(t,s));var i,n}));if(-1!==i){t[e]=is(t[i],s),t.splice(i,1),o=!0;break}}}return t}const xs=new WeakMap,Es=new WeakMap;function Is(e,t){xs.has(t)||(xs.set(t,new Map),Es.set(t,0));const o=xs.get(t),s=As(e);if(o.has(s)){const i=o.get(s);return t[i]=e,i}const i=Es.get(t)+1;return o.set(s,i),Es.set(t,i),t[i]=e,i}function Rs(e){const t={};for(const o in e){const s=wo(e[o].map(vs));for(const e of s)t[Qo(e)]=Number(o)}return t}function*Ts(e,t){for(const o in t){const s=Xo(o),i=t[o];for(let t=s.top;t<=s.bottom;t++)for(let o=s.left;o<=s.right;o++){const s={sheetId:e,col:o,row:t};yield[s,i]}}}function As(e){if(null===e)return"null";if(void 0===e)return"undefined";if("object"!=typeof e)return String(e);if(Array.isArray(e)){const t=e.length;let o="[";for(let s=0;s<t;s++)s>0&&(o+=","),o+=As(e[s]);return o+"]"}const t=Object.keys(e).sort();let o="{";for(const s of t)void 0!==e[s]&&(o+=`"${s}":${As(e[s])},`);return o+="}",o}class _s{jsDate;constructor(e,t,o,s=0,i=0,n=0){this.jsDate=new Date(Date.UTC(e,t,o,s,i,n,0))}static fromTimestamp(e){const t=new Date(e);return new _s(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),t.getUTCHours(),t.getUTCMinutes(),t.getUTCSeconds())}static now(){const e=new Date;return new _s(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds())}toString(){return this.jsDate.toString()}toLocaleDateString(){return this.jsDate.toLocaleDateString()}getTime(){return this.jsDate.getTime()}getFullYear(){return this.jsDate.getUTCFullYear()}getMonth(){return this.jsDate.getUTCMonth()}getQuarter(){return Math.floor(this.getMonth()/3)+1}getDate(){return this.jsDate.getUTCDate()}getDay(){return this.jsDate.getUTCDay()}getHours(){return this.jsDate.getUTCHours()}getMinutes(){return this.jsDate.getUTCMinutes()}getSeconds(){return this.jsDate.getUTCSeconds()}getIsoWeek(){const e=new Date(this.jsDate.getTime()),t=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-t);const o=new Date(Date.UTC(e.getUTCFullYear(),0,1));return Math.ceil(((e.getTime()-o.getTime())/864e5+1)/7)}setFullYear(e){return this.jsDate.setUTCFullYear(e)}setMonth(e){return this.jsDate.setUTCMonth(e)}setDate(e){return this.jsDate.setUTCDate(e)}setHours(e){return this.jsDate.setUTCHours(e)}setMinutes(e){return this.jsDate.setUTCMinutes(e)}setSeconds(e){return this.jsDate.setUTCSeconds(e)}}const Ds=new _s(1899,11,30),Os=864e5,Fs=2e3,Ms=_s.now().getFullYear(),Ps=_s.now().getMonth(),Ns=_s.fromTimestamp(0).getTime()-Ds.getTime(),ks=/^\d{1,2}(\/|-|\s)\d{1,2}((\/|-|\s)\d{1,4})?$/,Ls=/^\d{3,4}(\/|-|\s)\d{1,2}(\/|-|\s)\d{1,2}$/,Vs=/\/|-|\s/,Us=/^(\d{1,4})[\/-\s](\d{1,4})([\/-\s](\d{1,4}))?$/,Hs=/((\d+(:\d+)?(:\d+)?\s*(AM|PM))|(\d+:\d+(:\d+)?))$/;function Bs(e,t){switch(typeof e){case"number":return e;case"string":return zs(e,t)?Ws(e,t)?.value:!e||isNaN(Number(e))?void 0:Number(e);default:return}}function zs(e,t){return null!==Ws(e,t)}const $s=new Map;function Ws(e,t){return $s.has(t)||$s.set(t,new Map),$s.get(t).has(e)||$s.get(t).set(e,function(e,t){e=e.trim();let o=null;const s=e.match(Hs);if(s){if(o=function(e){if(e=e.trim(),Hs.test(e)){const t=/AM/i.test(e),o=/PM/i.test(e),s=(t||o?e.substring(0,e.length-2).trim():e).split(/:/),i=s.length>=2,n=3===s.length;let r=Number(s[0]),a=i?Number(s[1]):0,l=n?Number(s[2]):0,c=n?"hh:mm:ss":"hh:mm";if(t||o)c+=" a";else if(!i)return null;r>=12&&t?r-=12:r<12&&o&&(r+=12),a+=Math.floor(l/60),l%=60,r+=Math.floor(a/60),a%=60,r>=24&&(c="hhhh:mm:ss");return{value:r/24+a/1440+l/86400,format:c,jsDate:new _s(1899,11,30,r,a,l)}}return null}(s[0]),null===o)return null;e=e.replace(s[0],"").trim()}let i=null;const n=function(e,t){const o=e.match(Us);if(!o)return null;const[,s,i,,n]=o;if(s.length>2&&n&&n.length>2)return null;if(s.length>2)return{year:s,month:i,day:n,dateString:e,type:"ymd"};const r=function(e){switch(e.dateFormat[0]){case"d":return"dmy";case"m":return"mdy";case"y":return"ymd"}throw new Error("Invalid date format in locale")}(t);if(!n)return i.length>2?{month:s,year:i,day:void 0,dateString:e,type:r}:"dmy"===r?{day:s,month:i,year:n,dateString:e,type:"dmy"}:{month:s,day:i,year:n,dateString:e,type:"mdy"};if(n.length>2)return"mdy"===r?{month:s,day:i,year:n,dateString:e,type:"mdy"}:{day:s,month:i,year:n,dateString:e,type:"dmy"};if("mdy"===r)return{month:s,day:i,year:n,dateString:e,type:"mdy"};if("ymd"===r)return{year:s,month:i,day:n,dateString:e,type:"ymd"};if("dmy"===r)return{day:s,month:i,year:n,dateString:e,type:"dmy"};return null}(e,t);if(n){const t=n.dateString.match(Vs)[0];if(i=function(e,t){let{year:o,month:s,day:i}=e;const n=function(e){if(!e)return Ps;const t=Number(e);if(t>=1&&t<=12)return t-1;return null}(s),r=function(e){if(!e)return 1;const t=Number(e);if(t>=0&&t<=31)return t;return null}(i),a=function(e){if(!e)return Ms;const t=Number(e);switch(e.length){case 1:return Fs+t;case 2:return Fs+(Fs+t>Ms+10?-100:0)+t;case 3:case 4:return t}return null}(o);if(null===a||null===n||null===r)return null;const l=2===s?.length&&n+1<10||2===i?.length&&r<10,c=2!==o?.length,h=new _s(a,n,r);if(h.getMonth()!==n||h.getDate()!==r)return null;const d=h.getTime()-Ds.getTime(),u=function(e,t,o,s){const i=e.year?s?"yyyy":"yy":void 0,n=e.month?o?"mm":"m":void 0,r=e.day?o?"dd":"d":void 0;switch(e.type){case"mdy":return[n,r,i].filter(lt).join(t);case"ymd":return[i,n,r].filter(lt).join(t);case"dmy":return[r,n,i].filter(lt).join(t)}}(e,t,l,c);return{value:Math.round(d/Os),format:u,jsDate:h}}(n,t),null===i)return null;e=e.replace(n.dateString,"").trim()}if(""!==e||!i&&!o)return null;if(i&&i.jsDate&&o&&o.jsDate)return{value:i.value+o.value,format:i.format+" "+("hhhh:mm:ss"===o.format?"hh:mm:ss":o.format),jsDate:new _s(i.jsDate.getFullYear()+o.jsDate.getFullYear()-1899,i.jsDate.getMonth()+o.jsDate.getMonth()-11,i.jsDate.getDate()+o.jsDate.getDate()-30,i.jsDate.getHours()+o.jsDate.getHours(),i.jsDate.getMinutes()+o.jsDate.getMinutes(),i.jsDate.getSeconds()+o.jsDate.getSeconds())};return i||o}(e,t)),$s.get(t).get(e)}function Gs(e){const t=Math.trunc(e);let o=_s.fromTimestamp(t*Os-Ns),s=e-t;s=s<0?1+s:s;const i=Math.round(24*s),n=Math.round(24*(s-i/24)*60),r=Math.round(24*(s-i/24-n/24/60)*60*60);return o.setHours(i),o.setMinutes(n),o.setSeconds(r),o}function qs(e){return Math.round(Zs(e))}function Zs(e){return(e.getTime()-Ds.getTime())/Os}function js(e){return new _s(e.getFullYear(),e.getMonth()+1,0).getDate()}function Ys(e){return js(e)===e.getDate()}function Xs(e,t,o){const s=e.getFullYear(),i=e.getMonth(),n=e.getDate(),r=new _s(s,i+t,1);return o&&n===js(e)||n>js(r)?r.setDate(js(r)):r.setDate(n),r}function Ks(e){const t=Math.trunc(e);return t%4==0&&t%100!=0||t%400==0}function Js(e,t,o){if(e===t)return 0;if(e>t){const o=t;t=e,e=o}const s=Gs(e),i=Gs(t);let n=s.getDate(),r=i.getDate();const a=s.getMonth(),l=i.getMonth(),c=s.getFullYear(),h=i.getFullYear();let d=0,u=0;switch(o){case 0:31===n&&(n=30),30===n&&31===r&&(r=30),1===a&&n===(Ks(c)?29:28)&&(n=30,1===l&&r===(Ks(h)?29:28)&&(r=30)),d=c+(30*a+n)/360,u=h+(30*l+r)/360;break;case 1:let o=365;const s=c===h;if(!s&&!(c+1===h)||!s&&a<l||!s&&a===l&&n<r){let e=0,t=0;for(let o=c;o<=h;o++)e++,t+=Ks(o)?366:365;o=t/e}else s?Ks(c)&&(o=366):(Ks(c)&&a<2&&(o=366),Ks(h)&&(l>1||1===l&&29===r)&&(o=366));d=e/o,u=t/o;break;case 2:d=e/360,u=t/360;break;case 3:d=e/365,u=t/365;break;case 4:31===n&&(n=30),31===r&&(r=30),d=c+(30*a+n)/360,u=h+(30*l+r)/360}return u-d}function Qs(e,t){const o=12*(t.getFullYear()-e.getFullYear())+t.getMonth()-e.getMonth();return e.getDate()>t.getDate()?o-1:o}function ei(e,t){const o=e.getTime(),s=t.getTime();return Math.floor((s-o)/Os)}function ti(e,t){const o=t.getFullYear()-e.getFullYear(),s=e.getMonth(),i=t.getMonth(),n=e.getDate(),r=t.getDate();return i>s||i===s&&r>=n?o:o-1}function oi(e,t,o){return t>o?oi(e,o,t):(e=Math.trunc(e),t=Math.trunc(t),o=Math.trunc(o),e>=t&&e<=o)}const si=It((function(e){return e=Be(e),new RegExp(`(?:^-?\\d+(?:${e}?\\d*(?:e\\d+)?)?|^-?${e}\\d+)(?!\\w|!)`)})),ii=It((function(e){const t=Be(e.decimalSeparator),o="(?:\\s*"+`(?:\\d+(?:${Be(e.thousandsSeparator||"")}\\d{3,})*(?:${t}\\d*)?)`+"|"+`(?:${t}\\d+)`+")(?:e(?:\\+|-)?\\d+)?(?:\\s*%)?",s="(?:\\s*-)?",i="(?:\\s*[\\$€])?",n="^(?:(?:"+[s+i+o,s+o+i,i+s+o].join(")|(?:")+"))$";return new RegExp(n,"i")}));function ni(e,t){return!!e&&ii(t).test(e.trim())}const ri=It((function(e){return new RegExp(`[$€${Be(e.thousandsSeparator||"")}]`,"g")}));function ai(e,t){e=e.replace(ri(t),""),"."!==t.decimalSeparator&&(e=e.replace(t.decimalSeparator,"."));let o=Number(e);return isNaN(o)&&e.includes("%")&&(o=Number(e.split("%")[0]),!isNaN(o))?o/100:o}function li(e,t,o){const s=[...e].sort(((e,t)=>e-t));let i=(s.length+(o?-1:1))*t;if(o||i--,Number.isInteger(i))return s[i];const n=Math.ceil(i),r=Math.floor(i);return s[n]*(i-r)+s[r]*(n-i)}var ci,hi;!function(e){e.boolean="boolean",e.number="number",e.text="text",e.empty="empty",e.error="error"}(ci||(ci={})),function(e){e.PlainText="text/plain",e.Html="text/html"}(hi||(hi={}));const di=new Set(["RENAME_SHEET","DELETE_SHEET","CREATE_SHEET","DUPLICATE_SHEET","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","UNDO","REDO","ADD_MERGE","REMOVE_MERGE","DUPLICATE_SHEET","UPDATE_LOCALE","ADD_PIVOT","UPDATE_PIVOT","INSERT_PIVOT","RENAME_PIVOT","REMOVE_PIVOT","DUPLICATE_PIVOT"]),ui=new Set(["EVALUATE_CELLS","EVALUATE_CHARTS","UPDATE_CELL","UNHIDE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","GROUP_HEADERS","UNGROUP_HEADERS","FOLD_ALL_HEADER_GROUPS","FOLD_HEADER_GROUP","FOLD_HEADER_GROUPS_IN_ZONE","UNFOLD_ALL_HEADER_GROUPS","UNFOLD_HEADER_GROUP","UNFOLD_HEADER_GROUPS_IN_ZONE","UPDATE_TABLE","UPDATE_FILTER","UNDO","REDO"]),gi=new Set(["MOVE_RANGES"]),pi=new Set(["EVALUATE_CELLS","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY"]),mi=new Set(["AUTOFILL_CELL","SET_BORDER","SET_ZONE_BORDERS"]),fi=new Set(["START","ACTIVATE_SHEET","COPY","RESIZE_SHEETVIEW","SET_VIEWPORT_OFFSET","EVALUATE_CELLS","EVALUATE_CHARTS","SET_FORMULA_VISIBILITY","UPDATE_FILTER"]),vi=new Set(["UPDATE_CELL","UPDATE_CELL_POSITION","CLEAR_CELL","CLEAR_CELLS","DELETE_CONTENT","ADD_COLUMNS_ROWS","REMOVE_COLUMNS_ROWS","RESIZE_COLUMNS_ROWS","HIDE_COLUMNS_ROWS","UNHIDE_COLUMNS_ROWS","SET_GRID_LINES_VISIBILITY","UNFREEZE_COLUMNS","UNFREEZE_ROWS","FREEZE_COLUMNS","FREEZE_ROWS","UNFREEZE_COLUMNS_ROWS","ADD_MERGE","REMOVE_MERGE","CREATE_SHEET","DELETE_SHEET","DUPLICATE_SHEET","MOVE_SHEET","RENAME_SHEET","COLOR_SHEET","HIDE_SHEET","SHOW_SHEET","MOVE_RANGES","ADD_CONDITIONAL_FORMAT","REMOVE_CONDITIONAL_FORMAT","CHANGE_CONDITIONAL_FORMAT_PRIORITY","CREATE_FIGURE","DELETE_FIGURE","UPDATE_FIGURE","SET_FORMATTING","CLEAR_FORMATTING","SET_BORDER","SET_ZONE_BORDERS","CREATE_CHART","UPDATE_CHART","CREATE_TABLE","REMOVE_TABLE","UPDATE_TABLE","CREATE_TABLE_STYLE","REMOVE_TABLE_STYLE","CREATE_IMAGE","GROUP_HEADERS","UNGROUP_HEADERS","UNFOLD_HEADER_GROUP","FOLD_HEADER_GROUP","FOLD_ALL_HEADER_GROUPS","UNFOLD_ALL_HEADER_GROUPS","UNFOLD_HEADER_GROUPS_IN_ZONE","FOLD_HEADER_GROUPS_IN_ZONE","ADD_DATA_VALIDATION_RULE","REMOVE_DATA_VALIDATION_RULE","UPDATE_LOCALE","ADD_PIVOT","UPDATE_PIVOT","INSERT_PIVOT","RENAME_PIVOT","REMOVE_PIVOT","DUPLICATE_PIVOT"]);function bi(e){return vi.has(e.type)}class Si{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter((e=>"Success"!==e))}static get Success(){return yi}get isSuccessful(){return 0===this.reasons.length}isCancelledBecause(e){return this.reasons.includes(e)}}const yi=new Si;var Ci;e.CommandResult=void 0,(Ci=e.CommandResult||(e.CommandResult={})).Success="Success",Ci.CancelledForUnknownReason="CancelledForUnknownReason",Ci.WillRemoveExistingMerge="WillRemoveExistingMerge",Ci.MergeIsDestructive="MergeIsDestructive",Ci.CellIsMerged="CellIsMerged",Ci.InvalidTarget="InvalidTarget",Ci.EmptyUndoStack="EmptyUndoStack",Ci.EmptyRedoStack="EmptyRedoStack",Ci.NotEnoughElements="NotEnoughElements",Ci.NotEnoughSheets="NotEnoughSheets",Ci.MissingSheetName="MissingSheetName",Ci.UnchangedSheetName="UnchangedSheetName",Ci.DuplicatedSheetName="DuplicatedSheetName",Ci.DuplicatedSheetId="DuplicatedSheetId",Ci.ForbiddenCharactersInSheetName="ForbiddenCharactersInSheetName",Ci.WrongSheetMove="WrongSheetMove",Ci.WrongSheetPosition="WrongSheetPosition",Ci.InvalidAnchorZone="InvalidAnchorZone",Ci.SelectionOutOfBound="SelectionOutOfBound",Ci.TargetOutOfSheet="TargetOutOfSheet",Ci.WrongCutSelection="WrongCutSelection",Ci.WrongPasteSelection="WrongPasteSelection",Ci.WrongPasteOption="WrongPasteOption",Ci.WrongFigurePasteOption="WrongFigurePasteOption",Ci.EmptyClipboard="EmptyClipboard",Ci.EmptyRange="EmptyRange",Ci.InvalidRange="InvalidRange",Ci.InvalidZones="InvalidZones",Ci.InvalidSheetId="InvalidSheetId",Ci.InvalidCellId="InvalidCellId",Ci.InvalidFigureId="InvalidFigureId",Ci.InputAlreadyFocused="InputAlreadyFocused",Ci.MaximumRangesReached="MaximumRangesReached",Ci.MinimumRangesReached="MinimumRangesReached",Ci.InvalidChartDefinition="InvalidChartDefinition",Ci.InvalidDataSet="InvalidDataSet",Ci.InvalidLabelRange="InvalidLabelRange",Ci.InvalidScorecardKeyValue="InvalidScorecardKeyValue",Ci.InvalidScorecardBaseline="InvalidScorecardBaseline",Ci.InvalidGaugeDataRange="InvalidGaugeDataRange",Ci.EmptyGaugeRangeMin="EmptyGaugeRangeMin",Ci.GaugeRangeMinNaN="GaugeRangeMinNaN",Ci.EmptyGaugeRangeMax="EmptyGaugeRangeMax",Ci.GaugeRangeMaxNaN="GaugeRangeMaxNaN",Ci.GaugeLowerInflectionPointNaN="GaugeLowerInflectionPointNaN",Ci.GaugeUpperInflectionPointNaN="GaugeUpperInflectionPointNaN",Ci.InvalidAutofillSelection="InvalidAutofillSelection",Ci.MinBiggerThanMax="MinBiggerThanMax",Ci.LowerBiggerThanUpper="LowerBiggerThanUpper",Ci.MidBiggerThanMax="MidBiggerThanMax",Ci.MinBiggerThanMid="MinBiggerThanMid",Ci.FirstArgMissing="FirstArgMissing",Ci.SecondArgMissing="SecondArgMissing",Ci.MinNaN="MinNaN",Ci.MidNaN="MidNaN",Ci.MaxNaN="MaxNaN",Ci.ValueUpperInflectionNaN="ValueUpperInflectionNaN",Ci.ValueLowerInflectionNaN="ValueLowerInflectionNaN",Ci.MinInvalidFormula="MinInvalidFormula",Ci.MidInvalidFormula="MidInvalidFormula",Ci.MaxInvalidFormula="MaxInvalidFormula",Ci.ValueUpperInvalidFormula="ValueUpperInvalidFormula",Ci.ValueLowerInvalidFormula="ValueLowerInvalidFormula",Ci.InvalidSortAnchor="InvalidSortAnchor",Ci.InvalidSortZone="InvalidSortZone",Ci.SortZoneWithArrayFormulas="SortZoneWithArrayFormulas",Ci.WaitingSessionConfirmation="WaitingSessionConfirmation",Ci.MergeOverlap="MergeOverlap",Ci.TooManyHiddenElements="TooManyHiddenElements",Ci.Readonly="Readonly",Ci.InvalidViewportSize="InvalidViewportSize",Ci.InvalidScrollingDirection="InvalidScrollingDirection",Ci.ViewportScrollLimitsReached="ViewportScrollLimitsReached",Ci.FigureDoesNotExist="FigureDoesNotExist",Ci.InvalidConditionalFormatId="InvalidConditionalFormatId",Ci.InvalidCellPopover="InvalidCellPopover",Ci.EmptyTarget="EmptyTarget",Ci.InvalidFreezeQuantity="InvalidFreezeQuantity",Ci.FrozenPaneOverlap="FrozenPaneOverlap",Ci.ValuesNotChanged="ValuesNotChanged",Ci.InvalidFilterZone="InvalidFilterZone",Ci.TableNotFound="TableNotFound",Ci.TableOverlap="TableOverlap",Ci.InvalidTableConfig="InvalidTableConfig",Ci.InvalidTableStyle="InvalidTableStyle",Ci.FilterNotFound="FilterNotFound",Ci.MergeInTable="MergeInTable",Ci.NonContinuousTargets="NonContinuousTargets",Ci.DuplicatedFigureId="DuplicatedFigureId",Ci.InvalidSelectionStep="InvalidSelectionStep",Ci.DuplicatedChartId="DuplicatedChartId",Ci.ChartDoesNotExist="ChartDoesNotExist",Ci.InvalidHeaderIndex="InvalidHeaderIndex",Ci.InvalidQuantity="InvalidQuantity",Ci.MoreThanOneColumnSelected="MoreThanOneColumnSelected",Ci.EmptySplitSeparator="EmptySplitSeparator",Ci.SplitWillOverwriteContent="SplitWillOverwriteContent",Ci.NoSplitSeparatorInSelection="NoSplitSeparatorInSelection",Ci.NoActiveSheet="NoActiveSheet",Ci.InvalidLocale="InvalidLocale",Ci.MoreThanOneRangeSelected="MoreThanOneRangeSelected",Ci.NoColumnsProvided="NoColumnsProvided",Ci.ColumnsNotIncludedInZone="ColumnsNotIncludedInZone",Ci.DuplicatesColumnsSelected="DuplicatesColumnsSelected",Ci.InvalidHeaderGroupStartEnd="InvalidHeaderGroupStartEnd",Ci.HeaderGroupAlreadyExists="HeaderGroupAlreadyExists",Ci.UnknownHeaderGroup="UnknownHeaderGroup",Ci.UnknownDataValidationRule="UnknownDataValidationRule",Ci.UnknownDataValidationCriterionType="UnknownDataValidationCriterionType",Ci.InvalidDataValidationCriterionValue="InvalidDataValidationCriterionValue",Ci.InvalidNumberOfCriterionValues="InvalidNumberOfCriterionValues",Ci.InvalidCopyPasteSelection="InvalidCopyPasteSelection",Ci.NoChanges="NoChanges",Ci.InvalidInputId="InvalidInputId",Ci.SheetIsHidden="SheetIsHidden",Ci.InvalidTableResize="InvalidTableResize",Ci.PivotIdNotFound="PivotIdNotFound",Ci.PivotInError="PivotInError",Ci.EmptyName="EmptyName",Ci.ValueCellIsInvalidFormula="ValueCellIsInvalidFormula",Ci.InvalidDefinition="InvalidDefinition",Ci.InvalidColor="InvalidColor";const wi=[{name:"English (US)",code:"en_US",thousandsSeparator:",",decimalSeparator:".",weekStart:7,dateFormat:"m/d/yyyy",timeFormat:"hh:mm:ss a",formulaArgSeparator:","},{name:"French",code:"fr_FR",thousandsSeparator:" ",decimalSeparator:",",weekStart:1,dateFormat:"dd/mm/yyyy",timeFormat:"hh:mm:ss",formulaArgSeparator:";"}],xi=wi[0],Ei=["thin","medium","thick","dashed","dotted"];function Ii(e){return Array.isArray(e)&&Array.isArray(e[0])}var Ri;!function(e){e.UP="up",e.DOWN="down",e.LEFT="left",e.RIGHT="right"}(Ri||(Ri={}));const Ti={Background:0,Highlights:1,Clipboard:2,Chart:4,Autofill:5,Selection:6,Headers:100},Ai=It((()=>Object.keys(Ti).sort(((e,t)=>Ti[e]-Ti[t]))));const _i={NotAvailable:"#N/A",InvalidReference:"#REF",BadExpression:"#BAD_EXPR",CircularDependency:"#CYCLE",UnknownFunction:"#NAME?",DivisionByZero:"#DIV/0!",SpilledBlocked:"#SPILL!",GenericError:"#ERROR",NullError:"#NULL!"},Di=new Set(Object.values(_i));class Oi extends Error{value;constructor(e=Mo("Error"),t=_i.GenericError){super(e),this.value=t}}class Fi extends Oi{constructor(e=Mo("Invalid expression")){super(e,_i.BadExpression)}}class Mi extends Oi{constructor(e=Mo("Invalid reference")){super(e,_i.InvalidReference)}}class Pi extends Oi{constructor(e=Mo("Data not available")){super(e,_i.NotAvailable)}}class Ni extends Oi{constructor(e=Mo("Unknown function")){super(e,_i.UnknownFunction)}}class ki extends Oi{constructor(e=Mo("Spill range is not empty")){super(e,_i.SpilledBlocked)}}const Li=["number","string","boolean","undefined"];function Vi(e,t,o){if(!e())throw new Oi(t,o)}function Ui(e){if(void 0!==e)return Ii(e)?e[0][0]?.format:e.format}function Hi(e){return"string"==typeof e&&Di.has(e)}const Bi=e=>Mo("The function [[FUNCTION_NAME]] expects a number value, but '%s' is a string, and cannot be coerced to a number.",e);function zi(e,t){const o=tn(e);switch(typeof o){case"number":return o;case"boolean":return o?1:0;case"string":if(ni(o,t)||""===o)return ai(o,t);const e=Ws(o,t);if(e)return e.value;throw new Oi(Bi(o));default:return 0}}function $i(e,t){try{return zi(e,t)}catch(e){return}}function Wi(e,t){return wn(e).map((e=>e.map((e=>{if("number"!=typeof e.value)throw new Oi(Mo("Function [[FUNCTION_NAME]] expects number values for %s, but got a %s.",t,typeof e.value));return e.value}))))}function Gi(e,t){const o=tn(e);if(""===o)throw new Oi(Bi(o));return zi(o,t)}function qi(e,t){return Math.trunc(zi(e,t))}function Zi(e,t){return Math.trunc(Gi(e,t))}function ji(e){Vi((()=>e>=1),Mo("The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.",e.toString()))}function Yi(e){Vi((()=>0!==e),Mo("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."),_i.DivisionByZero)}function Xi(e){const t=tn(e);switch(typeof t){case"string":return t;case"number":return t.toString();case"boolean":return t?"TRUE":"FALSE";default:return""}}const Ki=It((function(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")})),Ji=e=>Mo("The function [[FUNCTION_NAME]] expects a boolean value, but '%s' is a text, and cannot be coerced to a boolean.",e);function Qi(e){const t=tn(e);switch(typeof t){case"boolean":return t;case"string":if(t){let e=t.toUpperCase();if("TRUE"===e)return!0;if("FALSE"===e)return!1;throw new Oi(Ji(t))}return!1;case"number":return!!t;default:return!1}}function en(e,t){return Gs(zi(tn(e),t))}function tn(e){if("object"==typeof e&&null!==e&&"value"in e){if(Hi(e.value))throw e;return e.value}if(Hi(e))throw new Oi("",e);return e}function on(e,t,o){for(let s of e)if(Ii(s)){const e=s.length,o=s[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)t(s[o][i])}else o(s)}function sn(e,t){on(e,(e=>{if(Hi(e.value))throw e;t(e)}),(e=>{if(Hi(e?.value))throw e;t(e)}))}function nn(e,t,o){on(e,(e=>{if("number"==typeof e?.value&&t(e),Hi(e?.value))throw e}),(e=>{t({value:Gi(e,o),format:e?.format})}))}function rn(e,t,o,s,i="rowFirst"){let n=s;for(let s of e)if(Ii(s)){const e=s.length,o=s[0].length;if("rowFirst"===i)for(let i=0;i<o;i++)for(let o=0;o<e;o++)n=t(n,s[o][i]);else for(let i=0;i<e;i++)for(let e=0;e<o;e++)n=t(n,s[i][e])}else n=o(n,s);return n}function an(e,t,o,s="rowFirst"){return rn(e,t,t,o,s)}function ln(e,t,o,s){return rn(e,((e,o)=>{const s=o?.value;if("number"==typeof s)return t(e,s);if(Hi(s))throw o;return e}),((e,o)=>t(e,Gi(o,s))),o)}function cn(e,t,o,s){return rn(e,((e,o)=>{const i=o?.value;if(null!=i){if("number"==typeof i)return t(e,i);if("boolean"==typeof i)return t(e,zi(i,s));if(Hi(i))throw o;return t(e,0)}return e}),((e,o)=>t(e,zi(o,s))),o)}function hn(e,t,o){const s=Array(e);for(let i=0;i<e;i++){s[i]=Array(t);for(let e=0;e<t;e++)s[i][e]=o(i,e)}return s}function dn(e,t){return 0===e.length?[]:hn(e.length,e[0].length,((o,s)=>t(e[o][s])))}function un(e){return e.length?hn(e[0].length,e.length,((t,o)=>e[o][t])):[]}function gn(e,t){return function(e,t,o){for(let s of e)if(Ii(s)){const e=s.length,o=s[0].length;for(let i=0;i<o;i++)for(let o=0;o<e;o++)if(!t(s[o][i]??void 0))return}else if(!o(s))return}(e,(e=>{const o=e?.value;if("boolean"==typeof o)return t(o);if("number"==typeof o)return t(!!o);if(Hi(o))throw e;return!0}),(e=>void 0===e||null===e.value||t(function(e){const t=tn(e);if(""===t)throw new Oi(Ji(t));return Qi(t)}(e))))}function pn(e,t){let o,s,i=e.substring(0,2);return"<="===i||">="===i||"<>"===i?(o=i,s=e.substring(2)):(i=e.substring(0,1),"<"===i||">"===i||"="===i?(o=i,s=e.substring(1)):(o="=",s=e)),ni(s,t)||zs(s,t)?s=zi(s,t):"TRUE"!==s&&"FALSE"!==s||(s=Qi(s)),{operator:o,operand:s}}const mn=It((function(e){if("*"===e)return/.+/;let t="",o="";for(let s of e)"?"===s&&"~"!==o?t+=".":"*"===s&&"~"!==o?t+=".*":("*"!==s&&"?"!==s||(t=t.slice(0,-1)),["^",".","[","]","$","(",")","*","+","?","|","{","}","\\"].includes(s)&&(t+="\\"),t+=s),o=s;return new RegExp("^"+t+"$","i")}));function fn(e="",t,o){const{operator:s,operand:i}=t;if(void 0===i||null===e||null===i)return!1;if("number"==typeof i&&"="===s)return"string"==typeof e&&(ni(e,o)||zs(e,o))?zi(e,o)===i:e===i;if("<>"===s||"="===s){let t;return t=typeof e==typeof i&&("string"==typeof e&&"string"==typeof i?mn(i).test(e):e===i),"="===s?t:!t}if(typeof e==typeof i)switch(s){case"<":return e<i;case">":return e>i;case"<=":return e<=i;case">=":return e>=i}return!1}function vn(e,t,o,s=!1){const i=e.length;if(i%2==1)throw new Oi(Mo("Function [[FUNCTION_NAME]] expects criteria_range and criterion to be in pairs."));const n=wn(e[0]),r=n.length,a=n[0].length;let l=[];for(let t=0;t<i-1;t+=2){const i=wn(e[t]);if(i.length!==r||i[0].length!==a)throw new Oi(Mo("Function [[FUNCTION_NAME]] expects criteria_range to have the same dimension"));const n=pn(Xi(e[t+1]),o);s&&"string"==typeof n.operand&&(n.operand+="*"),l.push(n)}for(let s=0;s<r;s++)for(let n=0;n<a;n++){let r=!0;for(let t=0;t<i-1;t+=2){if(r=fn(wn(e[t])[s][n].value??void 0,l[t/2],o),!r)break}r&&t(s,n)}}function bn(e,t,o,s,i,n){if(void 0===t||null===t.value)return-1;if(Hi(t.value))throw t;const r=yn(t.value),a=typeof r;let l,c,h,d,u,g,p=0,m=i-1;const f="desc"===s?t=>yn(n(e,i-t-1)):t=>yn(n(e,t));for(;m-p>=0;){for(h=Math.floor((p+m)/2),d=h,u=f(d),g=typeof u;p<d&&a!==g;)d--,u=f(d),g=typeof u;g===a&&null!=u?("strict"===o&&u===r?(l=u,c=d):"nextSmaller"===o&&u<=r?(null==l||l<u||l===u&&c<d)&&(l=u,c=d):"nextGreater"===o&&u>=r&&(void 0===l||l>u||l===u&&c<d)&&(l=u,c=d),u>r||"strict"===o&&u===r?m=d-1:p=h+1):p=h+1}return void 0===c?-1:"desc"===s?i-c-1:c}function Sn(e,t,o,s,i,n,r=!1){if(void 0===t||null===t.value)return-1;if(Hi(t.value))throw t;const a=yn(t.value),l=r?(e,t)=>yn(i(e,s-t-1)):(e,t)=>yn(i(e,t)),c="wildcard"!==o||"string"!=typeof a||!(a.includes("*")||a.includes("?"));if(n&&c){const t=r?"reverseSearch":"forwardSearch";let i=n[t].get(e);if(void 0===i){i=new Map;for(let t=0;t<s;t++){const o=l(e,t)??null;i.has(o)||i.set(o,t)}n[t].set(e,i)}if(i.has(a)){const e=i.get(a);return r?s-e-1:e}if("strict"===o)return-1}const h=function(e,t,o,s,i){let n=o=>i(e,o)===t;if("wildcard"===o&&"string"==typeof t&&(t.includes("*")||t.includes("?"))){const o=mn(t);n=t=>{const s=i(e,t);return"string"==typeof s&&o.test(s)}}let r,a=-1;"nextSmaller"===o&&(n=o=>{const s=i(e,o);return(!r&&Cn(t,s)>=0||Cn(t,s)>=0&&Cn(s,r)>0)&&(r=s,a=o),s===t});"nextGreater"===o&&(n=o=>{const s=i(e,o);return(!r&&Cn(t,s)<=0||Cn(t,s)<=0&&Cn(s,r)<0)&&(r=s,a=o),s===t});for(let e=0;e<s;e++)if(n(e))return e;return a}(e,a,o,s,l);return r&&-1!==h?s-h-1:h}function yn(e){return"string"==typeof e?Ki(e):e}function Cn(e,t){let o=Li.indexOf(typeof e)-Li.indexOf(typeof t);return 0===o&&("string"==typeof e&&"string"==typeof t?o=e.localeCompare(t):"number"==typeof e&&"number"==typeof t?o=e-t:"boolean"==typeof e&&"boolean"==typeof t&&(o=Number(e)-Number(t))),o}function wn(e){return void 0===e?[[]]:Ii(e)?e:[[e]]}function xn(e,t){return an(e,((e,o)=>(e.push(t(o)),e)),[],"rowFirst")}function En(e){if(void 0===e)return!1;const{value:t}=e;return null!==t&&""!==t}function In(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}const Rn=new n;function Tn(e,t){return{url:e=In(e),label:t||e,isExternal:!0,isUrlEditable:!0}}Rn.add("sheet_URL",{match:e=>nt(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){const o=at(e);return t.tryGetSheetName(o)||Mo("Invalid sheet")},open(e,t){const o=at(e);t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:o}).isCancelledBecause("SheetIsHidden")&&t.notifyUser({type:"warning",sticky:!1,text:Mo("Cannot open the link because the linked sheet is hidden.")})},sequence:0});const An={createLink