@trebco/treb 21.6.2 → 21.6.5
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/package.json +1 -1
- package/treb-bundle.css +1 -1
- package/treb-bundle.mjs +8 -8
package/treb-bundle.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/*! TREB v21.6.
|
|
2
|
-
var ns=Object.create;var si=Object.defineProperty;var os=Object.getOwnPropertyDescriptor;var as=Object.getOwnPropertyNames;var ls=Object.getPrototypeOf,cs=Object.prototype.hasOwnProperty;var ds=(c,e,t)=>e in c?si(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var tr=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var us=(c,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of as(e))!cs.call(c,r)&&r!==t&&si(c,r,{get:()=>e[r],enumerable:!(i=os(e,r))||i.enumerable});return c};var hs=(c,e,t)=>(t=c!=null?ns(ls(c)):{},us(e||!c||!c.__esModule?si(t,"default",{value:c,enumerable:!0}):t,c));var E=(c,e,t)=>(ds(c,typeof e!="symbol"?e+"":e,t),t);var ts=tr((ff,Cn)=>{Cn.exports={}});var is=tr((Ki,Yi)=>{(function(c,e){typeof define=="function"&&define.amd?define([],e):typeof Ki<"u"?e():(e(),c.FileSaver={})})(Ki,function(){"use strict";function c(o,a){return typeof a>"u"?a={autoBom:!1}:typeof a!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(o.type)?new Blob(["\uFEFF",o],{type:o.type}):o}function e(o,a,l){var d=new XMLHttpRequest;d.open("GET",o),d.responseType="blob",d.onload=function(){n(d.response,a,l)},d.onerror=function(){console.error("could not download file")},d.send()}function t(o){var a=new XMLHttpRequest;a.open("HEAD",o,!1);try{a.send()}catch{}return 200<=a.status&&299>=a.status}function i(o){try{o.dispatchEvent(new MouseEvent("click"))}catch{var a=document.createEvent("MouseEvents");a.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(a)}}var r=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof global=="object"&&global.global===global?global:void 0,s=r.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),n=r.saveAs||(typeof window!="object"||window!==r?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(o,a,l){var d=r.URL||r.webkitURL,u=document.createElement("a");a=a||o.name||"download",u.download=a,u.rel="noopener",typeof o=="string"?(u.href=o,u.origin===location.origin?i(u):t(u.href)?e(o,a,l):i(u,u.target="_blank")):(u.href=d.createObjectURL(o),setTimeout(function(){d.revokeObjectURL(u.href)},4e4),setTimeout(function(){i(u)},0))}:"msSaveOrOpenBlob"in navigator?function(o,a,l){if(a=a||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(c(o,l),a);else if(t(o))e(o,a,l);else{var d=document.createElement("a");d.href=o,d.target="_blank",setTimeout(function(){i(d)})}}:function(o,a,l,d){if(d=d||open("","_blank"),d&&(d.document.title=d.document.body.innerText="downloading..."),typeof o=="string")return e(o,a,l);var u=o.type==="application/octet-stream",h=/constructor/i.test(r.HTMLElement)||r.safari,p=/CriOS\/[\d]+/.test(navigator.userAgent);if((p||u&&h||s)&&typeof FileReader<"u"){var f=new FileReader;f.onloadend=function(){var _=f.result;_=p?_:_.replace(/^data:[^;]*;/,"data:attachment/file;"),d?d.location.href=_:location=_,d=null},f.readAsDataURL(o)}else{var m=r.URL||r.webkitURL,b=m.createObjectURL(o);d?d.location=b:location.href=b,d=null,setTimeout(function(){m.revokeObjectURL(b)},4e4)}});r.saveAs=n.saveAs=n,typeof Yi<"u"&&(Yi.exports=n)})});var P=c=>typeof c=="object"&&typeof c.row<"u"&&typeof c.column<"u",ir=c=>typeof c=="object"&&P(c.start)&&P(c.end),g=class{start_;end_;constructor(e,t=e,i=!1){this.end_=this.PatchNull(t),this.start_=this.PatchNull(e),i&&this.Normalize()}static FromColumn(e){return new g({row:1/0,column:e})}static FromRow(e){return new g({row:e,column:1/0})}static ColumnToLabel(e){let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}static CellAddressToLabel(e,t=!1){return(t?`${e.sheet_id||0}!`:"")+(e.absolute_column?"$":"")+this.ColumnToLabel(e.column)+(e.absolute_row?"$":"")+(e.row+1)}static Join(e,...t){let i=new g(e.start,e.end);for(let r of t)r&&(i.ConsumeAddress(r.start),i.ConsumeAddress(r.end));return i}static Bleed(e,t=1){return new g({row:Math.max(0,e.start.row-t),column:Math.max(0,e.start.column-t),sheet_id:e.start.sheet_id},{row:e.end.row+t,column:e.end.column+t})}get start(){return{...this.start_}}set start(e){this.start_=e}get end(){return{...this.end_}}set end(e){this.end_=e}get rows(){return this.start_.row===1/0||this.end_.row===1/0?1/0:this.end_.row-this.start_.row+1}get columns(){return this.start_.column===1/0||this.end_.column===1/0?1/0:this.end_.column-this.start_.column+1}get count(){return this.rows*this.columns}get entire_sheet(){return this.entire_row&&this.entire_column}get entire_column(){return this.start_.row===1/0}get entire_row(){return this.start_.column===1/0}PatchNull(e){let t={...e};return t.row===null&&(t.row=1/0),t.column===null&&(t.column=1/0),t}SetSheetID(e){this.start_.sheet_id=e}Normalize(){let e={...this.start_},t={...this.end_};e.row===1/0||t.row===1/0?e.row=t.row=1/0:e.row>t.row&&(e.row=this.end_.row,e.absolute_row=this.end_.absolute_row,t.row=this.start_.row,t.absolute_row=this.start_.absolute_row),e.column===1/0||t.column===1/0?e.column=t.column=1/0:e.column>t.column&&(e.column=this.end_.column,e.absolute_column=this.end_.absolute_column,t.column=this.start_.column,t.absolute_column=this.start_.absolute_column),this.start_=e,this.end_=t}TopLeft(){let e={row:0,column:0};return this.entire_row||(e.column=this.start.column),this.entire_column||(e.row=this.start.row),e}BottomRight(){let e={row:0,column:0};return this.entire_row||(e.column=this.end.column),this.entire_column||(e.row=this.end.row),e}ContainsRow(e){return this.entire_column||e>=this.start_.row&&e<=this.end_.row}ContainsColumn(e){return this.entire_row||e>=this.start_.column&&e<=this.end_.column}Contains(e){return(this.entire_column||e.row>=this.start_.row&&e.row<=this.end_.row)&&(this.entire_row||e.column>=this.start_.column&&e.column<=this.end_.column)}ContainsArea(e){return this.start.column<=e.start.column&&this.end.column>=e.end.column&&this.start.row<=e.start.row&&this.end.row>=e.end.row}Intersects(e){return!(e.start.column>this.end.column||this.start.column>e.end.column||e.start.row>this.end.row||this.start.row>e.end.row)}Equals(e){return e.start_.row===this.start_.row&&e.start_.column===this.start_.column&&e.end_.row===this.end_.row&&e.end_.column===this.end_.column}Clone(){return new g(this.start,this.end)}Array(){if(this.entire_column||this.entire_row)throw new Error("can't convert infinite area to array");let e=new Array(this.rows*this.columns),t=this.start_.sheet_id,i=0;for(let r=this.start_.row;r<=this.end_.row;r++)for(let s=this.start_.column;s<=this.end_.column;s++)e[i++]={row:r,column:s,sheet_id:t};return e}get left(){let e=new g(this.start_,this.end_);return e.end_.column=e.start_.column,e}get right(){let e=new g(this.start_,this.end_);return e.start_.column=e.end_.column,e}get top(){let e=new g(this.start_,this.end_);return e.end_.row=e.start_.row,e}get bottom(){let e=new g(this.start_,this.end_);return e.start_.row=e.end_.row,e}Shift(e,t){return this.start_.row+=e,this.start_.column+=t,this.end_.row+=e,this.end_.column+=t,this}ConsumeAddress(e){this.entire_row||(e.column<this.start_.column&&(this.start_.column=e.column),e.column>this.end_.column&&(this.end_.column=e.column)),this.entire_column||(e.row<this.start_.row&&(this.start_.row=e.row),e.row>this.end_.row&&(this.end_.row=e.row))}ConsumeArea(e){this.ConsumeAddress(e.start),this.ConsumeAddress(e.end)}Resize(e,t){return this.end_.row=this.start_.row+e-1,this.end_.column=this.start_.column+t-1,this}Iterate(e){if(this.entire_column||this.entire_row){console.warn("don't iterate infinite area");return}for(let t=this.start_.column;t<=this.end_.column;t++)for(let i=this.start_.row;i<=this.end_.row;i++)e({column:t,row:i,sheet_id:this.start_.sheet_id})}get spreadsheet_label(){let e;return this.entire_sheet?"":this.entire_column?(e=g.ColumnToLabel(this.start_.column),e+=":"+g.ColumnToLabel(this.end_.column),e):this.entire_row?(e=String(this.start_.row+1),e+=":"+(this.end_.row+1),e):(e=g.CellAddressToLabel(this.start_),this.columns>1||this.rows>1?e+":"+g.CellAddressToLabel(this.end_):e)}toJSON(){return{start:{...this.start_},end:{...this.end_}}}};var ge=c=>typeof c=="object"&&!!c&&typeof c.real=="number"&&typeof c.imaginary=="number",Ge=c=>c.real?c.imaginary?c.imaginary>0?`${c.real} + ${c.imaginary}i`:`${c.real} - ${Math.abs(c.imaginary)}i`:c.real.toString():c.imaginary?c.imaginary+"i":"0",ni=c=>typeof c=="object"&&!!c&&typeof c.value=="number"&&typeof c.unit=="string";var re=c=>{switch(typeof c){case"undefined":return 0;case"number":return 3;case"boolean":return 4;case"object":return c===null?0:ge(c)?7:ni(c)?9:5;case"string":return c[0]==="="?1:2;default:return 6}};var ce=class{static StringToColumn(e){let t=0;e=e.toUpperCase();for(let i=0;i<e.length;i++)t*=26,t+=e.charCodeAt(i)-64;return t-1}value;type=0;calculated;calculated_type;formatted;rendered_type;style;area;merge_area;renderer_data;render_clean=[];note;hyperlink;editing;render_function;click_function;validation;constructor(e,t){typeof e<"u"&&this.Set(e,t)}ValueIsNumber(){return this.type===3}ValueIsFormula(){return this.type===1}ValueIsBoolean(){return this.type===4}ValueIsComplex(){return this.type===7}FlushStyle(){this.formatted=this.rendered_type=this.style=void 0,this.render_clean=[]}FlushArray(){this.area=void 0}FlushCache(){this.calculated=this.calculated_type=this.formatted=this.rendered_type=this.render_function=this.click_function=void 0,this.render_clean=[]}Reset(){this.type=0,this.value=this.note=this.hyperlink=this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.area=this.renderer_data=this.render_function=this.click_function=void 0,this.render_clean=[]}Set(e,t=re(e)){this.value=e,this.type=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.render_function=this.click_function=this.area=void 0,this.render_clean=[]}SetCalculatedValue(e,t=re(e)){this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}SetCalculatedValueOrError(e,t){typeof t>"u"&&(typeof e=="object"&&e.error?(t=6,e=e.error):t=re(e)),this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}GetValue(){return this.calculated_type?this.calculated:typeof this.value=="string"&&this.value[0]==="'"?this.value.slice(1):this.value}GetValue4(){return this.calculated_type?{type:this.calculated_type,value:this.calculated}:this.type===1?{type:3,value:0}:{type:this.type,value:typeof this.value=="string"&&this.value[0]==="'"?this.value.slice(1):this.value}}SetNote(e){this.note=e,this.render_clean=[]}SetCalculationError(e="ERR"){this.SetCalculatedValue(e,6)}SetArray(e){this.type=0,this.value=this.formatted=this.rendered_type=this.style=this.hyperlink=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}SetArrayHead(e,t){this.type=re(t),this.value=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}};var oi=c=>!c.cells,Qe=c=>!!c[0]&&oi(c[0]),ai=c=>!!c[0]&&c[0].row!==void 0,vt=class{data=[];rows_=0;columns_=0;get rows(){return this.rows_}get columns(){return this.columns_}EnsureRow(e){this.rows_=Math.max(e+1,this.rows_)}EnsureColumn(e){this.columns_=Math.max(e+1,this.columns_)}InsertColumns(e=0,t=1){let i=JSON.parse(JSON.stringify(this.data[13]));this.data=this.data.map(r=>{if(r.length>=e){let s=r.slice(0,e),n=e+t,o=r.slice(e);for(let a=0;a<o.length;a++)s[n++]=o[a];return s}return r}),this.columns_+=t}DeleteColumns(e,t=1){this.data.forEach(i=>i.splice(e,t)),this.columns_-=t}DeleteRows(e,t=1){this.data.splice(e,t),this.rows_-=t}InsertRows(e=0,t=1){let i=[e,0,[]];for(let r=1;r<t;r++)i.push([]);Array.prototype.splice.apply(this.data,i),this.rows_+=t}GetCell(e,t){let{row:i,column:r}=e;if(!this.data[i])if(t)this.data[i]=[],this.rows_=Math.max(this.rows_,i+1);else return;return this.data[i][r]||t&&(this.data[i][r]=new ce,this.columns_=Math.max(this.columns_,r+1)),this.data[i][r]}EnsureCell(e){let{row:t,column:i}=e,r=this.data[t];r||(this.data[t]=r=[],this.rows_=Math.max(this.rows_,t+1));let s=r[i];return s||(s=r[i]=new ce,this.columns_=Math.max(this.columns_,i+1)),s}FromArray(e=[],t=!1){this.data=[];let i=0,r=0;if(t){r=e.length;for(let s=0;s<r;s++){let n=e[s];i=Math.max(i,n.length);for(let o=0;o<n.length;o++)this.data[o]||(this.data[o]=[]),this.data[o][s]=new ce(n[o])}}else{i=e.length;for(let s=0;s<i;s++){let n=[],o=e[s];r=Math.max(r,o.length);for(let a=0;a<o.length;a++)n[a]=new ce(o[a]);this.data[s]=n}}this.rows_=i,this.columns_=r}FromJSON(e=[],t){if(this.data=[],!Qe(e)){let i=[];if(ai(e))for(let r of e)for(let s of r.cells)i.push({...s,row:r.row});else for(let r of e)for(let s of r.cells)i.push({...s,column:r.column});e=i}for(let i of e){this.data[i.row]||(this.data[i.row]=[]);let r=new ce(i.value);if(typeof i.calculated<"u"&&r.SetCalculatedValue(i.calculated,i.calculated_type),t&&typeof i.style_ref<"u"&&(r.style=t[i.style_ref]),typeof i.note<"u"&&(r.note=i.note),typeof i.hyperlink<"u"&&(r.hyperlink=i.hyperlink),this.data[i.row][i.column]&&this.data[i.row][i.column].area&&(r.area=this.data[i.row][i.column].area),this.data[i.row][i.column]=r,i.area){let s=new g(i.area.start,i.area.end);for(let n=s.start.row;n<=s.end.row;n++)for(let o=s.start.column;o<=s.end.column;o++)this.data[n]||(this.data[n]=[]),this.data[n][o]||(this.data[n][o]=new ce),this.data[n][o].area=s}if(i.merge_area){let s=new g(i.merge_area.start,i.merge_area.end);for(let n=s.start.row;n<=s.end.row;n++)for(let o=s.start.column;o<=s.end.column;o++)this.data[n]||(this.data[n]=[]),this.data[n][o]||(this.data[n][o]=new ce),this.data[n][o].merge_area=s}i.validation&&(r.validation=i.validation)}this.rows_=this.data.length,this.columns_=this.data.reduce((i,r)=>Math.max(i,r.length),0)}toJSON(e={}){let t=0,i=0,r=this.data.length-1,s;e.subset&&(t=e.subset.start.column,i=e.subset.start.row,r=e.subset.end.row);let n=[],o=-1,a=-1,l={},d={};for(let u=i;u<=r;u++)if(this.data[u]){let h=this.data[u];s=h.length-1,e.subset&&(s=e.subset.end.column);for(let p=t;p<=s;p++){let f=h[p],m=f&&f.merge_area&&f.merge_area.start.row===u&&f.merge_area.start.column===p,b=f&&f.area&&f.area.start.row===u&&f.area.start.column===p,_=f?f.type===2&&!f.value:!0;if(f&&(!_||e.preserve_empty_strings)&&(m||f.type||f.calculated_type&&e.expand_arrays||f.calculated_type&&e.calculated_value||f.validation||e.decorated_cells&&f.style&&(f.style.fill||f.style.border_bottom||f.style.border_top||f.style.border_left||f.style.border_right))){let y={row:u,column:p,value:f.value};f.note&&(y.note=f.note),f.hyperlink&&(y.hyperlink=f.hyperlink),e.preserve_type&&(y.type=f.type),e.sheet_id&&(y.sheet_id=e.sheet_id),e.calculated_value&&typeof f.calculated<"u"&&(y.calculated=f.calculated,(e.preserve_type||f.calculated_type===6)&&(y.calculated_type=f.calculated_type)),f.area&&b&&(y.area=f.area.toJSON()),f.merge_area&&(y.merge_area=f.merge_area.toJSON()),f.validation&&(y.validation=f.validation),e.cell_style_refs&&e.cell_style_refs[p]&&e.cell_style_refs[p][u]&&(y.style_ref=e.cell_style_refs[p][u],e.cell_style_refs[p][u]=0),l[u]=u,d[p]=p,o=Math.max(u,o),a=Math.max(p,a),n.push(y)}}}if(e.nested){let u=Object.keys(l),h=Object.keys(d);if(u.length<=h.length&&u.length){let p={},f=[];for(let m of n){let{row:b,..._}=m;p[m.row]||(p[m.row]=[]),p[m.row].push(_)}for(let m of u){let b=Number(m);f.push({row:b,cells:p[b]})}return{data:f,rows:o,columns:a+1}}else if(h.length){let p={},f=[];for(let m of n){let{column:b,..._}=m;p[m.column]||(p[m.column]=[]),p[m.column].push(_)}for(let m of h){let b=Number(m);f.push({column:b,cells:p[b]})}return{data:f,rows:o,columns:a+1}}}return{data:n,rows:o+1,columns:a+1}}GetAll(e=!1){return this.GetRange({row:0,column:0},{row:this.rows_-1,column:this.columns_-1},e)}Normalize2(e,t){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),t.column===1/0&&(t={...t,column:this.columns_-1}),t.row===1/0&&(t={...t,row:this.rows_-1}),{from:e,to:t}}Normalize1(e){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),e}RawValue(e,t=e){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].value:void 0;let i=[],r=this.data.slice(e.row,t.row+1),s=e.column,n=t.column+1;for(let o of r){let a=[];for(let l=s,d=0;l<n;l++,d++){let u=o[l];a.push(u?u.value:void 0)}i.push(a)}return i}GetRange(e,t,i=!1){if(t?{from:e,to:t}=this.Normalize2(e,t):e=this.Normalize1(e),!t||e===t||e.column===t.column&&e.row===t.row)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue():void 0;let r=[];if(i)for(let s=e.column;s<=t.column;s++){let n=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][s]?n.push(this.data[o][s].GetValue()):n.push(void 0);r.push(n)}else for(let s=e.row;s<=t.row;s++){let n=[];for(let o=e.column;o<=t.column;o++)this.data[s]&&this.data[s][o]?n.push(this.data[s][o].GetValue()):n.push(void 0);r.push(n)}return r}GetRange4(e,t=e,i=!1){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue4():{value:void 0,type:0};let r=[];if(i)for(let s=e.column;s<=t.column;s++){let n=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][s]?n.push(this.data[o][s].GetValue4()):n.push({type:0});r.push(n)}else for(let s=e.row;s<=t.row;s++){let n=[];for(let o=e.column;o<=t.column;o++)this.data[s]&&this.data[s][o]?n.push(this.data[s][o].GetValue4()):n.push({type:0});r.push(n)}return{type:8,value:r}}Apply(e,t,i=!1){if(P(e)&&(e=new g(e)),e.entire_column||e.entire_row)throw new Error("don't iterate infinite cells");let r=e.start,s=e.end;if(i)for(let n=r.row;n<=s.row;n++){this.data[n]||(this.data[n]=[]);let o=this.data[n];for(let a=r.column;a<=s.column;a++)o[a]||(o[a]=new ce),t(o[a],a,n)}else for(let n=r.row;n<=s.row;n++)if(this.data[n]){let o=this.data[n];for(let a=r.column;a<=s.column;a++)o[a]&&t(o[a],a,n)}}SetArea(e,t){if(ArrayBuffer.isView(t))throw new Error("ABIV");if(Array.isArray(t))for(let i=e.start.row,r=0;i<=e.end.row;i++,r++){this.data[i]||(this.data[i]=[]);let s=this.data[i];if(t[r])for(let n=e.start.column,o=0;n<=e.end.column;n++,o++)s[n]||(s[n]=new ce),s[n].Set(t[r][o])}else{let i=re(t);for(let r=e.start.row;r<=e.end.row;r++){this.data[r]||(this.data[r]=[]);let s=this.data[r];for(let n=e.start.column;n<=e.end.column;n++)s[n]||(s[n]=new ce),s[n].Set(t,i)}}this.rows_=Math.max(this.rows_,e.end.row+1),this.columns_=Math.max(this.columns_,e.end.column+1)}IterateAll(e){for(let t of this.data)if(t)for(let i of t)i&&e(i)}FlushCellStyles(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushStyle()}FlushCachedValues(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushCache()}};var T=class{static UpdateLocale(e){if(e)this.locale=e;else if(typeof self<"u"){let r=self?.document?.location;if(r&&r.search&&/locale=([^?&]+?)(?:\?|$|&)/.test(r.search)){let s=r.search.match(/locale=(.*?)(?:\?|$|&)/);s&&(this.locale=s[1]),console.info("override locale",this.locale)}else typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]?this.locale=navigator.languages[0]:this.locale=navigator.language)}let t=new Intl.NumberFormat(this.locale,{minimumFractionDigits:1}).format(3.3).replace(/\d/g,"");this.decimal_separator=t===","?",":".",this.decimal_separator===","?(this.argument_separator=";",this.grouping_separator=" "):(this.argument_separator=",",this.grouping_separator=",");let i=new Date(2e3,0,2,12,0,0,0);this.UpdateDateComponent(0,0,i),i=new Date(2e3,1,7,12,0,0,0),this.UpdateDateComponent(1,1,i),i=new Date(2e3,2,7,12,0,0,0),this.UpdateDateComponent(2,2,i),i=new Date(2e3,3,5,12,0,0,0),this.UpdateDateComponent(3,3,i),i=new Date(2e3,4,4,12,0,0,0),this.UpdateDateComponent(4,4,i),i=new Date(2e3,5,2,12,0,0,0),this.UpdateDateComponent(5,5,i),i=new Date(2e3,6,1,12,0,0,0),this.UpdateDateComponent(6,6,i),i=new Date(2e3,7,1,12,0,0,0),this.UpdateDateComponent(7,-1,i),i=new Date(2e3,8,1,12,0,0,0),this.UpdateDateComponent(8,-1,i),i=new Date(2e3,9,1,12,0,0,0),this.UpdateDateComponent(9,-1,i),i=new Date(2e3,10,1,12,0,0,0),this.UpdateDateComponent(10,-1,i),i=new Date(2e3,11,1,12,0,0,0),this.UpdateDateComponent(11,-1,i)}static UpdateDateComponent(e,t,i){t>=0&&(this.date_components.short_days[t]=i.toLocaleString(this.locale,{weekday:"short"}),this.date_components.long_days[t]=i.toLocaleString(this.locale,{weekday:"long"})),e>=0&&(this.date_components.short_months[e]=i.toLocaleString(this.locale,{month:"short"}),this.date_components.long_months[e]=i.toLocaleString(this.locale,{month:"long"}))}};E(T,"locale","en-us"),E(T,"decimal_separator","."),E(T,"argument_separator",","),E(T,"grouping_separator",","),E(T,"date_components",{short_days:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],long_days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],short_months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],long_months:["January","February","March","April","May","June","July","August","September","October","November","December"]});T.UpdateLocale();var z=class{constructor(e=0,t=0,i=0,r=0){this.left=e;this.top=t;this.width=i;this.height=r}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static Create(e){return new z(e.left||0,e.top||0,e.width||0,e.height||0)}static IsRectangle(e){return typeof e=="object"&&typeof e?.left=="number"&&typeof e?.top=="number"&&typeof e?.width=="number"&&typeof e?.height=="number"}Shift(e=0,t=0){return new z(this.left+e,this.top+t,this.width,this.height)}Scale(e=1,t=e){return new z(this.left*e,this.top*t,this.width*e,this.height*t)}Expand(e=0,t=0){return new z(this.left,this.top,this.width+e,this.height+t)}Combine(e){return new z(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right)-Math.min(this.left,e.left),Math.max(this.bottom,e.bottom)-Math.min(this.top,e.top))}CheckEdges(e,t,i=16){let r=0;return e-this.left<i&&(r|=1),this.right-e<i&&(r|=2),t-this.top<i&&(r|=4),this.bottom-t<i&&(r|=8),r}Contains(e,t,i=0){return e>=this.left-i&&e<=this.left+this.width+i&&t>=this.top-i&&t<=this.top+this.height+i}ContextFill(e){e.fillRect(this.left,this.top,this.width,this.height)}ContextStroke(e){e.strokeRect(this.left,this.top,this.width,this.height)}Clamp(e,t){return e=Math.min(Math.max(e,this.left),this.right),t=Math.min(Math.max(t,this.top),this.bottom),{x:e,y:t}}ApplyStyle(e){e.style.top=this.top+"px",e.style.left=this.left+"px",e.style.width=this.width+"px",e.style.height=this.height+"px"}toJSON(){return{top:this.top,left:this.left,width:this.width,height:this.height}}};var A;(p=>{let c=JSON.stringify({}),e;(y=>(y.None="",y.Left="left",y.Center="center",y.Right="right"))(e=p.HorizontalAlign||={});let t;(y=>(y.None="",y.Top="top",y.Bottom="bottom",y.Middle="middle"))(t=p.VerticalAlign||={}),p.DefaultProperties={horizontal_align:"",vertical_align:"",number_format:"General",nan:"NaN",font_size:{unit:"pt",value:10.5},font_face:"sans-serif",bold:!1,italic:!1,underline:!1,strike:!1,text:{theme:1},border_top:0,border_left:0,border_right:0,border_bottom:0},p.CompositeBorders=f=>({top:{width:f.border_top||0,color:f.border_top_fill||{}},left:{width:f.border_left||0,color:f.border_left_fill||{}},right:{width:f.border_right||0,color:f.border_right_fill||{}},bottom:{width:f.border_bottom||0,color:f.border_bottom_fill||{}}}),p.Merge=(f,m,b=!0)=>{let _=b?{...f,...m}:{...m};return JSON.parse(JSON.stringify(_))},p.Composite=f=>JSON.parse(JSON.stringify(f.reduce((m,b)=>({...m,...b}),{}))),p.Empty=f=>JSON.stringify(f)===c,p.ValidColor=f=>!!(f&&!f.none&&(f.text||f.theme||f.theme===0)),p.ParseFontSize=(f="",m="em")=>{let b=f.match(/(-*[\d.]+)\s*(\S*)/);if(b){let _=Number(b[1]);if(!_||isNaN(_)||_<0)return{};let y=b[2].toLowerCase()||m;if(y==="pt"||y==="em"||y==="%"||y==="px")return{font_size:{unit:y,value:_}}}return{}},p.RelativeFontSize=(f,m)=>{let b=12,_=12;switch(f.font_size?.unit){case"pt":if(!f.font_size.value)return 1;_=f.font_size.value;break;case"px":if(!f.font_size.value)return 1;_=Math.round(f.font_size.value*300/4)/100;break;case"em":return f.font_size.value||1;case"%":return(f.font_size.value||100)/100;default:return 1}switch(m.font_size?.unit){case"pt":if(!m.font_size.value)return 1;b=m.font_size.value;break;case"px":if(!m.font_size.value)return 1;b=Math.round(m.font_size.value*300/4)/100;break;default:return 1}return _/b},p.FontSize=(f,m=!0)=>{let b=f.font_size?.value;switch(f.font_size?.unit){case"pt":return(b||12)+"pt";case"px":return m?Math.round((b||16)*300/4)/100+"pt":(b||16)+"px";case"em":return(b||1)+"em";case"%":return(b||100)+"%"}return""},p.Font=(f,m=1)=>{let b=[];return f.bold&&b.push("bold"),f.italic&&b.push("italic"),b.push(((f.font_size?.value||0)*m).toFixed(2)+(f.font_size?.unit||"pt")),b.push(f.font_face||""),b.join(" ")}})(A||={});var li=c=>!!c&&Array.isArray(c)&&Array.isArray(c[0]),q=(c,e)=>(typeof e>"u"&&(e=re(c)),{value:c,type:e}),be=c=>c.imaginary?{type:7,value:c}:{type:3,value:c.real};var ci=class{Darken(e,t,i,r,s=!1){let{h:n,s:o,l:a}=this.RGBToHSL(e,t,i);return s?a-=a*r/100:a-=r/100,a=Math.max(0,Math.min(1,a)),this.HSLToRGB(n,o,a)}Lighten(e,t,i,r,s=!1){let{h:n,s:o,l:a}=this.RGBToHSL(e,t,i);return s?a+=a*r/100:a+=r/100,a=Math.max(0,Math.min(1,a)),this.HSLToRGB(n,o,a)}RGBToHSL(e,t,i){e/=255,t/=255,i/=255;let r=Math.max(e,t,i),s=Math.min(e,t,i),n=0,o=0,a=(r+s)/2;if(r===s)n=o=0;else{let l=r-s;switch(o=a>.5?l/(2-r-s):l/(r+s),r){case e:n=(t-i)/l+(t<i?6:0);break;case t:n=(i-e)/l+2;break;case i:n=(e-t)/l+4;break}n/=6}return{h:n*360,s:o,l:a}}HSLToRGB(e,t,i){let r,s,n;if(t===0)r=s=n=i;else{e=e/360;let o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;r=this.HueToRGB(a,o,e+1/3),s=this.HueToRGB(a,o,e),n=this.HueToRGB(a,o,e-1/3)}return{r:Math.round(r*255),g:Math.round(s*255),b:Math.round(n*255)}}HueToRGB(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*(2/3-i)*6:e}},et=new ci;var wt={grid_color:"red",note_marker_color:"#d2c500"},fe=(c,e)=>D(c,e,0),ps=(c,e,t)=>{c.tint_cache||(c.tint_cache=[]),c.tint_cache[e]||(c.tint_cache[e]={});let i=c.tint_cache[e][t];if(!i){let r=(c.theme_colors_rgb?c.theme_colors_rgb[e]:[0,0,0])||[0,0,0],s;t>0?s=et.Lighten(r[0],r[1],r[2],t*100,!0):s=et.Darken(r[0],r[1],r[2],-t*100,!0),i=`rgb(${s.r},${s.g},${s.b})`,c.tint_cache[e][t]=i}return i},D=(c,e,t)=>e?.text?e.text==="none"?"":e.text:e?.theme||e?.theme===0?e.tint?ps(c,e.theme,e.tint):c.theme_colors?c.theme_colors[e.theme]:"":(t||t===0)&&c.theme_colors?c.theme_colors[t]:"",fs=c=>{let e=10,t="pt",i=c.match(/^([\d.]+)(\D.*)$/);return i&&(e=Number(i[1]),t=i[2]),{value:e,unit:t}},rr=c=>{let{value:e,unit:t}=fs(c.fontSize||""),i={fill:{text:c.backgroundColor},text:{text:c.color},font_size:{unit:t,value:e},font_face:c.fontFamily};return/italic/i.test(c.font)&&(i.italic=!0),c.fontWeight==="700"&&(i.bold=!0),i},sr=c=>{let e=JSON.parse(JSON.stringify(wt)),t=(d,u)=>{let h=document.createElement("div");return h.setAttribute("class",u),d.appendChild(h),h},i=(d,u)=>window.getComputedStyle(t(d,u)),r=t(c,""),s=i.bind(0,r),n=s("grid-cells");e.grid_cell=rr(n),e.grid_color=n.stroke||"",n=s("grid-headers"),e.headers=rr(n),e.headers_grid_color=n.stroke,(!e.headers_grid_color||e.headers_grid_color==="none")&&(e.headers_grid_color=e.grid_color),n=s("note-marker"),e.note_marker_color=n.backgroundColor,r.style.color="rgba(1,2,3,.4)",n=s("");let o=n.color;e.theme_colors=[e.grid_cell.fill?.text||"rgb(255, 255, 255)",e.grid_cell.text?.text||"rgb(51, 51, 51)"];for(let d=1;d<32&&(n=s(`theme-color-${d}`),!(!n.color||n.color===o));d++)e.theme_colors.push(n.color);let a=document.createElement("canvas");a.width=3,a.height=3;let l=a.getContext("2d");return l&&(e.theme_colors_rgb=e.theme_colors.map(d=>{l.fillStyle=d,l.fillRect(0,0,3,3);let u=l.getImageData(1,1,1,1);return Array.from(u.data)})),r.parentElement?.removeChild(r),e};var st=/[\s-+=<>!()]/,cr=/['*\\]/,di=34,ui=39,ms=160,_s=32,bs=9,ys=10,gs=13,ve=48,tt=57,hi=46,pi=43,it=45,nr=40,fi=41,xt=44,vs=37,mi=95,Ct=36,ws=123,xs=125,or=91,ar=93,Cs=33,lr=59,Ss=35,He=65,rt=97,As=69,Rs=101,St=90,At=122,Es=105;var _i=192,bi=312,yi={"==":6,"!=":6,"<>":6,"=":6,"<":7,">":7,"<=":7,">=":7,"+":9,"-":9,"&":9,"*":10,"/":10,"^":11,":":13},ks=Object.keys(yi).sort((c,e)=>e.length-c.length),Ts={"-":100,"+":100},$e=class{argument_separator=",";decimal_mark=".";flags={spreadsheet_semantics:!0,dimensioned_quantities:!1,fractions:!0};r1c1_regex=/[rR]((?:\[[-+]{0,1}\d+\]|\d+))[cC]((?:\[[-+]{0,1}\d+\]|\d+))$/;argument_separator_char=xt;decimal_mark_char=hi;imaginary_char=Es;imaginary_number="i";id_counter=0;expression="";data=[];index=0;length=0;valid=!0;error_position;error;dependencies={addresses:{},ranges:{}};address_refcount={};full_reference_list=[];Walk(e,t){switch(e.type){case"address":case"missing":case"literal":case"complex":case"identifier":case"operator":t(e);return;case"dimensioned":t(e)&&(this.Walk(e.expression,t),this.Walk(e.unit,t));return;case"range":t(e)&&(this.Walk(e.start,t),this.Walk(e.end,t));return;case"binary":t(e)&&(this.Walk(e.left,t),this.Walk(e.right,t));return;case"unary":t(e)&&this.Walk(e.operand,t);return;case"group":t(e)&&e.elements.forEach(i=>this.Walk(i,t));return;case"call":t(e)&&e.args.forEach(i=>this.Walk(i,t))}}Transpose(e){let t=e.length,i=[],r=0;for(let s=0;s<t;s++)Array.isArray(e[s])&&(r=Math.max(r,e[s].length));for(let s=0;s<r;s++){i[s]=[];for(let n=0;n<t;n++)i[s][n]=e[n][s]}return i}Render(e,t={rows:0,columns:0},i="(missing)",r,s,n){let o=this.argument_separator+" ";s===","?o=", ":s===";"&&(o="; ");let a=this.imaginary_number;n&&(a=n);let l=r===","?",":".",d=this.decimal_mark===","?/,/:/\./;switch(e.type){case"address":return this.AddressLabel(e,t);case"range":return this.AddressLabel(e.start,t)+":"+this.AddressLabel(e.end,t);case"missing":return i;case"array":return"{"+this.Transpose(e.values).map(u=>u.map(h=>typeof h=="string"?'"'+h+'"':h).join(", ")).join("; ")+"}";case"binary":return this.Render(e.left,t,i,r,s)+" "+e.operator+" "+this.Render(e.right,t,i,r,s);case"unary":return e.operator+this.Render(e.operand,t,i,r,s);case"complex":if(e.real){let u=Math.abs(e.imaginary);return`${e.real||0}${e.imaginary<0?" - ":" + "}${u===1?"":u}i`}else return e.imaginary===-1?"-i":e.imaginary===1?"i":`${e.imaginary}i`;break;case"literal":if(typeof e.value=="string")return'"'+e.value.replace(/"/g,'""')+'"';if(r&&typeof e.value=="number")if(e.text){let u=e.text;return r===","&&this.decimal_mark==="."&&(u=u.replace(/,/g,"")),u.replace(d,l)}else return e.value.toString().replace(/\./,l);else if(e.text)return e.text;return e.value.toString();case"identifier":return e.name;case"operator":return"["+e.operator+"]";case"group":return e.explicit?"("+e.elements.map(u=>this.Render(u,t,i,r,s)).join(o)+")":e.elements.map(u=>this.Render(u,t,i,r,s)).join(o);case"call":return e.name+"("+e.args.map(u=>this.Render(u,t,i,r,s)).join(o)+")";case"dimensioned":return this.Render(e.expression)+" "+this.Render(e.unit)}return"??"}Parse(e){switch(e=e.trim(),e[0]==="="&&(e=e.substr(1).trim()),this.expression=e,this.data=[],this.length=e.length,this.index=0,this.valid=!0,this.error_position=void 0,this.error=void 0,this.dependencies.addresses={},this.dependencies.ranges={},this.address_refcount={},this.full_reference_list=[],this.id_counter=0,this.argument_separator){case";":this.argument_separator_char=lr;break;default:this.argument_separator_char=xt;break}switch(this.decimal_mark){case",":this.decimal_mark_char=xt;break;default:this.decimal_mark_char=hi;break}for(let r=0;r<this.length;r++)this.data[r]=e.charCodeAt(r);let t=this.ParseGeneric(),i={};for(let r of Object.keys(this.dependencies.addresses))this.address_refcount[r]&&(i[r]=this.dependencies.addresses[r]);return this.dependencies.addresses=i,{expression:t||void 0,valid:this.valid,error:this.error,error_position:this.error_position,dependencies:this.dependencies,separator:this.argument_separator,decimal_mark:this.decimal_mark,full_reference_list:this.full_reference_list.slice(0)}}ColumnLabel(e){if(e===1/0)return"";let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}AddressLabel(e,t){let i=e.column;!e.absolute_column&&e.column!==1/0&&(i+=t.columns);let r=e.row;if(!e.absolute_row&&e.row!==1/0&&(r+=t.rows),r<0||i<0||r===1/0&&i===1/0)return"#REF";let s="";return e.sheet&&(s=(st.test(e.sheet)?"'"+e.sheet+"'":e.sheet)+"!"),r===1/0?s+(e.absolute_column?"$":"")+this.ColumnLabel(i):i===1/0?s+(e.absolute_row?"$":"")+(r+1):s+(e.absolute_column?"$":"")+this.ColumnLabel(i)+(e.absolute_row?"$":"")+(r+1)}ParseGeneric(e=[0]){let t=[];for(;this.index<this.length;){let i=this.ParseNext(t.length===0);if(typeof i=="number"){if(e.some(r=>i===r))break;if(i===nr){this.index++;let r=this.ParseGeneric([fi]);this.index++,r&&t.push({type:"group",id:this.id_counter++,elements:[r],explicit:!0})}else{let r=this.ConsumeOperator();r?t.push(r):(this.error=`unexpected character [1]: ${String.fromCharCode(i)}, ${i}`,this.valid=!1,this.index++)}}else t.push(i)}if(t.length){if(t=this.BinaryToRange2(t),this.flags.fractions){let i=[],r=n=>n.type==="literal"&&typeof n.value=="number"&&n.value%1===0,s=0;for(;s<t.length-3;s++)if(r(t[s])&&r(t[s+1])&&t[s+2].type==="operator"&&t[s+2].operator==="/"&&r(t[s+3])){let n=t[s],o=t[s+1],a=t[s+3],l=(n.value<0?-1:1)*(o.value/a.value);s+=3,i.push({id:t[s].id,type:"literal",text:this.expression.substring(n.position,a.position+1),value:n.value+l,position:n.position})}else i.push(t[s]);for(;s<t.length;s++)i.push(t[s]);t=i}if(t=t.map(i=>i.type==="identifier"&&i.name===this.imaginary_number?{type:"complex",real:0,imaginary:1,position:i.position,text:i.name,id:this.id_counter++}:i),this.flags.dimensioned_quantities){let i=[],r;for(let s=0;s<t.length;s++){let n=t[s];if(!r)r=n;else if(n.type==="identifier"&&(r.type==="literal"||r.type==="group"||r.type==="call")){let o=n;for(;t[s+1]?.type==="identifier";)o.name+=" "+t[++s].name;i.push({type:"dimensioned",expression:r,unit:n,id:this.id_counter++}),r=void 0}else i.push(r),r=n}r&&i.push(r),t=i}}return t.length===0?null:t.length===1?t[0]:this.BinaryToComplex(this.ArrangeUnits(t))}UnitToAddress(e){if(e.type==="literal"){if(typeof e.value=="number"&&e.value>0&&!/\./.test(e.text||""))return{type:"address",position:e.position,label:e.value.toString(),row:e.value-1,id:this.id_counter++,column:1/0}}else{let t,i=e.name,r=i.split("!");if(r.length>1&&(t=r.slice(0,r.length-1).join("!"),i=i.substr(t.length+1),t[0]==="'"))if(t.length>1&&t[t.length-1]==="'")t=t.substr(1,t.length-2);else return;let s=i[0]==="$";i=(s?i.substr(1):i).toUpperCase();let n=Number(i);if(isNaN(n)){if(/[A-Z]{1,3}/.test(i)){let o=-1;for(let a=0;a<i.length;a++){let l=i[a].charCodeAt(0);o=26*(1+o)+(l-He)}return{type:"address",position:e.position,absolute_column:s,label:e.name,column:o,id:this.id_counter++,row:1/0,sheet:t}}}else if(n>0&&n!==1/0&&!/\./.test(i))return{type:"address",position:e.position,absolute_row:s,label:e.name,row:n-1,id:this.id_counter++,column:1/0,sheet:t}}}BinaryToRange2(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],s=e[i+1],n=e[i+2],o,a="",l;if(r&&s&&n&&s.type==="operator"&&s.operator===":"){if(r.type==="address"&&n.type==="address"){let d=r.position+r.label.length,u=n.position;o={type:"range",id:this.id_counter++,position:r.position,start:r,end:n,label:r.label+this.expression.substring(d,u)+n.label},a=o.start.label+":"+o.end.label,this.address_refcount[o.start.label]--,this.address_refcount[o.end.label]--;let h=[r.position,n.position];this.full_reference_list=this.full_reference_list.filter(p=>p.position!==h[0]&&p.position!==h[1])}else if((r.type==="literal"||r.type==="identifier")&&(n.type==="literal"||n.type==="identifier")){let d=this.UnitToAddress(r);if(!d&&r.type==="literal"&&typeof r.value=="number"&&r.value<0){let h={...r,text:(r.text||"").replace(/^-/,""),position:r.position+1,value:-r.value};d=this.UnitToAddress(h),d&&(l={type:"operator",operator:"-",position:r.position,id:this.id_counter++})}let u=this.UnitToAddress(n);d&&u&&(d.column===1/0&&u.column===1/0||d.row===1/0&&u.row===1/0)&&(a=d.label+":"+u.label,o={type:"range",id:this.id_counter++,position:d.position,start:d,end:u,label:a})}}o?(l&&t.push(l),t.push(o),this.dependencies.ranges[a]=o,this.full_reference_list.push(o),i+=2):t.push(r)}return t}BinaryToComplex(e){if(e.type==="binary")if((e.operator==="+"||e.operator==="-")&&e.left.type==="literal"&&typeof e.left.value=="number"&&e.right.type==="complex"&&!e.right.composited){let t="";t=this.expression.substring(e.left.position,e.right.position+(e.right.text?.length||0));let i=e.right.imaginary;return e.operator==="-"&&(i=-i),{type:"complex",position:e.left.position,text:t,id:this.id_counter++,imaginary:i,real:e.left.value,composited:!0}}else e.left=this.BinaryToComplex(e.left),e.right=this.BinaryToComplex(e.right);else if(e.type==="unary"&&(e.operator==="-"||e.operator==="+")&&e.operand.type==="complex"&&e.operand.text===this.imaginary_number)return{...e.operand,position:e.position,text:this.expression.substring(e.position,e.operand.position+(e.operand.text||"").length),imaginary:e.operand.imaginary*(e.operator==="-"?-1:1)};return e}BinaryToRangeX(e){if(e.type==="binary"){if(e.operator===":"){let t,i="";if(e.left.type==="address"&&e.right.type==="address"){let r=e.left.position+e.left.label.length,s=e.right.position;t={type:"range",id:this.id_counter++,position:e.left.position,start:e.left,end:e.right,label:e.left.label+this.expression.substring(r,s)+e.right.label},i=t.start.label+":"+t.end.label,this.address_refcount[t.start.label]--,this.address_refcount[t.end.label]--;let n=[e.left.position,e.right.position];this.full_reference_list=this.full_reference_list.filter(o=>o.position!==n[0]&&o.position!==n[1])}else if((e.left.type==="literal"||e.left.type==="identifier")&&(e.right.type==="literal"||e.right.type==="identifier")){let r=this.UnitToAddress(e.left),s=this.UnitToAddress(e.right);r&&s&&(r.column===1/0&&s.column===1/0||r.row===1/0&&s.row===1/0)&&(i=r.label+":"+s.label,t={type:"range",id:this.id_counter++,position:e.left.position,start:r,end:s,label:i})}if(t)return this.dependencies.ranges[i]=t,this.full_reference_list.push(t),t;this.error="unexpected character: :",this.valid=!1}e.left=this.BinaryToRangeX(e.left),e.right=this.BinaryToRangeX(e.right)}return e}ArrangeUnits(e){if(e.length===0)return{type:"missing",id:this.id_counter++};if(e.length===1)return e[0];let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(r.type==="operator")if(t.length===0||t[t.length-1].type==="operator")if(Ts[r.operator]){let s=this.BinaryToComplex(this.ArrangeUnits(e.slice(i+1)));if(!this.valid)return{type:"group",id:this.id_counter++,elements:e,explicit:!1};s.type==="binary"?(s.left={type:"unary",id:this.id_counter++,operator:r.operator,operand:s.left,position:r.position},r=s):r={type:"unary",id:this.id_counter++,operator:r.operator,operand:s,position:r.position},i=e.length}else return this.error=`unexpected character [2]: ${r.operator}`,this.error_position=r.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1};else{t.push(r);continue}if(t.length<2)t.push(r);else if(t[t.length-1].type==="operator"){let s=t[t.length-2],n=t[t.length-1],o=n.operator,a={type:"binary",id:this.id_counter++,left:s,operator:o,position:n.position,right:r};s.type==="binary"&&yi[o]>yi[s.operator]&&(a.left=s.left,a.operator=s.operator,a.position=s.position,a.right={type:"binary",id:this.id_counter++,left:s.right,right:r,operator:o,position:n.position}),t.splice(-2,2,a)}else return this.error="multiple expressions",this.error_position=r.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1}}return t[0]}ParseNext(e=!0){this.ConsumeWhiteSpace();let t=this.data[this.index];if(t===di)return{type:"literal",id:this.id_counter++,position:this.index,value:this.ConsumeString()};if(t>=ve&&t<=tt||t===this.decimal_mark_char)return this.ConsumeNumber();if(t===ws)return this.ConsumeArray();if(e&&(t===it||t===pi)){let i=this.data[this.index+1];if(i>=ve&&i<=tt||i===this.decimal_mark_char)return this.ConsumeNumber()}else if(t>=He&&t<=St||t>=rt&&t<=At||t===mi||t===Ss||t===ui||t===Ct||t>=_i&&t<=bi)return this.ConsumeToken(t);return t}ConsumeArray(){let e={type:"array",id:this.id_counter++,values:[],position:this.index};this.index++;let t=0,i=0;for(;this.index<this.length;){let r=this.ParseNext(),s=this.index;if(typeof r=="number")switch(this.index++,r){case lr:i++,t=0;break;case xt:t++;break;case xs:return e;default:this.valid&&(this.error="invalid character in array literal",this.error_position=s,this.valid=!1);break}else switch(r.type){case"literal":e.values[t]||(e.values[t]=[]),e.values[t][i]=r.value;break;default:this.valid&&(this.error="invalid value in array literal",this.error_position=s,this.valid=!1);break}}return e}ConsumeOperator(){for(let e of ks)if(this.expression.substr(this.index,e.length)===e){let t=this.index;return this.index+=e.length,{type:"operator",id:this.id_counter++,operator:e,position:t}}return null}ConsumeArguments(){this.index++;let e=0,t=[];for(;this.index<this.length;){let i=this.ParseGeneric([this.argument_separator_char,fi]);i!==null&&t.push(i);let r=this.data[this.index];if(r===this.argument_separator_char){this.index++,e++;for(let s=t.length;s<e;s++)t.push({type:"missing",id:this.id_counter++})}else if(r===fi)return this.index++,t}return t}ConsumeToken(e){let t=[e],i=this.index,r=e===ui,s=!1;for(++this.index;this.index<this.length;this.index++){let l=this.data[this.index];if(l>=He&&l<=St||l>=rt&&l<=At||l>=_i&&l<=bi||l===mi||l===Ct||l===hi||l===Cs||r||l>=ve&&l<=tt||this.flags.r1c1&&(l===or||l===ar||l===it&&s))t.push(l),l===or&&(s=!0),l===ar&&(s=!1),l===ui&&(r=!1);else break}let n=t.map(l=>String.fromCharCode(l)).join("");if(r)return this.error="unbalanced single quote",this.error_position=i,this.valid=!1,{type:"identifier",id:this.id_counter++,name:n,position:i};if(n.toLowerCase()==="true")return{type:"literal",id:this.id_counter++,value:!0,position:i};if(n.toLowerCase()==="false")return{type:"literal",id:this.id_counter++,value:!1,position:i};if(this.ConsumeWhiteSpace(),this.data[this.index]===nr){let l=this.ConsumeArguments();return{type:"call",id:this.id_counter++,name:n,args:l,position:i}}if(this.flags.spreadsheet_semantics){let l=this.ConsumeAddress(n,i);if(l)return l}let a={type:"identifier",id:this.id_counter++,name:n,position:i};return this.full_reference_list.push(a),a}ConsumeAddress(e,t){let i=t,r=e.length,s,n=e.split("!");if(n.length>1&&(s=n.slice(0,n.length-1).join("!"),t+=s.length+1),this.flags.r1c1){let u=n[n.length-1].match(this.r1c1_regex);if(u){let h={type:"address",id:this.id_counter++,label:e,row:0,column:0,position:i,sheet:s,r1c1:!0};return u[1][0]==="["?(h.offset_row=!0,h.row=Number(u[1].substring(1,u[1].length-1))):h.row=Number(u[1])-1,u[2][0]==="["?(h.offset_column=!0,h.column=Number(u[2].substring(1,u[2].length-1))):h.column=Number(u[2])-1,h}}let o=this.ConsumeAddressColumn(t);if(!o)return null;t=o.position;let a=this.ConsumeAddressRow(t);if(!a)return null;t=a.position;let l=s?s+e.substr(s.length,t-i).toUpperCase():e.substr(0,t-i).toUpperCase();s&&s[0]==="'"&&(s=s.substr(1,s.length-2));let d={type:"address",id:this.id_counter++,label:l,row:a.row,column:o.column,absolute_row:a.absolute,absolute_column:o.absolute,position:i,sheet:s};return r!==t-i?null:(this.dependencies.addresses[d.label]=d,this.address_refcount[d.label]=(this.address_refcount[d.label]||0)+1,this.full_reference_list.push(d),d)}ConsumeAddressRow(e){let t=this.data[e]===Ct;t&&e++;let i=e,r=0;for(;;e++){let s=this.data[e];if(s>=ve&&s<=tt)r*=10,r+=s-ve;else break}return i===e?!1:{absolute:t,row:r-1,position:e}}ConsumeAddressColumn(e){let t=-1,i=0,r=this.data[e]===Ct;for(r&&e++;;e++,i++){if(i>=4)return!1;let s=this.data[e];if(s>=He&&s<=St)t=26*(1+t)+(s-He);else if(s>=rt&&s<=At)t=26*(1+t)+(s-rt);else break}return t<0?!1:{absolute:r,column:t,position:e}}ConsumeNumber(){let e=this.index,t=0,i=!1,r=!1,s=0,n=0,o=0,a="integer",l=0,d=!1,u=this.index;for(;this.index<this.length;this.index++,l++){let p=this.data[this.index];if(p===this.decimal_mark_char)if(a==="integer")a="fraction";else break;else if(p===vs){s/=100,o/=100,this.index++;break}else if(p===pi||p===it)if(l===0)p===it&&(r=!0);else break;else if(p===As||p===Rs)if(a==="integer"||a==="fraction")a="exponent",this.index<this.length-1&&(this.data[this.index+1]===pi?this.index++:this.data[this.index+1]===it&&(this.index++,i=!0));else break;else if(p===this.imaginary_char){let f=this.data[this.index+1];if(f>=He&&f<=St||f>=rt&&f<=At||f>=_i&&f<=bi||f===mi)break;if(a==="integer"||a==="fraction"){this.index++,d=!0;break}}else if(p>=ve&&p<=tt)switch(a){case"integer":s=s*10+(p-ve);break;case"fraction":o=o*10+(p-ve),n++;break;case"exponent":t=t*10+(p-ve);break}else break}let h=s+o/Math.pow(10,n);return a==="exponent"&&(h=h*Math.pow(10,(i?-1:1)*t)),d?{type:"complex",id:this.id_counter++,position:e,imaginary:r?-h:h,real:0,text:this.expression.substring(u,this.index)||""}:{type:"literal",id:this.id_counter++,position:e,value:r?-h:h,text:this.expression.substring(u,this.index)||""}}ConsumeString(){this.index++;let e=[];for(;this.index<this.length;this.index++){let t=this.data[this.index];if(t===di&&(this.index++,this.index>=this.length||this.data[this.index]!==di))break;e.push(t)}return e.map(t=>String.fromCharCode(t)).join("")}ConsumeWhiteSpace(){for(;this.index<this.length;){let e=this.data[this.index];if(e===_s||e===bs||e===ys||e===gs||e===ms)this.index++;else return}}};var dr=(c,e=",")=>{let t=0,i=[],r="",s=[],n=c.length;if(/[\r\n"]/.test(e))throw new Error("invalid delimiter");for(let o=0;o<n;o++){let a=c[o];if(t===0)switch(a){case e:i.push(r),r="";break;case"\r":break;case`
|
|
1
|
+
/*! TREB v21.6.5. Copyright 2018-2022 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
|
|
2
|
+
var ns=Object.create;var si=Object.defineProperty;var os=Object.getOwnPropertyDescriptor;var as=Object.getOwnPropertyNames;var ls=Object.getPrototypeOf,cs=Object.prototype.hasOwnProperty;var ds=(c,e,t)=>e in c?si(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t;var tr=(c,e)=>()=>(e||c((e={exports:{}}).exports,e),e.exports);var us=(c,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of as(e))!cs.call(c,r)&&r!==t&&si(c,r,{get:()=>e[r],enumerable:!(i=os(e,r))||i.enumerable});return c};var hs=(c,e,t)=>(t=c!=null?ns(ls(c)):{},us(e||!c||!c.__esModule?si(t,"default",{value:c,enumerable:!0}):t,c));var E=(c,e,t)=>(ds(c,typeof e!="symbol"?e+"":e,t),t);var ts=tr((ff,Cn)=>{Cn.exports={}});var is=tr((Ki,Yi)=>{(function(c,e){typeof define=="function"&&define.amd?define([],e):typeof Ki<"u"?e():(e(),c.FileSaver={})})(Ki,function(){"use strict";function c(o,a){return typeof a>"u"?a={autoBom:!1}:typeof a!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(o.type)?new Blob(["\uFEFF",o],{type:o.type}):o}function e(o,a,l){var d=new XMLHttpRequest;d.open("GET",o),d.responseType="blob",d.onload=function(){n(d.response,a,l)},d.onerror=function(){console.error("could not download file")},d.send()}function t(o){var a=new XMLHttpRequest;a.open("HEAD",o,!1);try{a.send()}catch{}return 200<=a.status&&299>=a.status}function i(o){try{o.dispatchEvent(new MouseEvent("click"))}catch{var a=document.createEvent("MouseEvents");a.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),o.dispatchEvent(a)}}var r=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof global=="object"&&global.global===global?global:void 0,s=r.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),n=r.saveAs||(typeof window!="object"||window!==r?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(o,a,l){var d=r.URL||r.webkitURL,u=document.createElement("a");a=a||o.name||"download",u.download=a,u.rel="noopener",typeof o=="string"?(u.href=o,u.origin===location.origin?i(u):t(u.href)?e(o,a,l):i(u,u.target="_blank")):(u.href=d.createObjectURL(o),setTimeout(function(){d.revokeObjectURL(u.href)},4e4),setTimeout(function(){i(u)},0))}:"msSaveOrOpenBlob"in navigator?function(o,a,l){if(a=a||o.name||"download",typeof o!="string")navigator.msSaveOrOpenBlob(c(o,l),a);else if(t(o))e(o,a,l);else{var d=document.createElement("a");d.href=o,d.target="_blank",setTimeout(function(){i(d)})}}:function(o,a,l,d){if(d=d||open("","_blank"),d&&(d.document.title=d.document.body.innerText="downloading..."),typeof o=="string")return e(o,a,l);var u=o.type==="application/octet-stream",h=/constructor/i.test(r.HTMLElement)||r.safari,p=/CriOS\/[\d]+/.test(navigator.userAgent);if((p||u&&h||s)&&typeof FileReader<"u"){var f=new FileReader;f.onloadend=function(){var _=f.result;_=p?_:_.replace(/^data:[^;]*;/,"data:attachment/file;"),d?d.location.href=_:location=_,d=null},f.readAsDataURL(o)}else{var m=r.URL||r.webkitURL,b=m.createObjectURL(o);d?d.location=b:location.href=b,d=null,setTimeout(function(){m.revokeObjectURL(b)},4e4)}});r.saveAs=n.saveAs=n,typeof Yi<"u"&&(Yi.exports=n)})});var P=c=>typeof c=="object"&&typeof c.row<"u"&&typeof c.column<"u",ir=c=>typeof c=="object"&&P(c.start)&&P(c.end),g=class{start_;end_;constructor(e,t=e,i=!1){this.end_=this.PatchNull(t),this.start_=this.PatchNull(e),i&&this.Normalize()}static FromColumn(e){return new g({row:1/0,column:e})}static FromRow(e){return new g({row:e,column:1/0})}static ColumnToLabel(e){let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}static CellAddressToLabel(e,t=!1){return(t?`${e.sheet_id||0}!`:"")+(e.absolute_column?"$":"")+this.ColumnToLabel(e.column)+(e.absolute_row?"$":"")+(e.row+1)}static Join(e,...t){let i=new g(e.start,e.end);for(let r of t)r&&(i.ConsumeAddress(r.start),i.ConsumeAddress(r.end));return i}static Bleed(e,t=1){return new g({row:Math.max(0,e.start.row-t),column:Math.max(0,e.start.column-t),sheet_id:e.start.sheet_id},{row:e.end.row+t,column:e.end.column+t})}get start(){return{...this.start_}}set start(e){this.start_=e}get end(){return{...this.end_}}set end(e){this.end_=e}get rows(){return this.start_.row===1/0||this.end_.row===1/0?1/0:this.end_.row-this.start_.row+1}get columns(){return this.start_.column===1/0||this.end_.column===1/0?1/0:this.end_.column-this.start_.column+1}get count(){return this.rows*this.columns}get entire_sheet(){return this.entire_row&&this.entire_column}get entire_column(){return this.start_.row===1/0}get entire_row(){return this.start_.column===1/0}PatchNull(e){let t={...e};return t.row===null&&(t.row=1/0),t.column===null&&(t.column=1/0),t}SetSheetID(e){this.start_.sheet_id=e}Normalize(){let e={...this.start_},t={...this.end_};e.row===1/0||t.row===1/0?e.row=t.row=1/0:e.row>t.row&&(e.row=this.end_.row,e.absolute_row=this.end_.absolute_row,t.row=this.start_.row,t.absolute_row=this.start_.absolute_row),e.column===1/0||t.column===1/0?e.column=t.column=1/0:e.column>t.column&&(e.column=this.end_.column,e.absolute_column=this.end_.absolute_column,t.column=this.start_.column,t.absolute_column=this.start_.absolute_column),this.start_=e,this.end_=t}TopLeft(){let e={row:0,column:0};return this.entire_row||(e.column=this.start.column),this.entire_column||(e.row=this.start.row),e}BottomRight(){let e={row:0,column:0};return this.entire_row||(e.column=this.end.column),this.entire_column||(e.row=this.end.row),e}ContainsRow(e){return this.entire_column||e>=this.start_.row&&e<=this.end_.row}ContainsColumn(e){return this.entire_row||e>=this.start_.column&&e<=this.end_.column}Contains(e){return(this.entire_column||e.row>=this.start_.row&&e.row<=this.end_.row)&&(this.entire_row||e.column>=this.start_.column&&e.column<=this.end_.column)}ContainsArea(e){return this.start.column<=e.start.column&&this.end.column>=e.end.column&&this.start.row<=e.start.row&&this.end.row>=e.end.row}Intersects(e){return!(e.start.column>this.end.column||this.start.column>e.end.column||e.start.row>this.end.row||this.start.row>e.end.row)}Equals(e){return e.start_.row===this.start_.row&&e.start_.column===this.start_.column&&e.end_.row===this.end_.row&&e.end_.column===this.end_.column}Clone(){return new g(this.start,this.end)}Array(){if(this.entire_column||this.entire_row)throw new Error("can't convert infinite area to array");let e=new Array(this.rows*this.columns),t=this.start_.sheet_id,i=0;for(let r=this.start_.row;r<=this.end_.row;r++)for(let s=this.start_.column;s<=this.end_.column;s++)e[i++]={row:r,column:s,sheet_id:t};return e}get left(){let e=new g(this.start_,this.end_);return e.end_.column=e.start_.column,e}get right(){let e=new g(this.start_,this.end_);return e.start_.column=e.end_.column,e}get top(){let e=new g(this.start_,this.end_);return e.end_.row=e.start_.row,e}get bottom(){let e=new g(this.start_,this.end_);return e.start_.row=e.end_.row,e}Shift(e,t){return this.start_.row+=e,this.start_.column+=t,this.end_.row+=e,this.end_.column+=t,this}ConsumeAddress(e){this.entire_row||(e.column<this.start_.column&&(this.start_.column=e.column),e.column>this.end_.column&&(this.end_.column=e.column)),this.entire_column||(e.row<this.start_.row&&(this.start_.row=e.row),e.row>this.end_.row&&(this.end_.row=e.row))}ConsumeArea(e){this.ConsumeAddress(e.start),this.ConsumeAddress(e.end)}Resize(e,t){return this.end_.row=this.start_.row+e-1,this.end_.column=this.start_.column+t-1,this}Iterate(e){if(this.entire_column||this.entire_row){console.warn("don't iterate infinite area");return}for(let t=this.start_.column;t<=this.end_.column;t++)for(let i=this.start_.row;i<=this.end_.row;i++)e({column:t,row:i,sheet_id:this.start_.sheet_id})}get spreadsheet_label(){let e;return this.entire_sheet?"":this.entire_column?(e=g.ColumnToLabel(this.start_.column),e+=":"+g.ColumnToLabel(this.end_.column),e):this.entire_row?(e=String(this.start_.row+1),e+=":"+(this.end_.row+1),e):(e=g.CellAddressToLabel(this.start_),this.columns>1||this.rows>1?e+":"+g.CellAddressToLabel(this.end_):e)}toJSON(){return{start:{...this.start_},end:{...this.end_}}}};var ge=c=>typeof c=="object"&&!!c&&typeof c.real=="number"&&typeof c.imaginary=="number",Ge=c=>c.real?c.imaginary?c.imaginary>0?`${c.real} + ${c.imaginary}i`:`${c.real} - ${Math.abs(c.imaginary)}i`:c.real.toString():c.imaginary?c.imaginary+"i":"0",ni=c=>typeof c=="object"&&!!c&&typeof c.value=="number"&&typeof c.unit=="string";var re=c=>{switch(typeof c){case"undefined":return 0;case"number":return 3;case"boolean":return 4;case"object":return c===null?0:ge(c)?7:ni(c)?9:5;case"string":return c[0]==="="?1:2;default:return 6}};var ce=class{static StringToColumn(e){let t=0;e=e.toUpperCase();for(let i=0;i<e.length;i++)t*=26,t+=e.charCodeAt(i)-64;return t-1}value;type=0;calculated;calculated_type;formatted;rendered_type;style;area;merge_area;renderer_data;render_clean=[];note;hyperlink;editing;render_function;click_function;validation;constructor(e,t){typeof e<"u"&&this.Set(e,t)}ValueIsNumber(){return this.type===3}ValueIsFormula(){return this.type===1}ValueIsBoolean(){return this.type===4}ValueIsComplex(){return this.type===7}FlushStyle(){this.formatted=this.rendered_type=this.style=void 0,this.render_clean=[]}FlushArray(){this.area=void 0}FlushCache(){this.calculated=this.calculated_type=this.formatted=this.rendered_type=this.render_function=this.click_function=void 0,this.render_clean=[]}Reset(){this.type=0,this.value=this.note=this.hyperlink=this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.area=this.renderer_data=this.render_function=this.click_function=void 0,this.render_clean=[]}Set(e,t=re(e)){this.value=e,this.type=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.render_function=this.click_function=this.area=void 0,this.render_clean=[]}SetCalculatedValue(e,t=re(e)){this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}SetCalculatedValueOrError(e,t){typeof t>"u"&&(typeof e=="object"&&e.error?(t=6,e=e.error):t=re(e)),this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}GetValue(){return this.calculated_type?this.calculated:typeof this.value=="string"&&this.value[0]==="'"?this.value.slice(1):this.value}GetValue4(){return this.calculated_type?{type:this.calculated_type,value:this.calculated}:this.type===1?{type:3,value:0}:{type:this.type,value:typeof this.value=="string"&&this.value[0]==="'"?this.value.slice(1):this.value}}SetNote(e){this.note=e,this.render_clean=[]}SetCalculationError(e="ERR"){this.SetCalculatedValue(e,6)}SetArray(e){this.type=0,this.value=this.formatted=this.rendered_type=this.style=this.hyperlink=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}SetArrayHead(e,t){this.type=re(t),this.value=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}};var oi=c=>!c.cells,Qe=c=>!!c[0]&&oi(c[0]),ai=c=>!!c[0]&&c[0].row!==void 0,vt=class{data=[];rows_=0;columns_=0;get rows(){return this.rows_}get columns(){return this.columns_}EnsureRow(e){this.rows_=Math.max(e+1,this.rows_)}EnsureColumn(e){this.columns_=Math.max(e+1,this.columns_)}InsertColumns(e=0,t=1){let i=JSON.parse(JSON.stringify(this.data[13]));this.data=this.data.map(r=>{if(r.length>=e){let s=r.slice(0,e),n=e+t,o=r.slice(e);for(let a=0;a<o.length;a++)s[n++]=o[a];return s}return r}),this.columns_+=t}DeleteColumns(e,t=1){this.data.forEach(i=>i.splice(e,t)),this.columns_-=t}DeleteRows(e,t=1){this.data.splice(e,t),this.rows_-=t}InsertRows(e=0,t=1){let i=[e,0,[]];for(let r=1;r<t;r++)i.push([]);Array.prototype.splice.apply(this.data,i),this.rows_+=t}GetCell(e,t){let{row:i,column:r}=e;if(!this.data[i])if(t)this.data[i]=[],this.rows_=Math.max(this.rows_,i+1);else return;return this.data[i][r]||t&&(this.data[i][r]=new ce,this.columns_=Math.max(this.columns_,r+1)),this.data[i][r]}EnsureCell(e){let{row:t,column:i}=e,r=this.data[t];r||(this.data[t]=r=[],this.rows_=Math.max(this.rows_,t+1));let s=r[i];return s||(s=r[i]=new ce,this.columns_=Math.max(this.columns_,i+1)),s}FromArray(e=[],t=!1){this.data=[];let i=0,r=0;if(t){r=e.length;for(let s=0;s<r;s++){let n=e[s];i=Math.max(i,n.length);for(let o=0;o<n.length;o++)this.data[o]||(this.data[o]=[]),this.data[o][s]=new ce(n[o])}}else{i=e.length;for(let s=0;s<i;s++){let n=[],o=e[s];r=Math.max(r,o.length);for(let a=0;a<o.length;a++)n[a]=new ce(o[a]);this.data[s]=n}}this.rows_=i,this.columns_=r}FromJSON(e=[],t){if(this.data=[],!Qe(e)){let i=[];if(ai(e))for(let r of e)for(let s of r.cells)i.push({...s,row:r.row});else for(let r of e)for(let s of r.cells)i.push({...s,column:r.column});e=i}for(let i of e){this.data[i.row]||(this.data[i.row]=[]);let r=new ce(i.value);if(typeof i.calculated<"u"&&r.SetCalculatedValue(i.calculated,i.calculated_type),t&&typeof i.style_ref<"u"&&(r.style=t[i.style_ref]),typeof i.note<"u"&&(r.note=i.note),typeof i.hyperlink<"u"&&(r.hyperlink=i.hyperlink),this.data[i.row][i.column]&&this.data[i.row][i.column].area&&(r.area=this.data[i.row][i.column].area),this.data[i.row][i.column]=r,i.area){let s=new g(i.area.start,i.area.end);for(let n=s.start.row;n<=s.end.row;n++)for(let o=s.start.column;o<=s.end.column;o++)this.data[n]||(this.data[n]=[]),this.data[n][o]||(this.data[n][o]=new ce),this.data[n][o].area=s}if(i.merge_area){let s=new g(i.merge_area.start,i.merge_area.end);for(let n=s.start.row;n<=s.end.row;n++)for(let o=s.start.column;o<=s.end.column;o++)this.data[n]||(this.data[n]=[]),this.data[n][o]||(this.data[n][o]=new ce),this.data[n][o].merge_area=s}i.validation&&(r.validation=i.validation)}this.rows_=this.data.length,this.columns_=this.data.reduce((i,r)=>Math.max(i,r.length),0)}toJSON(e={}){let t=0,i=0,r=this.data.length-1,s;e.subset&&(t=e.subset.start.column,i=e.subset.start.row,r=e.subset.end.row);let n=[],o=-1,a=-1,l={},d={};for(let u=i;u<=r;u++)if(this.data[u]){let h=this.data[u];s=h.length-1,e.subset&&(s=e.subset.end.column);for(let p=t;p<=s;p++){let f=h[p],m=f&&f.merge_area&&f.merge_area.start.row===u&&f.merge_area.start.column===p,b=f&&f.area&&f.area.start.row===u&&f.area.start.column===p,_=f?f.type===2&&!f.value:!0;if(f&&(!_||e.preserve_empty_strings)&&(m||f.type||f.calculated_type&&e.expand_arrays||f.calculated_type&&e.calculated_value||f.validation||e.decorated_cells&&f.style&&(f.style.fill||f.style.border_bottom||f.style.border_top||f.style.border_left||f.style.border_right))){let y={row:u,column:p,value:f.value};f.note&&(y.note=f.note),f.hyperlink&&(y.hyperlink=f.hyperlink),e.preserve_type&&(y.type=f.type),e.sheet_id&&(y.sheet_id=e.sheet_id),e.calculated_value&&typeof f.calculated<"u"&&(y.calculated=f.calculated,(e.preserve_type||f.calculated_type===6)&&(y.calculated_type=f.calculated_type)),f.area&&b&&(y.area=f.area.toJSON()),f.merge_area&&(y.merge_area=f.merge_area.toJSON()),f.validation&&(y.validation=f.validation),e.cell_style_refs&&e.cell_style_refs[p]&&e.cell_style_refs[p][u]&&(y.style_ref=e.cell_style_refs[p][u],e.cell_style_refs[p][u]=0),l[u]=u,d[p]=p,o=Math.max(u,o),a=Math.max(p,a),n.push(y)}}}if(e.nested){let u=Object.keys(l),h=Object.keys(d);if(u.length<=h.length&&u.length){let p={},f=[];for(let m of n){let{row:b,..._}=m;p[m.row]||(p[m.row]=[]),p[m.row].push(_)}for(let m of u){let b=Number(m);f.push({row:b,cells:p[b]})}return{data:f,rows:o,columns:a+1}}else if(h.length){let p={},f=[];for(let m of n){let{column:b,..._}=m;p[m.column]||(p[m.column]=[]),p[m.column].push(_)}for(let m of h){let b=Number(m);f.push({column:b,cells:p[b]})}return{data:f,rows:o,columns:a+1}}}return{data:n,rows:o+1,columns:a+1}}GetAll(e=!1){return this.GetRange({row:0,column:0},{row:this.rows_-1,column:this.columns_-1},e)}Normalize2(e,t){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),t.column===1/0&&(t={...t,column:this.columns_-1}),t.row===1/0&&(t={...t,row:this.rows_-1}),{from:e,to:t}}Normalize1(e){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),e}RawValue(e,t=e){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].value:void 0;let i=[],r=this.data.slice(e.row,t.row+1),s=e.column,n=t.column+1;for(let o of r){let a=[];for(let l=s,d=0;l<n;l++,d++){let u=o[l];a.push(u?u.value:void 0)}i.push(a)}return i}GetRange(e,t,i=!1){if(t?{from:e,to:t}=this.Normalize2(e,t):e=this.Normalize1(e),!t||e===t||e.column===t.column&&e.row===t.row)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue():void 0;let r=[];if(i)for(let s=e.column;s<=t.column;s++){let n=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][s]?n.push(this.data[o][s].GetValue()):n.push(void 0);r.push(n)}else for(let s=e.row;s<=t.row;s++){let n=[];for(let o=e.column;o<=t.column;o++)this.data[s]&&this.data[s][o]?n.push(this.data[s][o].GetValue()):n.push(void 0);r.push(n)}return r}GetRange4(e,t=e,i=!1){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue4():{value:void 0,type:0};let r=[];if(i)for(let s=e.column;s<=t.column;s++){let n=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][s]?n.push(this.data[o][s].GetValue4()):n.push({type:0});r.push(n)}else for(let s=e.row;s<=t.row;s++){let n=[];for(let o=e.column;o<=t.column;o++)this.data[s]&&this.data[s][o]?n.push(this.data[s][o].GetValue4()):n.push({type:0});r.push(n)}return{type:8,value:r}}Apply(e,t,i=!1){if(P(e)&&(e=new g(e)),e.entire_column||e.entire_row)throw new Error("don't iterate infinite cells");let r=e.start,s=e.end;if(i)for(let n=r.row;n<=s.row;n++){this.data[n]||(this.data[n]=[]);let o=this.data[n];for(let a=r.column;a<=s.column;a++)o[a]||(o[a]=new ce),t(o[a],a,n)}else for(let n=r.row;n<=s.row;n++)if(this.data[n]){let o=this.data[n];for(let a=r.column;a<=s.column;a++)o[a]&&t(o[a],a,n)}}SetArea(e,t){if(ArrayBuffer.isView(t))throw new Error("ABIV");if(Array.isArray(t))for(let i=e.start.row,r=0;i<=e.end.row;i++,r++){this.data[i]||(this.data[i]=[]);let s=this.data[i];if(t[r])for(let n=e.start.column,o=0;n<=e.end.column;n++,o++)s[n]||(s[n]=new ce),s[n].Set(t[r][o])}else{let i=re(t);for(let r=e.start.row;r<=e.end.row;r++){this.data[r]||(this.data[r]=[]);let s=this.data[r];for(let n=e.start.column;n<=e.end.column;n++)s[n]||(s[n]=new ce),s[n].Set(t,i)}}this.rows_=Math.max(this.rows_,e.end.row+1),this.columns_=Math.max(this.columns_,e.end.column+1)}IterateAll(e){for(let t of this.data)if(t)for(let i of t)i&&e(i)}FlushCellStyles(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushStyle()}FlushCachedValues(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushCache()}};var T=class{static UpdateLocale(e){if(e)this.locale=e;else if(typeof self<"u"){let r=self?.document?.location;if(r&&r.search&&/locale=([^?&]+?)(?:\?|$|&)/.test(r.search)){let s=r.search.match(/locale=(.*?)(?:\?|$|&)/);s&&(this.locale=s[1]),console.info("override locale",this.locale)}else typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]?this.locale=navigator.languages[0]:this.locale=navigator.language)}let t=new Intl.NumberFormat(this.locale,{minimumFractionDigits:1}).format(3.3).replace(/\d/g,"");this.decimal_separator=t===","?",":".",this.decimal_separator===","?(this.argument_separator=";",this.grouping_separator=" "):(this.argument_separator=",",this.grouping_separator=",");let i=new Date(2e3,0,2,12,0,0,0);this.UpdateDateComponent(0,0,i),i=new Date(2e3,1,7,12,0,0,0),this.UpdateDateComponent(1,1,i),i=new Date(2e3,2,7,12,0,0,0),this.UpdateDateComponent(2,2,i),i=new Date(2e3,3,5,12,0,0,0),this.UpdateDateComponent(3,3,i),i=new Date(2e3,4,4,12,0,0,0),this.UpdateDateComponent(4,4,i),i=new Date(2e3,5,2,12,0,0,0),this.UpdateDateComponent(5,5,i),i=new Date(2e3,6,1,12,0,0,0),this.UpdateDateComponent(6,6,i),i=new Date(2e3,7,1,12,0,0,0),this.UpdateDateComponent(7,-1,i),i=new Date(2e3,8,1,12,0,0,0),this.UpdateDateComponent(8,-1,i),i=new Date(2e3,9,1,12,0,0,0),this.UpdateDateComponent(9,-1,i),i=new Date(2e3,10,1,12,0,0,0),this.UpdateDateComponent(10,-1,i),i=new Date(2e3,11,1,12,0,0,0),this.UpdateDateComponent(11,-1,i)}static UpdateDateComponent(e,t,i){t>=0&&(this.date_components.short_days[t]=i.toLocaleString(this.locale,{weekday:"short"}),this.date_components.long_days[t]=i.toLocaleString(this.locale,{weekday:"long"})),e>=0&&(this.date_components.short_months[e]=i.toLocaleString(this.locale,{month:"short"}),this.date_components.long_months[e]=i.toLocaleString(this.locale,{month:"long"}))}};E(T,"locale","en-us"),E(T,"decimal_separator","."),E(T,"argument_separator",","),E(T,"grouping_separator",","),E(T,"date_components",{short_days:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],long_days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],short_months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],long_months:["January","February","March","April","May","June","July","August","September","October","November","December"]});T.UpdateLocale();var z=class{constructor(e=0,t=0,i=0,r=0){this.left=e;this.top=t;this.width=i;this.height=r}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static Create(e){return new z(e.left||0,e.top||0,e.width||0,e.height||0)}static IsRectangle(e){return typeof e=="object"&&typeof e?.left=="number"&&typeof e?.top=="number"&&typeof e?.width=="number"&&typeof e?.height=="number"}Shift(e=0,t=0){return new z(this.left+e,this.top+t,this.width,this.height)}Scale(e=1,t=e){return new z(this.left*e,this.top*t,this.width*e,this.height*t)}Expand(e=0,t=0){return new z(this.left,this.top,this.width+e,this.height+t)}Combine(e){return new z(Math.min(this.left,e.left),Math.min(this.top,e.top),Math.max(this.right,e.right)-Math.min(this.left,e.left),Math.max(this.bottom,e.bottom)-Math.min(this.top,e.top))}CheckEdges(e,t,i=16){let r=0;return e-this.left<i&&(r|=1),this.right-e<i&&(r|=2),t-this.top<i&&(r|=4),this.bottom-t<i&&(r|=8),r}Contains(e,t,i=0){return e>=this.left-i&&e<=this.left+this.width+i&&t>=this.top-i&&t<=this.top+this.height+i}ContextFill(e){e.fillRect(this.left,this.top,this.width,this.height)}ContextStroke(e){e.strokeRect(this.left,this.top,this.width,this.height)}Clamp(e,t){return e=Math.min(Math.max(e,this.left),this.right),t=Math.min(Math.max(t,this.top),this.bottom),{x:e,y:t}}ApplyStyle(e){e.style.top=this.top+"px",e.style.left=this.left+"px",e.style.width=this.width+"px",e.style.height=this.height+"px"}toJSON(){return{top:this.top,left:this.left,width:this.width,height:this.height}}};var A;(p=>{let c=JSON.stringify({}),e;(y=>(y.None="",y.Left="left",y.Center="center",y.Right="right"))(e=p.HorizontalAlign||={});let t;(y=>(y.None="",y.Top="top",y.Bottom="bottom",y.Middle="middle"))(t=p.VerticalAlign||={}),p.DefaultProperties={horizontal_align:"",vertical_align:"",number_format:"General",nan:"NaN",font_size:{unit:"pt",value:10.5},font_face:"sans-serif",bold:!1,italic:!1,underline:!1,strike:!1,text:{theme:1},border_top:0,border_left:0,border_right:0,border_bottom:0},p.CompositeBorders=f=>({top:{width:f.border_top||0,color:f.border_top_fill||{}},left:{width:f.border_left||0,color:f.border_left_fill||{}},right:{width:f.border_right||0,color:f.border_right_fill||{}},bottom:{width:f.border_bottom||0,color:f.border_bottom_fill||{}}}),p.Merge=(f,m,b=!0)=>{let _=b?{...f,...m}:{...m};return JSON.parse(JSON.stringify(_))},p.Composite=f=>JSON.parse(JSON.stringify(f.reduce((m,b)=>({...m,...b}),{}))),p.Empty=f=>JSON.stringify(f)===c,p.ValidColor=f=>!!(f&&!f.none&&(f.text||f.theme||f.theme===0)),p.ParseFontSize=(f="",m="em")=>{let b=f.match(/(-*[\d.]+)\s*(\S*)/);if(b){let _=Number(b[1]);if(!_||isNaN(_)||_<0)return{};let y=b[2].toLowerCase()||m;if(y==="pt"||y==="em"||y==="%"||y==="px")return{font_size:{unit:y,value:_}}}return{}},p.RelativeFontSize=(f,m)=>{let b=12,_=12;switch(f.font_size?.unit){case"pt":if(!f.font_size.value)return 1;_=f.font_size.value;break;case"px":if(!f.font_size.value)return 1;_=Math.round(f.font_size.value*300/4)/100;break;case"em":return f.font_size.value||1;case"%":return(f.font_size.value||100)/100;default:return 1}switch(m.font_size?.unit){case"pt":if(!m.font_size.value)return 1;b=m.font_size.value;break;case"px":if(!m.font_size.value)return 1;b=Math.round(m.font_size.value*300/4)/100;break;default:return 1}return _/b},p.FontSize=(f,m=!0)=>{let b=f.font_size?.value;switch(f.font_size?.unit){case"pt":return(b||12)+"pt";case"px":return m?Math.round((b||16)*300/4)/100+"pt":(b||16)+"px";case"em":return(b||1)+"em";case"%":return(b||100)+"%"}return""},p.Font=(f,m=1)=>{let b=[];return f.bold&&b.push("bold"),f.italic&&b.push("italic"),b.push(((f.font_size?.value||0)*m).toFixed(2)+(f.font_size?.unit||"pt")),b.push(f.font_face||""),b.join(" ")}})(A||={});var li=c=>!!c&&Array.isArray(c)&&Array.isArray(c[0]),q=(c,e)=>(typeof e>"u"&&(e=re(c)),{value:c,type:e}),be=c=>c.imaginary?{type:7,value:c}:{type:3,value:c.real};var ci=class{Darken(e,t,i,r,s=!1){let{h:n,s:o,l:a}=this.RGBToHSL(e,t,i);return s?a-=a*r/100:a-=r/100,a=Math.max(0,Math.min(1,a)),this.HSLToRGB(n,o,a)}Lighten(e,t,i,r,s=!1){let{h:n,s:o,l:a}=this.RGBToHSL(e,t,i);return s?a+=a*r/100:a+=r/100,a=Math.max(0,Math.min(1,a)),this.HSLToRGB(n,o,a)}RGBToHSL(e,t,i){e/=255,t/=255,i/=255;let r=Math.max(e,t,i),s=Math.min(e,t,i),n=0,o=0,a=(r+s)/2;if(r===s)n=o=0;else{let l=r-s;switch(o=a>.5?l/(2-r-s):l/(r+s),r){case e:n=(t-i)/l+(t<i?6:0);break;case t:n=(i-e)/l+2;break;case i:n=(e-t)/l+4;break}n/=6}return{h:n*360,s:o,l:a}}HSLToRGB(e,t,i){let r,s,n;if(t===0)r=s=n=i;else{e=e/360;let o=i<.5?i*(1+t):i+t-i*t,a=2*i-o;r=this.HueToRGB(a,o,e+1/3),s=this.HueToRGB(a,o,e),n=this.HueToRGB(a,o,e-1/3)}return{r:Math.round(r*255),g:Math.round(s*255),b:Math.round(n*255)}}HueToRGB(e,t,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?e+(t-e)*6*i:i<1/2?t:i<2/3?e+(t-e)*(2/3-i)*6:e}},et=new ci;var wt={grid_color:"red",note_marker_color:"#d2c500"},fe=(c,e)=>D(c,e,0),ps=(c,e,t)=>{c.tint_cache||(c.tint_cache=[]),c.tint_cache[e]||(c.tint_cache[e]={});let i=c.tint_cache[e][t];if(!i){let r=(c.theme_colors_rgb?c.theme_colors_rgb[e]:[0,0,0])||[0,0,0],s;t>0?s=et.Lighten(r[0],r[1],r[2],t*100,!0):s=et.Darken(r[0],r[1],r[2],-t*100,!0),i=`rgb(${s.r},${s.g},${s.b})`,c.tint_cache[e][t]=i}return i},D=(c,e,t)=>e?.text?e.text==="none"?"":e.text:e?.theme||e?.theme===0?e.tint?ps(c,e.theme,e.tint):c.theme_colors?c.theme_colors[e.theme]:"":(t||t===0)&&c.theme_colors?c.theme_colors[t]:"",fs=c=>{let e=10,t="pt",i=c.match(/^([\d.]+)(\D.*)$/);return i&&(e=Number(i[1]),t=i[2]),{value:e,unit:t}},rr=c=>{let{value:e,unit:t}=fs(c.fontSize||""),i={fill:{text:c.backgroundColor},text:{text:c.color},font_size:{unit:t,value:e},font_face:c.fontFamily};return/italic/i.test(c.font)&&(i.italic=!0),c.fontWeight==="700"&&(i.bold=!0),i},sr=c=>{let e=JSON.parse(JSON.stringify(wt)),t=(d,u)=>{let h=document.createElement("div");return h.setAttribute("class",u),d.appendChild(h),h},i=(d,u)=>window.getComputedStyle(t(d,u)),r=t(c,""),s=i.bind(0,r),n=s("grid-cells");e.grid_cell=rr(n),e.grid_color=n.stroke||"",n=s("grid-headers"),e.headers=rr(n),e.headers_grid_color=n.stroke,(!e.headers_grid_color||e.headers_grid_color==="none")&&(e.headers_grid_color=e.grid_color),n=s("note-marker"),e.note_marker_color=n.backgroundColor,r.style.color="rgba(1,2,3,.4)",n=s("");let o=n.color;e.theme_colors=[e.grid_cell.fill?.text||"rgb(255, 255, 255)",e.grid_cell.text?.text||"rgb(51, 51, 51)"];for(let d=1;d<32&&(n=s(`theme-color-${d}`),!(!n.color||n.color===o));d++)e.theme_colors.push(n.color);let a=document.createElement("canvas");a.width=3,a.height=3;let l=a.getContext("2d",{willReadFrequently:!0});return l&&(e.theme_colors_rgb=e.theme_colors.map(d=>{l.fillStyle=d,l.fillRect(0,0,3,3);let u=l.getImageData(1,1,1,1);return Array.from(u.data)})),r.parentElement?.removeChild(r),e};var st=/[\s-+=<>!()]/,cr=/['*\\]/,di=34,ui=39,ms=160,_s=32,bs=9,ys=10,gs=13,ve=48,tt=57,hi=46,pi=43,it=45,nr=40,fi=41,xt=44,vs=37,mi=95,Ct=36,ws=123,xs=125,or=91,ar=93,Cs=33,lr=59,Ss=35,He=65,rt=97,As=69,Rs=101,St=90,At=122,Es=105;var _i=192,bi=312,yi={"==":6,"!=":6,"<>":6,"=":6,"<":7,">":7,"<=":7,">=":7,"+":9,"-":9,"&":9,"*":10,"/":10,"^":11,":":13},ks=Object.keys(yi).sort((c,e)=>e.length-c.length),Ts={"-":100,"+":100},$e=class{argument_separator=",";decimal_mark=".";flags={spreadsheet_semantics:!0,dimensioned_quantities:!1,fractions:!0};r1c1_regex=/[rR]((?:\[[-+]{0,1}\d+\]|\d+))[cC]((?:\[[-+]{0,1}\d+\]|\d+))$/;argument_separator_char=xt;decimal_mark_char=hi;imaginary_char=Es;imaginary_number="i";id_counter=0;expression="";data=[];index=0;length=0;valid=!0;error_position;error;dependencies={addresses:{},ranges:{}};address_refcount={};full_reference_list=[];Walk(e,t){switch(e.type){case"address":case"missing":case"literal":case"complex":case"identifier":case"operator":t(e);return;case"dimensioned":t(e)&&(this.Walk(e.expression,t),this.Walk(e.unit,t));return;case"range":t(e)&&(this.Walk(e.start,t),this.Walk(e.end,t));return;case"binary":t(e)&&(this.Walk(e.left,t),this.Walk(e.right,t));return;case"unary":t(e)&&this.Walk(e.operand,t);return;case"group":t(e)&&e.elements.forEach(i=>this.Walk(i,t));return;case"call":t(e)&&e.args.forEach(i=>this.Walk(i,t))}}Transpose(e){let t=e.length,i=[],r=0;for(let s=0;s<t;s++)Array.isArray(e[s])&&(r=Math.max(r,e[s].length));for(let s=0;s<r;s++){i[s]=[];for(let n=0;n<t;n++)i[s][n]=e[n][s]}return i}Render(e,t={rows:0,columns:0},i="(missing)",r,s,n){let o=this.argument_separator+" ";s===","?o=", ":s===";"&&(o="; ");let a=this.imaginary_number;n&&(a=n);let l=r===","?",":".",d=this.decimal_mark===","?/,/:/\./;switch(e.type){case"address":return this.AddressLabel(e,t);case"range":return this.AddressLabel(e.start,t)+":"+this.AddressLabel(e.end,t);case"missing":return i;case"array":return"{"+this.Transpose(e.values).map(u=>u.map(h=>typeof h=="string"?'"'+h+'"':h).join(", ")).join("; ")+"}";case"binary":return this.Render(e.left,t,i,r,s)+" "+e.operator+" "+this.Render(e.right,t,i,r,s);case"unary":return e.operator+this.Render(e.operand,t,i,r,s);case"complex":if(e.real){let u=Math.abs(e.imaginary);return`${e.real||0}${e.imaginary<0?" - ":" + "}${u===1?"":u}i`}else return e.imaginary===-1?"-i":e.imaginary===1?"i":`${e.imaginary}i`;break;case"literal":if(typeof e.value=="string")return'"'+e.value.replace(/"/g,'""')+'"';if(r&&typeof e.value=="number")if(e.text){let u=e.text;return r===","&&this.decimal_mark==="."&&(u=u.replace(/,/g,"")),u.replace(d,l)}else return e.value.toString().replace(/\./,l);else if(e.text)return e.text;return e.value.toString();case"identifier":return e.name;case"operator":return"["+e.operator+"]";case"group":return e.explicit?"("+e.elements.map(u=>this.Render(u,t,i,r,s)).join(o)+")":e.elements.map(u=>this.Render(u,t,i,r,s)).join(o);case"call":return e.name+"("+e.args.map(u=>this.Render(u,t,i,r,s)).join(o)+")";case"dimensioned":return this.Render(e.expression)+" "+this.Render(e.unit)}return"??"}Parse(e){switch(e=e.trim(),e[0]==="="&&(e=e.substr(1).trim()),this.expression=e,this.data=[],this.length=e.length,this.index=0,this.valid=!0,this.error_position=void 0,this.error=void 0,this.dependencies.addresses={},this.dependencies.ranges={},this.address_refcount={},this.full_reference_list=[],this.id_counter=0,this.argument_separator){case";":this.argument_separator_char=lr;break;default:this.argument_separator_char=xt;break}switch(this.decimal_mark){case",":this.decimal_mark_char=xt;break;default:this.decimal_mark_char=hi;break}for(let r=0;r<this.length;r++)this.data[r]=e.charCodeAt(r);let t=this.ParseGeneric(),i={};for(let r of Object.keys(this.dependencies.addresses))this.address_refcount[r]&&(i[r]=this.dependencies.addresses[r]);return this.dependencies.addresses=i,{expression:t||void 0,valid:this.valid,error:this.error,error_position:this.error_position,dependencies:this.dependencies,separator:this.argument_separator,decimal_mark:this.decimal_mark,full_reference_list:this.full_reference_list.slice(0)}}ColumnLabel(e){if(e===1/0)return"";let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}AddressLabel(e,t){let i=e.column;!e.absolute_column&&e.column!==1/0&&(i+=t.columns);let r=e.row;if(!e.absolute_row&&e.row!==1/0&&(r+=t.rows),r<0||i<0||r===1/0&&i===1/0)return"#REF";let s="";return e.sheet&&(s=(st.test(e.sheet)?"'"+e.sheet+"'":e.sheet)+"!"),r===1/0?s+(e.absolute_column?"$":"")+this.ColumnLabel(i):i===1/0?s+(e.absolute_row?"$":"")+(r+1):s+(e.absolute_column?"$":"")+this.ColumnLabel(i)+(e.absolute_row?"$":"")+(r+1)}ParseGeneric(e=[0]){let t=[];for(;this.index<this.length;){let i=this.ParseNext(t.length===0);if(typeof i=="number"){if(e.some(r=>i===r))break;if(i===nr){this.index++;let r=this.ParseGeneric([fi]);this.index++,r&&t.push({type:"group",id:this.id_counter++,elements:[r],explicit:!0})}else{let r=this.ConsumeOperator();r?t.push(r):(this.error=`unexpected character [1]: ${String.fromCharCode(i)}, 0x${i.toString(16)}`,this.valid=!1,this.index++)}}else t.push(i)}if(t.length){if(t=this.BinaryToRange2(t),this.flags.fractions){let i=[],r=n=>n.type==="literal"&&typeof n.value=="number"&&n.value%1===0,s=0;for(;s<t.length-3;s++)if(r(t[s])&&r(t[s+1])&&t[s+2].type==="operator"&&t[s+2].operator==="/"&&r(t[s+3])){let n=t[s],o=t[s+1],a=t[s+3],l=(n.value<0?-1:1)*(o.value/a.value);s+=3,i.push({id:t[s].id,type:"literal",text:this.expression.substring(n.position,a.position+1),value:n.value+l,position:n.position})}else i.push(t[s]);for(;s<t.length;s++)i.push(t[s]);t=i}if(t=t.map(i=>i.type==="identifier"&&i.name===this.imaginary_number?{type:"complex",real:0,imaginary:1,position:i.position,text:i.name,id:this.id_counter++}:i),this.flags.dimensioned_quantities){let i=[],r;for(let s=0;s<t.length;s++){let n=t[s];if(!r)r=n;else if(n.type==="identifier"&&(r.type==="literal"||r.type==="group"||r.type==="call")){let o=n;for(;t[s+1]?.type==="identifier";)o.name+=" "+t[++s].name;i.push({type:"dimensioned",expression:r,unit:n,id:this.id_counter++}),r=void 0}else i.push(r),r=n}r&&i.push(r),t=i}}return t.length===0?null:t.length===1?t[0]:this.BinaryToComplex(this.ArrangeUnits(t))}UnitToAddress(e){if(e.type==="literal"){if(typeof e.value=="number"&&e.value>0&&!/\./.test(e.text||""))return{type:"address",position:e.position,label:e.value.toString(),row:e.value-1,id:this.id_counter++,column:1/0}}else{let t,i=e.name,r=i.split("!");if(r.length>1&&(t=r.slice(0,r.length-1).join("!"),i=i.substr(t.length+1),t[0]==="'"))if(t.length>1&&t[t.length-1]==="'")t=t.substr(1,t.length-2);else return;let s=i[0]==="$";i=(s?i.substr(1):i).toUpperCase();let n=Number(i);if(isNaN(n)){if(/[A-Z]{1,3}/.test(i)){let o=-1;for(let a=0;a<i.length;a++){let l=i[a].charCodeAt(0);o=26*(1+o)+(l-He)}return{type:"address",position:e.position,absolute_column:s,label:e.name,column:o,id:this.id_counter++,row:1/0,sheet:t}}}else if(n>0&&n!==1/0&&!/\./.test(i))return{type:"address",position:e.position,absolute_row:s,label:e.name,row:n-1,id:this.id_counter++,column:1/0,sheet:t}}}BinaryToRange2(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i],s=e[i+1],n=e[i+2],o,a="",l;if(r&&s&&n&&s.type==="operator"&&s.operator===":"){if(r.type==="address"&&n.type==="address"){let d=r.position+r.label.length,u=n.position;o={type:"range",id:this.id_counter++,position:r.position,start:r,end:n,label:r.label+this.expression.substring(d,u)+n.label},a=o.start.label+":"+o.end.label,this.address_refcount[o.start.label]--,this.address_refcount[o.end.label]--;let h=[r.position,n.position];this.full_reference_list=this.full_reference_list.filter(p=>p.position!==h[0]&&p.position!==h[1])}else if((r.type==="literal"||r.type==="identifier")&&(n.type==="literal"||n.type==="identifier")){let d=this.UnitToAddress(r);if(!d&&r.type==="literal"&&typeof r.value=="number"&&r.value<0){let h={...r,text:(r.text||"").replace(/^-/,""),position:r.position+1,value:-r.value};d=this.UnitToAddress(h),d&&(l={type:"operator",operator:"-",position:r.position,id:this.id_counter++})}let u=this.UnitToAddress(n);d&&u&&(d.column===1/0&&u.column===1/0||d.row===1/0&&u.row===1/0)&&(a=d.label+":"+u.label,o={type:"range",id:this.id_counter++,position:d.position,start:d,end:u,label:a})}}o?(l&&t.push(l),t.push(o),this.dependencies.ranges[a]=o,this.full_reference_list.push(o),i+=2):t.push(r)}return t}BinaryToComplex(e){if(e.type==="binary")if((e.operator==="+"||e.operator==="-")&&e.left.type==="literal"&&typeof e.left.value=="number"&&e.right.type==="complex"&&!e.right.composited){let t="";t=this.expression.substring(e.left.position,e.right.position+(e.right.text?.length||0));let i=e.right.imaginary;return e.operator==="-"&&(i=-i),{type:"complex",position:e.left.position,text:t,id:this.id_counter++,imaginary:i,real:e.left.value,composited:!0}}else e.left=this.BinaryToComplex(e.left),e.right=this.BinaryToComplex(e.right);else if(e.type==="unary"&&(e.operator==="-"||e.operator==="+")&&e.operand.type==="complex"&&e.operand.text===this.imaginary_number)return{...e.operand,position:e.position,text:this.expression.substring(e.position,e.operand.position+(e.operand.text||"").length),imaginary:e.operand.imaginary*(e.operator==="-"?-1:1)};return e}BinaryToRangeX(e){if(e.type==="binary"){if(e.operator===":"){let t,i="";if(e.left.type==="address"&&e.right.type==="address"){let r=e.left.position+e.left.label.length,s=e.right.position;t={type:"range",id:this.id_counter++,position:e.left.position,start:e.left,end:e.right,label:e.left.label+this.expression.substring(r,s)+e.right.label},i=t.start.label+":"+t.end.label,this.address_refcount[t.start.label]--,this.address_refcount[t.end.label]--;let n=[e.left.position,e.right.position];this.full_reference_list=this.full_reference_list.filter(o=>o.position!==n[0]&&o.position!==n[1])}else if((e.left.type==="literal"||e.left.type==="identifier")&&(e.right.type==="literal"||e.right.type==="identifier")){let r=this.UnitToAddress(e.left),s=this.UnitToAddress(e.right);r&&s&&(r.column===1/0&&s.column===1/0||r.row===1/0&&s.row===1/0)&&(i=r.label+":"+s.label,t={type:"range",id:this.id_counter++,position:e.left.position,start:r,end:s,label:i})}if(t)return this.dependencies.ranges[i]=t,this.full_reference_list.push(t),t;this.error="unexpected character: :",this.valid=!1}e.left=this.BinaryToRangeX(e.left),e.right=this.BinaryToRangeX(e.right)}return e}ArrangeUnits(e){if(e.length===0)return{type:"missing",id:this.id_counter++};if(e.length===1)return e[0];let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(r.type==="operator")if(t.length===0||t[t.length-1].type==="operator")if(Ts[r.operator]){let s=this.BinaryToComplex(this.ArrangeUnits(e.slice(i+1)));if(!this.valid)return{type:"group",id:this.id_counter++,elements:e,explicit:!1};s.type==="binary"?(s.left={type:"unary",id:this.id_counter++,operator:r.operator,operand:s.left,position:r.position},r=s):r={type:"unary",id:this.id_counter++,operator:r.operator,operand:s,position:r.position},i=e.length}else return this.error=`unexpected character [2]: ${r.operator}`,this.error_position=r.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1};else{t.push(r);continue}if(t.length<2)t.push(r);else if(t[t.length-1].type==="operator"){let s=t[t.length-2],n=t[t.length-1],o=n.operator,a={type:"binary",id:this.id_counter++,left:s,operator:o,position:n.position,right:r};s.type==="binary"&&yi[o]>yi[s.operator]&&(a.left=s.left,a.operator=s.operator,a.position=s.position,a.right={type:"binary",id:this.id_counter++,left:s.right,right:r,operator:o,position:n.position}),t.splice(-2,2,a)}else return this.error="multiple expressions",this.error_position=r.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1}}return t[0]}ParseNext(e=!0){this.ConsumeWhiteSpace();let t=this.data[this.index];if(t===di)return{type:"literal",id:this.id_counter++,position:this.index,value:this.ConsumeString()};if(t>=ve&&t<=tt||t===this.decimal_mark_char)return this.ConsumeNumber();if(t===ws)return this.ConsumeArray();if(e&&(t===it||t===pi)){let i=this.data[this.index+1];if(i>=ve&&i<=tt||i===this.decimal_mark_char)return this.ConsumeNumber()}else if(t>=He&&t<=St||t>=rt&&t<=At||t===mi||t===Ss||t===ui||t===Ct||t>=_i&&t<=bi)return this.ConsumeToken(t);return t}ConsumeArray(){let e={type:"array",id:this.id_counter++,values:[],position:this.index};this.index++;let t=0,i=0;for(;this.index<this.length;){let r=this.ParseNext(),s=this.index;if(typeof r=="number")switch(this.index++,r){case lr:i++,t=0;break;case xt:t++;break;case xs:return e;default:this.valid&&(this.error="invalid character in array literal",this.error_position=s,this.valid=!1);break}else switch(r.type){case"literal":e.values[t]||(e.values[t]=[]),e.values[t][i]=r.value;break;default:this.valid&&(this.error="invalid value in array literal",this.error_position=s,this.valid=!1);break}}return e}ConsumeOperator(){for(let e of ks)if(this.expression.substr(this.index,e.length)===e){let t=this.index;return this.index+=e.length,{type:"operator",id:this.id_counter++,operator:e,position:t}}return null}ConsumeArguments(){this.index++;let e=0,t=[];for(;this.index<this.length;){let i=this.ParseGeneric([this.argument_separator_char,fi]);i!==null&&t.push(i);let r=this.data[this.index];if(r===this.argument_separator_char){this.index++,e++;for(let s=t.length;s<e;s++)t.push({type:"missing",id:this.id_counter++})}else if(r===fi)return this.index++,t}return t}ConsumeToken(e){let t=[e],i=this.index,r=e===ui,s=!1;for(++this.index;this.index<this.length;this.index++){let l=this.data[this.index];if(l>=He&&l<=St||l>=rt&&l<=At||l>=_i&&l<=bi||l===mi||l===Ct||l===hi||l===Cs||r||l>=ve&&l<=tt||this.flags.r1c1&&(l===or||l===ar||l===it&&s))t.push(l),l===or&&(s=!0),l===ar&&(s=!1),l===ui&&(r=!1);else break}let n=t.map(l=>String.fromCharCode(l)).join("");if(r)return this.error="unbalanced single quote",this.error_position=i,this.valid=!1,{type:"identifier",id:this.id_counter++,name:n,position:i};if(n.toLowerCase()==="true")return{type:"literal",id:this.id_counter++,value:!0,position:i};if(n.toLowerCase()==="false")return{type:"literal",id:this.id_counter++,value:!1,position:i};if(this.ConsumeWhiteSpace(),this.data[this.index]===nr){let l=this.ConsumeArguments();return{type:"call",id:this.id_counter++,name:n,args:l,position:i}}if(this.flags.spreadsheet_semantics){let l=this.ConsumeAddress(n,i);if(l)return l}let a={type:"identifier",id:this.id_counter++,name:n,position:i};return this.full_reference_list.push(a),a}ConsumeAddress(e,t){let i=t,r=e.length,s,n=e.split("!");if(n.length>1&&(s=n.slice(0,n.length-1).join("!"),t+=s.length+1),this.flags.r1c1){let u=n[n.length-1].match(this.r1c1_regex);if(u){let h={type:"address",id:this.id_counter++,label:e,row:0,column:0,position:i,sheet:s,r1c1:!0};return u[1][0]==="["?(h.offset_row=!0,h.row=Number(u[1].substring(1,u[1].length-1))):h.row=Number(u[1])-1,u[2][0]==="["?(h.offset_column=!0,h.column=Number(u[2].substring(1,u[2].length-1))):h.column=Number(u[2])-1,h}}let o=this.ConsumeAddressColumn(t);if(!o)return null;t=o.position;let a=this.ConsumeAddressRow(t);if(!a)return null;t=a.position;let l=s?s+e.substr(s.length,t-i).toUpperCase():e.substr(0,t-i).toUpperCase();s&&s[0]==="'"&&(s=s.substr(1,s.length-2));let d={type:"address",id:this.id_counter++,label:l,row:a.row,column:o.column,absolute_row:a.absolute,absolute_column:o.absolute,position:i,sheet:s};return r!==t-i?null:(this.dependencies.addresses[d.label]=d,this.address_refcount[d.label]=(this.address_refcount[d.label]||0)+1,this.full_reference_list.push(d),d)}ConsumeAddressRow(e){let t=this.data[e]===Ct;t&&e++;let i=e,r=0;for(;;e++){let s=this.data[e];if(s>=ve&&s<=tt)r*=10,r+=s-ve;else break}return i===e?!1:{absolute:t,row:r-1,position:e}}ConsumeAddressColumn(e){let t=-1,i=0,r=this.data[e]===Ct;for(r&&e++;;e++,i++){if(i>=4)return!1;let s=this.data[e];if(s>=He&&s<=St)t=26*(1+t)+(s-He);else if(s>=rt&&s<=At)t=26*(1+t)+(s-rt);else break}return t<0?!1:{absolute:r,column:t,position:e}}ConsumeNumber(){let e=this.index,t=0,i=!1,r=!1,s=0,n=0,o=0,a="integer",l=0,d=!1,u=this.index;for(;this.index<this.length;this.index++,l++){let p=this.data[this.index];if(p===this.decimal_mark_char)if(a==="integer")a="fraction";else break;else if(p===vs){s/=100,o/=100,this.index++;break}else if(p===pi||p===it)if(l===0)p===it&&(r=!0);else break;else if(p===As||p===Rs)if(a==="integer"||a==="fraction")a="exponent",this.index<this.length-1&&(this.data[this.index+1]===pi?this.index++:this.data[this.index+1]===it&&(this.index++,i=!0));else break;else if(p===this.imaginary_char){let f=this.data[this.index+1];if(f>=He&&f<=St||f>=rt&&f<=At||f>=_i&&f<=bi||f===mi)break;if(a==="integer"||a==="fraction"){this.index++,d=!0;break}}else if(p>=ve&&p<=tt)switch(a){case"integer":s=s*10+(p-ve);break;case"fraction":o=o*10+(p-ve),n++;break;case"exponent":t=t*10+(p-ve);break}else break}let h=s+o/Math.pow(10,n);return a==="exponent"&&(h=h*Math.pow(10,(i?-1:1)*t)),d?{type:"complex",id:this.id_counter++,position:e,imaginary:r?-h:h,real:0,text:this.expression.substring(u,this.index)||""}:{type:"literal",id:this.id_counter++,position:e,value:r?-h:h,text:this.expression.substring(u,this.index)||""}}ConsumeString(){this.index++;let e=[];for(;this.index<this.length;this.index++){let t=this.data[this.index];if(t===di&&(this.index++,this.index>=this.length||this.data[this.index]!==di))break;e.push(t)}return e.map(t=>String.fromCharCode(t)).join("")}ConsumeWhiteSpace(){for(;this.index<this.length;){let e=this.data[this.index];if(e===_s||e===bs||e===ys||e===gs||e===ms)this.index++;else return}}};var dr=(c,e=",")=>{let t=0,i=[],r="",s=[],n=c.length;if(/[\r\n"]/.test(e))throw new Error("invalid delimiter");for(let o=0;o<n;o++){let a=c[o];if(t===0)switch(a){case e:i.push(r),r="";break;case"\r":break;case`
|
|
3
3
|
`:i.push(r),r="",s.push(i),i=[];break;case'"':r.length===0?t=1:r+=a;break;default:r+=a;break}else a==='"'?o+1<n&&c[o+1]==='"'?(r+='"',o++):t=0:r+=a}return(i.length||r.length)&&(i.push(r),s.push(i)),s};var wi=class{constructor(){}static get instance(){return this._instance}HTML(e){let t=[];for(let i of e){let r=[];for(let s of i)s.pre&&r.push("<pre>"),s.emphasis&&r.push("<em>"),s.strong&&r.push("<strong>"),s.strike&&r.push("<strike>"),r.push(s.text),s.strike&&r.push("</strike>"),s.strong&&r.push("</strong>"),s.emphasis&&r.push("</em>"),s.pre&&r.push("</pre>");t.push(r.join(""))}return t.join(`<br/>
|
|
4
4
|
`)}Dummy(e=""){return e.split(/\n/).map(t=>[{text:t}])}Parse(e=""){let t=this.Tokenize(e);for(let i=0;i<t.length;i++){let r=t[i];if(r.type==="delimeter"){let s=t[i-1],n=t[i+1],o=!s||s.type==="whitespace"||s.type==="newline",a=s&&s.type==="text"&&/[^\w\d]$/.test(s.text),l=!n||n.type==="whitespace"||n.type==="newline",d=n&&n.type==="text"&&/^[^\w\d]/.test(n.text);r.left_flanking=!l&&(!d||o),r.right_flanking=!o&&(!a||l)}}return this.ApplyFormatting(t),this.Consolidate(t)}IsWhitespace(e){return e===" "||e===" "}IsNewline(e){return e==="\r"||e===`
|
|
5
|
-
`}IsDelimeter(e){return e==="*"||e==="_"||e==="~"}Consolidate(e){let t=[],i={},r=[],s={type:"text",text:""};for(let n of e)if(n.type==="newline")s.text.length&&r.push(s),s={...i,text:"",type:"text"},t.push(r),r=[];else switch((!!i.strong!=!!n.strong||!!i.emphasis!=!!n.emphasis||!!i.strike!=!!n.strike)&&(i.strong=!!n.strong,i.emphasis=!!n.emphasis,i.strike=!!n.strike,s.text.length&&r.push(s),s={...i,text:"",type:"text"}),n.type){case"text":case"whitespace":s.text+=n.text;break;case"delimeter":for(let o=0;o<n.length;o++)s.text+=n.char;break}return s.text.length&&r.push(s),r.length&&t.push(r),t}ApplyFormatting(e,t){let i=0,r=e.length;for(i=0;i<r;i++){let s=e[i];if(s.type==="delimeter"){if(t&&s.right_flanking&&t.char===s.char&&s.length>0)return{index:i,token:s};if(s.left_flanking){let n=this.ApplyFormatting(e.slice(i+1),s);if(n.token){let o=Math.min(n.token.length,s.length),a=s.char==="~",l=!a&&!!(o%2),d=!a&&o>=2;for(let u=i+1;u<=i+n.index;u++)e[u].strong=!!e[u].strong||d,e[u].emphasis=!!e[u].emphasis||l,e[u].strike=!!e[u].strike||a;n.token.length-=o,s.length-=o,s.length>0?i--:i+=n.index}}}}return{index:i}}Tokenize(e=""){let t=[],i=e.length,r=0,s=!1,n="";for(r=0;r<i;r++){let o=e[r];if(this.IsWhitespace(o)){n&&t.push({type:"text",text:n});let a=o;for(;;){let l=e[r+1];if(this.IsWhitespace(l))a+=l,r++;else break}t.push({type:"whitespace",text:a}),s=!1,n=""}else if(this.IsNewline(o)){n&&t.push({type:"text",text:n});let a=o;for(;;){let l=e[r+1];if(this.IsNewline(l))a+=l,r++;else break}t.push({type:"newline",text:a}),s=!1,n=""}else if(s)n+=o,s=!1;else if(this.IsDelimeter(o)){n&&t.push({type:"text",text:n});let a=o;for(;;){let l=e[r+1];if(l===o)a+=l,r++;else break}t.push({type:"delimeter",text:a,char:o,length:a.length}),s=!1,n=""}else o==="\\"?s=!0:n+=o}return n&&t.push({type:"text",text:n}),t}},we=wi;E(we,"_instance",new wi);var se=()=>Promise.resolve();var Us=1e3,Q=class{constructor(e=!1,t){this.verbose=e;this.log_id=t}queue=[];dispatched=!1;subscribers=[];Publish(e){this.verbose&&console.info(`es publish (${this.log_id})`,e),Array.isArray(e)?this.queue.push(...e):this.queue.push(e),this.dispatched||(this.dispatched=!0,se().then(()=>{let t=this.queue.slice(0);this.dispatched=!1,this.queue=[];for(let i of t)for(let r of this.subscribers)r.subscriber(i)}))}Subscribe(e){let t=Us++;return this.subscribers.push({subscriber:e,token:t}),t}Cancel(e){this.subscribers=this.subscribers.filter(t=>t.token!==e)}CancelAll(){this.subscribers=[]}};var B=class{constructor(e,t,i,r=e){B.Create({container:e,node:t,resize_callback:i,layout_reference:r})}static Create(e){let t=document.createElement("div");if(t.classList.add("treb-embed-resize-handle"),(e.layout_reference||e.container).appendChild(t),!B.resize_mask){let l=document.querySelector(".treb-embed-mouse-mask");l||(l=document.createElement("div"),l.classList.add("treb-embed-mouse-mask"),document.body.appendChild(l)),B.resize_mask=l}if(!B.resize_rect){let l=document.querySelector(".treb-embed-resize-rect");l||(l=document.createElement("div"),l.classList.add("treb-embed-resize-rect"),B.resize_mask.appendChild(l)),B.resize_rect=l}let i,r,s={width:0,height:0},n={x:0,y:0},o={x:0,y:0},a=()=>{if(B.resize_mask.removeEventListener("mousemove",r),B.resize_mask.removeEventListener("mouseup",i),B.resize_mask.style.display="none",o.x||o.y){let l=e.container.getBoundingClientRect(),d=l.width+o.x,u=l.height+o.y;e.container.style.width=`${d}px`,e.container.style.height=`${u}px`,e.resize_callback&&e.resize_callback()}};r=l=>{if(!l.buttons){a();return}o.x!==l.clientX-n.x&&(o.x=l.clientX-n.x,B.resize_rect.style.width=`${s.width+o.x+4}px`),o.y!==l.clientY-n.y&&(o.y=l.clientY-n.y,B.resize_rect.style.height=`${s.height+o.y+4}px`)},i=()=>{a()},t.addEventListener("mousedown",l=>{l.stopPropagation(),l.preventDefault();let d=e.node.getBoundingClientRect();s={width:d.width,height:d.height},B.resize_rect&&(B.resize_rect.style.top=`${d.top-2}px`,B.resize_rect.style.left=`${d.left-2}px`,B.resize_rect.style.width=`${d.width+4}px`,B.resize_rect.style.height=`${d.height+4}px`),n={x:l.clientX,y:l.clientY},o={x:0,y:0},B.resize_mask.style.display="block",B.resize_mask.addEventListener("mousemove",r),B.resize_mask.addEventListener("mouseup",i)})}},Be=B;E(Be,"resize_mask"),E(Be,"resize_rect");var ee=class{static MeasureColorARGB(e){let t=this.MeasureColor(e),i="FF";for(let r=0;r<3;r++){let s=t[r].toString(16);s.length===0?i+="00":s.length===1?i+=`0${s}`:i+=s}return i.toUpperCase()}static MeasureColor(e){let t=this.color_cache[e];if(t)return t;this.color_measurement_canvas||(this.color_measurement_canvas=document.createElement("canvas"),this.color_measurement_canvas.width=1,this.color_measurement_canvas.height=1);let i=this.color_measurement_canvas.getContext("2d");return i?(i.fillStyle="#fff",i.fillRect(0,0,1,1),i.fillStyle=e,i.fillRect(0,0,1,1),t=i.getImageData(0,0,1,1).data,this.color_cache[e]=t,t):new Uint8ClampedArray(3)}static EnsureMeasurementNode(){if(!this.text_measurement_node){let e=document.querySelector(".treb-chart-measurement-node");e?this.text_measurement_node=e:(this.text_measurement_node=document.createElement("div"),this.text_measurement_node.classList.add("treb-chart-measurement-node"),this.text_measurement_node.style.margin="0px",this.text_measurement_node.style.padding="0px",this.text_measurement_node.style.height="initial",this.text_measurement_node.style.width="initial",this.text_measurement_node.style.whiteSpace="nowrap",this.text_measurement_node.style.position="fixed",this.text_measurement_node.style.border="0px",this.text_measurement_node.style.border="1px solid red",this.text_measurement_node.style.boxSizing="content-box",this.text_measurement_node.style.top=this.text_measurement_node.style.left="-1000px",document.body.appendChild(this.text_measurement_node))}}static FontLoaded(e,t=!1,i=400){let r=`${t?"italic":""} ${i} 20pt ${e}`,s=this.MeasureText(`${r}, sans-serif`,"check font"),n=this.MeasureText(`${r}, serif`,"check font"),o=this.MeasureText(`${r}, monospace`,"check font");return s.width===n.width&&n.width===o.width}static MeasureText(e,t,i=0){this.EnsureMeasurementNode(),this.text_measurement_node.style.font=e,/\n/.test(t)?(t=t.replace(/\n/g,"<BR/>"),this.text_measurement_node.innerHTML=t):this.text_measurement_node.textContent=t,this.text_measurement_node.style.lineHeight="1em",i?this.text_measurement_node.style.transform=`rotate(${i}deg)`:this.text_measurement_node.style.transform="";let r=this.text_measurement_node.getBoundingClientRect();return{width:r.width,height:r.height}}};E(ee,"color_measurement_canvas"),E(ee,"text_measurement_node"),E(ee,"color_cache",{});var xi,Ms=(c,e,t)=>{let i={};return Array.prototype.forEach.call(e,r=>{e[r]!==t[r]&&(i[r]=e[r])}),(Object.keys(i).map(r=>`${r}: ${i[r]}`).join("; ")+"; "+(c.getAttribute("style")||"")).trim().replace(/"/g,"'")},ur=(c,e)=>{let t=c.cloneNode(!1),i=getComputedStyle(c),r=Ms(c,i,e);return t.removeAttribute("class"),t.setAttribute("style",r),Array.prototype.forEach.call(c.childNodes,s=>{switch(s.nodeType){case Node.ELEMENT_NODE:t.appendChild(ur(s,i));break;case Node.TEXT_NODE:c.textContent&&t.appendChild(document.createTextNode(c.textContent));break;case Node.COMMENT_NODE:break;default:console.warn("unhandled node type in serialize",s)}}),t},hr=c=>{if(!xi){let e={},t=document.createElement("iframe");t.style.width="10px",t.style.height="10px",t.style.position="absolute",t.style.left="-100px",document.body.appendChild(t);let i=t.contentDocument;if(i){let r=i.createElement("div");i.body.appendChild(r);let s=getComputedStyle(r);Array.prototype.forEach.call(s,n=>e[n]=s[n])}document.body.removeChild(t),xi=e}return ur(c,xi)};var pr=(c,e,t=6.5,i=!1,r=!1)=>{if(e===c)e++,c&&c--;else{let u=Math.round(e*1e5)/1e5;Math.abs(u-e)/(e-c)<1e-5&&(e=u)}let s=e-c,n=Math.log(s)/Math.log(10),o=Math.floor(Math.abs(n))*(n<0?-1:1)-1;r&&(o=Math.max(0,o));let a=r?[1,2,5,10,15,20,25,50,100]:[.1,.25,.5,1,2.5,5,10,25,50,100],l=-1,d=0;for(let u of a){let h=u*Math.pow(10,o),p=Math.floor(c/h)*h,m=(Math.ceil(e/h)*h-p)/h,b=Math.abs(m-t);(l<0||b<d)&&(!i||m<=t)&&(d=b,l=h)}return c=Math.floor(c/l)*l,e=Math.ceil(e/l)*l,t=Math.round((e-c)/l),{scale:o,step:l,count:t,min:c,max:e}};var fr=(c,e,t)=>{[].forEach.call(c.children,i=>{i.id&&(t[i.id]=i,i.id=`${e}-${i.id}`),i.children&&i.children.length&&fr(i,e,t)})},Ds=(c,e)=>{let t=Math.random().toString(36).substring(2,15),i=document.createElement("div");i.innerHTML=c;let r={};if(fr(i,t,r),typeof e=="string"&&(e=document.querySelector(e)),e){let s=[].map.call(i.childNodes,n=>n);for(let n of s)e.appendChild(n)}return r},Rt=(c,...e)=>{let t=[];for(let i=0;i<c.length;i++)t.push(c[i]),e[i]&&t.push(e[i].toString());return t.join("")},Et=(c,...e)=>Ds(Rt(c,...e));var xe=class{date_format=!1;string_format=!1;fraction_format=!1;twelve_hour=!1;fraction_denominator=0;fraction_integer=!0;fraction_align=0;fraction_denominator_digits=0;integer_min_digits=0;decimal_min_digits=0;decimal_max_digits=0;grouping=!1;has_number_format=!1;prefix=[{text:""}];suffix=[{text:""}];scaling=0;percent=!1;exponential=!1;has_asterisk=!1};var mr=42,_r=95,Ci=63,kt=48,br=46,Si=44,yr=37,Ai=34,nt=35,gr=59,Tt=92,vr=64,Ls=91,Vs=93,wr=69,xr=101,Is=72,Fs=104,zs=77,Ps=109,Ns=83,Os=115,Gs=68,Hs=100,$s=89,Bs=121,js=65,Js=97;var de=class{static Parse(e){if(this.pattern=e,this.characters=e.split("").map(t=>t.charCodeAt(0)),this.char_index=0,this.current_section=new xe,this.sections=[this.current_section],this.ParseDatePattern())return this.sections;for(this.char_index=0,this.current_section=new xe,this.sections=[this.current_section];this.char_index<this.characters.length;)this.ConsumeChar();return this.sections}static ConsumeString(){let e="";for(this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case Tt:this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index+1<this.characters.length&&(e+=this.pattern[++this.char_index]);break;case Ai:return this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated string")}static ConsumeFormatting(){let e="";for(++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case Tt:throw new Error("invalid escape character in formatting block");case Vs:return this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated format")}static ScanFractionFormat(){let e=/^([#?]+ +){0,1}([#?]+)\/([#?0-9]+)(?:$|[^#?0-9])/,i=this.pattern.substr(this.char_index).match(e);if(!i)return!1;let r=(i[1]||"").length+i[2].length+i[3].length+1;this.current_section.fraction_format=!0,this.current_section.fraction_integer=!!i[1];let s=Number(i[3]);return isNaN(s)||(this.current_section.fraction_denominator=s),this.current_section.decimal_max_digits=this.current_section.fraction_denominator_digits=i[3].length,this.char_index+=r,this.current_section.has_number_format=!0,!0}static ConsumeNumberFormat(){let e=0;for(this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case this.group_separator:{let i=!1;for(let r=this.char_index+1;!i&&r<this.characters.length;r++){let s=this.characters[r];if(s===this.decimal_mark||s===nt||s===kt)i=!0;else if(s!==Si)break}if(i){if(e===1)throw new Error("invalid grouping in decimal part");this.current_section.grouping=!0}else this.current_section.scaling=(this.current_section.scaling||1)*1e3}break;case this.decimal_mark:if(e===1)throw new Error("too many decimal marks");e=1;break;case nt:e===1?this.current_section.decimal_max_digits++:this.current_section.integer_min_digits&&this.current_section.integer_min_digits++;break;case kt:e===1?(this.current_section.decimal_max_digits++,this.current_section.decimal_min_digits=this.current_section.decimal_max_digits):this.current_section.integer_min_digits++;break;default:return}}static AppendCharAsText(e=!0){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=this.pattern[this.char_index]:this.current_section.prefix[this.current_section.prefix.length-1].text+=this.pattern[this.char_index],e&&this.char_index++}static AppendString(e){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=e:this.current_section.prefix[this.current_section.prefix.length-1].text+=e}static AppendTextPart(e){this.current_section.has_number_format?(this.current_section.suffix.push(e),this.current_section.suffix.push({text:""})):(this.current_section.prefix.push(e),this.current_section.prefix.push({text:""}))}static ConsumeChar(){let e=this.characters[this.char_index];if(!((e===Ci||e===nt)&&!this.current_section.has_number_format&&!this.current_section.string_format&&this.ScanFractionFormat()))switch(e){case gr:this.char_index++,this.current_section=new xe,this.sections.length===3&&(this.current_section.string_format=!0),this.sections.push(this.current_section);break;case vr:this.char_index++,this.AppendTextPart({text:"@",flag:5}),this.current_section.string_format=!0;break;case kt:case nt:case br:case Si:!this.current_section.has_number_format&&!this.current_section.string_format?(this.ConsumeNumberFormat(),this.current_section.has_number_format=!0):this.AppendCharAsText();break;case Ls:this.AppendTextPart({text:this.ConsumeFormatting(),flag:6});break;case Ai:this.AppendString(this.ConsumeString());break;case Ci:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case _r:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case mr:if(this.current_section.has_asterisk)throw new Error("we don't support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case xr:case wr:this.current_section.percent||this.current_section.exponential||this.current_section.string_format?this.AppendCharAsText():(this.current_section.exponential=!0,this.char_index++);break;case yr:!this.current_section.exponential&&!this.current_section.string_format&&(this.current_section.percent=!0),this.AppendCharAsText();break;case Tt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}static ParseDatePattern(){for(this.date_pattern=!0;this.date_pattern&&this.char_index<this.pattern.length;)this.DatePatternConsumeChar();if(this.date_pattern){this.date_pattern=!1;for(let e of this.sections)for(let t of e.prefix)t.flag&&t.flag&7&&(this.date_pattern=!0)}return this.date_pattern&&(this.sections[0].date_format=!0,this.sections[0].prefix.forEach((e,t)=>{if(e.flag===3&&(e.text==="mm"||e.text==="m")){if(t)for(let i=t-1;i;i--){let r=this.sections[0].prefix[i];if(r.flag===3){/h/i.test(r.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}if(t<this.sections[0].prefix.length-1)for(let i=t+1;i<this.sections[0].prefix.length;i++){let r=this.sections[0].prefix[i];if(r.flag===3){/s/i.test(r.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}}})),this.date_pattern}static ConsumeDatePart(){let e=this.pattern[this.char_index++],t=e.toLowerCase(),i={text:e,flag:3};for(;this.pattern[this.char_index]&&this.pattern[this.char_index].toLowerCase()===t;)i.text+=this.pattern[this.char_index++];if(t==="s"&&this.pattern[this.char_index]===".")for(i.text+=this.pattern[this.char_index++];this.pattern[this.char_index]==="0";)i.text+=this.pattern[this.char_index++];return i}static ConsumeAMPM(){let e=this.pattern.substr(this.char_index,5);if(e==="am/pm"||e==="AM/PM")return this.char_index+=5,this.sections[0].twelve_hour=!0,{text:e,flag:3};if(e=this.pattern.substr(this.char_index,3),e==="a/p"||e==="A/P")return this.char_index+=3,this.sections[0].twelve_hour=!0,{text:e,flag:3}}static DatePatternConsumeChar(){switch(this.characters[this.char_index]){case gr:this.char_index=this.characters.length;break;case kt:case nt:case xr:case wr:case yr:case vr:this.date_pattern=!1;break;case Is:case Fs:case zs:case Ps:case Ns:case Os:case Gs:case Hs:case $s:case Bs:this.AppendTextPart(this.ConsumeDatePart());break;case js:case Js:{let t=this.ConsumeAMPM();t?this.AppendTextPart(t):this.AppendCharAsText()}break;case Ai:this.AppendString(this.ConsumeString());break;case Ci:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case _r:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case mr:if(this.current_section.has_asterisk)throw new Error("we don't support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case Tt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}};E(de,"date_pattern",!1),E(de,"pattern",""),E(de,"char_index",0),E(de,"characters",[]),E(de,"sections",[]),E(de,"current_section",new xe),E(de,"preserve_formatting_characters",!1),E(de,"decimal_mark",br),E(de,"group_separator",Si);var Ve=c=>(c>=60&&c--,new Date(-22090752e5+864e5*c)),je=(c,e=!0)=>{if(e){let t=new Date(c),i=new Date;i.setUTCMilliseconds(t.getUTCMilliseconds()),i.setUTCSeconds(t.getUTCSeconds()),i.setUTCMinutes(t.getUTCMinutes()),i.setUTCHours(t.getHours()),i.setUTCDate(t.getDate()),i.setUTCMonth(t.getMonth()),i.setUTCFullYear(t.getFullYear()),c=i.getTime()}return c=(c+22090752e5)/864e5,c>=60&&c++,c},Ce=class{magic_decimal=!1;transform_value;_pattern="";sections;decimal_zero_regexp=[];cloned=[];get pattern(){return this._pattern}get date_format(){return this.sections[0]&&this.sections[0].date_format}constructor(e){if(this._pattern=e,this.sections=de.Parse(e),this.sections.length||(this.sections=[]),this.sections[0]||(this.sections[0]=new xe),this.sections[1]||(this.sections[1]={...this.sections[0]},this.sections[1].prefix=JSON.parse(JSON.stringify(this.sections[1].prefix)),this.sections[1].suffix=JSON.parse(JSON.stringify(this.sections[1].suffix)),this.sections[1].prefix.push({text:"-"}),this.cloned[1]=!0),this.sections[2]||(this.sections[2]={...this.sections[0]},this.cloned[2]=!0),!this.sections[3]){for(let t of this.sections[0].prefix)if(t.flag===5){this.sections[3]={...this.sections[0]},this.sections[3].string_format=!0,this.cloned[3]=!0;break}}this.decimal_zero_regexp=this.sections.map(t=>{if(t.decimal_max_digits>t.decimal_min_digits)return new RegExp(`0{1,${t.decimal_max_digits-t.decimal_min_digits}}(?:$|e)`)})}static FormatPartsAsText(e,t=0){let i=-1,r=e.map((s,n)=>{switch(s.flag){case 2:return i=n,s.text;case 1:return s.text.replace(/./g," ");case 6:return"";default:return s.text}});if(i>=0&&t){let s=r.reduce((o,a,l)=>l===i?o:o+a.length,0),n="";for(let o=0;o<t-s;o++)n+=r[i];r[i]=n}return r.join("")}SetDecimal(e){for(let t of this.sections)t.fraction_format||(t.decimal_min_digits=e,t.decimal_max_digits=e)}IncreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.min(e.fraction_denominator_digits+1,4)):(e.decimal_min_digits++,e.decimal_max_digits=e.decimal_min_digits)})}DecreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.max(e.fraction_denominator_digits-1,1)):(e.decimal_min_digits=Math.max(0,e.decimal_min_digits-1),e.decimal_max_digits=e.decimal_min_digits)})}AddGrouping(){this.sections.forEach(e=>{e.grouping=!0})}RemoveGrouping(){this.sections.forEach(e=>{e.grouping=!1})}ToggleGrouping(){let e=!this.sections[0].grouping;this.sections.forEach(t=>{t.grouping=e})}toString(){return this.sections[0].date_format?this._pattern:this.sections.filter((e,t)=>!this.cloned[t]).map(e=>{let t="",i=0;if(e.fraction_format){e.fraction_integer&&(t+="? ");let r="";for(let s=0;s<e.fraction_denominator_digits;s++)r+="#";t+=r,t+="/",e.fraction_denominator?t+=e.fraction_denominator:t+=r}else if(e.has_number_format){for(i=0;i<e.integer_min_digits;i++)t+="0";if(e.grouping&&(t.length<4&&(t=("####"+t).slice(-4)),t=t.replace(/[\d#]{1,3}(?=([\d#]{3})+(?![\d#]))/g,"$&,")),e.decimal_max_digits||e.decimal_min_digits){for(t+=".",i=0;i<e.decimal_min_digits;i++)t+="0";for(;i<e.decimal_max_digits;i++)t+="#"}if(e.scaling){let r=Math.log10(e.scaling)/3;for(i=0;i<r;i++)t+=","}e.exponential&&(t+="e")}return e.prefix.map(r=>r.flag===1?r.text==="0"?"?":"_"+r.text:r.flag===2?"*"+r.text:r.flag===6?"["+r.text+"]":r.text).join("")+t+e.suffix.map(r=>r.flag===1?r.text==="0"?"?":"_"+r.text:r.flag===2?"*"+r.text:r.text).join("")}).join(";")}FormatDimensionedQuantity(e){if(this.transform_value){let i=this.transform_value(e);if(ni(i))e=i;else return typeof i=="string"?i:this.FormatParts(i)}let t=this.FormatParts(e.value||0);return e.unit&&t.push({text:" "},{text:e.unit}),t}FormatComplex(e){let t=[],i=[],r=!1,s=!!e.imaginary;s&&(t=this.FormatParts(e.imaginary),s=t.some(a=>/[1-9]/.test(a.text)),t.length===1&&this.sections[0].integer_min_digits<=1&&t[0].text==="1"?(t[0].text="",r=!0):t.length===1&&this.sections[1].integer_min_digits<=1&&t[0].text==="-1"&&(t[0].text="-",r=!0));let n=!!e.real;n&&(i=this.FormatParts(e.real),n=i.some(a=>/[1-9]/.test(a.text)));let o=[];if(n||!n&&!s){if(o.push(...i),s){let a=Math.abs(e.imaginary);o.push({text:e.imaginary<0?` ${Ce.minus_character} `:" + "});let l=r?[]:this.FormatParts(Math.abs(e.imaginary));o.push(...l,{text:Ce.imaginary_character})}}else s&&o.push(...t,{text:Ce.imaginary_character});return o}FormatParts(e){if(typeof e!="number"&&!this.sections[3])return[{text:e.toString()}];let{parts:t,section:i}=this.BaseFormat(e),r=[];if(i.date_format||i.string_format)for(let s of t)typeof s=="string"?r.push({text:s}):r.push(s);else this.magic_decimal&&t[1]===""&&t.splice(1,1),r=[...i.prefix.map(s=>({...s})),{text:i.has_number_format?t.join(T.decimal_separator):""},...i.suffix.map(s=>({...s}))];for(let s=1;s<r.length;s++)r[s].flag===r[s-1].flag&&(r[s].text=r[s-1].text+r[s].text,r[s-1].text="");return r.filter(s=>s.text)}Format(e,t=0){return Ce.FormatPartsAsText(this.FormatParts(e),t)}ZeroPad(e,t){for(;e.length<t;)e="0"+e;return e}DateFormat(e){let t=Ve(e),i=this.sections[0],r=t.getUTCHours();return i.twelve_hour&&(r>12&&(r-=12),r===0&&(r=12)),{parts:i.prefix.map(n=>{if(n.flag===4)return n.text==="mm"?{text:this.ZeroPad(t.getUTCMinutes().toString(),2)}:{text:this.ZeroPad(t.getUTCMinutes().toString(),1)};if(n.flag===3){switch(n.text.toLowerCase()){case"am/pm":case"a/p":{let a=n.text.split("/");return{text:t.getUTCHours()>12?a[1]:a[0]}}case"mmmmm":return{text:T.date_components.long_months[t.getUTCMonth()][0]};case"mmmm":return n.text==="MMMM"?{text:T.date_components.long_months[t.getUTCMonth()].toUpperCase()}:{text:T.date_components.long_months[t.getUTCMonth()]};case"mmm":return n.text==="MMM"?{text:T.date_components.short_months[t.getUTCMonth()].toUpperCase()}:{text:T.date_components.short_months[t.getUTCMonth()]};case"mm":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),2)};case"m":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),1)};case"ddddd":case"dddd":return n.text==="DDDDD"||n.text==="DDDD"?{text:T.date_components.long_days[t.getUTCDay()].toUpperCase()}:{text:T.date_components.long_days[t.getUTCDay()]};case"ddd":return n.text==="DDD"?{text:T.date_components.short_days[t.getUTCDay()].toUpperCase()}:{text:T.date_components.short_days[t.getUTCDay()]};case"dd":return{text:this.ZeroPad(t.getUTCDate().toString(),2)};case"d":return{text:this.ZeroPad(t.getUTCDate().toString(),1)};case"yyyy":case"yyy":return{text:t.getUTCFullYear().toString()};case"yy":case"y":return{text:this.ZeroPad((t.getUTCFullYear()%100).toString(),2)};case"hh":return{text:this.ZeroPad(r.toString(),2)};case"h":return{text:this.ZeroPad(r.toString(),1)};case"ss":return{text:this.ZeroPad(t.getUTCSeconds().toString(),2)};case"s":return{text:this.ZeroPad(t.getUTCSeconds().toString(),1)}}let o=n.text.match(/^(s+)\.(0+)$/);if(o)return{text:this.ZeroPad(t.getUTCSeconds().toString(),o[1].length)+T.decimal_separator+(t.getUTCMilliseconds()/1e3).toFixed(o[2].length).substr(2)}}return{...n}}),section:i}}StringFormat(e,t){let i=[];for(let r of t.prefix)r.flag===5?i.push({text:e}):i.push({...r});return{parts:i,section:t}}Round2(e,t){let i=Math.pow(10,t);return Math.round(i*e)/i}FormatFraction(e,t){t.percent&&(e*=100);let i={denominator:1,numerator:Math.round(e),error:Math.abs(Math.round(e)-e)};if(t.fraction_denominator)i.denominator=t.fraction_denominator,i.numerator=Math.round(e*i.denominator);else if(i.error){let s=Ce.fraction_limits[t.fraction_denominator_digits-1]||Ce.fraction_limits[0];for(let n=2;n<=s;n++){let o=Math.round(e*n),a=Math.abs(o/n-e);if(a<i.error&&(i={numerator:o,denominator:n,error:a},!a))break}}let r=[];if(t.fraction_integer){let s=Math.floor(i.numerator/i.denominator);i.numerator%=i.denominator,(s||!i.numerator)&&(r.push(s.toString()),i.numerator&&r.push(" "))}else i.numerator||r.push("0");return i.numerator&&(r.push(i.numerator.toString()),r.push("/"),r.push(i.denominator.toString())),r.join("")}BaseFormat(e){if(this.sections[0].date_format)return this.DateFormat(Number(e));if(typeof e!="number")return this.StringFormat(e.toString(),this.sections[3]);let t=this.sections[0],i=this.decimal_zero_regexp[0];e<0&&(t=this.sections[1]);let r=t.percent?t.decimal_max_digits+2:t.decimal_max_digits,s=Math.pow(10,-r)/2,n=Math.abs(e);if(n<s&&(t=this.sections[2],i=this.decimal_zero_regexp[2]),t.scaling&&(n/=t.scaling,n<s&&(t=this.sections[2],i=this.decimal_zero_regexp[2])),t.string_format)return this.StringFormat(e.toString(),t);let o="";if(t.fraction_format)return{parts:[this.FormatFraction(n,t)],section:t};t.exponential?o=n.toExponential(t.decimal_max_digits):(t.percent&&(n*=100),o=this.Round2(n,t.decimal_max_digits).toFixed(t.decimal_max_digits)),i&&(o=o.replace(i,""));let a=o.split(".");for(;a[0].length<t.integer_min_digits;)a[0]=("0000000000000000"+a[0]).slice(-t.integer_min_digits);return t.integer_min_digits===0&&a[0]==="0"&&(a[0]=""),t.grouping&&(a[0]=a[0].replace(Ce.grouping_regexp,"$&"+T.grouping_separator)),{parts:a,section:t}}},X=Ce;E(X,"grouping_regexp",/\d{1,3}(?=(\d{3})+(?!\d))/g),E(X,"fraction_limits",[9,99,999,9999]),E(X,"imaginary_character","\u{1D456}"),E(X,"minus_character","-");var L=class{static Get(e,t=!1){if(t&&e==="General")return this.complex_general;let i=this.symbolc_name_map[e.toLowerCase()],r=this.cache[i||e];return r||(r=new X(e),this.cache[e]=r),r}static Equals(e,t){if(e===t)return!0;let i=this.Get(e),r=this.Get(t);return i.pattern===r.pattern}static Translate(e){let t=this.symbolc_name_map[e.toLowerCase()];return t?this.cache[t].toString():e}static SymbolicName(e){for(let t of Object.keys(this.base_formats))if(e===this.base_formats[t])return t;return null}static InitCache(){for(let e of Object.keys(this.base_formats))this.cache[e]=new X(this.base_formats[e]),this.symbolc_name_map[e.toLowerCase()]=e;this.cache.General.magic_decimal=!0,this.complex_general=new X("0.###"),this.complex_general.magic_decimal=!0;for(let e of Object.keys(this.aliases))this.cache[e]=this.cache[this.aliases[e]],this.symbolc_name_map[e.toLowerCase()]=e}};E(L,"cache",{}),E(L,"complex_general"),E(L,"symbolc_name_map",{}),E(L,"base_formats",{Accounting:"_(#,##0.00_);(#,##0.00);-???",Number:"0.00",Integer:"0",Percent:"0.00%",General:"0.######",Fraction:"# ?/?",Dollar:"$* _(#,##0.00_);$* (#,##0.00);$* -???",Exponential:"0.000e","Short Date":"mm/dd/yy","Long Date":"dddd, mmm d yyyy",Timestamp:"mm-dd-yy hh:mm:ss"}),E(L,"aliases",{Scientific:"Exponential",Percentage:"Percent",Currency:"Dollar"});L.InitCache();var Cr=new Date().getUTCFullYear(),Ei=class{compare_day;compare_month;TestDate(e){let t=Date.parse(e);if(isNaN(t))return!1;let i=new Date(t),s=e.replace(/[\d\-\\/,.\s]+/g," ").toLocaleLowerCase().split(/\s+/).map(a=>a.trim()).filter(a=>!!a);if(!s.length)return t;if(!this.compare_month){this.compare_month={};for(let a=0;a<12;a++)this.compare_month[T.date_components.long_months[a].toLocaleLowerCase().replace(/\./,"")]=a,this.compare_month[T.date_components.short_months[a].toLocaleLowerCase().replace(/\./,"")]=a}if(!this.compare_day){this.compare_day={};for(let a=0;a<7;a++)this.compare_day[T.date_components.long_days[a].toLocaleLowerCase().replace(/\./,"")]=a,this.compare_day[T.date_components.short_days[a].toLocaleLowerCase().replace(/\./,"")]=a}let n=!1,o=!1;for(let a of s){let l=!1;for(let[d,u]of Object.entries(this.compare_month))if(a===d){if(n||i.getUTCMonth()!==u)return!1;l=!0,n=!0}if(!l){for(let[d,u]of Object.entries(this.compare_day))if(a===d){if(o||i.getUTCDay()!==u)return!1;l=!0,o=!0}}if(!l)return!1}return o&&!n?!1:t}TryParse(e=""){let t=0;if(e[0]==="'")return{value:e,type:2};if(e==="")return{value:e,type:2};if(e==="NaN")return{value:NaN,type:3,hints:1};let i=e.trim(),r=i.match(/^[$](.*?)$/);r&&(i=r[1],t|=8);let s=i.match(/^\((.*?)\)$/);s&&(i=s[1],t|=32);let n=i.match(/^(.*?)%\s*$/);n&&(i=n[1],t|=4),T.decimal_separator==="."?/,/.test(i)&&(i=i.replace(/,/g,""),t|=16):(i=i.replace(/(\d)\s+/g,"$1"),i=i.replace(/\./g,""),i=i.replace(/,/,"."));let o=Number(i);if(o===null||isNaN(o)){let a=e.toLowerCase();if(a==="false")return{value:!1,type:4};if(a==="true")return{value:!0,type:4};let l=this.TestDate(e);if(l!==!1&&!isNaN(l)){let d=new Date(l),u=d.getUTCFullYear();if(u>=Cr-200&&u<=Cr+200)return t=64,(d.getHours()||d.getMinutes()||d.getSeconds())&&(t|=128),{value:je(l),type:3,hints:t}}return{value:e,type:2}}if(s&&(o=-o),n){let a=o<0?-1:1,l=(a*o).toString().split(".");l[0]=("00"+l[0]).replace(/(\d\d)$/,".$1"),o=Number(l.join(""))*a}return/e/.test(e)&&(t|=2),{value:o,type:3,hints:t}}},ye=new Ei;var ot="http://www.w3.org/2000/svg",Ut=class{constructor(e,t,i={x:0,y:0}){this.theme=t;this.offset=i;this.g=document.createElementNS(ot,"g"),this.g.setAttribute("transform",`translate(${i.x}, ${i.y})`),this.outline=document.createElementNS(ot,"rect"),this.outline.setAttribute("class","outline"),e?(this.g.setAttribute("class","selection primary-selection"),this.fill=document.createElementNS(ot,"path"),this.fill.setAttribute("class","fill"),this.nub=document.createElementNS(ot,"rect"),this.nub.setAttribute("class","nub"),this.g.appendChild(this.fill),this.g.appendChild(this.outline),this.g.appendChild(this.nub)):(this.g.setAttribute("class","selection alternate-selection"),this.fill=document.createElementNS(ot,"rect"),this.fill.setAttribute("class","fill"),this.g.appendChild(this.fill),this.g.appendChild(this.outline))}g;outline;fill;nub;Offset(e){this.g.setAttribute("transform",`translate(${e.x}, ${e.y})`)}Show(e=!0){this.g.style.display=e?"block":"none"}SetOutline(e,t=!1){this.outline.setAttribute("x",(e.left-1).toString()),this.outline.setAttribute("y",(e.top-1).toString()),this.outline.setAttribute("width",(e.width+1).toString()),this.outline.setAttribute("height",(e.height+1).toString()),t&&this.fill&&(this.fill.setAttribute("x",e.left.toString()),this.fill.setAttribute("y",e.top.toString()),this.fill.setAttribute("width",e.width.toString()),this.fill.setAttribute("height",e.height.toString()))}SetFill(e,t){if(!this.fill)return;let i=[];i.push("M"+e.left+" "+e.top),i.push("L"+e.left+" "+e.bottom),i.push("L"+e.right+" "+e.bottom),i.push("L"+e.right+" "+e.top),i.push("Z"),i.push("M"+t.left+" "+t.top),i.push("L"+t.right+" "+t.top),i.push("L"+t.right+" "+t.bottom),i.push("L"+t.left+" "+t.bottom),i.push("Z"),this.fill.setAttribute("d",i.join(" "))}SetNub(e){!this.nub||(this.nub.setAttribute("x",(e.left+e.width-4).toString()),this.nub.setAttribute("y",(e.top+e.height-4).toString()),this.nub.setAttribute("width","7"),this.nub.setAttribute("height","7"))}};var ki="http://www.w3.org/2000/svg";var Ie=class{constructor(e,t,i){this.theme=e;this.container=t;this.orientation=i;this.g=document.createElementNS(ki,"g"),this.g.setAttribute("class","header-overlay"),this.overlay=document.createElementNS(ki,"rect"),this.overlay.setAttribute("class","overlay"),this.highlight=document.createElementNS(ki,"rect"),this.highlight.setAttribute("class","highlight"),this.g.style.display="none",this.g.appendChild(this.highlight),this.g.appendChild(this.overlay),t.appendChild(this.g)}g;overlay;highlight;Remove(){this.container.removeChild(this.g)}Hide(){this.g.style.display="none"}Show(e,t,i,r){this.overlay.setAttribute("x",e.toString()),this.overlay.setAttribute("y",t.toString()),this.overlay.setAttribute("width",i.toString()),this.overlay.setAttribute("height",r.toString()),this.orientation===0?(this.highlight.setAttribute("x",e.toString()),this.highlight.setAttribute("y",(t+r-2).toString()),this.highlight.setAttribute("width",i.toString()),this.highlight.setAttribute("height","2")):(this.highlight.setAttribute("x",(e+i-2).toString()),this.highlight.setAttribute("y",t.toString()),this.highlight.setAttribute("width","2"),this.highlight.setAttribute("height",r.toString())),this.g.style.display="block"}};var Mt=class{constructor(e,t,i,r,s,n){this.theme=e;this.layout=t;this.model=i;this.view=r;this.primary_selection=s;this.additional_selections=n}nub_rectangle=new z(-1,-1,0,0);cached_additional_selections="";grid_selections=[];row_header_selections=[];column_header_selections=[];corner_selections=[];row_overlay;column_overlay;corner_row_overlay;corner_column_overlay;Initialize(){this.row_overlay=new Ie(this.theme,this.layout.row_header_selection,0),this.column_overlay=new Ie(this.theme,this.layout.column_header_selection,1),this.corner_row_overlay=new Ie(this.theme,this.layout.corner_selection,0),this.corner_column_overlay=new Ie(this.theme,this.layout.corner_selection,1)}RenderSelections(e=!0,t=!0){let i=this.primary_selection.empty;e||(this.primary_selection.empty=!0);let r=[this.primary_selection].concat(this.additional_selections);this.RenderSelectionGroup(r,this.layout.grid_selection,void 0,void 0,this.grid_selections,void 0,t);let s=new z(-1,-1,0,0);if(!this.primary_selection.empty){let a=this.view.active_sheet.RealArea(this.primary_selection.area);s=this.layout.CellAddressToRectangle(a.start).Combine(this.layout.CellAddressToRectangle(a.end))}if(!this.primary_selection.empty&&this.layout.header_offset.y>2?(this.row_overlay.Show(s.left,0,s.width,this.layout.header_offset.y),this.corner_row_overlay.Show(s.left+this.layout.header_offset.x,0,s.width,this.layout.header_offset.y)):(this.row_overlay.Hide(),this.corner_row_overlay.Hide()),!this.primary_selection.empty&&this.layout.header_offset.x>2?(this.column_overlay.Show(0,s.top,this.layout.header_offset.x,s.height),this.corner_column_overlay.Show(0,s.top+this.layout.header_offset.y,this.layout.header_offset.x,s.height)):(this.column_overlay.Hide(),this.corner_column_overlay.Hide()),!this.view.active_sheet.freeze.columns&&!this.view.active_sheet.freeze.rows){this.primary_selection.empty=i;return}let n=[],o=[];if(this.primary_selection.empty)n.push(!1),o.push(!1);else{let a=this.primary_selection.area.start;n.push(a.row<=this.view.active_sheet.freeze.rows||a.row===1/0),o.push(a.column<=this.view.active_sheet.freeze.columns||a.column===1/0)}for(let{area:a}of this.additional_selections)n.push(a.start.row<=this.view.active_sheet.freeze.rows||a.start.row===1/0),o.push(a.start.column<=this.view.active_sheet.freeze.columns||a.start.column===1/0);this.view.active_sheet.freeze.rows&&this.RenderSelectionGroup(r,this.layout.row_header_selection,n,void 0,this.row_header_selections,{x:0,y:this.layout.header_offset.y}),this.view.active_sheet.freeze.columns&&this.RenderSelectionGroup(r,this.layout.column_header_selection,o,void 0,this.column_header_selections,{x:this.layout.header_offset.x,y:0}),this.view.active_sheet.freeze.rows&&this.view.active_sheet.freeze.columns&&this.RenderSelectionGroup(r,this.layout.corner_selection,o,n,this.corner_selections,{...this.layout.header_offset}),this.primary_selection.empty=i}RenderSelectionGroup(e,t,i,r,s,n,o=!0){for(let a=0;a<e.length;a++)if((!e[a].area.start.sheet_id||e[a].area.start.sheet_id===this.view.active_sheet.id)&&!e[a].empty&&(!i||i[a])&&(!r||r[a])){if(o||!e[a].rendered){let d=this.EnsureGridSelectionBlock(t,s,a,n);this.RenderSVGSelection(e[a],d,a)}}else s[a]&&s[a].Show(!1);for(let a=e.length;a<s.length;a++)s[a]&&s[a].Show(!1)}EnsureGridSelectionBlock(e,t,i,r){let s=t[i];if(!s)if(s=new Ut(!i,this.theme),t[i]=s,i){let n=e.querySelector(".alternate-selections");n||(n=document.createElementNS("http://www.w3.org/2000/svg","g"),n.setAttribute("class","alternate-selections"),e.appendChild(n)),n?.appendChild(s.g)}else e.appendChild(s.g);return r&&s.Offset(r),s}ClampEnd(e){return{row:Math.min(e.row,this.view.active_sheet.rows-1),column:Math.min(e.column,this.view.active_sheet.columns-1)}}RenderSVGSelection(e,t,i=0){let r=this.view.active_sheet.RealArea(e.area,!0),s=this.layout.CellAddressToRectangle(r.start);if(r.count>1)s=s.Combine(this.layout.CellAddressToRectangle(r.end));else if(i){let n=this.view.active_sheet.CellData(e.target);n.merge_area&&(s=this.layout.CellAddressToRectangle(n.merge_area.start),s=s.Combine(this.layout.CellAddressToRectangle(n.merge_area.end)))}if(i||(this.nub_rectangle=new z(s.left+s.width-6,s.top+s.height-6,11,11)),s.top===0&&this.layout.header_offset.y<=1&&(s.top=1,s.height-=1),s.left===0&&this.layout.header_offset.x<=1&&(s.left=1,s.width-=1),s.height<=0||s.height<=0){t.Show(!1);return}if(t.SetOutline(s,!!i),i)e.rendered=!0;else{let n=this.layout.CellAddressToRectangle(e.target),o=this.view.active_sheet.CellData(e.target);o.merge_area&&(n=this.layout.CellAddressToRectangle(o.merge_area.start),n=n.Combine(this.layout.CellAddressToRectangle(o.merge_area.end))),t.SetFill(n,s),t.SetNub(s)}t.Show()}};function me(c,e=[],t,i){typeof e=="string"&&(e=[e]);let r,s=o=>{o.stopPropagation(),o.preventDefault(),r(),i&&i(o)},n=o=>{if(o.stopPropagation(),o.preventDefault(),!o.buttons){r(),i&&i(o);return}t&&t(o)};r=()=>{c.style.display="none",c.removeEventListener("mousemove",n),c.removeEventListener("mouseup",s);for(let o of e)c.classList.remove(o)};for(let o of e)c.classList.add(o);c.style.display="block",t&&c.addEventListener("mousemove",n),i&&c.addEventListener("mouseup",s)}var V=class{static CreateDiv(e="",t,i){return this.Create("div",e,t,i)}static Create(e="",t="",i,r,s){let n=document.createElement(e);if(t&&n.setAttribute("class",t),r&&n.setAttribute(r,""),s){let o=Object.keys(s);for(let a of o)n.setAttribute(a,s[a])}return i&&i.appendChild(n),n}};var Dt=class extends Q{constructor(t){super();this.container=t;this.format=L.Get("0.0");let i=V.CreateDiv("treb-scale-control-2",t);this.input=V.Create("input","treb-scale-input",i);let r=V.CreateDiv("treb-slider-container",i);this.input.addEventListener("keypress",s=>{switch(s.key){case"ArrowUp":case"ArrowDown":s.stopPropagation(),s.preventDefault(),console.info("mark?");break}}),this.input.addEventListener("keydown",s=>{switch(s.key){case"Enter":this.input.blur();break;case"ArrowUp":this.Tick(-1);break;case"ArrowDown":this.Tick(1);break;case"Escape":this.input.value=this.format.Format(this.scale)+"%",this.input.blur();break;default:return}s.stopPropagation(),s.preventDefault()}),this.input.addEventListener("change",()=>{let s=this.input.value;s=s.replace(/%/g,"");let n=ye.TryParse(s);n.type===3?this.UpdateScale(Number(n.value),!0):this.input.value=this.format.Format(this.scale)+"%"}),this.slider=V.Create("input",void 0,r,void 0,{type:"range",min:"50",max:"200",value:"100",step:"2.5"}),this.slider.addEventListener("input",()=>{this.UpdateScale(Number(this.slider.value),!0)}),i.addEventListener("wheel",s=>{s.stopPropagation(),s.preventDefault(),this.Tick(s.deltaY)})}input;slider;scale=0;format;timeout=0;Tick(t){let i=Math.round(this.scale/2.5)*2.5;t>0?this.UpdateScale(i-2.5,!0,!0):t<0&&this.UpdateScale(i+2.5,!0,!0)}UpdateScale(t,i=!1,r=!1){t=Math.max(50,Math.min(200,t)),t!==this.scale&&(this.scale=t,this.input.value=this.format.Format(t)+"%",this.slider.value=t.toFixed(1),i&&(this.timeout||(this.timeout=requestAnimationFrame(()=>{this.timeout=0,this.Publish({type:"scale",value:this.scale/100,keep_focus:r})}))))}};var Lt=class extends Q{constructor(t,i,r,s,n,o){super();this.layout=t;this.model=i;this.view=r;this.options=s;this.theme=n;this.grid_container=o;this.Init(o)}node;container;scale_control;stats_panel;dragging=!1;double_click_data={};_visible=!1;get visible(){return this._visible}set stats_data(t){if(this.stats_panel){this.stats_panel.innerText="";for(let i of t){let r=document.createElement("span");r.classList.add("treb-stats-label"),r.textContent=i.label,this.stats_panel.appendChild(r);let s=document.createElement("span");s.classList.add("treb-stats-value"),s.textContent=i.value,this.stats_panel.appendChild(s)}}}IsDoubleClick(t,i=300){return this.double_click_data.index===t?(clearTimeout(this.double_click_data.timeout),this.double_click_data.index=void 0,this.double_click_data.timeout=void 0,!0):(this.double_click_data.timeout&&clearTimeout(this.double_click_data.timeout),this.double_click_data.index=t,this.double_click_data.timeout=setTimeout(()=>{this.double_click_data.index=void 0,this.double_click_data.timeout=void 0},i),!1)}Hide(){this.Show(!1)}Show(t=!0){!this.container||(this._visible=t,t?(this.grid_container.classList.add("treb-tab-bar-layout"),this.grid_container.parentElement?.classList.add("has-tab-bar"),this.container.style.display="flex"):(this.grid_container.classList.remove("treb-tab-bar-layout"),this.grid_container.parentElement?.classList.remove("has-tab-bar"),this.container.style.display="none"))}SetActive(t,i){i?t.classList.add("selected"):t.classList.remove("selected")}UpdateScale(t){this.scale_control?.UpdateScale(t*100)}Update(){if(this.dragging||!this.node)return;if(this.options.tab_bar==="auto"){if(this.model.sheets.list.reduce((o,a)=>a.visible?o+1:o,0)<=1){this.Show(!1);return}this.Show(!0)}this.grid_container.classList.add("treb-tab-bar-layout"),this.grid_container.parentElement?.classList.add("has-tab-bar");let t=this.node,i=!1,r=Array.prototype.map.call(t.children,n=>n);for(let n of r)n.dataset.preserve?i=!0:t.removeChild(n);if(!i){let n=document.createElement("div");n.classList.add("tab-bar-spacer"),n.dataset.preserve="true",t.appendChild(n),n=document.createElement("div"),n.classList.add("tab-bar-end"),n.dataset.preserve="true",this.options.stats&&(this.stats_panel=document.createElement("div"),this.stats_panel.classList.add("treb-stats-panel"),n.appendChild(this.stats_panel)),this.options.scale_control&&(this.scale_control=new Dt(n),this.scale_control.Subscribe(o=>{this.Publish(o)}),this.UpdateScale(this.options.initial_scale||1)),t.appendChild(n)}if(this.options.delete_tab){let n=document.createElement("div");n.classList.add("delete-tab"),n.innerHTML="<svg viewbox='0 0 16 16'><path d='M4,4 L12,12 M12,4 L4,12'/></svg>",n.style.order=(-1).toString(),n.title="Delete current sheet",n.addEventListener("click",()=>{this.Publish({type:"delete-sheet"})}),t.appendChild(n)}let s=[];for(let n of this.model.sheets.list){if(!n.visible)continue;let o=s.length,a=document.createElement("div");a.classList.add("tab"),a.style.order=(o*2).toString(),this.SetActive(a,n===this.view.active_sheet);let l=u=>{if(u.stopPropagation(),u.preventDefault(),this.IsDoubleClick(o))return;this.Publish({type:"activate-sheet",sheet:n});let h=s.map(v=>v.getBoundingClientRect()),p=o*2-1,f=h[0].left,m=h[h.length-1].right,b=h[0].top,_=h[0].bottom,y=-1,x=(h.length-1)*2+1;for(let v of s)this.SetActive(v,v===a);this.dragging=!0,me(this.layout.mask,[],v=>{let[w,C]=[v.clientX,v.clientY];if(C>b&&C<_){let S=p;if(w<f)S=y;else if(w>m)S=x;else for(let U=0;U<h.length;U++){let J=h[U];if(w>=J.left&&w<=J.right){U!==o&&(w>=J.left+J.width/2?S=U*2+1:S=U*2-1);break}}S!==p&&(p=S,a.style.order=p.toString(),h=s.map(U=>U.getBoundingClientRect()))}},()=>{let v=o,w=(p+1)/2;this.dragging=!1;for(let C=0;C<this.model.sheets.length;C++)this.model.sheets.list[C].visible||(v>=C&&v++,w>=C&&w++);v===w||v===0&&w<=0||v===s.length-1&&w>=s.length-1||this.Publish({type:"reorder-sheet",index:v,move_before:w})})},d=()=>{a.removeEventListener("mousedown",l),a.removeEventListener("dblclick",d),a.contentEditable="true";let u=window.getSelection();if(u){u.removeAllRanges();let h=document.createRange();h.selectNodeContents(a),u.addRange(h)}a.addEventListener("keydown",h=>{switch(h.key){case"Enter":this.Publish({type:"rename-sheet",name:a.innerText.trim(),sheet:n});break;case"Escape":a.innerText=n.name,this.Publish({type:"cancel"});break;default:return}h.stopPropagation(),h.preventDefault()}),a.addEventListener("focusout",()=>{let h=a.innerText.trim();h!==n.name&&this.Publish({type:"rename-sheet",name:h,sheet:n})}),a.focus()};a.textContent=n.name,a.addEventListener("dblclick",d),a.addEventListener("mousedown",l),t.appendChild(a),s.push(a)}if(this.options.add_tab){let n=document.createElement("a");n.classList.add("add-tab"),n.style.order=(this.model.sheets.length*2).toString(),n.innerText="+",n.title="Add sheet",n.addEventListener("click",()=>{this.Publish({type:"add-sheet"})}),t.appendChild(n)}}Init(t){this.container=document.createElement("div"),this.container.classList.add("treb-tab-bar-container"),t.appendChild(this.container),this.node=document.createElement("div"),this.node.classList.add("treb-tab-bar"),this.container.appendChild(this.node)}};var Sr=()=>({target:{row:0,column:0},area:new g({row:0,column:0}),empty:!0});var Ws=100,Te=class{get key(){return this.key_}rect;scaled_rect;layout;data={};type="";temp={};resizable=!0;movable=!0;removable=!0;selectable=!0;move_with_cells=!0;resize_with_cells=!0;view=[];dirty;formula="";extent;key_=Ws++;constructor(e={}){for(let t of Object.keys(this))t!=="layout"&&e[t]&&(this[t]=e[t]);e.layout&&(this.layout=JSON.parse(JSON.stringify(e.layout))),e.rect&&(this.rect=z.Create(e.rect))}toJSON(){let e={};return this.data&&(e.data=this.data),this.formula&&(e.formula=this.formula),this.type&&(e.type=this.type),this.resizable||(e.resizable=this.resizable),this.movable||(e.movable=this.movable),this.removable||(e.removable=this.removable),this.selectable||(e.selectable=this.selectable),this.move_with_cells||(e.move_with_cells=this.move_with_cells),this.resize_with_cells||(e.resize_with_cells=this.resize_with_cells),this.layout&&(e.layout=this.layout),this.extent&&(e.extent=this.extent),e}};var qs=100,Ar=60,Ue=class{default_style_properties;annotations=[];freeze={rows:0,columns:0};visible=!0;default_column_width=100;default_row_height=25;cells=new vt;selection=Sr();scroll_offset={x:0,y:0};name=Ue.default_sheet_name;id_;row_height_=[];column_width_=[];row_headers=[];column_headers=[];row_header_width=100;column_header_height=25;style_map=[];style_json_map=[];sheet_style={};row_styles={};column_styles={};row_pattern=[];cell_style=[];get header_offset(){return{x:this.row_header_width,y:this.column_header_height}}get rows(){return this.cells.rows}get columns(){return this.cells.columns}get id(){return this.id_}set id(e){this.id_=e,this.id>=Ue.base_id&&(Ue.base_id=this.id+1)}constructor(e){this.default_style_properties=e,this.default_column_width=qs,this.row_header_width=Ar,this.UpdateDefaultRowHeight(),this.id_=Ue.base_id++}static Reset(){this.base_id=100}static Blank(e,t,i=30,r=20){let s=new Ue(e);return t&&(s.name=t),i=Math.max(i,1),r=Math.max(r,1),s.cells.EnsureCell({row:i-1,column:r-1}),s}static UpdateStyle(e){if(typeof e.horizontal_align=="number"){let t=[A.HorizontalAlign.None,A.HorizontalAlign.Left,A.HorizontalAlign.Center,A.HorizontalAlign.Right];e.horizontal_align=t[e.horizontal_align]||void 0}if(typeof e.vertical_align=="number"){let t=[A.VerticalAlign.None,A.VerticalAlign.Top,A.VerticalAlign.Bottom,A.VerticalAlign.Middle];e.vertical_align=t[e.vertical_align]||void 0}}static FromJSON(e,t,i){let r=typeof e=="string"?JSON.parse(e):e,s=(l,d)=>{Object.keys(d).forEach(u=>{let h=Number(u)||0;l[h]=d[u]})};i||(i=new Ue(t)),r.default_column_width&&(i.default_column_width=r.default_column_width),r.default_row_height&&(i.default_row_height=r.default_row_height),r.id&&(i.id=r.id),r.name&&(i.name=r.name);let n=l=>{let d=l;this.UpdateStyle(d),(d.font_size_value||d.font_size_unit)&&(d.font_size={unit:d.font_size_unit||"pt",value:d.font_size_value||10},d.font_size_unit=void 0,d.font_size_value=void 0),d.font_bold&&(d.bold=!0,d.font_bold=void 0),d.font_italic&&(d.italic=!0,d.font_italic=void 0),d.font_underline&&(d.underline=!0,d.font_underline=void 0),d.font_strike&&(d.strike=!0,d.font_strike=void 0),d.text_color&&(d.text_color!=="none"&&(d.text={text:d.text_color}),d.text_color=void 0),d.background&&(d.background!=="none"&&(d.fill={text:d.background}),d.background=void 0),d.border_top_color&&(d.border_top_color!=="none"&&(d.border_top_fill={text:d.border_top_color}),d.border_top_color=void 0),d.border_left_color&&(d.border_left_color!=="none"&&(d.border_left_fill={text:d.border_left_color}),d.border_left_color=void 0),d.border_bottom_color&&(d.border_bottom_color!=="none"&&(d.border_bottom_fill={text:d.border_bottom_color}),d.border_bottom_color=void 0),d.border_right_color&&(d.border_right_color!=="none"&&(d.border_right_fill={text:d.border_right_color}),d.border_right_color=void 0)},o=r.styles||r.cell_style_refs||[];for(let l of o)n(l);if(i.cell_style=[],o&&(r.cell_styles||[]).forEach(l=>{typeof l.ref=="number"&&(l.style=JSON.parse(JSON.stringify(o[l.ref])))}),i.cells.FromJSON(r.data),r.rows&&i.cells.EnsureRow(r.rows-1),r.columns&&i.cells.EnsureColumn(r.columns-1),r.data)if(Qe(r.data))for(let l of r.data)l.style_ref&&(i.cell_style[l.column]||(i.cell_style[l.column]=[]),i.cell_style[l.column][l.row]=JSON.parse(JSON.stringify(o[l.style_ref])));else if(ai(r.data))for(let l of r.data){let d=l.row;for(let u of l.cells){let h=u.column;u.style_ref&&(i.cell_style[h]||(i.cell_style[h]=[]),i.cell_style[h][d]=JSON.parse(JSON.stringify(o[u.style_ref])))}}else for(let l of r.data){let d=l.column;for(let u of l.cells){let h=u.row;u.style_ref&&(i.cell_style[d]||(i.cell_style[d]=[]),i.cell_style[d][h]=JSON.parse(JSON.stringify(o[u.style_ref])))}}i.freeze.rows=0,i.freeze.columns=0,r.freeze&&(i.freeze.rows=r.freeze.rows||0,i.freeze.columns=r.freeze.columns||0),i.scroll_offset=r.scroll?{...r.scroll}:{x:0,y:0};for(let l of r.cell_styles||[])if(l.style&&(i.cell_style[l.column]||(i.cell_style[l.column]=[]),i.cell_style[l.column][l.row]=l.style,l.rows))for(let d=1;d<l.rows;d++)i.cell_style[l.column][l.row+d]=JSON.parse(JSON.stringify(l.style));i.sheet_style=r.sheet_style||{},i.column_styles={},i.row_styles={};let a=(l,d)=>{for(let u of Object.keys(l)){let h=Number(u),p=l[h];if(typeof p=="number"){let f=o[p];f&&(d[h]=JSON.parse(JSON.stringify(f)),n(d[h]))}else p&&(d[h]=p,n(d[h]))}};a(r.row_style,i.row_styles),a(r.column_style,i.column_styles),i.row_pattern=r.row_pattern||[],n(i.sheet_style||{});for(let l of i.row_pattern)n(l);return i.row_height_=[],s(i.row_height_,r.row_height||{}),i.row_height_.length&&i.cells.EnsureRow(i.row_height_.length-1),i.column_width_=[],s(i.column_width_,r.column_width||{}),i.column_width_.length&&i.cells.EnsureColumn(i.column_width_.length-1),i.annotations=(r.annotations||[]).map(l=>new Te(l)),r.selection&&(i.selection=JSON.parse(JSON.stringify(r.selection))),i.visible=!0,typeof r.visible<"u"&&(i.visible=!!r.visible),i}MergeCells(e){e=e.Clone(),this.cells.Apply(e,(t,i,r)=>{t.merge_area=e,t.render_clean=[],(i!==e.start.column||r!==e.start.row)&&t.Reset()},!0)}UnmergeCells(e){let t=!0;if(this.cells.Apply(e,i=>{t=t&&!!i.merge_area&&e.Equals(i.merge_area)},!1),!t){console.warn("area mismatch");return}this.cells.Apply(e,i=>{i.merge_area=void 0,i.render_clean=[]},!1)}StyleFontSize(e,t={}){let i=e.font_size?.value||0,r=0;switch(e.font_size?.unit){case"px":i*=75/100;break;case"em":r=e.font_size.value||1;break;case"%":r=(e.font_size.value||100)/100;break}return r&&(i=r*(t.font_size?.value||10),t.font_size?.unit==="px"&&(i*=75/100)),i||10}UpdateDefaultRowHeight(){let e=A.Composite([this.default_style_properties,this.sheet_style]);if(typeof window<"u"){let t=ee.MeasureText(A.Font(e),"M"),i=Math.round(t.height*1.4);this.default_row_height<i&&(this.default_row_height=i)}}SetRowHeaders(e){this.row_headers=e.map(t=>t===void 0?"":t.toString()),this.row_headers&&this.cells.EnsureRow(this.row_headers.length-1)}SetColumnHeaders(e){this.column_headers=e.map(t=>t===void 0?"":t.toString()),e&&this.cells.EnsureColumn(e.length-1)}RowHeader(e){return this.row_headers?this.row_headers.length>e?this.row_headers[e]:"":e+1}ColumnHeader(e){let t="";if(this.column_headers)return this.column_headers.length>e?this.column_headers[e]:"";for(;;){let i=e%26;if(t=String.fromCharCode(65+i)+t,e=Math.floor(e/26),e)e--;else break}return t}GetRowHeight(e){let t=this.row_height_[e];return typeof t>"u"?this.default_row_height:t}SetRowHeight(e,t){return this.row_height_[e]=t,this.cells.EnsureRow(e),t}GetColumnWidth(e){let t=this.column_width_[e];return typeof t>"u"?this.default_column_width:t}SetColumnWidth(e,t){return this.column_width_[e]=t,this.cells.EnsureColumn(e),t}Delta(e,t){let i={},r=[...Object.keys(e),...Object.keys(t)];for(let s of r){let n=e[s],o=t[s];typeof n=="object"&&typeof o=="object"?JSON.stringify(n)!==JSON.stringify(o)&&(i[s]=o):n!==o&&(i[s]=o)}return i}UpdateCellStyle(e,t,i=!0){let{row:r,column:s}=e;this.cell_style[s]||(this.cell_style[s]=[]);let n=this.CompositeStyleForCell(e,!1,!1),o=A.Composite([this.default_style_properties,n,A.Merge(this.cell_style[s][r]||{},t,i)]),a=this.Delta(n,o);this.cell_style[s][r]=a,this.CellData(e).FlushStyle()}Invalidate(e){this.cells.Apply(this.RealArea(e),t=>t.render_clean=[])}UpdateAreaStyle(e,t={},i=!0){if(!!e)if(e.entire_sheet)this.UpdateSheetStyle(t,i);else if(e.entire_column)for(let r=e.start.column;r<=e.end.column;r++)this.UpdateColumnStyle(r,t,i);else if(e.entire_row)for(let r=e.start.row;r<=e.end.row;r++)this.UpdateRowStyle(r,t,i);else e.Array().forEach(r=>this.UpdateCellStyle(r,t,i))}HasCellStyle(e){return!!(this.cell_style[e.column]&&this.cell_style[e.column][e.row]||this.row_styles[e.row]||this.column_styles[e.column]||this.row_pattern.length)}NextVisibleColumn(e){for(++e;this.column_width_[e]===0;e++);return e}PreviousVisibleColumn(e){for(--e;e>=0&&this.column_width_[e]===0;e--);return e}NextVisibleRow(e){for(++e;this.row_height_[e]===0;e++);return e}PreviousVisibleRow(e){for(--e;e>=0&&this.row_height_[e]===0;e--);return e}SurroundingStyle(e){let t=[{},{},{},{},{},{},{},{},{},{}],i=e.column+1,r=e.column-1,s=e.row+1,n=e.row-1;for(;this.column_width_[i]===0;i++);for(;this.row_height_[s]===0;s++);for(;r>=0&&this.column_width_[r]===0;r--);for(;n>=0&&this.row_height_[n]===0;n--);return r>=0&&n>=0&&(t[7]=this.CellStyleData({row:n,column:r})||{}),r>=0&&(t[4]=this.CellStyleData({row:e.row,column:r})||{},t[1]=this.CellStyleData({row:s,column:r})||{}),n>=0&&(t[8]=this.CellStyleData({row:n,column:e.column})||{},t[9]=this.CellStyleData({row:n,column:i})||{}),t[6]=this.CellStyleData({row:e.row,column:i})||{},t[2]=this.CellStyleData({row:s,column:e.column})||{},t[3]=this.CellStyleData({row:s,column:i})||{},t}CellStyleData(e){let t=this.cells.GetCell(e);if(!!t){if(!t.style){let i=this.GetStyleIndex(this.CompositeStyleForCell(e));t.style=this.style_map[i]}return t.style}}GetCopyStyle(e){return this.CompositeStyleForCell(e,!0,!1)}CellData(e){let t=this.cells.EnsureCell(e);if(t.rendered_type)return t;let i,r;if(t.calculated_type?(r=t.calculated,i=t.calculated_type):(r=t.value,i=t.type),!t.style){let s=this.GetStyleIndex(this.CompositeStyleForCell(e));t.style=this.style_map[s]}if(!i||r===null||typeof r>"u")t.formatted="",t.rendered_type=2;else if(i===3)isNaN(r)?t.formatted=typeof t.style.nan>"u"?"NaN":t.style.nan:t.formatted=this.FormatNumber(r,t.style.number_format),t.rendered_type=3;else if(i===6)t.formatted="#"+(r||"ERR?"),t.rendered_type=6;else if(i===4)t.formatted=r.toString().toUpperCase(),t.rendered_type=4;else if(i===1&&t.calculated===void 0)t.formatted="",t.rendered_type=2;else if(i===7){let s=r;if(isNaN(s.real)||isNaN(s.imaginary))t.formatted=typeof t.style.nan>"u"?"NaN":t.style.nan;else{let n=L.Get(t.style.number_format||"",!0);t.formatted=n.FormatComplex(s)}t.rendered_type=7}else if(i===9){if(isNaN(r.value))t.formatted=typeof t.style.nan>"u"?"NaN":t.style.nan,t.formatted+=" "+r.unit;else{let s=L.Get(t.style.number_format||"",!0);t.formatted=s.FormatDimensionedQuantity(r)}t.rendered_type=9}else t.formatted=this.FormatNumber(r,t.style.number_format),t.rendered_type=2;return t}FormatNumber(e,t=""){let i=L.Get(t).FormatParts(e);return i.length?i.length===1&&!i[0].flag?i[0].text||"":i:""}SetHeaderSize(e=Ar,t=this.default_row_height){this.row_header_width=e,this.column_header_height=t}AutoSizeRow(e,t={},i=!0){let r=this.default_row_height,s=9;for(let n=0;n<this.cells.columns;n++){let o=this.CellData({row:e,column:n}),a=o.style,l=o.formatted||"";if(typeof l!="string"&&(l=l.map(d=>d.text).join("")),a&&l&&l.length){let d=l.split(/\n/),u=Math.round(this.StyleFontSize(a,t)*1.5);r=Math.max(r,((u||10)+s)*d.length)}}!i&&this.GetRowHeight(e)>=r||this.SetRowHeight(e,r)}GetStyle(e){return this.style_map[e]}InsertRows(e=0,t=1){if(e)for(let a=0;a<this.cells.columns;a++){let l=this.cells.GetCell({row:e-1,column:a},!1);if(l&&l.area){let d=this.cells.GetCell({row:e,column:a},!1);if(d&&d.area&&d.area.Equals(l.area))return!1}}t<0?this.cells.DeleteRows(e,-t):this.cells.InsertRows(e,t);let i={},r={};for(let a=e;a<this.cells.rows;a++)for(let l=0;l<this.cells.columns;l++){let d=this.cells.GetCell({row:a,column:l},!1);d&&(d.area&&!r[d.area.spreadsheet_label]&&(r[d.area.spreadsheet_label]=d.area),d.merge_area&&!i[d.merge_area.spreadsheet_label]&&(i[d.merge_area.spreadsheet_label]=d.merge_area))}for(let a of Object.keys(r)){let l=r[a],d=new g({row:l.start.row+t,column:l.start.column},{row:l.end.row+t,column:l.end.column});d.Iterate(u=>{let h=this.cells.GetCell(u,!0);h.area=d})}for(let a of Object.keys(i)){let l=i[a],d={row:l.start.row,column:l.start.column};l.start.row>=e&&(d.row+=t);let u=new g(d,{row:l.end.row+t,column:l.end.column});u.Iterate(h=>{let p=this.cells.GetCell(h,!0);p.merge_area=u})}let s=Object.keys(this.row_styles),n={};s.forEach(a=>{let l=Number(a);l<e?n[l]=this.row_styles[l]:t<0&&l<e-t||(n[l+t]=this.row_styles[l])}),this.row_styles=n;let o=[];if(t<0)o=[e,-t];else{o=[e,0];for(let a=0;a<t;a++)o.push(void 0)}return this.cell_style.forEach(a=>{a&&a.length>=e&&a.splice.apply(a,o)}),this.row_height_.splice.apply(this.row_height_,o),this.FlushCellStyles(),!0}InsertColumns(e=0,t=1){if(e)for(let a=0;a<this.cells.rows;a++){let l=this.cells.GetCell({row:a,column:e-1},!1);if(l&&l.area){let d=this.cells.GetCell({row:a,column:e},!1);if(d&&d.area&&d.area.Equals(l.area))return!1}}t<0?this.cells.DeleteColumns(e,-t):this.cells.InsertColumns(e,t);let i={},r={};for(let a=e;a<this.cells.columns;a++)for(let l=0;l<this.cells.rows;l++){let d=this.cells.GetCell({row:l,column:a},!1);d&&(d.area&&!r[d.area.spreadsheet_label]&&(r[d.area.spreadsheet_label]=d.area),d.merge_area&&!i[d.merge_area.spreadsheet_label]&&(i[d.merge_area.spreadsheet_label]=d.merge_area))}for(let a of Object.keys(r)){let l=r[a],d=new g({row:l.start.row,column:l.start.column+t},{row:l.end.row,column:l.end.column+t});d.Iterate(u=>{let h=this.cells.GetCell(u,!0);h.area=d})}for(let a of Object.keys(i)){let l=i[a],d={row:l.start.row,column:l.start.column};l.start.column>=e&&(d.column+=t);let u=new g(d,{row:l.end.row,column:l.end.column+t});u.Iterate(h=>{let p=this.cells.GetCell(h,!0);p.merge_area=u})}let s=Object.keys(this.column_styles),n={};s.forEach(a=>{let l=Number(a);l<e?n[l]=this.column_styles[l]:t<0&&l<e-t||(n[l+t]=this.column_styles[l])}),this.column_styles=n;let o=[];if(t<0)o=[e,-t];else{o=[e,0];for(let a=0;a<t;a++)o.push(void 0)}return this.cell_style.splice.apply(this.cell_style,o),this.column_width_.splice.apply(this.column_width_,o),this.FlushCellStyles(),!0}ClearArea(e){e=this.RealArea(e),this.cells.Apply(e,t=>t.Reset())}SetAreaValues2(e,t){e=this.RealArea(e),this.cells.SetArea(e,t)}SetArrayValue(e,t){e=this.RealArea(e),this.cells.Apply(e,r=>r.SetArray(e),!0),this.cells.GetCell(e.start,!0).SetArrayHead(e,t)}SetCellValue(e,t){this.cells.GetCell(e,!0).Set(t)}RealArea(e,t=!1){let i=e.start,r=e.end;return e.entire_row&&(i.column=0,i.absolute_column=!1,r.column=this.cells.columns-1,r.absolute_column=!1),e.entire_column&&(i.row=0,i.absolute_row=!1,r.row=this.cells.rows-1,r.absolute_row=!1),t&&(r.row>=this.rows&&(r.row=this.rows-1,r.absolute_row=!1),r.column>=this.columns&&(r.column=this.columns-1,r.absolute_column=!1)),new g(i,r)}GetCellStyle(e,t=!1){if(P(e))return this.CompositeStyleForCell(e,!0,!1,t);if(e.start.row===e.end.row&&e.start.column===e.end.column)return this.CompositeStyleForCell(e.start,!0,!1,t);let i=[];for(let r=e.start.row;r<=e.end.row;r++){let s=[];for(let n=e.start.column;n<=e.end.column;n++)s.push(this.CompositeStyleForCell({row:r,column:n},!0,!1,t));i.push(s)}return i}FormattedCellValue(e){let t=this.CellData(e);if(!!t)return typeof t.formatted=="string"?t.formatted:t.formatted?t.formatted.map(i=>{switch(i.flag){case 1:return" ";case 2:return" ";default:return i.text}}).join(""):t.value}GetFormattedRange(e,t=e){if(e.row===t.row&&e.column===t.column)return this.FormattedCellValue(e);let i=[];for(let r=e.row;r<=t.row;r++){let s=[];for(let n=e.column;n<=t.column;n++)s.push(this.FormattedCellValue({row:r,column:n}));i.push(s)}return i}NumberFormatsAndColors(e,t){let i=r=>{r.number_format&&(t[r.number_format]=1),r.text?.text&&r.text.text!=="none"&&(e[r.text.text]=1),r.fill?.text&&(e[r.fill.text]=1),r.border_top_fill?.text&&(e[r.border_top_fill.text]=1),r.border_left_fill?.text&&(e[r.border_left_fill.text]=1),r.border_right_fill?.text&&(e[r.border_right_fill.text]=1),r.border_bottom_fill?.text&&(e[r.border_bottom_fill.text]=1)};i(this.sheet_style);for(let r in this.row_styles)i(this.row_styles[r]);for(let r in this.column_styles)i(this.column_styles[r]);for(let r of this.row_pattern)i(r);for(let r of this.cell_style)if(r)for(let s of r)s&&i(s)}CompressCellStyles(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(r)for(let s=0;s<r.length;s++){let n=r[s];if(n){let o=s+1;for(;o<r.length&&r[o]===n;o++);o>s+1?t.push({row:s,column:i,ref:n,rows:o-s}):t.push({row:s,column:i,ref:n}),s=o-1}}}return t}toJSON(e={}){let t=(w,C)=>{let S={};for(let U=0;U<w.length;U++)typeof w[U]<"u"&&w[U]!==C&&(S[U]=w[U]);if(Object.keys(S).length)return S},i=[{}],r={},s=[],n=JSON.stringify({});for(let w=0;w<this.cell_style.length;w++){let C=this.cell_style[w];if(C){s[w]=[];for(let S=0;S<C.length;S++)if(C[S]){let U=JSON.stringify(C[S]);if(U!==n){let J=r[U];typeof J!="number"&&(r[U]=J=i.length,i.push(C[S])),s[w][S]=J}}}}let o=w=>{let C=JSON.stringify(w);if(C===n)return 0;let S=r[C];return typeof S!="number"&&(r[C]=S=i.length,i.push(w)),S};i=JSON.parse(JSON.stringify(i));let a=JSON.parse(JSON.stringify(this.sheet_style)),l=JSON.parse(JSON.stringify(this.row_pattern)),d={},u={};for(let w of Object.keys(this.column_styles)){let C=Number(w),S=this.column_styles[C];if(S){let U=o(S);U&&(d[C]=U)}}for(let w of Object.keys(this.row_styles)){let C=Number(w),S=this.row_styles[C];if(S){let U=o(S);U&&(u[C]=U)}}let h=(w,C)=>{if(typeof w<"u"&&w!=="none")return w===C?void 0:ee.MeasureColorARGB(w)},p=(w={},C={})=>{let S={...C,...w};if(S.text)return S.text=ee.MeasureColorARGB(S.text),S;if(typeof S.theme=="number")return S};if(e.export_colors){let w=[];for(let C of[i,[a],l])if(Array.isArray(C))for(let S of C)w.push(S);else for(let S of Object.keys(C))w.push(C[S]);for(let C of w){let S=p(C.border_top_fill,A.DefaultProperties.border_top_fill);S!==void 0&&(C.border_top_fill=S),S=p(C.border_left_fill,A.DefaultProperties.border_left_fill),S!==void 0&&(C.border_left_fill=S),S=p(C.border_right_fill,A.DefaultProperties.border_right_fill),S!==void 0&&(C.border_right_fill=S),S=p(C.border_bottom_fill,A.DefaultProperties.border_bottom_fill),S!==void 0&&(C.border_bottom_fill=S),C.fill?.text&&(C.fill.text=ee.MeasureColorARGB(C.fill.text)),C.text&&C.text.text&&C.text.text!=="none"&&(C.text.text=ee.MeasureColorARGB(C.text.text))}}let f={calculated_value:!!e.rendered_values,preserve_type:!!e.preserve_type,expand_arrays:!!e.expand_arrays,decorated_cells:!!e.decorated_cells,nested:!0,cell_style_refs:s},m=this.cells.toJSON(f),b=m.data,{rows:_,columns:y}=m;e.shrink?(_+=2,y+=1):(_=this.rows,y=this.columns);for(let w of this.annotations)w.extent||this.CalculateAnnotationExtent(w),w.extent&&(_=Math.max(_,w.extent.row+1),y=Math.max(y,w.extent.column+1));let x=this.CompressCellStyles(s),v={id:this.id,name:this.name,data:b,sheet_style:a,rows:_,columns:y,cell_styles:x,styles:i,row_style:u,column_style:d,row_pattern:l.length?l:void 0,default_row_height:this.default_row_height,default_column_width:this.default_column_width,row_height:t(this.row_height_,this.default_row_height),column_width:t(this.column_width_,this.default_column_width),selection:JSON.parse(JSON.stringify(this.selection)),annotations:JSON.parse(JSON.stringify(this.annotations))};return this.visible||(v.visible=this.visible),(this.scroll_offset.x||this.scroll_offset.y)&&(v.scroll=this.scroll_offset),(this.freeze.rows||this.freeze.columns)&&(v.freeze=this.freeze),v}FlushCellStyles(){this.style_map=[],this.style_json_map=[],this.cells.FlushCellStyles()}ImportData(e){let t=e.styles,i=e.sheet_style;i&&this.UpdateAreaStyle(new g({row:1/0,column:1/0},{row:1/0,column:1/0}),t[i]);let r=e.column_styles;if(r)for(let n=0;n<r.length;n++)r[n]&&this.UpdateAreaStyle(new g({row:1/0,column:n},{row:1/0,column:n}),t[r[n]]);this.cells.FromJSON(e.cells),e.name&&(this.name=e.name||"");let s=this.cell_style;for(let n of e.cells)n.style_ref&&(s[n.column]||(s[n.column]=[]),s[n.column][n.row]=t[n.style_ref]);for(let n=0;n<e.column_widths.length;n++)typeof e.column_widths[n]<"u"&&this.SetColumnWidth(n,e.column_widths[n]);for(let n=0;n<e.row_heights.length;n++)typeof e.row_heights[n]<"u"&&this.SetRowHeight(n,e.row_heights[n]);for(let n of e.annotations||[])this.annotations.push(new Te(n));e.hidden&&(this.visible=!1)}CalculateAnnotationExtent(e){if(e.layout){e.extent={...e.layout.br.address};return}let t=1e3;e.extent={row:0,column:0};let i=e.rect?.right;if(i&&this.default_column_width){for(let s=0;i>=0&&s<t;s++)if(i-=this.GetColumnWidth(s),i<0){e.extent.column=s;break}}let r=e.rect?.bottom;if(r&&this.default_row_height){for(let s=0;r>=0&&s<t;s++)if(r-=this.GetRowHeight(s),r<0){e.extent.row=s;break}}}UpdateSheetStyle(e,t=!0){this.sheet_style=A.Merge(this.sheet_style,e,t);let i=Object.keys(e);for(let r of this.cell_style)if(r)for(let s of r)s&&i.forEach(n=>delete s[n]);for(let r of Object.keys(this.row_styles))i.forEach(s=>delete this.row_styles[r][s]);for(let r of Object.keys(this.column_styles))i.forEach(s=>delete this.column_styles[r][s]);this.FlushCellStyles()}UpdateRowStyle(e,t,i=!0){this.row_styles[e]=A.Merge(this.row_styles[e]||{},t,i);let r=Object.keys(t);for(let s of this.cell_style)s&&s[e]&&r.forEach(n=>delete s[e][n]);for(let s=0;s<this.cells.columns;s++)if(this.column_styles[s]){let n=this.column_styles[s],o=this.cell_style[s]?this.cell_style[s][e]||{}:{};for(let a of r)typeof n[a]<"u"&&(o[a]=t[a]);Object.keys(o).length&&(this.cell_style[s]||(this.cell_style[s]=[]),this.cell_style[s][e]=JSON.parse(JSON.stringify(o)))}this.cells.Apply(this.RealArea(g.FromRow(e)),s=>s.FlushStyle())}UpdateColumnStyle(e,t,i=!0){this.column_styles[e]=A.Merge(this.column_styles[e]||{},t,i);let r=Object.keys(t);if(this.cell_style[e])for(let s of this.cell_style[e])s&&r.forEach(n=>delete s[n]);this.cells.Apply(this.RealArea(g.FromColumn(e)),s=>s.FlushStyle())}CompositeStyleForCell(e,t=!0,i=!0,r=!0){let{row:s,column:n}=e,o=[];return r&&o.push(this.default_style_properties),o.push(this.sheet_style),i&&this.row_pattern.length&&o.push(this.row_pattern[s%this.row_pattern.length]),this.row_styles[s]&&o.push(this.row_styles[s]),this.column_styles[n]&&o.push(this.column_styles[n]),t&&this.cell_style[n]&&this.cell_style[n][s]&&o.push(this.cell_style[n][s]),A.Composite(o)}GetStyleIndex(e){let t=JSON.stringify(e);for(let r=0;r<this.style_json_map.length;r++)if(t===this.style_json_map[r])return r;let i=this.style_map.length;return this.style_map.push(JSON.parse(t)),this.style_json_map.push(t),i}},j=Ue;E(j,"base_id",100),E(j,"default_sheet_name","Sheet1");var Rr="http://www.w3.org/2000/svg",Vt=class{constructor(e,t){this.model=e;this.view=t;this.mask=V.CreateDiv("treb-mouse-mask"),this.tooltip=V.CreateDiv("treb-tooltip"),this.dropdown_caret=document.createElementNS(Rr,"svg"),this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_caret.setAttribute("viewBox","0 0 24 24"),this.dropdown_caret.tabIndex=-1;let i=document.createElementNS(Rr,"path");i.setAttribute("d","M5,7 L12,17 L19,7"),this.dropdown_caret.appendChild(i),this.dropdown_caret.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),this.grid_cover.classList.remove("nub-select");let s=this.dropdown_caret.getAttribute("class")||"";/active/i.test(s)?this.dropdown_caret.setAttribute("class","treb-dropdown-caret"):(this.dropdown_caret.setAttribute("class","treb-dropdown-caret active"),this.dropdown_list.focus())}),this.dropdown_list=V.CreateDiv("treb-dropdown-list"),this.dropdown_list.setAttribute("tabindex","-1"),this.dropdown_list.addEventListener("keydown",r=>{let s=0;switch(r.key){case"ArrowDown":s=1;break;case"ArrowUp":s=-1;break;case"Escape":break;case"Enter":break;default:console.info(r.key);return}if(r.stopPropagation(),r.preventDefault(),r.key==="Escape"||r.key==="Enter")this.container?.focus(),this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),r.key==="Enter"&&this.dropdown_callback&&this.dropdown_selected&&this.dropdown_callback.call(0,this.dropdown_selected.dropdown_value);else if(s&&this.dropdown_selected)if(s>0&&this.dropdown_selected.nextSibling){this.dropdown_selected.nextSibling.classList.add("selected"),this.dropdown_selected.classList.remove("selected"),this.dropdown_selected=this.dropdown_selected.nextSibling;let n=this.dropdown_selected.offsetTop+this.dropdown_selected.offsetHeight;n>this.dropdown_list.offsetHeight+this.dropdown_list.scrollTop&&(this.dropdown_list.scrollTop=n-this.dropdown_list.offsetHeight)}else s<0&&this.dropdown_selected.previousSibling&&(this.dropdown_selected.previousSibling.classList.add("selected"),this.dropdown_selected.classList.remove("selected"),this.dropdown_selected=this.dropdown_selected.previousSibling,this.dropdown_selected.offsetTop<this.dropdown_list.scrollTop&&(this.dropdown_list.scrollTop=this.dropdown_selected.offsetTop))}),this.dropdown_list.addEventListener("mousedown",r=>{let s=r.target;r.target!==this.dropdown_list&&(r.stopPropagation(),r.preventDefault(),this.container?.focus(),this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_callback&&this.dropdown_callback.call(0,s.dropdown_value))}),this.dropdown_list.addEventListener("mousemove",r=>{let s=r.target;s!==this.dropdown_selected&&(this.grid_cover.classList.remove("nub-select"),this.dropdown_selected&&this.dropdown_selected.classList.remove("selected"),s.classList.add("selected"),this.dropdown_selected=s)}),this.mock_selection=V.CreateDiv("mock-selection-node"),this.mock_selection.innerHTML=" ",this.note_node=V.CreateDiv("treb-note"),this.title_node=V.CreateDiv("treb-hover-title"),this.HideNote()}column_header;row_header;contents;buffer_canvas;corner;corner_canvas;grid_selection;grid_cover;column_header_cover;row_header_cover;annotation_container;mask;mock_selection;container;grid_tiles=[];column_header_tiles=[];row_header_tiles=[];corner_selection;row_header_selection;column_header_selection;corner_annotations;row_header_annotations;column_header_annotations;frozen_row_tiles=[];frozen_column_tiles=[];header_size={width:0,height:0};last_column=0;total_height=0;total_width=0;default_row_height=0;default_column_width=0;header_offset={x:0,y:0};dpr=Math.max(1,self.devicePixelRatio||1);scale=1;scroll_reference_node;get scroll_offset(){return this.scroll_reference_node?{x:this.scroll_reference_node.scrollLeft,y:this.scroll_reference_node.scrollTop}:{x:0,y:0}}set scroll_offset(e){!this.scroll_reference_node||(this.scroll_reference_node.scrollLeft=e.x,this.scroll_reference_node.scrollTop=e.y)}dropdown_caret;trident=typeof navigator<"u"&&navigator.userAgent&&/trident/i.test(navigator.userAgent);default_tile_size={width:1200,height:800};tooltip_state;tooltip;dropdown_list;dropdown_caret_visible=!1;dropdown_callback;dropdown_selected;note_node;title_node;row_cache=[];column_cache=[];initialized=!1;UpdateDPR(){let e=Math.max(1,self.devicePixelRatio||1);return e===this.dpr?!1:(this.dpr=e,!0)}ColumnWidth(e){return Math.round(this.view.active_sheet.GetColumnWidth(e)*this.scale)}RowHeight(e){return Math.round(this.view.active_sheet.GetRowHeight(e)*this.scale)}SetRowHeight(e,t){this.view.active_sheet.SetRowHeight(e,Math.round(t/this.scale))}SetColumnWidth(e,t){this.view.active_sheet.SetColumnWidth(e,Math.round(t/this.scale))}ShowSelections(e=!0){this.grid_selection.style.display=e?"block":"none"}HideTitle(){this.title_node.style.opacity="0"}ShowTitle(e,t){if(this.title_node.textContent=e,!this.title_node.parentElement)return;let i=this.title_node.parentElement.getBoundingClientRect(),r=this.OffsetCellAddressToRectangle(t).Shift(this.header_size.width,this.header_size.height);this.title_node.style.left=i.left+r.left-this.scroll_reference_node.scrollLeft+0+"px",this.title_node.style.top=i.top+r.bottom-this.scroll_reference_node.scrollTop+8+"px",this.title_node.style.opacity="1"}HideNote(){this.note_node.style.opacity="0",this.note_node.style.pointerEvents="none"}ShowNote(e,t,i,r){if(r?this.note_node.innerHTML=r:this.note_node.textContent=e,!this.note_node.parentElement)return;let s=this.note_node.getBoundingClientRect(),n=this.note_node.parentElement.getBoundingClientRect(),o={x:8,y:2},a=this.OffsetCellAddressToRectangle(t).Shift(this.header_size.width,this.header_size.height);this.note_node.style.left=n.left+a.right-this.scroll_reference_node.scrollLeft+o.x+"px",this.note_node.style.top=n.top+a.top-this.scroll_reference_node.scrollTop-s.height/5-o.y+"px",this.note_node.style.opacity="1",this.note_node.style.pointerEvents="auto"}AnnotationLayoutOrder(e,t){let i=-1;for(let s=0;s<this.view.active_sheet.annotations.length;s++)if(this.view.active_sheet.annotations[s]===e){i=s;break}if(i<0)return!1;let r=Math.min(Math.max(0,i+t),this.view.active_sheet.annotations.length-1);if(r===i)return!1;this.view.active_sheet.annotations.splice(i,1),this.view.active_sheet.annotations.splice(r,0,e);for(let s=0;s<this.view.active_sheet.annotations.length;s++){let n=this.view.active_sheet.annotations[s].key,o=this.container?.querySelectorAll(`.annotation[data-key="${n}"]`);if(o)for(let a=0;a<o?.length;a++)o[a].style.zIndex=(s+1).toString()}return!0}PointToAnnotationCorner(e){let t=this.PointToAddress_Grid(e,void 0,!1),i=this.CellAddressToRectangle(t);return{address:t,offset:{x:(e.x-i.left)/i.width,y:(e.y-i.top)/i.height}}}RectToAnnotationLayout(e){return{tl:this.PointToAnnotationCorner({x:(e.left||0)+1,y:(e.top||0)+1}),br:this.PointToAnnotationCorner({x:e.right||e.left||100,y:e.bottom||e.top||100})}}AddressToAnnotationLayout(e,t){let i={tl:this.CellAddressToRectangle(e),br:this.CellAddressToRectangle(t)};return{tl:this.PointToAnnotationCorner({x:i.tl.left||0,y:i.tl.top||0}),br:this.PointToAnnotationCorner({x:i.br.right||i.tl.left||100,y:i.br.bottom||i.tl.left||100})}}AnnotationLayoutToRect(e){let t=this.CellAddressToRectangle(e.tl.address),i=this.CellAddressToRectangle(e.br.address),r=t.left+t.width*e.tl.offset.x-1,s=t.top+t.height*e.tl.offset.y-1;return new z(r,s,i.left+i.width*e.br.offset.x-r,i.top+i.height*e.br.offset.y-s)}UpdateAnnotation(e){Array.isArray(e)||(e=[e]);for(let t of e){let i=t.view[this.view.view_index]||{};if(i.node){if(i.node.dataset.scale=this.scale.toString(),i.node.style.fontSize=`${10*this.scale}pt`,t.rect&&!t.layout&&(t.scaled_rect=t.rect.Scale(this.scale),t.layout=this.RectToAnnotationLayout(t.scaled_rect)),t.layout){let r=this.AnnotationLayoutToRect(t.layout);r.ApplyStyle(i.node),t.scaled_rect=r}i.node.dataset.key=t.key.toString(),(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&this.CloneFrozenAnnotation(t)}}}GetFrozenAnnotations(e){return[this.row_header_annotations,this.column_header_annotations,this.corner_annotations].map(i=>i.querySelector(`.annotation[data-key="${e.key}"]`)).filter(i=>i!==null)}CloneFrozenAnnotations(){for(let e of this.view.active_sheet.annotations)e.view[this.view.view_index]?.node&&e.key&&this.CloneFrozenAnnotation(e)}ClearFrozenAnnotations(){for(let e of[this.row_header_annotations,this.column_header_annotations,this.corner_annotations]){let t=e.querySelectorAll(".annotation");for(let i=0;i<t.length;i++)t[i].parentElement?.removeChild(t[i])}}RemoveFrozenAnnotation(e){for(let t of[this.row_header_annotations,this.column_header_annotations,this.corner_annotations]){let i=t.querySelector(`.annotation[data-key="${e.key}"]`);i&&i.parentElement?.removeChild(i)}}CloneFrozenAnnotation(e){for(let t of[this.row_header_annotations,this.column_header_annotations,this.corner_annotations]){let i=t.querySelector(`.annotation[data-key="${e.key}"]`);i&&i.parentElement?.removeChild(i);let r=e.view[this.view.view_index];if(i=r?.node?.cloneNode(!0),i){let s=i.querySelector(".annotation-move-target"),n=i.querySelector(".annotation-resize-target");i.addEventListener("mousedown",o=>{let a=r.node;requestAnimationFrame(()=>{a?.focus()}),this.AnnotationMouseDown(e,r.node,o,s,n)}),t.appendChild(i)}}}RemoveAnnotation(e){let t=e.view[this.view.view_index]||{};t.node&&t.node.parentElement?.removeChild(t.node),this.RemoveFrozenAnnotation(e)}RemoveAnnotationNodes(){let e=Array.prototype.map.call(this.annotation_container.children,t=>t);for(let t of e)this.annotation_container.removeChild(t);(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&this.ClearFrozenAnnotations()}AddAnnotation(e){let t=e.view[this.view.view_index]||{};if(!t.node)throw new Error("annotation view/node missing");this.annotation_container.appendChild(t.node),this.UpdateAnnotation(e)}AnnotationMouseDown(e,t,i,r,s){let n=e.scaled_rect;return n?new Promise(o=>{let a={left:n.left,top:n.top,width:n.width,height:n.height},l=this.scroll_reference_node,d=l.getBoundingClientRect(),u=t.getBoundingClientRect();if(i.target===r||i.target!==s&&i.altKey){i.stopPropagation(),i.preventDefault(),t.focus();let h={x:u.left+i.offsetX-n.left,y:u.top+i.offsetY-n.top},p=[t,...this.GetFrozenAnnotations(e)],f=25,m=this.CellAddressToRectangle({row:0,column:0}).Combine(this.CellAddressToRectangle({row:this.view.active_sheet.rows-1,column:this.view.active_sheet.columns-1})).Expand(-1,-1);me(this.mask,"move",b=>{if(b.offsetY-d.top<this.header_offset.y){let _=Math.min(f,l.scrollTop);l.scrollTop-=_,h.y+=_}else if(b.offsetY-d.top>=d.height&&l.scrollTop+d.height<m.height){let _=f;l.scrollTop+=_,h.y-=_}if(b.offsetX-d.left<this.header_offset.x){let _=Math.min(f,l.scrollLeft);l.scrollLeft-=_,h.x+=_}else if(b.offsetX-d.left>=d.width&&l.scrollLeft+d.width<m.width){let _=f;l.scrollLeft+=_,h.x-=_}if(n.top=b.offsetY-h.y,n.left=b.offsetX-h.x,b.shiftKey){let _=Math.abs(n.left-a.left),y=Math.abs(n.top-a.top);_<=y?n.left=a.left:n.top=a.top}if(b.ctrlKey){let _=this.ClampToGrid({x:n.left,y:n.top});n.left=_.x,n.top=_.y}for(let _ of p)_.style.top=n.top+"px",_.style.left=n.left+"px"},()=>{e.extent=void 0,e.layout=this.RectToAnnotationLayout(n),o({type:"annotation",annotation:e,event:"move"})});return}else if(i.target===s){i.stopPropagation(),i.preventDefault(),t.focus();let h=0;e.data?.original_size&&e.data.original_size.width&&e.data.original_size.height&&(h=e.data.original_size.width/e.data.original_size.height);let p=t.getBoundingClientRect(),f={x:p.left+i.offsetX-n.width+s.offsetLeft,y:p.top+i.offsetY-n.height+s.offsetTop};me(this.mask,"nw-resize",m=>{let b=[t,...this.GetFrozenAnnotations(e)];if(n.height=m.offsetY-f.y,n.width=m.offsetX-f.x,m.shiftKey&&m.ctrlKey){if(h){let _=Math.abs(n.width-a.width),y=Math.abs(n.height-a.height);_<y?n.width=h*n.height:n.height=n.width/h}}else if(m.shiftKey){let _=Math.abs(n.height-a.height),y=Math.abs(n.width-a.width);_>y?n.width=a.width:n.height=a.height}else if(m.ctrlKey){let _=this.ClampToGrid({x:n.right,y:n.bottom});n.width=_.x-n.left+1,n.height=_.y-n.top+1}for(let _ of b)_.style.height=n.height+"px",_.style.width=n.width+"px"},()=>{e.extent=void 0,e.layout=this.RectToAnnotationLayout(n),o({type:"annotation",annotation:e,event:"resize"})});return}else o()}):(console.info("missing scaled rect!"),Promise.reject())}Initialize(e,t,i,r=!0){this.mask.parentElement||e.appendChild(this.mask),this.tooltip.parentElement||e.appendChild(this.tooltip),this.dropdown_caret.parentElement||e.appendChild(this.dropdown_caret),this.dropdown_list.parentElement||e.appendChild(this.dropdown_list),this.note_node.parentElement||e.appendChild(this.note_node),this.title_node.parentElement||e.appendChild(this.title_node),this.InitializeInternal(e,t),!r&&this.scroll_reference_node&&(this.scroll_reference_node.style.overflow="hidden"),this.dropdown_callback=i,this.initialized=!0}MockSelection(){if(!this.container||this.trident)return;let e=window.getSelection();if(e){let t=document.createRange();t.selectNodeContents(this.mock_selection),e.removeAllRanges(),e.addRange(t)}}CreateTile(e,t,i,r,s,n,o,a=!0){let l=document.createElement("canvas");return l.setAttribute("class",e),l.logical_size=t,l.width=t.width*this.dpr,l.height=t.height*this.dpr,l.style.width=`${t.width}px`,l.style.height=`${t.height}px`,l.tile_position=i,l.first_cell=r,this.UpdateTileGridPosition(l),l.last_cell={row:r.row+s.rows-1,column:r.column+s.columns-1},l.pixel_start=n,l.pixel_end={x:n.x+t.width,y:n.y+t.height},l.dirty=!!a,l.needs_full_repaint=!0,o.appendChild(l),l}ApplyTheme(e){this.row_header.style.backgroundColor=this.column_header.style.backgroundColor=this.corner.style.backgroundColor=e.headers?.fill?fe(e,e.headers.fill):"",this.corner.style.borderColor=e.grid_color||"";for(let t of this.grid_tiles)for(let i of t)i.style.backgroundColor=fe(e,e.grid_cell?.fill)||"#fff";this.dropdown_list.style.font=A.Font(e.grid_cell||{})}UpdateTotalSize(){this.total_height=0;let e=this.view.active_sheet.rows;for(let i=0;i<e;i++)this.total_height+=this.RowHeight(i);this.total_width=0;let t=this.view.active_sheet.columns;for(let i=0;i<t;i++)this.total_width+=this.ColumnWidth(i)}UpdateContentsSize(){let e=this.row_header_tiles.reduce((i,r)=>i+r.logical_size.height,0),t=this.column_header_tiles.reduce((i,r)=>i+r.logical_size.width,0);this.column_header.style.width=this.contents.style.width=`${t}px`,this.row_header.style.height=this.contents.style.height=`${e}px`}HideTooltip(){this.tooltip.style.display="none",this.tooltip_state=void 0,this.tooltip.classList.remove("arrow-up"),this.tooltip.classList.remove("arrow-left")}ShowTooltip(e={}){e.up?(this.tooltip.classList.add("arrow-up"),this.tooltip_state="up"):e.left&&(this.tooltip.classList.add("arrow-left"),this.tooltip_state="left"),this.tooltip.style.display="block",this.UpdateTooltip(e)}ShowDropdownCaret(e,t,i){let r=this.OffsetCellAddressToRectangle(e.start);e.count>1&&(r=r.Combine(this.OffsetCellAddressToRectangle(e.end))),r=r.Shift(this.header_size.width,this.header_size.height);let s=Math.round(this.scale*Math.max(8,Math.min(20,r.height)));this.dropdown_caret.style.height=`${s}px`,this.dropdown_caret.style.width=`${s}px`,this.dropdown_caret.style.left=`${r.right+1}px`,this.dropdown_caret.style.top=`${r.bottom-s}px`,this.dropdown_list.style.top=`${r.bottom+2}px`,this.dropdown_list.style.left=`${r.left+2}px`,this.dropdown_list.style.minWidth=`${r.width}px`,this.dropdown_list.textContent="";for(let n of t){let o=V.CreateDiv(void 0,this.dropdown_list);i===n&&(this.dropdown_selected=o,o.classList.add("selected")),o.dropdown_value=n,o.textContent=n?.toString()||""}this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_caret.style.display="block",this.dropdown_caret_visible=!0}HideDropdownCaret(){this.dropdown_caret_visible&&(this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_caret_visible=!1,this.dropdown_caret.style.display="none")}GetScrollOffset(){return{x:this.scroll_reference_node.scrollLeft+this.header_offset.x,y:this.scroll_reference_node.scrollTop+this.header_offset.y}}ScrollTo(e,t=!0,i=!0,r=!1){let s=this.CellAddressToRectangle(e);if(r&&!!this.scroll_reference_node.scrollTo){let n={left:this.scroll_reference_node.scrollLeft,top:this.scroll_reference_node.scrollTop},o={left:t?s.left:n.left,top:i?s.top:n.top,behavior:"smooth"};this.scroll_reference_node.scrollTo(o)}else i&&(this.scroll_reference_node.scrollTop=s.top),t&&(this.scroll_reference_node.scrollLeft=s.left)}ScrollIntoView(e){let t=this.CellAddressToRectangle(e),i=this.scroll_reference_node.clientWidth-this.row_header.offsetWidth,r=this.scroll_reference_node.clientHeight-this.column_header.offsetHeight,s={x:0,y:0},n={x:!1,y:!1},o=new z(this.scroll_reference_node.scrollLeft,this.scroll_reference_node.scrollTop,i,r);(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&(this.view.active_sheet.freeze.rows&&e.row>=this.view.active_sheet.freeze.rows?s.y=this.frozen_row_tiles[0].logical_size.height:this.view.active_sheet.freeze.rows&&(n.y=!0),this.view.active_sheet.freeze.columns&&e.column>=this.view.active_sheet.freeze.columns?s.x=this.frozen_column_tiles[0].logical_size.width:this.view.active_sheet.freeze.columns&&(n.x=!0)),e.row!==1/0&&(t.top<o.top+s.y&&!n.y?this.scroll_reference_node.scrollTop=t.top-s.y:t.bottom>o.bottom&&(this.scroll_reference_node.scrollTop=t.bottom-r)),e.column!==1/0&&(t.left<o.left+s.x&&!n.x?this.scroll_reference_node.scrollLeft=t.left-s.x:t.right>o.right&&(this.scroll_reference_node.scrollLeft=t.right-i))}UpdateTooltip(e={}){if(typeof e.text<"u"&&(this.tooltip.textContent=e.text),typeof e.x<"u"){let t=e.x||0;this.tooltip_state==="up"&&(t-=this.tooltip.offsetWidth/2),this.tooltip.style.left=Math.round(t)+"px"}if(typeof e.y<"u"){let t=e.y||0;this.tooltip_state==="left"&&(t-=this.tooltip.offsetHeight/2),this.tooltip.style.top=Math.round(t)+"px"}}CoordinateToRowHeader(e){let t={column:1/0,row:0};if(this.view.active_sheet.freeze.rows&&this.frozen_row_tiles[0].pixel_end.y>=e-this.scroll_reference_node.scrollTop){let i=0;e-=this.scroll_reference_node.scrollTop;for(let r=0;r<this.view.active_sheet.freeze.rows;r++)if(i+=this.RowHeight(r),i>=e)return t.row=r,t}for(let i of this.row_header_tiles)if(i.pixel_end.y>=e){let r=e-i.pixel_start.y,s=0;for(t.row=i.first_cell.row;t.row<=i.last_cell.row;t.row++,r-=s)if(s=this.RowHeight(t.row),s>r)return t;return t}return t}CoordinateToColumnHeader(e){let t={row:1/0,column:0};if(this.view.active_sheet.freeze.columns&&this.frozen_column_tiles[0].pixel_end.x>=e-this.scroll_reference_node.scrollLeft){let i=0;e-=this.scroll_reference_node.scrollLeft;for(let r=0;r<this.view.active_sheet.freeze.columns;r++)if(i+=this.ColumnWidth(r),i>=e)return t.column=r,t}for(let i of this.column_header_tiles)if(i.pixel_end.x>=e){let r=e-i.pixel_start.x,s=0;for(t.column=i.first_cell.column;t.column<=i.last_cell.column;t.column++,r-=s)if(s=this.ColumnWidth(t.column),s>r)return t;return t}return t}PointToAddress_Grid(e,t=!1,i=!0){if(i){if(this.view.active_sheet.freeze.rows){let o=this.frozen_row_tiles[0].logical_size.height;e.y-this.scroll_reference_node.scrollTop<o&&(e.y-=this.scroll_reference_node.scrollTop)}if(this.view.active_sheet.freeze.columns){let o=this.frozen_column_tiles[0].logical_size.width;e.x-this.scroll_reference_node.scrollLeft<o&&(e.x-=this.scroll_reference_node.scrollLeft)}}let r={row:0,column:0},s=this.grid_tiles[this.grid_tiles.length-1],n=s[s.length-1];if(e.y>n.pixel_end.y){let o=e.y-n.pixel_end.y;for(r.row=n.last_cell.row;o>0;)r.row++,o-=this.default_row_height}else for(let o of s)if(o.pixel_start.y<=e.y&&o.pixel_end.y>=e.y){let a=e.y-o.pixel_start.y,l=0;for(r.row=o.first_cell.row;r.row<=o.last_cell.row&&(l=this.RowHeight(r.row),!(l>a));r.row++,a-=l);break}if(e.x>n.pixel_end.x){let o=e.x-n.pixel_end.x;for(r.column=n.last_cell.column;o>0;)r.column++,o-=this.default_column_width}else for(let o of this.grid_tiles)if(o[0].pixel_start.x<=e.x&&o[0].pixel_end.x>=e.x){let a=o[0],l=e.x-a.pixel_start.x,d=0;for(r.column=a.first_cell.column;r.column<=a.last_cell.column&&(d=this.ColumnWidth(r.column),!(d>l));r.column++,l-=d);break}return r}AdjacentTile(e,t=0,i=0){if(!t&&!i)return e;let r=e.tile_position,s=e.tile_position.row+t,n=e.tile_position.column+i;if(!(s<0||n<0)){if(this.grid_tiles[r.column]&&this.grid_tiles[r.column][r.row]===e&&this.grid_tiles[n])return this.grid_tiles[n][s];if(!r.column&&this.frozen_column_tiles[r.row]===e)return this.frozen_column_tiles[s];if(!r.row&&this.frozen_row_tiles[r.column]===e)return this.frozen_row_tiles[n]}}UpdateTiles(){if(!this.container)throw new Error("invalid container");this.grid_tiles.forEach(v=>{v.forEach(w=>{w.parentElement&&w.parentElement.removeChild(w)})});for(let v of[this.column_header_tiles,this.row_header_tiles,this.frozen_row_tiles,this.frozen_column_tiles])for(let w of v)w.parentElement&&w.parentElement.removeChild(w);this.frozen_row_tiles=[],this.frozen_column_tiles=[],this.row_header_tiles=[],this.column_header_tiles=[],this.grid_tiles=[];let e=this.view.active_sheet;this.default_row_height=Math.round(e.default_row_height*this.scale),this.default_column_width=Math.round(e.default_column_width*this.scale),this.header_offset={x:Math.round(e.header_offset.x*this.scale),y:Math.round(e.header_offset.y*this.scale)},this.UpdateContainingGrid();let t=this.view.active_sheet.rows,i=this.view.active_sheet.columns;t||(t=100),i||(i=40);let r=0,s=0;for(let v=0;v<t;v++)r+=this.RowHeight(v);for(let v=0;v<i;v++)s+=this.ColumnWidth(v);if(!s||!r)throw"unexpected missing total size";if(r||(r=this.default_row_height*t),s||(s=this.default_column_width*i),this.container.offsetWidth>s){let v=Math.ceil((this.container.offsetWidth-s)/this.default_column_width);s+=v*this.default_column_width,i+=v}if(this.last_column=i,this.container.offsetHeight>r){let v=Math.ceil((this.container.offsetHeight-r)/this.default_row_height);r+=v*this.default_row_height,t+=v}this.column_header.style.width=this.contents.style.width=`${s}px`,this.row_header.style.height=this.contents.style.height=`${r}px`;let n=[],o=[],a=0,l=0;for(let v=0;v<i;v++){let w=this.ColumnWidth(v);a&&a+w>this.default_tile_size.width&&(n.push(a),o.push(l),l=v,a=0),a+=w}n.push(a),o.push(l);let d=[],u=[],h=0,p=0;for(let v=0;v<t;v++){let w=this.RowHeight(v);h&&h+w>this.default_tile_size.height&&(d.push(h),u.push(p),h=0,p=v),h+=w}d.push(h),u.push(p);let f=n.length,m=d.length,b=0,_=0,y=0,x=0;for(let v=0;v<this.view.active_sheet.freeze.rows;v++)y+=this.RowHeight(v);for(let v=0;v<this.view.active_sheet.freeze.columns;v++)x+=this.ColumnWidth(v);for(let v=0;v<f;v++){let w=[];b=0;let C=v===f-1?i-o[v]:o[v+1]-o[v];this.column_header_tiles.push(this.CreateTile("column-header-tile",{height:this.header_offset.y,width:n[v]},{row:0,column:v},{row:0,column:o[v]},{rows:0,columns:C},{x:_,y:0},this.column_header)),this.view.active_sheet.freeze.rows&&this.frozen_row_tiles.push(this.CreateTile("frozen-row-tile",{height:y,width:n[v]},{row:1,column:v},{row:0,column:o[v]},{rows:0,columns:C},{x:_,y:0},this.column_header));for(let S=0;S<m;S++){let U=S===m-1?t-u[S]:u[S+1]-u[S];v||(this.row_header_tiles.push(this.CreateTile("row-header-tile",{height:d[S],width:this.header_offset.x},{row:S,column:0},{row:u[S],column:0},{rows:U,columns:1},{x:0,y:b},this.row_header)),this.view.active_sheet.freeze.columns&&this.frozen_column_tiles.push(this.CreateTile("frozen-column-tile",{height:d[S],width:x},{row:S,column:1},{row:u[S],column:0},{rows:U,columns:1},{x:0,y:b},this.row_header))),w.push(this.CreateTile("grid-tile",{height:d[S],width:n[v]},{row:S,column:v},{row:u[S],column:o[v]},{rows:U,columns:C},{x:_,y:b},this.contents)),b+=d[S]}this.grid_tiles.push(w),_+=n[v]}this.total_height=r,this.total_width=s,this.ClearLayoutCaches(),this.UpdateGridTemplates(!0,!0)}ClearLayoutCaches(){this.row_cache=[],this.column_cache=[]}TileIndexForColumn(e){for(let t of this.column_header_tiles)if(t.first_cell.column<=e&&t.last_cell.column>=e)return t.tile_position.column;return-1}TileIndexForRow(e){for(let t of this.row_header_tiles)if(t.first_cell.row<=e&&t.last_cell.row>=e)return t.tile_position.row;return-1}DirtyHeaders(e){if(!!e){for(let t of this.column_header_tiles){if(t.dirty)continue;let i=new g({row:e.start.row,column:t.first_cell.column},{row:e.start.row,column:t.last_cell.column});(e.entire_row||i.Intersects(e))&&(t.dirty=!0)}for(let t of this.row_header_tiles){if(t.dirty)continue;let i=new g({column:e.start.column,row:t.first_cell.row},{column:e.start.column,row:t.last_cell.row});(e.entire_column||i.Intersects(e))&&(t.dirty=!0)}}}DirtyAll(){for(let e of this.grid_tiles)for(let t of e)t.dirty=!0}DirtyArea(e){if(!this.initialized)return;let t={row:0,column:0},i={row:this.grid_tiles[0].length-1,column:this.grid_tiles.length-1};e.start.column!==1/0&&(t.column=i.column=this.TileIndexForColumn(e.start.column),e.end.column!==e.start.column&&(i.column=this.TileIndexForColumn(e.end.column))),e.start.row!==1/0&&(t.row=i.row=this.TileIndexForRow(e.start.row),e.end.row!==e.start.row&&(i.row=this.TileIndexForRow(e.end.row)));for(let r=t.column;r<=i.column;r++)for(let s=t.row;s<=i.row;s++)this.grid_tiles[r][s].dirty=!0}VisibleTiles(){let e=[{row:0,column:0},{row:0,column:0}];if(!this.container||!this.grid_tiles.length||!this.grid_tiles[0].length)return new g(e[0],e[1]);let t=this.scroll_reference_node.scrollLeft,i=t+this.scroll_reference_node.offsetWidth,r=this.scroll_reference_node.scrollTop,s=r+this.scroll_reference_node.offsetHeight;for(let n of this.grid_tiles){let o=n[0];if(o.pixel_start.x<=t&&o.pixel_end.x>=t){for(o of n)if(o.pixel_start.y<=r&&o.pixel_end.y>=r){e[0]=o.tile_position;break}}if(n===this.grid_tiles[this.grid_tiles.length-1]||o.pixel_start.x<=i&&o.pixel_end.x>=i){for(o of n)if(o===n[n.length-1]||o.pixel_start.y<=s&&o.pixel_end.y>=s)return e[1]=o.tile_position,new g(e[0],e[1])}}return new g(e[0],e[1])}UpdateTileHeights(e=!0,t=-1){let i=0;for(let r=0;r<this.row_header_tiles.length;r++){let s=this.row_header_tiles[r];if(t>s.last_cell.row){i+=s.logical_size.height;continue}let n=0;for(let a=s.first_cell.row;a<=s.last_cell.row;a++)n+=this.RowHeight(a);let o=s.logical_size.height===n;if(s.pixel_start.y=i,i+=n,s.pixel_end.y=i,!o){if(s.logical_size.height=n,s.style.height=`${n}px`,s.height=this.dpr*n,this.view.active_sheet.freeze.columns){let a=this.frozen_column_tiles[r];a.logical_size.height=n,a.style.height=`${n}px`,a.height=this.dpr*n}e&&(s.dirty=!0,s.needs_full_repaint=!0)}for(let a of this.grid_tiles){let l=a[r];l.pixel_start.y=s.pixel_start.y,l.pixel_end.y=s.pixel_end.y,o||(l.logical_size.height=n,l.style.height=`${n}px`,l.height=this.dpr*n,e&&(l.dirty=!0,l.needs_full_repaint=!0))}}if(this.view.active_sheet.freeze.rows){let r=0;for(let s=0;s<this.view.active_sheet.freeze.rows;s++)r+=this.RowHeight(s);for(let s of this.frozen_row_tiles)s.style.height=`${r}px`,s.height=r*this.dpr;r+=this.header_offset.y,this.corner_canvas.style.height=`${r}px`,this.corner_canvas.height=r*this.dpr;for(let s of this.grid_tiles)s[0].dirty=!0}this.UpdateGridTemplates(!1,!0),this.row_header.style.height=this.contents.style.height=`${i}px`,this.ClearLayoutCaches()}UpdateTileWidths(e=!0,t=-1){let i=0;for(let r=0;r<this.column_header_tiles.length;r++){let s=this.column_header_tiles[r],n=this.grid_tiles[r];if(t>s.last_cell.column){i+=s.logical_size.width;continue}let o=0;for(let l=s.first_cell.column;l<=s.last_cell.column;l++)o+=this.ColumnWidth(l);let a=s.logical_size.width===o;if(s.pixel_start.x=i,i+=o,s.pixel_end.x=i,!a){if(s.logical_size.width=o,s.style.width=`${o}px`,s.width=this.dpr*o,this.view.active_sheet.freeze.rows){let l=this.frozen_row_tiles[r];l.logical_size.width=o,l.style.width=`${o}px`,l.width=this.dpr*o}e&&(s.dirty=!0,s.needs_full_repaint=!0)}for(let l of n)l.pixel_start.x=s.pixel_start.x,l.pixel_end.x=s.pixel_end.x,a||(l.logical_size.width=o,l.style.width=`${o}px`,l.width=this.dpr*o,e&&(l.dirty=!0,l.needs_full_repaint=!0))}if(this.view.active_sheet.freeze.columns){let r=0;for(let s=0;s<this.view.active_sheet.freeze.columns;s++)r+=this.ColumnWidth(s);for(let s of this.frozen_column_tiles)s.style.width=`${r}px`,s.width=r*this.dpr;r+=this.header_offset.x,this.corner_canvas.style.width=`${r}px`,this.corner_canvas.width=r*this.dpr;for(let s of this.grid_tiles[0])s.dirty=!0}this.UpdateGridTemplates(!0,!1),this.column_header.style.width=this.contents.style.width=`${i}px`,this.ClearLayoutCaches()}ClampToGrid(e){let t=this.PointToAddress_Grid(e),i=this.OffsetCellAddressToRectangle(t);return e.x>i.left+i.width/2?e.x=i.left+i.width-1:e.x=i.left-1,e.y>i.top+i.height/2?e.y=i.top+i.height-1:e.y=i.top-1,e}OffsetCellAddressToRectangle(e){let t=this.CellAddressToRectangle(e);return e.column>=0&&e.column<this.view.active_sheet.freeze.columns&&(t=t.Shift(this.scroll_reference_node.scrollLeft,0)),e.row>=0&&e.row<this.view.active_sheet.freeze.rows&&(t=t.Shift(0,this.scroll_reference_node.scrollTop)),t}CellAddressToRectangle(e){let t=e.row===1/0||e.row<0?0:e.row,i=e.column===1/0||e.column<0?0:e.column;if(this.column_cache.length<=i+1){this.column_cache.length||(this.column_cache[0]=0);for(let n=this.column_cache.length-1;n<=i;n++)this.column_cache[n+1]=this.column_cache[n]+this.ColumnWidth(n)}if(this.row_cache.length<=t+1){this.row_cache.length||(this.row_cache[0]=0);for(let n=this.row_cache.length-1;n<=t;n++)this.row_cache[n+1]=this.row_cache[n]+this.RowHeight(n)}let r=this.column_cache[i],s=this.row_cache[t];return new z(r,s,this.column_cache[i+1]-r,this.row_cache[t+1]-s)}ResizeTileWidth(e,t,i=!0){let r=this.column_header_tiles[e],s=t-r.logical_size.width;r.logical_size.width=t,r.style.width=`${t}px`,r.width=this.dpr*t,r.pixel_end.x+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);for(let o=e+1;o<this.column_header_tiles.length;o++){this.column_header_tiles[o].pixel_start.x+=s,this.column_header_tiles[o].pixel_end.x+=s;for(let a of this.grid_tiles[o])a.pixel_start.x+=s,a.pixel_end.x+=s}let n=this.grid_tiles[e];for(r of n)r.logical_size.width=t,r.style.width=`${t}px`,r.width=this.dpr*t,r.pixel_end.x+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);this.UpdateTotalSize(),this.UpdateGridTemplates(!0,!1),this.UpdateContentsSize()}ResizeTileHeight(e,t,i=!0){let r=this.row_header_tiles[e],s=t-r.logical_size.height;r.logical_size.height=t,r.style.height=`${t}px`,r.height=this.dpr*t,r.pixel_end.y+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);for(let n=e+1;n<this.row_header_tiles.length;n++)r=this.row_header_tiles[n],r.pixel_start.y+=s,r.pixel_end.y+=s;for(let n of this.grid_tiles){r=n[e],r.logical_size.height=t,r.style.height=`${t}px`,r.height=this.dpr*t,r.pixel_end.y+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);for(let o=e+1;o<n.length;o++)n[o].pixel_start.y+=s,n[o].pixel_end.y+=s}this.UpdateTotalSize(),this.UpdateGridTemplates(!1,!0),this.UpdateContentsSize()}};var It="http://www.w3.org/2000/svg",Ft=class extends Vt{constructor(e,t){super(e,t),this.column_header=V.CreateDiv("top-header"),this.row_header=V.CreateDiv("left-header"),this.corner=V.CreateDiv("corner"),this.corner_canvas=document.createElement("canvas"),this.corner.appendChild(this.corner_canvas),this.contents=V.CreateDiv("contents"),this.buffer_canvas=V.Create("canvas","treb-buffer-canvas",this.contents),this.grid_selection=document.createElementNS(It,"svg"),this.grid_selection.classList.add("grid-selection"),this.contents.appendChild(this.grid_selection),this.row_header_selection=document.createElementNS(It,"svg"),this.row_header_selection.classList.add("frozen-selection"),this.row_header_selection.classList.add("frozen-selection-rows"),this.column_header.appendChild(this.row_header_selection),this.row_header_annotations=V.CreateDiv("frozen-annotation-container frozen-annotation-container-rows",this.column_header),this.column_header_selection=document.createElementNS(It,"svg"),this.column_header_selection.classList.add("frozen-selection"),this.column_header_selection.classList.add("frozen-selection-columns"),this.row_header.appendChild(this.column_header_selection),this.column_header_annotations=V.CreateDiv("frozen-annotation-container frozen-annotation-container-columns",this.row_header),this.corner_selection=document.createElementNS(It,"svg"),this.corner_selection.classList.add("frozen-selection"),this.corner.appendChild(this.corner_selection),this.corner_annotations=V.CreateDiv("frozen-annotation-container frozen-annotation-container-corner",this.corner),this.annotation_container=V.CreateDiv("annotation-container"),this.grid_cover=V.CreateDiv("tile-cover grid-cover"),this.column_header_cover=V.CreateDiv("tile-cover column-header-cover"),this.row_header_cover=V.CreateDiv("tile-cover row-header-cover")}InitializeInternal(e,t){this.container=e,this.container.classList.add("grid-layout"),this.scroll_reference_node=this.container,e.appendChild(this.column_header),e.appendChild(this.row_header),e.appendChild(this.corner),e.appendChild(this.contents),e.appendChild(this.annotation_container),e.appendChild(this.grid_cover),e.appendChild(this.column_header_cover),e.appendChild(this.row_header_cover),e.appendChild(this.mock_selection),this.container.addEventListener("scroll",()=>t())}ResizeCursor(e){switch(e){case"row":this.row_header_cover.classList.add("resize");break;case"column":this.column_header_cover.classList.add("resize");break;default:this.row_header_cover.classList.remove("resize"),this.column_header_cover.classList.remove("resize");break}}UpdateTileGridPosition(e){e.style.gridColumn=`${e.tile_position.column+1} / ${e.tile_position.column+2}`,e.style.gridRow=`${e.tile_position.row+1} / ${e.tile_position.row+2}`}UpdateContainingGrid(){if(!this.container)throw new Error("missing container");this.header_size.width=this.header_offset.x,this.header_size.height=this.header_offset.y;let e=this.header_offset.x,t=this.header_offset.y;if(this.view.active_sheet.freeze.columns)for(let i=0;i<this.view.active_sheet.freeze.columns;i++)e+=this.ColumnWidth(i);if(this.view.active_sheet.freeze.rows)for(let i=0;i<this.view.active_sheet.freeze.rows;i++)t+=this.RowHeight(i);this.container.style.gridTemplateColumns=`${this.header_offset.x}px auto`,this.container.style.gridTemplateRows=`${this.header_offset.y}px auto`,this.corner_canvas.setAttribute("width",`${this.dpr*e}`),this.corner_canvas.setAttribute("height",`${this.dpr*t}`),this.column_header.style.height=`${t}px`,this.corner_canvas.style.width=`${e}px`,this.corner_canvas.style.height=`${t}px`}UpdateGridTemplates(e=!0,t=!0){let i=0,r=0;this.column_header.style.gridTemplateColumns=this.contents.style.gridTemplateColumns=this.column_header_tiles.map(l=>(i+=l.logical_size.width,`${l.logical_size.width}px`)).join(" "),this.column_header.style.gridTemplateRows=`${this.header_offset.y}px auto`,this.row_header.style.gridTemplateRows=this.contents.style.gridTemplateRows=this.row_header_tiles.map(l=>(r+=l.logical_size.height,`${l.logical_size.height}px`)).join(" ");let s=this.header_offset.y;if(this.view.active_sheet.freeze.rows)for(let l=0;l<this.view.active_sheet.freeze.rows;l++)s+=this.RowHeight(l);this.column_header.style.height=`${s}px`,this.row_header_selection.style.display="block",this.row_header_selection.style.width=`${i}px`,this.corner_selection.style.height=this.row_header_selection.style.height=`${s}px`,this.corner_selection.style.top=this.row_header_selection.style.top="0px",this.row_header_selection.style.left="0px";let n=this.header_offset.x;if(this.view.active_sheet.freeze.columns)for(let l=0;l<this.view.active_sheet.freeze.columns;l++)n+=this.ColumnWidth(l);this.column_header_selection.style.display="block",this.corner_selection.style.width=this.column_header_selection.style.width=`${n}px`,this.column_header_selection.style.height=`${r}px`,this.column_header_selection.style.top="0px",this.corner_selection.style.left=this.column_header_selection.style.left="0px";let o={x:this.view.active_sheet.header_offset.x*this.scale,y:this.view.active_sheet.header_offset.y*this.scale},a=this.view.active_sheet.freeze;a.rows&&a.columns?(this.row_header_annotations.style.display="block",this.column_header_annotations.style.display="block",this.corner_annotations.style.display="block"):a.rows?(this.row_header_annotations.style.display="block",this.column_header_annotations.style.display="none",this.corner_annotations.style.display="none"):a.columns?(this.row_header_annotations.style.display="none",this.column_header_annotations.style.display="block",this.corner_annotations.style.display="none"):(this.row_header_annotations.style.display="none",this.column_header_annotations.style.display="none",this.corner_annotations.style.display="none"),this.row_header_annotations.style.width=`${i}px`,this.corner_annotations.style.height=this.row_header_annotations.style.height=`${s-o.y}px`,this.corner_annotations.style.top=this.row_header_annotations.style.top=`${o.y}px`,this.column_header_annotations.style.width=this.corner_annotations.style.width=`${n-o.x}px`,this.column_header_annotations.style.height=`${r}px`,this.corner_annotations.style.left=this.column_header_annotations.style.left=`${o.x}px`,this.corner_selection.style.display="block",this.grid_selection.style.width=`${i}px`,this.grid_selection.style.height=`${r}px`,this.grid_selection.style.top=`${this.header_offset.y}px`,this.grid_selection.style.left=`${this.header_offset.x}px`,this.annotation_container.style.width=`${i}px`,this.annotation_container.style.height=`${r}px`,this.annotation_container.style.top=`${this.header_offset.y}px`,this.annotation_container.style.left=`${this.header_offset.x}px`}};var zt=class{function_names=[];argument_separator=T.argument_separator.charCodeAt(0);function_map={};RemoveFunctions(e){Array.isArray(e)||(e=[e]);let t=Object.keys(this.function_map).map(i=>this.function_map[i]);for(let i of e)t=t.filter(r=>r.name!==i.name);this.SetFunctions(t)}AddFunctions(e){Array.isArray(e)||(e=[e]);let t=Object.keys(this.function_map).map(i=>this.function_map[i]).concat(...e);this.SetFunctions(t)}SetFunctions(e){this.function_map={},this.function_names=e.map(t=>(this.function_map[t.name.toLowerCase()]=t,t.name)).sort((t,i)=>t.toLowerCase().localeCompare(i.toLowerCase()))}NormalizeIdentifier(e){let t=this.function_map[e.toLowerCase()];return t?t.name:void 0}Exec(e){if(e.text[0]!=="=")return{};let t,i={};if(e.cursor===e.text.length&&(t=e.text.match(/(?:^|[^A-Za-z_\d])([A-Za-z_][\w\d_.]*)\s*$/),t)){let s=t[1],n=new RegExp("^"+s.replace(".","\\."),"i");i={completions:this.function_names.filter(a=>n.test(a)).map(a=>this.function_map[a.toLowerCase()]),token:s,position:e.cursor-s.length}}let r=this.ParseTooltip(e.text.substr(0,e.cursor));if(r.function){let s=this.function_map[r.function.toLowerCase()];s&&(i.tooltip='<span class="notranslate">'+s.name+"</span>",i.arguments="("+(s.arguments||[]).map((n,o)=>{let a=n.name||"argument";return o===r.argument?`<span class="active-argument">${a}</span>`:a}).join(T.argument_separator+" ")+")",i.description=s.description?`<span class="function-description">${s.description}</span>`:"",i.function_position=r.position||0)}return i}ParseTooltip(e){let t=[],i=0,r="",s=!1,n=0;for(let a of e){let l=a.charCodeAt(0);if(s)l===34&&(s=!1);else switch(l){case 40:t.push({buffer:r.trim(),argument:i,position:n-r.length}),r="",i=0;break;case this.argument_separator:i++;break;case 41:i=t.pop()?.argument||0;break;case 34:r="",s=!0;break;default:l>=97&&l<=122||l>=65&&l<=90||l>=48&&l<=57||l===95||l===46?r+=a:r=""}n++}let o=t.pop();return{function:o?.buffer||void 0,position:o?.position||0,argument:i}}};var Xs=typeof navigator>"u"?"":navigator.appVersion,Se=typeof navigator>"u"?"":navigator.userAgent,Ti=class{is_edge=/Edge/.test(Xs);is_ipad=/iPad|iPhone/.test(Se);is_android=/android|samsung/i.test(Se);is_mobile=this.is_ipad||this.is_android;is_firefox=/firefox/i.test(Se);is_safari=/safari/i.test(Se)&&!/edg/i.test(Se);is_mac=/macintosh/i.test(Se);is_chrome=/Chrome/i.test(Se);is_windows=/win64|win32|windows\s+nt/i.test(Se);is_modern=!this.is_edge&&!(this.is_firefox&&this.is_android)&&/webkit|firefox/i.test(Se)},Ks={is_edge:!1,is_ipad:!1,is_android:!1,is_firefox:!1,is_safari:!1,is_mac:!1,is_chrome:!1,trident:!1,is_windows:!1,is_modern:!0,is_node:!0,is_mobile:!1},te=typeof navigator>"u"?Ks:new Ti;var Ui=class extends Q{constructor(t,i,r,s,n){super();this.parser=t;this.theme=i;this.model=r;this.view=s;this.autocomplete=n;this.measurement_node=document.createElement("div")}active_cell;autocomplete_matcher;measurement_node;selecting_=!1;editor_insert_node;editor_node;container_node;last_parse_string="";last_parse_result;reference_list;dependency_list=[];reference_index_map=[];last_reconstructed_text="";enable_reconstruct=!0;get selecting(){return this.selecting_}selection_={target:{row:0,column:0},area:new g({row:0,column:0})};get selection(){return this.selection_}set selection(t){if(t){let i=t.target||t.area.start;this.selection_={target:{row:i.row,column:i.column},area:new g(t.area.start,t.area.end)}}else{let i={row:0,column:0};this.selection_={target:i,area:new g(i)}}}UpdateTheme(t){}InsertReference(t,i){if(!this.editor_node)return;if(!this.editor_insert_node){let s=window.getSelection();if(s){let n=s.getRangeAt(0);this.editor_insert_node=document.createElement("span"),n.insertNode(this.editor_insert_node),s.collapseToEnd()}}if(this.editor_insert_node&&(this.editor_insert_node.innerText=t,t.length)){let s=window.getSelection();if(s){let n=document.createRange();n.selectNodeContents(this.editor_insert_node),s.removeAllRanges(),s.addRange(n),s.collapseToEnd()}}let r=this.ListDependencies();this.Publish({type:"update",text:this.editor_node.textContent||void 0,dependencies:r})}Autocomplete(t,i){if(!this.container_node)return;let r;i?.nodeType===Node.ELEMENT_NODE?r=i.getBoundingClientRect():r=this.container_node.getBoundingClientRect();let s=new z(Math.round(r.left),Math.round(r.top),r.width,r.height);this.autocomplete.Show(this.AcceptAutocomplete.bind(this),t,s)}FlushReference(){this.editor_insert_node=void 0}SubstringToCaret(t){let i=window.getSelection();if(!i)throw new Error("error getting selection");if(i.rangeCount===0)return console.warn("range count is 0"),"";let r=i.getRangeAt(0),s=r.cloneRange();return s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),this.measurement_node.textContent="",this.measurement_node.appendChild(s.cloneContents()),this.measurement_node.textContent}UpdateSelectState(t=!1){let i=!1,r=!1;if(!this.editor_node)return;let s=this.editor_node.textContent||"";if(s.trim()[0]==="="){r=!0;let o=this.SubstringToCaret(this.editor_node).trim();if(o.length){let a=o[o.length-1];Ui.FormulaChars.some(d=>a===d)&&(i=!0);let l=this.autocomplete_matcher;l&&se().then(()=>{let d=l.Exec({text:s,cursor:o.length}),u=this.NodeAtIndex(d.completions?d.position||0:d.function_position||0);this.Autocomplete(d,u)})}}i!==this.selecting_?(this.selecting_=i,i||this.Reconstruct(),(t||!i)&&this.Publish({type:"end-selection"})):i&&t&&this.Publish({type:"end-selection"});let n=r?this.ListDependencies():void 0;this.Publish({type:"update",text:s,dependencies:n})}NodeAtIndex(t){let i=this.editor_node?.childNodes||[];for(let r=0;r<i.length;r++){let s=i[r].textContent?.length||0;if(s>t)return i[r];t-=s}}Reconstruct(){if(!this.enable_reconstruct||!this.editor_node||(this.ParseDependencies(),!this.reference_list))return;let t=this.editor_node.textContent||"";if(t.trim()[0]!=="="||(this.editor_node.spellcheck=!1,this.selecting)||t.trim()===this.last_reconstructed_text.trim())return;this.last_reconstructed_text=t;let r=this.SubstringToCaret(this.editor_node).length,s=document.createDocumentFragment(),n,o=0,a,l="";if(this.last_parse_result){let d=0,u="",h=0,p=(f,m,b)=>{let _=document.createTextNode(m);if(b==="text")s.appendChild(_);else{let y=document.createElement("span");y.appendChild(_),y.dataset.position=f.toString(),y.dataset.type=b,b==="address"||b==="range"?y.classList.add(`highlight-${this.reference_index_map[h++]%5+1}`):b==="identifier"&&this.model.named_ranges.Get(m)&&y.classList.add(`highlight-${this.reference_index_map[h++]%5+1}`),s.appendChild(y)}return r>=f&&r<f+m.length&&(n=_,o=r-f),_};this.last_parse_result.expression&&this.parser.Walk(this.last_parse_result.expression,f=>{switch(f.type){case"address":case"range":case"call":case"identifier":f.position!==d-1&&p(d,t.substring(d,f.position+1),"text"),f.type==="call"||f.type==="identifier"?u=f.name:u=this.last_parse_string.substring(f.position+1,f.position+f.label.length+1),p(f.position+1,u,f.type),d=f.position+u.length+1;break}return f.type!=="range"}),l=t.substring(d)||"",a=p(d,l,"text")}if(!n)if(t.length===r){let d=document.createElement("span");s.appendChild(d),n=d,o=0}else n=a,o=Math.max(0,l.length-(t.length-r));if(this.editor_node.textContent="",this.editor_node.appendChild(s),n){let d=document.createRange(),u=window.getSelection();u&&(d.setStart(n,o),d.setEnd(n,o),d.collapse(!0),u.removeAllRanges(),u.addRange(d))}}ParseDependencies(){if(!this.editor_node)return;let t=this.editor_node.textContent||"";if(t!==this.last_parse_string||!this.reference_list){let i={};for(let r of this.model.sheets.list)i[r.name.toLowerCase()]=r.id;if(this.dependency_list=[],this.reference_index_map=[],t){let r=this.parser.Parse(t);if(this.last_parse_string=t,this.last_parse_result=r,this.reference_list=[],r.full_reference_list)for(let s of r.full_reference_list)if(s.type==="address"||s.type==="range"){let n=s.type==="address"?s:s.start;n.sheet_id||(n.sheet?n.sheet_id=i[n.sheet.toLowerCase()]||0:n.sheet_id=this.view.active_sheet.id),this.reference_list.push(s)}else{let n=this.model.named_ranges.Get(s.name);n&&(n.count===1?this.reference_list.push({type:"address",...n.start,label:s.name,position:s.position,id:s.id}):this.reference_list.push({type:"range",start:{type:"address",position:s.position,id:s.id,label:s.name,...n.start},end:{type:"address",position:s.position,label:s.name,id:s.id,...n.end},label:s.name,position:s.position,id:s.id}))}if(this.reference_list){this.reference_list.sort((s,n)=>s.position-n.position);for(let s of this.reference_list){let n;s.type==="address"?n=new g({row:s.row,column:s.column,sheet_id:s.sheet_id}):n=new g({row:s.start.row,column:s.start.column,sheet_id:s.start.sheet_id},{row:s.end.row,column:s.end.column});let o=n.spreadsheet_label;this.dependency_list.some((a,l)=>a.spreadsheet_label===o&&a.start.sheet_id===n.start.sheet_id?(this.reference_index_map.push(l),!0):!1)||(this.reference_index_map.push(this.dependency_list.length),this.dependency_list.push(n))}}}else this.reference_list=void 0}}ListDependencies(){return this.ParseDependencies(),this.dependency_list||[]}AcceptAutocomplete(t){if(!this.editor_node)return;let i=window.getSelection(),r=0;if(t.data&&t.data.completions){for(let d of t.data.completions)if(d.name.toLowerCase()===t.value?.toLowerCase()){r=d.type||0;break}}if(!i)throw new Error("error getting selection");let s=i.getRangeAt(0),n=s.cloneRange(),o=document.createElement("div");n.selectNodeContents(this.editor_node),n.setEnd(s.endContainer,s.endOffset),o.appendChild(n.cloneContents());let a=(o.textContent||"").substr(0,t.data?t.data.position:0)+t.value,l=r===1?a:a+"(";this.editor_node.textContent=l,this.autocomplete.Hide(),te.is_firefox||this.Reconstruct(),i=window.getSelection(),s=document.createRange(),this.editor_node?.lastChild&&s.setStartAfter(this.editor_node.lastChild),s.collapse(!0),i?.removeAllRanges(),i?.addRange(s),this.selecting_=!0,t.click&&this.UpdateSelectState()}},Fe=Ui;E(Fe,"FormulaChars",("$^&*(-+={[<>/~%"+T.argument_separator).split(""));var Pt=class extends Fe{constructor(t,i,r,s,n,o){super(i,r,s,n,o);this.container=t;this.edit_container=document.createElement("div"),this.edit_container.classList.add("overlay-container"),this.edit_container.classList.add("notranslate"),this.edit_container.translate=!1,this.edit_node=document.createElement("div"),this.edit_node.classList.add("overlay-editor"),this.edit_node.contentEditable="true",this.edit_node.tabIndex=-1,this.edit_node.spellcheck=!0,this.edit_node.setAttribute("role","gridcell"),te.is_firefox&&this.edit_node.classList.add("firefox"),this.edit_node.inputMode="none",this.edit_node.addEventListener("input",()=>{let a=this.edit_node.firstChild;a&&a.tagName==="BR"&&this.edit_node.removeChild(a),this.editing&&(this.Reconstruct(),this.UpdateSelectState())}),this.edit_node.addEventListener("keyup",a=>{if(!(!this.editing||this.autocomplete.HandleKey("keyup",a).handled)){if(this.selecting_)switch(a.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"Shift":case"Control":return}this.FlushReference(),this.UpdateSelectState(!0)}}),this.edit_inset=document.createElement("div"),this.edit_inset.classList.add("overlay-inset"),this.edit_container.appendChild(this.edit_node),this.edit_container.appendChild(this.edit_inset),this.edit_inset.appendChild(this.edit_node),t.appendChild(this.edit_container),this.edit_container.style.opacity="0",this.editor_node=this.edit_node,this.container_node=this.edit_container,this.ClearContents()}edit_node;edit_container;edit_inset;scale=1;_editing=!1;get editing(){return this._editing}set editing(t){this._editing!==t&&(this._editing=t,t?(this.edit_container.style.opacity="1",this.edit_container.style.pointerEvents="initial"):(this.edit_container.style.opacity="0",this.edit_container.style.pointerEvents="none"))}UpdateCaption(t=""){this.edit_node.setAttribute("aria-label",t)}Focus(t=""){this.edit_node!==document.activeElement&&(this.edit_container.style.top=`${this.container.scrollTop+this.view.active_sheet.header_offset.y}px`,this.edit_container.style.left=`${this.container.scrollLeft+this.view.active_sheet.header_offset.x}px`),this.edit_node.focus(),this.UpdateCaption(t)}CloseEditor(){this.editing=!1,this.ClearContents(),this.edit_node.spellcheck=!0,this.autocomplete.Hide(),this.active_cell=void 0}ClearContents(){te.is_firefox?this.edit_node.innerHTML="<span></span>":this.edit_node.textContent=""}Edit(t,i,r,s,n){this.Publish({type:"start-editing",editor:"ice"}),this.active_cell=r;let o=r.style||{};switch(this.edit_node.style.font=A.Font(o,this.scale),this.edit_node.style.color=D(this.theme,o.text,1),this.edit_inset.style.backgroundColor=D(this.theme,o.fill,0),o.horizontal_align){case A.HorizontalAlign.Right:this.edit_container.classList.add("align-right"),this.edit_container.classList.remove("align-center"),this.edit_container.classList.remove("align-left");break;case A.HorizontalAlign.Center:this.edit_container.classList.remove("align-right"),this.edit_container.classList.add("align-center"),this.edit_container.classList.remove("align-left");break;default:this.edit_container.classList.remove("align-right"),this.edit_container.classList.remove("align-center"),this.edit_container.classList.add("align-left");break}this.edit_node.style.paddingBottom=`${Math.max(0,(self.devicePixelRatio||1)-1)}px`;let a=s?.toString()||"";if(a&&a[0]==="="&&(this.edit_node.spellcheck=!1),this.autocomplete.ResetBlock(),this.FlushReference(),this.selection=t,typeof s<"u"){let l=a[0]!=="="&&a[a.length-1]==="%",d=a.length;this.edit_node.textContent=a;{let u=document.createRange(),h=window.getSelection();if(!h)throw new Error("invalid selection object");this.edit_node.lastChild&&(l?(u.setStart(this.edit_node.lastChild,d-1),u.setEnd(this.edit_node.lastChild,d-1)):u.setStartAfter(this.edit_node.lastChild)),u.collapse(!0),h.removeAllRanges(),h.addRange(u)}if(!n){let u=this.ListDependencies();this.Publish({type:"update",text:s.toString(),dependencies:u})}}i.ApplyStyle(this.edit_container),this.editing=!0,se().then(()=>{this.last_reconstructed_text="",this.Reconstruct()})}HandleKeyDown(t){if(!this.editing)return 0;let i=this.autocomplete.HandleKey("keydown",t);if(i.accept&&this.AcceptAutocomplete(i),i.handled)return 1;switch(t.key){case"Enter":case"Tab":return this.selecting_=!1,2;case"Escape":case"Esc":return this.selecting_=!1,3;case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"Up":case"Down":case"Left":case"Right":return this.selecting_?0:1}return 1}UpdateTheme(t){this.scale=t}};var Mi=class{canvas;cache={};constructor(){typeof document<"u"&&(this.canvas=document.createElement("canvas"))}Flush(){this.cache={}}Get(e,t=10){let i=e+";"+t,r=this.cache[i];return r||(r=this.Measure(e,t),this.cache[i]=r,r)}Measure(e,t){let i=e.match(/([\d.]+)((?:%|em))/);if(i){let h=i[1]+i[2],p=Number(i[1])*t;i[2]==="%"&&(p/=100),e=e.replace(h,p+"px")}let r=this.canvas.getContext("2d");if(!r)throw new Error("invalid context");r.font=e;let s=r.measureText("MMM"),n=Math.ceil(s.width);if(this.canvas.setAttribute("width",n.toString()),this.canvas.setAttribute("height",n.toString()),r=this.canvas.getContext("2d"),!r)throw new Error("invalid context");r.font=e,r.textAlign="center",r.textBaseline="alphabetic",r.fillStyle="#000";let o=Math.round(n*2/3),a=Math.round(n/2);r.clearRect(0,0,n,n);for(let h=32;h<=126;h++){let p=String.fromCharCode(h);r.fillText(p,a,o)}let l=r.getImageData(0,0,this.canvas.width,this.canvas.height).data,d=Math.floor(this.GetFirstIndex(l)/n),u=Math.floor(this.GetLastIndex(l)/n);return{ascender:o-d,descender:u-o,block:u-d+1,paren:r.measureText("(").width,hash:r.measureText("##").width-r.measureText("#").width}}GetFirstIndex(e){for(let t=3,i=e.length;t<i;t+=4)if(e[t]>0)return(t-3)/4;return e.length}GetLastIndex(e){for(let t=e.length-1;t>=3;t-=4)if(e[t]>0)return t/4;return 0}},Nt=new Mi;var Di="bottom",Er=/webkit/i.test(typeof navigator>"u"?"":navigator?.userAgent||"")?1:0,Ot=class{constructor(e,t,i,r,s){this.theme=e;this.layout=t;this.model=i;this.view=r;this.options=s;this.buffer_canvas=t.buffer_canvas,this.buffer_canvas.width=this.buffer_canvas_size.width,this.buffer_canvas.height=this.buffer_canvas_size.height;let n=this.buffer_canvas.getContext("2d",{alpha:!1});if(n){let o=this.layout.dpr;this.buffer_context=n,this.buffer_context.setTransform(o,0,0,o,0,0),this.buffer_context.textAlign="left",this.buffer_context.textBaseline=Di}}cell_edge_buffer=4;overflow_areas=[];buffer_canvas;buffer_context;buffer_canvas_size={width:256,height:256};FlushOverflows(){this.view.active_sheet.cells.IterateAll(t=>{t.renderer_data?.overflowed&&(t.renderer_data=void 0,t.render_clean[this.view.view_index]=!1)});for(let t of this.overflow_areas)t.tile.dirty=!0;this.overflow_areas=[]}MeasureText(e,t){let i=this.layout.grid_tiles[0][0].getContext("2d",{alpha:!1});if(!i)throw new Error("invalid context");return t&&(i.font=t),i.measureText(e)}EnsureBuffer(e=0,t=0,i=0){let r=this.layout.dpr;if(e=e*r,t=t*r,i=i*r,e>this.buffer_canvas_size.width||t>this.buffer_canvas_size.height){this.buffer_canvas_size.width=Math.max(Math.ceil(e/256)*256,this.buffer_canvas_size.width),this.buffer_canvas_size.height=Math.max(Math.ceil(t/256)*256,this.buffer_canvas_size.height),this.buffer_canvas.width=this.buffer_canvas_size.width,this.buffer_canvas.height=this.buffer_canvas_size.height;let s=this.buffer_canvas.getContext("2d",{alpha:!1});s&&(this.buffer_context=s,this.buffer_context.textAlign="left",this.buffer_context.textBaseline=Di)}this.buffer_context.setTransform(r,0,0,r,i,0)}OverflowDirty(e=!1){let t=[];for(let i of this.overflow_areas){let r=i.area.start.row,s=e;if(!s)for(let n=i.area.start.column;!s&&n<=i.area.end.column;n++){let o=this.view.active_sheet.cells.GetCell({row:r,column:n},!1);s=!!(o&&!o.render_clean[this.view.view_index])}if(s){for(let n=i.area.start.column;n<=i.area.end.column;n++){let o=this.view.active_sheet.cells.GetCell({row:r,column:n},!1);o&&(o.render_clean[this.view.view_index]=!1,o.renderer_data&&o.renderer_data.overflowed&&(o.renderer_data=void 0))}i.tile.dirty=!0}else t.push(i)}this.overflow_areas=t}RenderCorner(){let t=this.layout.corner_canvas.getContext("2d",{alpha:!1});if(!t)throw new Error("invalid context");let i=Nt.Get(A.Font(this.theme.headers||{},this.layout.scale)),r=this.layout.dpr,s=this.layout.header_offset,n=s.x;for(let a=0;a<this.view.active_sheet.freeze.columns;a++)n+=this.layout.ColumnWidth(a);let o=s.y;for(let a=0;a<this.view.active_sheet.freeze.rows;a++)o+=this.layout.RowHeight(a);t.setTransform(r,0,0,r,0,0),t.fillStyle=this.theme.headers?.fill?D(this.theme,this.theme.headers.fill):"",t.fillRect(0,0,n,s.y),t.fillRect(0,0,s.x,o),t.strokeStyle=this.theme.headers_grid_color||"",t.beginPath(),t.moveTo(s.x-.5,0),t.lineTo(s.x-.5,s.y),t.moveTo(0,s.y-.5),t.lineTo(s.x,s.y-.5),t.stroke(),!(!this.view.active_sheet.freeze.columns&&!this.view.active_sheet.freeze.rows)&&(t.strokeStyle=this.theme.grid_color||"",t.beginPath(),o!==s.y&&(t.moveTo(s.x-.5,s.y),t.lineTo(s.x-.5,o)),n!==s.x&&(t.moveTo(s.x,s.y-.5),t.lineTo(n,s.y-.5)),t.stroke(),t.strokeStyle=this.theme.headers_grid_color||"",t.textAlign="center",t.textBaseline="middle",t.font=A.Font(this.theme.headers||{},this.layout.scale),t.fillStyle=D(this.theme,this.theme.headers?.text),this.view.active_sheet.freeze.rows&&this.layout.header_offset.x>1&&(t.setTransform(r,0,0,r,0,0),t.translate(0,s.y),t.beginPath(),t.moveTo(0,0-.5),t.lineTo(s.x,0-.5),t.stroke(),this.RenderRowLabels(t,0,this.view.active_sheet.freeze.rows-1,i.block)),this.view.active_sheet.freeze.columns&&this.layout.header_offset.y>1&&(t.setTransform(r,0,0,r,0,0),t.translate(s.x,0),t.beginPath(),t.moveTo(0-.5,0),t.lineTo(0-.5,s.y),t.stroke(),this.RenderColumnLabels(t,0,this.view.active_sheet.freeze.columns-1)))}RenderColumnLabels(e,t,i){let r=this.layout.header_offset.y;for(e.fillStyle=D(this.theme,this.theme.headers?.text,0),e.beginPath();t<=i;t++){let s=this.layout.ColumnWidth(t),n=g.ColumnToLabel(t),o=e.measureText(n);s>o.width&&e.fillText(n,s/2,r/2+1),e.moveTo(s-.5,0),e.lineTo(s-.5,r),e.translate(s,0)}e.stroke()}RenderRowLabels(e,t,i,r){let s=this.layout.header_offset.x;for(e.fillStyle=D(this.theme,this.theme.headers?.text,0),e.beginPath();t<=i;t++){let n=this.layout.RowHeight(t);n>=r*1.2&&e.fillText(`${t+1}`,s/2,n/2+1),e.moveTo(0,n-.5),e.lineTo(s,n-.5),e.translate(0,n)}e.stroke()}RenderHeaders(e,t=!1){let i=this.layout.dpr,r=this.layout.header_offset,s=Nt.Get(A.Font(this.theme.headers||{},this.layout.scale));for(let n=e.start.column;n<=e.end.column;n++){let o=this.layout.column_header_tiles[n];if(o.dirty||t){let a=o.getContext("2d",{alpha:!1});if(!a)continue;a.setTransform(i,0,0,i,0,0),a.textAlign="center",a.textBaseline="middle",a.font=A.Font(this.theme.headers||{},this.layout.scale),a.fillStyle=this.theme.headers?.fill?D(this.theme,this.theme.headers.fill):"",a.fillRect(0,0,o.logical_size.width,this.layout.header_offset.y),a.strokeStyle=this.theme.headers_grid_color||"",a.beginPath(),a.moveTo(0,r.y-.5),a.lineTo(o.logical_size.width,r.y-.5),a.stroke(),a.strokeStyle=this.theme.headers_grid_color||"",this.RenderColumnLabels(a,o.first_cell.column,o.last_cell.column),o.dirty=!1}}for(let n=e.start.row;n<=e.end.row;n++){let o=this.layout.row_header_tiles[n];if(o.dirty||t){let a=o.getContext("2d",{alpha:!1});if(!a)continue;a.fillStyle=this.theme.headers?.fill?D(this.theme,this.theme.headers.fill):"",a.setTransform(i,0,0,i,0,0),a.textAlign="center",a.textBaseline="middle",a.font=A.Font(this.theme.headers||{},this.layout.scale),a.fillRect(0,0,this.layout.header_offset.x,o.logical_size.height),a.strokeStyle=this.theme.headers_grid_color||"",a.beginPath(),a.moveTo(r.x-.5,0),a.lineTo(r.x-.5,o.logical_size.height),a.stroke(),a.strokeStyle=this.theme.headers_grid_color||"",this.RenderRowLabels(a,o.first_cell.row,o.last_cell.row,s.block),o.dirty=!1}}(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&this.RenderCorner()}CopyToAdjacent(e,t,i,r,s,n,o){let a=this.layout.AdjacentTile(e,r,i);if(!a)return;let l=s,d=n;i>0?l=s-(e.pixel_end.x-e.pixel_start.x)*t:i<0&&(l=s+(a.pixel_end.x-a.pixel_start.x)*t),r>0&&(d=n-(e.pixel_end.y-e.pixel_start.y)*t);let u=a.getContext("2d",{alpha:!1});u&&(u.setTransform(t,0,0,t,l,d),u.drawImage(this.buffer_canvas,0,0,(o.width||0)*t,(o.height||0)*t,o.left||0,0,o.width||0,o.height||0))}Render(e){let t=e.getContext("2d",{alpha:!1});if(!t)return;t.textBaseline=Di;let i=this.layout.dpr;t.setTransform(i,0,0,i,0,0);let r=0,s=0;for(let a=e.first_cell.column;a<=e.last_cell.column;a++){let l=this.layout.ColumnWidth(a);if(!!l){s=0;for(let d=e.first_cell.row;d<=e.last_cell.row;d++){let u=this.layout.RowHeight(d);if(u){t.setTransform(i,0,0,i,r,s);let h=this.view.active_sheet.CellData({row:d,column:a});if(e.needs_full_repaint||!h.render_clean[this.view.view_index]){let p=this.RenderCell(e,h,t,{row:d,column:a},l,u);p.tile_overflow_right&&this.CopyToAdjacent(e,i,1,0,r,s,p),p.tile_overflow_left&&this.CopyToAdjacent(e,i,-1,0,r,s,p),p.tile_overflow_bottom&&this.CopyToAdjacent(e,i,0,1,r,s,p)}}s+=u*i}r+=l*i}}if(!this.view.active_sheet.freeze.rows&&!this.view.active_sheet.freeze.columns)return;let n=0,o=0;if(e.first_cell.row<=this.view.active_sheet.freeze.rows-1)for(let a=e.first_cell.row;a<this.view.active_sheet.freeze.rows&&a<=e.last_cell.row;a++)n+=this.layout.RowHeight(a);if(e.first_cell.column<=this.view.active_sheet.freeze.columns-1)for(let a=e.first_cell.column;a<this.view.active_sheet.freeze.columns&&a<=e.last_cell.column;a++)o+=this.layout.ColumnWidth(a);if(n){let a=this.layout.frozen_row_tiles[e.tile_position.column];if(!a)throw new Error("can't find matching header tile");let l=a.getContext("2d",{alpha:!0});if(!l)throw new Error("header context failed");l.setTransform(i,0,0,i,0,0),l.drawImage(e,0,0,e.logical_size.width*i,n*i,0,0,e.logical_size.width,n)}if(o){let a=this.layout.frozen_column_tiles[e.tile_position.row];if(!a)throw new Error("can't find matching header tile");let l=a.getContext("2d",{alpha:!0});if(!l)throw new Error("header context failed");l.setTransform(i,0,0,i,0,0),l.drawImage(e,0,0,o*i,e.logical_size.height*i,0,0,o,e.logical_size.height)}if(o&&n){let a=this.layout.corner_canvas.getContext("2d",{alpha:"false"});if(!a)throw new Error("corner context failed");a.setTransform(i,0,0,i,this.layout.header_offset.x*i,this.layout.header_offset.y*i),a.drawImage(e,0,0,o*i,n*i,0,0,o,n)}}PrepText(e,t,i,r){let s=[],n=i.style||{},o,a=0,l,d=i.editing?"":i.formatted;if(Array.isArray(d)){for(let u of d){if(u.flag===6){l=u.text;continue}let h=e.measureText(u.text).width,p={width:h,text:u.text,hidden:u.flag===1};s.push(p),u.flag===2?o=p:a+=h}if(o){let u=o.text,h=o.width,p=r-a-2*this.cell_edge_buffer;if(o.width=Math.max(0,p),p>0){let f=Math.floor(p/h);for(let m=1;m<f;m++)o.text+=u;a=r-2*this.cell_edge_buffer}else o.text=""}return{strings:[s],format:l,width:a}}else if(d){i.type===2&&d[0]==="'"&&(d=d.slice(1));let u;this.options.markdown?u=we.instance.Parse(d):(u=we.instance.Dummy(d),e.font=t.base);let h=0,p=r-2*this.cell_edge_buffer,f=[];if(n.wrap)for(let m of u){for(let _=1;_<m.length;_++){let y=m[_].text.match(/^(\s+)/);y&&(m[_-1].text+=y[1],m[_].text=m[_].text.replace(/^\s+/,""))}let b=[];for(let _ of m){this.options.markdown&&(_.strong&&_.emphasis?e.font=t.strong_emphasis:_.strong?e.font=t.strong:_.emphasis?e.font=t.emphasis:e.font=t.base);let y=_.text.match(/\S+\s*/g);if(y&&y.length)for(let x of y){let v=e.measureText(x.trim()).width,w=e.measureText(x).width;b.push({part:_,text:x,trimmed:v,width:w})}}for(;b.length;){let _=b.shift(),y=[_],x=_.trimmed;for(;x<p&&b.length;){let v=b[0],w=x-_.trimmed+_.width+v.trimmed;if(w>=p)break;_=v,y.push(v),x=w,b.shift()}_.text=_.text.trim(),_.width=_.trimmed,f.push(y.map(v=>({...v.part,hidden:!1,width:v.width,text:v.text})))}}else for(let m of u){let b=[],_=0;for(let y of m){this.options.markdown&&(y.strong&&y.emphasis?e.font=t.strong_emphasis:y.strong?e.font=t.strong:y.emphasis?e.font=t.emphasis:e.font=t.base);let x=e.measureText(y.text).width;_+=x,b.push({...y,hidden:!1,width:x})}h=Math.max(h,_),f.push(b)}return{strings:f,width:h}}return{strings:[[{text:"",hidden:!1,width:0}]],width:0}}ResolveColors(e){let t={...e};return t.text={text:D(this.theme,e.text,1)},t}RenderCellBorders(e,t,i,r=0,s=0,n=0,o=0){let a=this.view.active_sheet.SurroundingStyle(e),l=D(this.theme,a[8].fill);l&&(t.fillStyle=l,t.fillRect(r+0,s-1,n,1)),l=D(this.theme,a[4].fill),l&&(t.fillStyle=l,t.fillRect(r-1,s,1,o)),l=D(this.theme,i.fill),l&&(t.fillStyle=l,t.fillRect(r-1,s-1,n+1,o+1)),l=D(this.theme,a[6].fill),l&&(t.fillStyle=l,t.fillRect(r+n-1,s-1,1,o+1)),l=D(this.theme,a[2].fill),l&&(t.fillStyle=l,t.fillRect(r-1,s+o-1,n+1,1)),a[6].border_top&&!a[6].border_left&&(t.fillStyle=D(this.theme,a[6].border_top_fill,1),t.fillRect(r+n-1,s-2+a[6].border_top,1,1)),a[9].border_left&&(t.fillStyle=D(this.theme,a[9].border_left_fill,1),t.fillRect(r+n-1,s-1,1,1)),a[9].border_bottom&&(t.fillStyle=D(this.theme,a[9].border_bottom_fill,1),t.fillRect(r+n-1,s-2+a[9].border_bottom,1,1)),a[4].border_top&&!a[4].border_right&&(t.fillStyle=D(this.theme,a[4].border_right_fill,1),t.fillRect(r-1,s-2+a[4].border_top,1,1)),a[7].border_right&&(t.fillStyle=D(this.theme,a[7].border_right_fill,1),t.fillRect(r-1,s-1,1,1)),a[7].border_bottom&&(t.fillStyle=D(this.theme,a[7].border_bottom_fill,1),t.fillRect(r-1,s-2+a[7].border_bottom,1,1)),a[6].border_bottom&&!a[6].border_left&&(t.fillStyle=D(this.theme,a[6].border_bottom_fill,1),t.fillRect(r+n-1,s+o-a[6].border_bottom,1,1)),a[3].border_left&&(t.fillStyle=D(this.theme,a[3].border_left_fill,1),t.fillRect(r+n-1,s+o-1,1,1)),a[3].border_top&&(t.fillStyle=D(this.theme,a[3].border_top_fill,1),t.fillRect(r+n-1,s+o-a[3].border_top,1,1)),a[4].border_bottom&&!a[4].border_right&&(t.fillStyle=D(this.theme,a[4].border_bottom_fill,1),t.fillRect(r-1,s+o-a[4].border_bottom,1,1)),a[1].border_right&&(t.fillStyle=D(this.theme,a[1].border_right_fill,1),t.fillRect(r-1,s+o-1,1,1)),a[1].border_top&&(t.fillStyle=D(this.theme,a[1].border_top_fill,1),t.fillRect(r-1,s+o-a[1].border_top,1,1)),a[8].border_bottom&&(t.fillStyle=D(this.theme,a[8].border_bottom_fill,1),a[8].border_bottom===2&&(t.fillRect(r-1,s-2,n+1,1),t.fillRect(r-1,s-0,n+1,1),t.fillStyle=D(this.theme,a[8].fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s-1,n+1,1)),a[4].border_right&&(t.fillStyle=D(this.theme,a[4].border_right_fill,1),t.fillRect(r-1,s-1,1,o+1)),a[6].border_left&&(t.fillStyle=D(this.theme,a[4].border_left_fill,1),t.fillRect(r+n-1,s-1,1,o+1)),a[2].border_top&&(t.fillStyle=D(this.theme,a[2].border_top_fill,1),a[2].border_top===2&&(t.fillRect(r-1,s+o-2,n+1,1),t.fillRect(r-1,s+o-0,n+1,1),t.fillStyle=D(this.theme,a[2].fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s+o-1,n+1,1)),i.border_top&&(t.fillStyle=D(this.theme,i.border_top_fill,1),i.border_top===2&&(t.fillRect(r-1,s-2,n+1,1),t.fillRect(r-1,s+0,n+1,1),t.fillStyle=D(this.theme,i.fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s-1,n+1,1)),i.border_left&&(t.fillStyle=D(this.theme,i.border_left_fill,1),t.fillRect(r-1,s-1,1,o+1)),i.border_right&&(t.fillStyle=D(this.theme,i.border_right_fill,1),t.fillRect(r+n-1,s-1,1,o+1)),i.border_bottom&&(t.fillStyle=D(this.theme,i.border_bottom_fill,1),i.border_bottom===2&&(t.fillRect(r-1,s+o-2,n+1,1),t.fillRect(r-1,s+o+0,n+1,1),t.fillStyle=D(this.theme,i.fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s+o-1,n+1,1))}RenderCellBackground(e,t,i,r,s,n){i.fillStyle=this.theme.grid_color,i.fillRect(0,0,s,n);let o=D(this.theme,r.fill);o?(i.fillStyle=o,i.fillRect(0,0,s-1,n-1)):(i.fillStyle=fe(this.theme,this.theme.grid_cell?.fill)||"#fff",i.fillRect(0,0,s-1,n-1)),e&&(i.fillStyle=this.theme.note_marker_color,i.beginPath(),i.moveTo(s-2,1),i.lineTo(s-2-8,1),i.lineTo(s-2,1+8),i.lineTo(s-2,1),i.fill()),this.RenderCellBorders(t,i,r,0,0,s,n)}RenderCell(e,t,i,r,s,n){let o={},a=!t.render_clean[this.view.view_index];if(t.render_clean[this.view.view_index]=!0,e.needs_full_repaint&&t.renderer_data?.overflowed)return{};let l=t.style?{...t.style}:{};if(t.merge_area)if(r.row===t.merge_area.start.row&&r.column===t.merge_area.start.column){for(let k=t.merge_area.start.column+1;k<=t.merge_area.end.column;k++)s+=this.layout.ColumnWidth(k);for(let k=t.merge_area.start.row+1;k<=t.merge_area.end.row;k++)n+=this.layout.RowHeight(k);if(t.merge_area.count>1){let k=this.view.active_sheet.CellStyleData(t.merge_area.end);k&&(l.border_bottom=k.border_bottom,l.border_right=k.border_right,l.border_bottom_fill=k.border_bottom_fill,l.border_right_fill=k.border_right_fill)}t.merge_area.end.column>e.last_cell.column&&(o.tile_overflow_right=!0),t.merge_area.end.row>e.last_cell.row&&(o.tile_overflow_bottom=!0),(o.tile_overflow_bottom||o.tile_overflow_right)&&this.overflow_areas.push({tile:e,head:{...r},area:new g(t.merge_area.start,t.merge_area.end)})}else return{};let d=!!t.hyperlink;if(t.render_function){this.RenderCellBackground(!!t.note,r,i,l,s,n),i.strokeStyle=i.fillStyle=D(this.theme,l.text,1);let k=this.ResolveColors(l);if(t.render_function.call(void 0,{width:s,height:n,context:i,cell:t,style:k,scale:this.layout.scale||1}).handled)return o}let u={base:A.Font(l,this.layout.scale),strong:A.Font({...l,bold:!0},this.layout.scale),emphasis:A.Font({...l,italic:!0},this.layout.scale),strong_emphasis:A.Font({...l,bold:!0,italic:!0},this.layout.scale)};if(i.font=u.base,a||!t.renderer_data||t.renderer_data.width!==s||t.renderer_data.height!==n){let k=this.PrepText(i,u,t,s);t.renderer_data={text_data:k,width:s,height:n}}let h=t.renderer_data.text_data,p=h.width>s-2*this.cell_edge_buffer,f=s,m=0,b=!1,_=t.type===3||t.calculated_type===3||t.type===7||t.calculated_type===7||t.type===9||t.calculated_type===9,y=l.horizontal_align;y||(y=_?A.HorizontalAlign.Right:A.HorizontalAlign.Left);let x=[];if(p)if(t.type!==3&&t.calculated_type!==3&&!l.wrap&&!t.merge_area){let W=h.width-s+this.cell_edge_buffer,ae=0,Z=0;y===A.HorizontalAlign.Center?ae=Z=W/2:y===A.HorizontalAlign.Right?ae=W:Z=W;let he=r.column,pe=r.column;for(;Z>0&&he<this.layout.last_column;){he++;let $={row:r.row,column:he},F=this.view.active_sheet.CellData($),ie=this.layout.ColumnWidth(he);if(Z-=ie,F&&!F.type&&!F.calculated_type)x.push({address:$,cell:F,grid:new z(f,0,ie,n),background:new z(f-1,0,ie,n-1),border:new z(f,0,ie,n)}),f+=ie,F.render_clean[this.view.view_index]=!0,F.renderer_data={overflowed:!0};else{b=!0;break}}for(he>e.last_cell.column&&(o.tile_overflow_right=!0);ae>0&&pe>=1;){pe--;let $={row:r.row,column:pe},F=this.view.active_sheet.CellData($),ie=this.layout.ColumnWidth(pe);if(ae-=ie,F&&!F.type&&!F.calculated_type)m-=ie,x.push({address:$,cell:F,grid:new z(m,0,ie,n),background:new z(m,0,ie,n-1),border:new z(m,0,ie,n)});else{b=!0;break}}pe<e.first_cell.column&&(o.tile_overflow_left=!0),this.overflow_areas.push({head:{...r},tile:e,area:new g({row:r.row,column:pe},{row:r.row,column:he})})}else b=!_;let v=!1,w=i;(o.tile_overflow_bottom||o.tile_overflow_left||o.tile_overflow_right)&&(v=!0,o.width=f-m,o.height=n,o.left=m,this.EnsureBuffer(o.width+1,n+1,-m),i=this.buffer_context,i.font=u.base),this.RenderCellBackground(!!t.note,r,i,l,s,n);for(let k of x)k.cell.style?.fill&&(k.cell.style.fill.text||k.cell.style.fill.theme||k.cell.style.fill.theme===0)&&!this.options.grid_over_background?(i.fillStyle=fe(this.theme,k.cell.style.fill),i.fillRect(k.grid.left,k.grid.top,k.grid.width,k.grid.height)):(i.fillStyle=this.theme.grid_color||"",i.fillRect(k.grid.left,k.grid.top,k.grid.width,k.grid.height),i.fillStyle=this.theme.grid_cell?.fill?fe(this.theme,this.theme.grid_cell.fill):"",i.fillRect(k.background.left,k.background.top,k.background.width,k.background.height)),k.cell.style&&this.RenderCellBorders(k.address,i,k.cell.style,k.border.left,k.border.top,k.border.width,k.border.height);let C=Nt.Get(u.base,this.theme.grid_cell?.font_size?.value);i.lineWidth=1,i.strokeStyle=i.fillStyle=h.format?h.format:D(this.theme,l.text,1),i.beginPath();let S=this.cell_edge_buffer,U=1.25,J=h.strings.length,oe=J*C.block*U;b=(b||oe>=n)&&!v,b&&(i.save(),i.beginPath(),i.moveTo(m+1.5,0),i.lineTo(m+1.5,n),i.lineTo(f-1.5,n),i.lineTo(f-1.5,0),i.clip()),i.beginPath();let R=Math.round(n-2-C.block*U*(J-1)+Er);switch(l.vertical_align){case A.VerticalAlign.Top:R=Math.round(C.block*U)+1;break;case A.VerticalAlign.Middle:R=Math.round((n-oe)/2+C.block*U);break}if((t.type===3||t.calculated_type===3||t.type===7||t.calculated_type===7)&&p){let k=Math.floor((s-2*this.cell_edge_buffer)/C.hash),W="";for(let Z=0;Z<k;Z++)W+="#";let ae=i.measureText(W).width;y===A.HorizontalAlign.Center?S=Math.round((s-ae)/2):y===A.HorizontalAlign.Right&&(S=s-this.cell_edge_buffer-ae),i.fillText(W,S,R)}else{let k=R,W=0;for(let ae of h.strings){let Z=0;for(let F of ae)Z+=F.width;y===A.HorizontalAlign.Center?S=Math.round((s-Z)/2):y===A.HorizontalAlign.Right&&(S=s-this.cell_edge_buffer-Z);let he=Math.floor(k+1.5-C.descender-Er)+.5,pe=Math.floor(k-C.descender-C.ascender/2)+.5,$=S;for(let F of ae)F.strong&&F.emphasis?i.font=u.strong_emphasis:F.strong?i.font=u.strong:F.emphasis?i.font=u.emphasis:i.font=u.base,F.hidden||(F.text&&i.fillText(F.text,$,k),l.underline&&(i.moveTo($,he),i.lineTo($+F.width,he)),(l.strike||F.strike)&&(i.moveTo($,pe),i.lineTo($+F.width,pe)),d&&(F.left=$,F.top=k-C.block,F.height=C.block)),$+=F.width;W++,k=Math.round(R+W*C.block*U)}}if(i.stroke(),b)i.restore();else if(v){let k=this.layout.dpr;w.drawImage(this.buffer_canvas,0,0,(o.width||0)*k,n*k,m,0,o.width||0,n)}return o}};var Gt=class extends Fe{constructor(t,i,r,s,n,o,a){super(i,r,s,n,a);this.container=t;this.options=o;let l=V.CreateDiv("treb-formula-bar-container notranslate",t),d=V.CreateDiv("treb-formula-bar",l);this.address_label_container=V.CreateDiv("address-label",d),this.address_label=V.CreateDiv("",this.address_label_container),this.InitAddressLabel(),this.options.insert_function_button&&(this.button=V.Create("button","formula-button",d),this.button.addEventListener("click",()=>{let u=this.editor_node&&this.editor_node.textContent||"";this.Publish({type:"formula-button",formula:u})})),this.container_node=V.CreateDiv("editor-container",d),this.editor_node=V.CreateDiv("formula-editor",this.container_node),this.editor_node.setAttribute("contenteditable","true"),this.editor_node.spellcheck=!1,this.editor_node.addEventListener("focusin",()=>{if(!this.editor_node)return;let u=this.editor_node.textContent||"";u[0]==="{"&&u[u.length-1]==="}"&&(u=u.substr(1,u.length-2),this.editor_node.textContent=u,this.last_reconstructed_text=""),this.editor_node.spellcheck=u[0]!=="=",this.autocomplete.ResetBlock(),se().then(()=>{this.Reconstruct()});let h=this.ListDependencies();this.Publish([{type:"start-editing",editor:"formula-bar"},{type:"update",text:u,cell:this.active_cell,dependencies:h}]),this.focused_=!0}),this.editor_node.addEventListener("focusout",()=>{this.selecting&&console.info("focusout, but selecting..."),this.autocomplete.Hide(),this.Publish([{type:"stop-editing"}]),this.focused_=!1,this.editor_node&&(this.editor_node.spellcheck=!1)}),this.editor_node.addEventListener("keydown",u=>this.FormulaKeyDown(u)),this.editor_node.addEventListener("keyup",u=>this.FormulaKeyUp(u)),this.editor_node.addEventListener("input",()=>{this.Reconstruct(),this.UpdateSelectState()}),this.options.expand_formula_button&&(this.expand_button=V.Create("button","expand-button",d),this.expand_button.addEventListener("click",u=>{u.stopPropagation(),u.preventDefault(),this.editor_node&&(this.editor_node.scrollTop=0),d.classList.toggle("expanded")}))}focused_=!1;get focused(){return this.focused_}address_label_container;address_label;button;expand_button;drag_corner;lines=1;last_formula="";label_update_timer=0;get formula(){return this.editor_node&&this.editor_node.textContent||""}set formula(t){this.editor_node&&(this.editor_node.textContent=t,this.last_reconstructed_text=""),this.last_formula=t}get label(){return this.address_label?.textContent||""}set label(t){t.trim().length?(this.address_label.textContent=t,this.label_update_timer||(this.label_update_timer=requestAnimationFrame(()=>{this.label_update_timer=0,this.address_label.scrollWidth>this.address_label.offsetWidth?this.address_label.setAttribute("title",t):this.address_label.removeAttribute("title")}))):(this.address_label.innerHTML=" ",this.address_label.removeAttribute("title"))}set editable(t){!this.editor_node||!this.container_node||(this.editor_node.setAttribute("contenteditable",t.toString()),t?this.container_node.classList.remove("locked"):this.container_node.classList.add("locked"))}IsElement(t){return t===this.editor_node}InitAddressLabel(){this.address_label.contentEditable="true",this.address_label.spellcheck=!1,this.address_label.addEventListener("focusin",t=>{requestAnimationFrame(()=>{if(document.body.createTextRange){let i=document.body.createTextRange();i.moveToElementText(this.address_label),i.select()}else{let i=window.getSelection(),r=document.createRange();r.selectNodeContents(this.address_label),i?.removeAllRanges(),i?.addRange(r)}})}),this.address_label.addEventListener("keydown",t=>{switch(t.key){case"Enter":t.stopPropagation(),t.preventDefault(),this.Publish({type:"address-label-event",text:this.address_label.textContent||void 0});break;case"Esc":case"Escape":t.stopPropagation(),t.preventDefault(),this.Publish({type:"address-label-event"});break}})}FocusEditor(){this.editor_node&&this.editor_node.focus()}GetTextContent(t){let i=t.childNodes,r=[];for(let s=0;s<i.length;s++){let n=i[s];switch(n.nodeType){case Node.ELEMENT_NODE:r.push(...this.GetTextContent(n)),n instanceof Element&&n.tagName==="DIV"&&r.push(`
|
|
5
|
+
`}IsDelimeter(e){return e==="*"||e==="_"||e==="~"}Consolidate(e){let t=[],i={},r=[],s={type:"text",text:""};for(let n of e)if(n.type==="newline")s.text.length&&r.push(s),s={...i,text:"",type:"text"},t.push(r),r=[];else switch((!!i.strong!=!!n.strong||!!i.emphasis!=!!n.emphasis||!!i.strike!=!!n.strike)&&(i.strong=!!n.strong,i.emphasis=!!n.emphasis,i.strike=!!n.strike,s.text.length&&r.push(s),s={...i,text:"",type:"text"}),n.type){case"text":case"whitespace":s.text+=n.text;break;case"delimeter":for(let o=0;o<n.length;o++)s.text+=n.char;break}return s.text.length&&r.push(s),r.length&&t.push(r),t}ApplyFormatting(e,t){let i=0,r=e.length;for(i=0;i<r;i++){let s=e[i];if(s.type==="delimeter"){if(t&&s.right_flanking&&t.char===s.char&&s.length>0)return{index:i,token:s};if(s.left_flanking){let n=this.ApplyFormatting(e.slice(i+1),s);if(n.token){let o=Math.min(n.token.length,s.length),a=s.char==="~",l=!a&&!!(o%2),d=!a&&o>=2;for(let u=i+1;u<=i+n.index;u++)e[u].strong=!!e[u].strong||d,e[u].emphasis=!!e[u].emphasis||l,e[u].strike=!!e[u].strike||a;n.token.length-=o,s.length-=o,s.length>0?i--:i+=n.index}}}}return{index:i}}Tokenize(e=""){let t=[],i=e.length,r=0,s=!1,n="";for(r=0;r<i;r++){let o=e[r];if(this.IsWhitespace(o)){n&&t.push({type:"text",text:n});let a=o;for(;;){let l=e[r+1];if(this.IsWhitespace(l))a+=l,r++;else break}t.push({type:"whitespace",text:a}),s=!1,n=""}else if(this.IsNewline(o)){n&&t.push({type:"text",text:n});let a=o;for(;;){let l=e[r+1];if(this.IsNewline(l))a+=l,r++;else break}t.push({type:"newline",text:a}),s=!1,n=""}else if(s)n+=o,s=!1;else if(this.IsDelimeter(o)){n&&t.push({type:"text",text:n});let a=o;for(;;){let l=e[r+1];if(l===o)a+=l,r++;else break}t.push({type:"delimeter",text:a,char:o,length:a.length}),s=!1,n=""}else o==="\\"?s=!0:n+=o}return n&&t.push({type:"text",text:n}),t}},we=wi;E(we,"_instance",new wi);var se=()=>Promise.resolve();var Us=1e3,Q=class{constructor(e=!1,t){this.verbose=e;this.log_id=t}queue=[];dispatched=!1;subscribers=[];Publish(e){this.verbose&&console.info(`es publish (${this.log_id})`,e),Array.isArray(e)?this.queue.push(...e):this.queue.push(e),this.dispatched||(this.dispatched=!0,se().then(()=>{let t=this.queue.slice(0);this.dispatched=!1,this.queue=[];for(let i of t)for(let r of this.subscribers)r.subscriber(i)}))}Subscribe(e){let t=Us++;return this.subscribers.push({subscriber:e,token:t}),t}Cancel(e){this.subscribers=this.subscribers.filter(t=>t.token!==e)}CancelAll(){this.subscribers=[]}};var B=class{constructor(e,t,i,r=e){B.Create({container:e,node:t,resize_callback:i,layout_reference:r})}static Create(e){let t=document.createElement("div");if(t.classList.add("treb-embed-resize-handle"),(e.layout_reference||e.container).appendChild(t),!B.resize_mask){let l=document.querySelector(".treb-embed-mouse-mask");l||(l=document.createElement("div"),l.classList.add("treb-embed-mouse-mask"),document.body.appendChild(l)),B.resize_mask=l}if(!B.resize_rect){let l=document.querySelector(".treb-embed-resize-rect");l||(l=document.createElement("div"),l.classList.add("treb-embed-resize-rect"),B.resize_mask.appendChild(l)),B.resize_rect=l}let i,r,s={width:0,height:0},n={x:0,y:0},o={x:0,y:0},a=()=>{if(B.resize_mask.removeEventListener("mousemove",r),B.resize_mask.removeEventListener("mouseup",i),B.resize_mask.style.display="none",o.x||o.y){let l=e.container.getBoundingClientRect(),d=l.width+o.x,u=l.height+o.y;e.container.style.width=`${d}px`,e.container.style.height=`${u}px`,e.resize_callback&&e.resize_callback()}};r=l=>{if(!l.buttons){a();return}o.x!==l.clientX-n.x&&(o.x=l.clientX-n.x,B.resize_rect.style.width=`${s.width+o.x+4}px`),o.y!==l.clientY-n.y&&(o.y=l.clientY-n.y,B.resize_rect.style.height=`${s.height+o.y+4}px`)},i=()=>{a()},t.addEventListener("mousedown",l=>{l.stopPropagation(),l.preventDefault();let d=e.node.getBoundingClientRect();s={width:d.width,height:d.height},B.resize_rect&&(B.resize_rect.style.top=`${d.top-2}px`,B.resize_rect.style.left=`${d.left-2}px`,B.resize_rect.style.width=`${d.width+4}px`,B.resize_rect.style.height=`${d.height+4}px`),n={x:l.clientX,y:l.clientY},o={x:0,y:0},B.resize_mask.style.display="block",B.resize_mask.addEventListener("mousemove",r),B.resize_mask.addEventListener("mouseup",i)})}},Be=B;E(Be,"resize_mask"),E(Be,"resize_rect");var ee=class{static MeasureColorARGB(e){let t=this.MeasureColor(e),i="FF";for(let r=0;r<3;r++){let s=t[r].toString(16);s.length===0?i+="00":s.length===1?i+=`0${s}`:i+=s}return i.toUpperCase()}static MeasureColor(e){let t=this.color_cache[e];if(t)return t;this.color_measurement_canvas||(this.color_measurement_canvas=document.createElement("canvas"),this.color_measurement_canvas.width=1,this.color_measurement_canvas.height=1);let i=this.color_measurement_canvas.getContext("2d",{willReadFrequently:!0});return i?(i.fillStyle="#fff",i.fillRect(0,0,1,1),i.fillStyle=e,i.fillRect(0,0,1,1),t=new Uint8ClampedArray(i.getImageData(0,0,1,1).data),this.color_cache[e]=t,t):new Uint8ClampedArray(3)}static EnsureMeasurementNode(){if(!this.text_measurement_node){let e=document.querySelector(".treb-chart-measurement-node");e?this.text_measurement_node=e:(this.text_measurement_node=document.createElement("div"),this.text_measurement_node.classList.add("treb-chart-measurement-node"),this.text_measurement_node.style.margin="0px",this.text_measurement_node.style.padding="0px",this.text_measurement_node.style.height="initial",this.text_measurement_node.style.width="initial",this.text_measurement_node.style.whiteSpace="nowrap",this.text_measurement_node.style.position="fixed",this.text_measurement_node.style.border="0px",this.text_measurement_node.style.border="1px solid red",this.text_measurement_node.style.boxSizing="content-box",this.text_measurement_node.style.top=this.text_measurement_node.style.left="-1000px",document.body.appendChild(this.text_measurement_node))}}static FontLoaded(e,t=!1,i=400){let r=`${t?"italic":""} ${i} 20pt ${e}`,s=this.MeasureText(`${r}, sans-serif`,"check font"),n=this.MeasureText(`${r}, serif`,"check font"),o=this.MeasureText(`${r}, monospace`,"check font");return s.width===n.width&&n.width===o.width}static MeasureText(e,t,i=0){this.EnsureMeasurementNode(),this.text_measurement_node.style.font=e,/\n/.test(t)?(t=t.replace(/\n/g,"<BR/>"),this.text_measurement_node.innerHTML=t):this.text_measurement_node.textContent=t,this.text_measurement_node.style.lineHeight="1em",i?this.text_measurement_node.style.transform=`rotate(${i}deg)`:this.text_measurement_node.style.transform="";let r=this.text_measurement_node.getBoundingClientRect();return{width:r.width,height:r.height}}};E(ee,"color_measurement_canvas"),E(ee,"text_measurement_node"),E(ee,"color_cache",{});var xi,Ms=(c,e,t)=>{let i={};return Array.prototype.forEach.call(e,r=>{e[r]!==t[r]&&(i[r]=e[r])}),(Object.keys(i).map(r=>`${r}: ${i[r]}`).join("; ")+"; "+(c.getAttribute("style")||"")).trim().replace(/"/g,"'")},ur=(c,e)=>{let t=c.cloneNode(!1),i=getComputedStyle(c),r=Ms(c,i,e);return t.removeAttribute("class"),t.setAttribute("style",r),Array.prototype.forEach.call(c.childNodes,s=>{switch(s.nodeType){case Node.ELEMENT_NODE:t.appendChild(ur(s,i));break;case Node.TEXT_NODE:c.textContent&&t.appendChild(document.createTextNode(c.textContent));break;case Node.COMMENT_NODE:break;default:console.warn("unhandled node type in serialize",s)}}),t},hr=c=>{if(!xi){let e={},t=document.createElement("iframe");t.style.width="10px",t.style.height="10px",t.style.position="absolute",t.style.left="-100px",document.body.appendChild(t);let i=t.contentDocument;if(i){let r=i.createElement("div");i.body.appendChild(r);let s=getComputedStyle(r);Array.prototype.forEach.call(s,n=>e[n]=s[n])}document.body.removeChild(t),xi=e}return ur(c,xi)};var pr=(c,e,t=6.5,i=!1,r=!1)=>{if(e===c)e++,c&&c--;else{let u=Math.round(e*1e5)/1e5;Math.abs(u-e)/(e-c)<1e-5&&(e=u)}let s=e-c,n=Math.log(s)/Math.log(10),o=Math.floor(Math.abs(n))*(n<0?-1:1)-1;r&&(o=Math.max(0,o));let a=r?[1,2,5,10,15,20,25,50,100]:[.1,.25,.5,1,2.5,5,10,25,50,100],l=-1,d=0;for(let u of a){let h=u*Math.pow(10,o),p=Math.floor(c/h)*h,m=(Math.ceil(e/h)*h-p)/h,b=Math.abs(m-t);(l<0||b<d)&&(!i||m<=t)&&(d=b,l=h)}return c=Math.floor(c/l)*l,e=Math.ceil(e/l)*l,t=Math.round((e-c)/l),{scale:o,step:l,count:t,min:c,max:e}};var fr=(c,e,t)=>{[].forEach.call(c.children,i=>{i.id&&(t[i.id]=i,i.id=`${e}-${i.id}`),i.children&&i.children.length&&fr(i,e,t)})},Ds=(c,e)=>{let t=Math.random().toString(36).substring(2,15),i=document.createElement("div");i.innerHTML=c;let r={};if(fr(i,t,r),typeof e=="string"&&(e=document.querySelector(e)),e){let s=[].map.call(i.childNodes,n=>n);for(let n of s)e.appendChild(n)}return r},Rt=(c,...e)=>{let t=[];for(let i=0;i<c.length;i++)t.push(c[i]),e[i]&&t.push(e[i].toString());return t.join("")},Et=(c,...e)=>Ds(Rt(c,...e));var xe=class{date_format=!1;string_format=!1;fraction_format=!1;twelve_hour=!1;fraction_denominator=0;fraction_integer=!0;fraction_align=0;fraction_denominator_digits=0;integer_min_digits=0;decimal_min_digits=0;decimal_max_digits=0;grouping=!1;has_number_format=!1;prefix=[{text:""}];suffix=[{text:""}];scaling=0;percent=!1;exponential=!1;has_asterisk=!1};var mr=42,_r=95,Ci=63,kt=48,br=46,Si=44,yr=37,Ai=34,nt=35,gr=59,Tt=92,vr=64,Ls=91,Vs=93,wr=69,xr=101,Is=72,Fs=104,zs=77,Ps=109,Ns=83,Os=115,Gs=68,Hs=100,$s=89,Bs=121,js=65,Js=97;var de=class{static Parse(e){if(this.pattern=e,this.characters=e.split("").map(t=>t.charCodeAt(0)),this.char_index=0,this.current_section=new xe,this.sections=[this.current_section],this.ParseDatePattern())return this.sections;for(this.char_index=0,this.current_section=new xe,this.sections=[this.current_section];this.char_index<this.characters.length;)this.ConsumeChar();return this.sections}static ConsumeString(){let e="";for(this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case Tt:this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index+1<this.characters.length&&(e+=this.pattern[++this.char_index]);break;case Ai:return this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated string")}static ConsumeFormatting(){let e="";for(++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case Tt:throw new Error("invalid escape character in formatting block");case Vs:return this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated format")}static ScanFractionFormat(){let e=/^([#?]+ +){0,1}([#?]+)\/([#?0-9]+)(?:$|[^#?0-9])/,i=this.pattern.substr(this.char_index).match(e);if(!i)return!1;let r=(i[1]||"").length+i[2].length+i[3].length+1;this.current_section.fraction_format=!0,this.current_section.fraction_integer=!!i[1];let s=Number(i[3]);return isNaN(s)||(this.current_section.fraction_denominator=s),this.current_section.decimal_max_digits=this.current_section.fraction_denominator_digits=i[3].length,this.char_index+=r,this.current_section.has_number_format=!0,!0}static ConsumeNumberFormat(){let e=0;for(this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case this.group_separator:{let i=!1;for(let r=this.char_index+1;!i&&r<this.characters.length;r++){let s=this.characters[r];if(s===this.decimal_mark||s===nt||s===kt)i=!0;else if(s!==Si)break}if(i){if(e===1)throw new Error("invalid grouping in decimal part");this.current_section.grouping=!0}else this.current_section.scaling=(this.current_section.scaling||1)*1e3}break;case this.decimal_mark:if(e===1)throw new Error("too many decimal marks");e=1;break;case nt:e===1?this.current_section.decimal_max_digits++:this.current_section.integer_min_digits&&this.current_section.integer_min_digits++;break;case kt:e===1?(this.current_section.decimal_max_digits++,this.current_section.decimal_min_digits=this.current_section.decimal_max_digits):this.current_section.integer_min_digits++;break;default:return}}static AppendCharAsText(e=!0){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=this.pattern[this.char_index]:this.current_section.prefix[this.current_section.prefix.length-1].text+=this.pattern[this.char_index],e&&this.char_index++}static AppendString(e){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=e:this.current_section.prefix[this.current_section.prefix.length-1].text+=e}static AppendTextPart(e){this.current_section.has_number_format?(this.current_section.suffix.push(e),this.current_section.suffix.push({text:""})):(this.current_section.prefix.push(e),this.current_section.prefix.push({text:""}))}static ConsumeChar(){let e=this.characters[this.char_index];if(!((e===Ci||e===nt)&&!this.current_section.has_number_format&&!this.current_section.string_format&&this.ScanFractionFormat()))switch(e){case gr:this.char_index++,this.current_section=new xe,this.sections.length===3&&(this.current_section.string_format=!0),this.sections.push(this.current_section);break;case vr:this.char_index++,this.AppendTextPart({text:"@",flag:5}),this.current_section.string_format=!0;break;case kt:case nt:case br:case Si:!this.current_section.has_number_format&&!this.current_section.string_format?(this.ConsumeNumberFormat(),this.current_section.has_number_format=!0):this.AppendCharAsText();break;case Ls:this.AppendTextPart({text:this.ConsumeFormatting(),flag:6});break;case Ai:this.AppendString(this.ConsumeString());break;case Ci:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case _r:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case mr:if(this.current_section.has_asterisk)throw new Error("we don't support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case xr:case wr:this.current_section.percent||this.current_section.exponential||this.current_section.string_format?this.AppendCharAsText():(this.current_section.exponential=!0,this.char_index++);break;case yr:!this.current_section.exponential&&!this.current_section.string_format&&(this.current_section.percent=!0),this.AppendCharAsText();break;case Tt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}static ParseDatePattern(){for(this.date_pattern=!0;this.date_pattern&&this.char_index<this.pattern.length;)this.DatePatternConsumeChar();if(this.date_pattern){this.date_pattern=!1;for(let e of this.sections)for(let t of e.prefix)t.flag&&t.flag&7&&(this.date_pattern=!0)}return this.date_pattern&&(this.sections[0].date_format=!0,this.sections[0].prefix.forEach((e,t)=>{if(e.flag===3&&(e.text==="mm"||e.text==="m")){if(t)for(let i=t-1;i;i--){let r=this.sections[0].prefix[i];if(r.flag===3){/h/i.test(r.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}if(t<this.sections[0].prefix.length-1)for(let i=t+1;i<this.sections[0].prefix.length;i++){let r=this.sections[0].prefix[i];if(r.flag===3){/s/i.test(r.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}}})),this.date_pattern}static ConsumeDatePart(){let e=this.pattern[this.char_index++],t=e.toLowerCase(),i={text:e,flag:3};for(;this.pattern[this.char_index]&&this.pattern[this.char_index].toLowerCase()===t;)i.text+=this.pattern[this.char_index++];if(t==="s"&&this.pattern[this.char_index]===".")for(i.text+=this.pattern[this.char_index++];this.pattern[this.char_index]==="0";)i.text+=this.pattern[this.char_index++];return i}static ConsumeAMPM(){let e=this.pattern.substr(this.char_index,5);if(e==="am/pm"||e==="AM/PM")return this.char_index+=5,this.sections[0].twelve_hour=!0,{text:e,flag:3};if(e=this.pattern.substr(this.char_index,3),e==="a/p"||e==="A/P")return this.char_index+=3,this.sections[0].twelve_hour=!0,{text:e,flag:3}}static DatePatternConsumeChar(){switch(this.characters[this.char_index]){case gr:this.char_index=this.characters.length;break;case kt:case nt:case xr:case wr:case yr:case vr:this.date_pattern=!1;break;case Is:case Fs:case zs:case Ps:case Ns:case Os:case Gs:case Hs:case $s:case Bs:this.AppendTextPart(this.ConsumeDatePart());break;case js:case Js:{let t=this.ConsumeAMPM();t?this.AppendTextPart(t):this.AppendCharAsText()}break;case Ai:this.AppendString(this.ConsumeString());break;case Ci:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case _r:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case mr:if(this.current_section.has_asterisk)throw new Error("we don't support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case Tt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}};E(de,"date_pattern",!1),E(de,"pattern",""),E(de,"char_index",0),E(de,"characters",[]),E(de,"sections",[]),E(de,"current_section",new xe),E(de,"preserve_formatting_characters",!1),E(de,"decimal_mark",br),E(de,"group_separator",Si);var Ve=c=>(c>=60&&c--,new Date(-22090752e5+864e5*c)),je=(c,e=!0)=>{if(e){let t=new Date(c),i=new Date;i.setUTCMilliseconds(t.getUTCMilliseconds()),i.setUTCSeconds(t.getUTCSeconds()),i.setUTCMinutes(t.getUTCMinutes()),i.setUTCHours(t.getHours()),i.setUTCDate(t.getDate()),i.setUTCMonth(t.getMonth()),i.setUTCFullYear(t.getFullYear()),c=i.getTime()}return c=(c+22090752e5)/864e5,c>=60&&c++,c},Ce=class{magic_decimal=!1;transform_value;_pattern="";sections;decimal_zero_regexp=[];cloned=[];get pattern(){return this._pattern}get date_format(){return this.sections[0]&&this.sections[0].date_format}constructor(e){if(this._pattern=e,this.sections=de.Parse(e),this.sections.length||(this.sections=[]),this.sections[0]||(this.sections[0]=new xe),this.sections[1]||(this.sections[1]={...this.sections[0]},this.sections[1].prefix=JSON.parse(JSON.stringify(this.sections[1].prefix)),this.sections[1].suffix=JSON.parse(JSON.stringify(this.sections[1].suffix)),this.sections[1].prefix.push({text:"-"}),this.cloned[1]=!0),this.sections[2]||(this.sections[2]={...this.sections[0]},this.cloned[2]=!0),!this.sections[3]){for(let t of this.sections[0].prefix)if(t.flag===5){this.sections[3]={...this.sections[0]},this.sections[3].string_format=!0,this.cloned[3]=!0;break}}this.decimal_zero_regexp=this.sections.map(t=>{if(t.decimal_max_digits>t.decimal_min_digits)return new RegExp(`0{1,${t.decimal_max_digits-t.decimal_min_digits}}(?:$|e)`)})}static FormatPartsAsText(e,t=0){let i=-1,r=e.map((s,n)=>{switch(s.flag){case 2:return i=n,s.text;case 1:return s.text.replace(/./g," ");case 6:return"";default:return s.text}});if(i>=0&&t){let s=r.reduce((o,a,l)=>l===i?o:o+a.length,0),n="";for(let o=0;o<t-s;o++)n+=r[i];r[i]=n}return r.join("")}SetDecimal(e){for(let t of this.sections)t.fraction_format||(t.decimal_min_digits=e,t.decimal_max_digits=e)}IncreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.min(e.fraction_denominator_digits+1,4)):(e.decimal_min_digits++,e.decimal_max_digits=e.decimal_min_digits)})}DecreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.max(e.fraction_denominator_digits-1,1)):(e.decimal_min_digits=Math.max(0,e.decimal_min_digits-1),e.decimal_max_digits=e.decimal_min_digits)})}AddGrouping(){this.sections.forEach(e=>{e.grouping=!0})}RemoveGrouping(){this.sections.forEach(e=>{e.grouping=!1})}ToggleGrouping(){let e=!this.sections[0].grouping;this.sections.forEach(t=>{t.grouping=e})}toString(){return this.sections[0].date_format?this._pattern:this.sections.filter((e,t)=>!this.cloned[t]).map(e=>{let t="",i=0;if(e.fraction_format){e.fraction_integer&&(t+="? ");let r="";for(let s=0;s<e.fraction_denominator_digits;s++)r+="#";t+=r,t+="/",e.fraction_denominator?t+=e.fraction_denominator:t+=r}else if(e.has_number_format){for(i=0;i<e.integer_min_digits;i++)t+="0";if(e.grouping&&(t.length<4&&(t=("####"+t).slice(-4)),t=t.replace(/[\d#]{1,3}(?=([\d#]{3})+(?![\d#]))/g,"$&,")),e.decimal_max_digits||e.decimal_min_digits){for(t+=".",i=0;i<e.decimal_min_digits;i++)t+="0";for(;i<e.decimal_max_digits;i++)t+="#"}if(e.scaling){let r=Math.log10(e.scaling)/3;for(i=0;i<r;i++)t+=","}e.exponential&&(t+="e")}return e.prefix.map(r=>r.flag===1?r.text==="0"?"?":"_"+r.text:r.flag===2?"*"+r.text:r.flag===6?"["+r.text+"]":r.text).join("")+t+e.suffix.map(r=>r.flag===1?r.text==="0"?"?":"_"+r.text:r.flag===2?"*"+r.text:r.text).join("")}).join(";")}FormatDimensionedQuantity(e){if(this.transform_value){let i=this.transform_value(e);if(ni(i))e=i;else return typeof i=="string"?i:this.FormatParts(i)}let t=this.FormatParts(e.value||0);return e.unit&&t.push({text:" "},{text:e.unit}),t}FormatComplex(e){let t=[],i=[],r=!1,s=!!e.imaginary;s&&(t=this.FormatParts(e.imaginary),s=t.some(a=>/[1-9]/.test(a.text)),t.length===1&&this.sections[0].integer_min_digits<=1&&t[0].text==="1"?(t[0].text="",r=!0):t.length===1&&this.sections[1].integer_min_digits<=1&&t[0].text==="-1"&&(t[0].text="-",r=!0));let n=!!e.real;n&&(i=this.FormatParts(e.real),n=i.some(a=>/[1-9]/.test(a.text)));let o=[];if(n||!n&&!s){if(o.push(...i),s){let a=Math.abs(e.imaginary);o.push({text:e.imaginary<0?` ${Ce.minus_character} `:" + "});let l=r?[]:this.FormatParts(Math.abs(e.imaginary));o.push(...l,{text:Ce.imaginary_character})}}else s&&o.push(...t,{text:Ce.imaginary_character});return o}FormatParts(e){if(typeof e!="number"&&!this.sections[3])return[{text:e.toString()}];let{parts:t,section:i}=this.BaseFormat(e),r=[];if(i.date_format||i.string_format)for(let s of t)typeof s=="string"?r.push({text:s}):r.push(s);else this.magic_decimal&&t[1]===""&&t.splice(1,1),r=[...i.prefix.map(s=>({...s})),{text:i.has_number_format?t.join(T.decimal_separator):""},...i.suffix.map(s=>({...s}))];for(let s=1;s<r.length;s++)r[s].flag===r[s-1].flag&&(r[s].text=r[s-1].text+r[s].text,r[s-1].text="");return r.filter(s=>s.text)}Format(e,t=0){return Ce.FormatPartsAsText(this.FormatParts(e),t)}ZeroPad(e,t){for(;e.length<t;)e="0"+e;return e}DateFormat(e){let t=Ve(e),i=this.sections[0],r=t.getUTCHours();return i.twelve_hour&&(r>12&&(r-=12),r===0&&(r=12)),{parts:i.prefix.map(n=>{if(n.flag===4)return n.text==="mm"?{text:this.ZeroPad(t.getUTCMinutes().toString(),2)}:{text:this.ZeroPad(t.getUTCMinutes().toString(),1)};if(n.flag===3){switch(n.text.toLowerCase()){case"am/pm":case"a/p":{let a=n.text.split("/");return{text:t.getUTCHours()>12?a[1]:a[0]}}case"mmmmm":return{text:T.date_components.long_months[t.getUTCMonth()][0]};case"mmmm":return n.text==="MMMM"?{text:T.date_components.long_months[t.getUTCMonth()].toUpperCase()}:{text:T.date_components.long_months[t.getUTCMonth()]};case"mmm":return n.text==="MMM"?{text:T.date_components.short_months[t.getUTCMonth()].toUpperCase()}:{text:T.date_components.short_months[t.getUTCMonth()]};case"mm":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),2)};case"m":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),1)};case"ddddd":case"dddd":return n.text==="DDDDD"||n.text==="DDDD"?{text:T.date_components.long_days[t.getUTCDay()].toUpperCase()}:{text:T.date_components.long_days[t.getUTCDay()]};case"ddd":return n.text==="DDD"?{text:T.date_components.short_days[t.getUTCDay()].toUpperCase()}:{text:T.date_components.short_days[t.getUTCDay()]};case"dd":return{text:this.ZeroPad(t.getUTCDate().toString(),2)};case"d":return{text:this.ZeroPad(t.getUTCDate().toString(),1)};case"yyyy":case"yyy":return{text:t.getUTCFullYear().toString()};case"yy":case"y":return{text:this.ZeroPad((t.getUTCFullYear()%100).toString(),2)};case"hh":return{text:this.ZeroPad(r.toString(),2)};case"h":return{text:this.ZeroPad(r.toString(),1)};case"ss":return{text:this.ZeroPad(t.getUTCSeconds().toString(),2)};case"s":return{text:this.ZeroPad(t.getUTCSeconds().toString(),1)}}let o=n.text.match(/^(s+)\.(0+)$/);if(o)return{text:this.ZeroPad(t.getUTCSeconds().toString(),o[1].length)+T.decimal_separator+(t.getUTCMilliseconds()/1e3).toFixed(o[2].length).substr(2)}}return{...n}}),section:i}}StringFormat(e,t){let i=[];for(let r of t.prefix)r.flag===5?i.push({text:e}):i.push({...r});return{parts:i,section:t}}Round2(e,t){let i=Math.pow(10,t);return Math.round(i*e)/i}FormatFraction(e,t){t.percent&&(e*=100);let i={denominator:1,numerator:Math.round(e),error:Math.abs(Math.round(e)-e)};if(t.fraction_denominator)i.denominator=t.fraction_denominator,i.numerator=Math.round(e*i.denominator);else if(i.error){let s=Ce.fraction_limits[t.fraction_denominator_digits-1]||Ce.fraction_limits[0];for(let n=2;n<=s;n++){let o=Math.round(e*n),a=Math.abs(o/n-e);if(a<i.error&&(i={numerator:o,denominator:n,error:a},!a))break}}let r=[];if(t.fraction_integer){let s=Math.floor(i.numerator/i.denominator);i.numerator%=i.denominator,(s||!i.numerator)&&(r.push(s.toString()),i.numerator&&r.push(" "))}else i.numerator||r.push("0");return i.numerator&&(r.push(i.numerator.toString()),r.push("/"),r.push(i.denominator.toString())),r.join("")}BaseFormat(e){if(this.sections[0].date_format)return this.DateFormat(Number(e));if(typeof e!="number")return this.StringFormat(e.toString(),this.sections[3]);let t=this.sections[0],i=this.decimal_zero_regexp[0];e<0&&(t=this.sections[1]);let r=t.percent?t.decimal_max_digits+2:t.decimal_max_digits,s=Math.pow(10,-r)/2,n=Math.abs(e);if(n<s&&(t=this.sections[2],i=this.decimal_zero_regexp[2]),t.scaling&&(n/=t.scaling,n<s&&(t=this.sections[2],i=this.decimal_zero_regexp[2])),t.string_format)return this.StringFormat(e.toString(),t);let o="";if(t.fraction_format)return{parts:[this.FormatFraction(n,t)],section:t};t.exponential?o=n.toExponential(t.decimal_max_digits):(t.percent&&(n*=100),o=this.Round2(n,t.decimal_max_digits).toFixed(t.decimal_max_digits)),i&&(o=o.replace(i,""));let a=o.split(".");for(;a[0].length<t.integer_min_digits;)a[0]=("0000000000000000"+a[0]).slice(-t.integer_min_digits);return t.integer_min_digits===0&&a[0]==="0"&&(a[0]=""),t.grouping&&(a[0]=a[0].replace(Ce.grouping_regexp,"$&"+T.grouping_separator)),{parts:a,section:t}}},X=Ce;E(X,"grouping_regexp",/\d{1,3}(?=(\d{3})+(?!\d))/g),E(X,"fraction_limits",[9,99,999,9999]),E(X,"imaginary_character","\u{1D456}"),E(X,"minus_character","-");var L=class{static Get(e,t=!1){if(t&&e==="General")return this.complex_general;let i=this.symbolc_name_map[e.toLowerCase()],r=this.cache[i||e];return r||(r=new X(e),this.cache[e]=r),r}static Equals(e,t){if(e===t)return!0;let i=this.Get(e),r=this.Get(t);return i.pattern===r.pattern}static Translate(e){let t=this.symbolc_name_map[e.toLowerCase()];return t?this.cache[t].toString():e}static SymbolicName(e){for(let t of Object.keys(this.base_formats))if(e===this.base_formats[t])return t;return null}static InitCache(){for(let e of Object.keys(this.base_formats))this.cache[e]=new X(this.base_formats[e]),this.symbolc_name_map[e.toLowerCase()]=e;this.cache.General.magic_decimal=!0,this.complex_general=new X("0.###"),this.complex_general.magic_decimal=!0;for(let e of Object.keys(this.aliases))this.cache[e]=this.cache[this.aliases[e]],this.symbolc_name_map[e.toLowerCase()]=e}};E(L,"cache",{}),E(L,"complex_general"),E(L,"symbolc_name_map",{}),E(L,"base_formats",{Accounting:"_(#,##0.00_);(#,##0.00);-???",Number:"0.00",Integer:"0",Percent:"0.00%",General:"0.######",Fraction:"# ?/?",Dollar:"$* _(#,##0.00_);$* (#,##0.00);$* -???",Exponential:"0.000e","Short Date":"mm/dd/yy","Long Date":"dddd, mmm d yyyy",Timestamp:"mm-dd-yy hh:mm:ss"}),E(L,"aliases",{Scientific:"Exponential",Percentage:"Percent",Currency:"Dollar"});L.InitCache();var Cr=new Date().getUTCFullYear(),Ei=class{compare_day;compare_month;TestDate(e){let t=Date.parse(e);if(isNaN(t))return!1;let i=new Date(t),s=e.replace(/[\d\-\\/,.\s]+/g," ").toLocaleLowerCase().split(/\s+/).map(a=>a.trim()).filter(a=>!!a);if(!s.length)return t;if(!this.compare_month){this.compare_month={};for(let a=0;a<12;a++)this.compare_month[T.date_components.long_months[a].toLocaleLowerCase().replace(/\./,"")]=a,this.compare_month[T.date_components.short_months[a].toLocaleLowerCase().replace(/\./,"")]=a}if(!this.compare_day){this.compare_day={};for(let a=0;a<7;a++)this.compare_day[T.date_components.long_days[a].toLocaleLowerCase().replace(/\./,"")]=a,this.compare_day[T.date_components.short_days[a].toLocaleLowerCase().replace(/\./,"")]=a}let n=!1,o=!1;for(let a of s){let l=!1;for(let[d,u]of Object.entries(this.compare_month))if(a===d){if(n||i.getUTCMonth()!==u)return!1;l=!0,n=!0}if(!l){for(let[d,u]of Object.entries(this.compare_day))if(a===d){if(o||i.getUTCDay()!==u)return!1;l=!0,o=!0}}if(!l)return!1}return o&&!n?!1:t}TryParse(e=""){let t=0;if(e[0]==="'")return{value:e,type:2};if(e==="")return{value:e,type:2};if(e==="NaN")return{value:NaN,type:3,hints:1};let i=e.trim(),r=i.match(/^[$](.*?)$/);r&&(i=r[1],t|=8);let s=i.match(/^\((.*?)\)$/);s&&(i=s[1],t|=32);let n=i.match(/^(.*?)%\s*$/);n&&(i=n[1],t|=4),T.decimal_separator==="."?/,/.test(i)&&(i=i.replace(/,/g,""),t|=16):(i=i.replace(/(\d)\s+/g,"$1"),i=i.replace(/\./g,""),i=i.replace(/,/,"."));let o=Number(i);if(o===null||isNaN(o)){let a=e.toLowerCase();if(a==="false")return{value:!1,type:4};if(a==="true")return{value:!0,type:4};let l=this.TestDate(e);if(l!==!1&&!isNaN(l)){let d=new Date(l),u=d.getUTCFullYear();if(u>=Cr-200&&u<=Cr+200)return t=64,(d.getHours()||d.getMinutes()||d.getSeconds())&&(t|=128),{value:je(l),type:3,hints:t}}return{value:e,type:2}}if(s&&(o=-o),n){let a=o<0?-1:1,l=(a*o).toString().split(".");l[0]=("00"+l[0]).replace(/(\d\d)$/,".$1"),o=Number(l.join(""))*a}return/e/.test(e)&&(t|=2),{value:o,type:3,hints:t}}},ye=new Ei;var ot="http://www.w3.org/2000/svg",Ut=class{constructor(e,t,i={x:0,y:0}){this.theme=t;this.offset=i;this.g=document.createElementNS(ot,"g"),this.g.setAttribute("transform",`translate(${i.x}, ${i.y})`),this.outline=document.createElementNS(ot,"rect"),this.outline.setAttribute("class","outline"),e?(this.g.setAttribute("class","selection primary-selection"),this.fill=document.createElementNS(ot,"path"),this.fill.setAttribute("class","fill"),this.nub=document.createElementNS(ot,"rect"),this.nub.setAttribute("class","nub"),this.g.appendChild(this.fill),this.g.appendChild(this.outline),this.g.appendChild(this.nub)):(this.g.setAttribute("class","selection alternate-selection"),this.fill=document.createElementNS(ot,"rect"),this.fill.setAttribute("class","fill"),this.g.appendChild(this.fill),this.g.appendChild(this.outline))}g;outline;fill;nub;Offset(e){this.g.setAttribute("transform",`translate(${e.x}, ${e.y})`)}Show(e=!0){this.g.style.display=e?"block":"none"}SetOutline(e,t=!1){this.outline.setAttribute("x",(e.left-1).toString()),this.outline.setAttribute("y",(e.top-1).toString()),this.outline.setAttribute("width",(e.width+1).toString()),this.outline.setAttribute("height",(e.height+1).toString()),t&&this.fill&&(this.fill.setAttribute("x",e.left.toString()),this.fill.setAttribute("y",e.top.toString()),this.fill.setAttribute("width",e.width.toString()),this.fill.setAttribute("height",e.height.toString()))}SetFill(e,t){if(!this.fill)return;let i=[];i.push("M"+e.left+" "+e.top),i.push("L"+e.left+" "+e.bottom),i.push("L"+e.right+" "+e.bottom),i.push("L"+e.right+" "+e.top),i.push("Z"),i.push("M"+t.left+" "+t.top),i.push("L"+t.right+" "+t.top),i.push("L"+t.right+" "+t.bottom),i.push("L"+t.left+" "+t.bottom),i.push("Z"),this.fill.setAttribute("d",i.join(" "))}SetNub(e){!this.nub||(this.nub.setAttribute("x",(e.left+e.width-4).toString()),this.nub.setAttribute("y",(e.top+e.height-4).toString()),this.nub.setAttribute("width","7"),this.nub.setAttribute("height","7"))}};var ki="http://www.w3.org/2000/svg";var Ie=class{constructor(e,t,i){this.theme=e;this.container=t;this.orientation=i;this.g=document.createElementNS(ki,"g"),this.g.setAttribute("class","header-overlay"),this.overlay=document.createElementNS(ki,"rect"),this.overlay.setAttribute("class","overlay"),this.highlight=document.createElementNS(ki,"rect"),this.highlight.setAttribute("class","highlight"),this.g.style.display="none",this.g.appendChild(this.highlight),this.g.appendChild(this.overlay),t.appendChild(this.g)}g;overlay;highlight;Remove(){this.container.removeChild(this.g)}Hide(){this.g.style.display="none"}Show(e,t,i,r){this.overlay.setAttribute("x",e.toString()),this.overlay.setAttribute("y",t.toString()),this.overlay.setAttribute("width",i.toString()),this.overlay.setAttribute("height",r.toString()),this.orientation===0?(this.highlight.setAttribute("x",e.toString()),this.highlight.setAttribute("y",(t+r-2).toString()),this.highlight.setAttribute("width",i.toString()),this.highlight.setAttribute("height","2")):(this.highlight.setAttribute("x",(e+i-2).toString()),this.highlight.setAttribute("y",t.toString()),this.highlight.setAttribute("width","2"),this.highlight.setAttribute("height",r.toString())),this.g.style.display="block"}};var Mt=class{constructor(e,t,i,r,s,n){this.theme=e;this.layout=t;this.model=i;this.view=r;this.primary_selection=s;this.additional_selections=n}nub_rectangle=new z(-1,-1,0,0);cached_additional_selections="";grid_selections=[];row_header_selections=[];column_header_selections=[];corner_selections=[];row_overlay;column_overlay;corner_row_overlay;corner_column_overlay;Initialize(){this.row_overlay=new Ie(this.theme,this.layout.row_header_selection,0),this.column_overlay=new Ie(this.theme,this.layout.column_header_selection,1),this.corner_row_overlay=new Ie(this.theme,this.layout.corner_selection,0),this.corner_column_overlay=new Ie(this.theme,this.layout.corner_selection,1)}RenderSelections(e=!0,t=!0){let i=this.primary_selection.empty;e||(this.primary_selection.empty=!0);let r=[this.primary_selection].concat(this.additional_selections);this.RenderSelectionGroup(r,this.layout.grid_selection,void 0,void 0,this.grid_selections,void 0,t);let s=new z(-1,-1,0,0);if(!this.primary_selection.empty){let a=this.view.active_sheet.RealArea(this.primary_selection.area);s=this.layout.CellAddressToRectangle(a.start).Combine(this.layout.CellAddressToRectangle(a.end))}if(!this.primary_selection.empty&&this.layout.header_offset.y>2?(this.row_overlay.Show(s.left,0,s.width,this.layout.header_offset.y),this.corner_row_overlay.Show(s.left+this.layout.header_offset.x,0,s.width,this.layout.header_offset.y)):(this.row_overlay.Hide(),this.corner_row_overlay.Hide()),!this.primary_selection.empty&&this.layout.header_offset.x>2?(this.column_overlay.Show(0,s.top,this.layout.header_offset.x,s.height),this.corner_column_overlay.Show(0,s.top+this.layout.header_offset.y,this.layout.header_offset.x,s.height)):(this.column_overlay.Hide(),this.corner_column_overlay.Hide()),!this.view.active_sheet.freeze.columns&&!this.view.active_sheet.freeze.rows){this.primary_selection.empty=i;return}let n=[],o=[];if(this.primary_selection.empty)n.push(!1),o.push(!1);else{let a=this.primary_selection.area.start;n.push(a.row<=this.view.active_sheet.freeze.rows||a.row===1/0),o.push(a.column<=this.view.active_sheet.freeze.columns||a.column===1/0)}for(let{area:a}of this.additional_selections)n.push(a.start.row<=this.view.active_sheet.freeze.rows||a.start.row===1/0),o.push(a.start.column<=this.view.active_sheet.freeze.columns||a.start.column===1/0);this.view.active_sheet.freeze.rows&&this.RenderSelectionGroup(r,this.layout.row_header_selection,n,void 0,this.row_header_selections,{x:0,y:this.layout.header_offset.y}),this.view.active_sheet.freeze.columns&&this.RenderSelectionGroup(r,this.layout.column_header_selection,o,void 0,this.column_header_selections,{x:this.layout.header_offset.x,y:0}),this.view.active_sheet.freeze.rows&&this.view.active_sheet.freeze.columns&&this.RenderSelectionGroup(r,this.layout.corner_selection,o,n,this.corner_selections,{...this.layout.header_offset}),this.primary_selection.empty=i}RenderSelectionGroup(e,t,i,r,s,n,o=!0){for(let a=0;a<e.length;a++)if((!e[a].area.start.sheet_id||e[a].area.start.sheet_id===this.view.active_sheet.id)&&!e[a].empty&&(!i||i[a])&&(!r||r[a])){if(o||!e[a].rendered){let d=this.EnsureGridSelectionBlock(t,s,a,n);this.RenderSVGSelection(e[a],d,a)}}else s[a]&&s[a].Show(!1);for(let a=e.length;a<s.length;a++)s[a]&&s[a].Show(!1)}EnsureGridSelectionBlock(e,t,i,r){let s=t[i];if(!s)if(s=new Ut(!i,this.theme),t[i]=s,i){let n=e.querySelector(".alternate-selections");n||(n=document.createElementNS("http://www.w3.org/2000/svg","g"),n.setAttribute("class","alternate-selections"),e.appendChild(n)),n?.appendChild(s.g)}else e.appendChild(s.g);return r&&s.Offset(r),s}ClampEnd(e){return{row:Math.min(e.row,this.view.active_sheet.rows-1),column:Math.min(e.column,this.view.active_sheet.columns-1)}}RenderSVGSelection(e,t,i=0){let r=this.view.active_sheet.RealArea(e.area,!0),s=this.layout.CellAddressToRectangle(r.start);if(r.count>1)s=s.Combine(this.layout.CellAddressToRectangle(r.end));else if(i){let n=this.view.active_sheet.CellData(e.target);n.merge_area&&(s=this.layout.CellAddressToRectangle(n.merge_area.start),s=s.Combine(this.layout.CellAddressToRectangle(n.merge_area.end)))}if(i||(this.nub_rectangle=new z(s.left+s.width-6,s.top+s.height-6,11,11)),s.top===0&&this.layout.header_offset.y<=1&&(s.top=1,s.height-=1),s.left===0&&this.layout.header_offset.x<=1&&(s.left=1,s.width-=1),s.height<=0||s.height<=0){t.Show(!1);return}if(t.SetOutline(s,!!i),i)e.rendered=!0;else{let n=this.layout.CellAddressToRectangle(e.target),o=this.view.active_sheet.CellData(e.target);o.merge_area&&(n=this.layout.CellAddressToRectangle(o.merge_area.start),n=n.Combine(this.layout.CellAddressToRectangle(o.merge_area.end))),t.SetFill(n,s),t.SetNub(s)}t.Show()}};function me(c,e=[],t,i){typeof e=="string"&&(e=[e]);let r,s=o=>{o.stopPropagation(),o.preventDefault(),r(),i&&i(o)},n=o=>{if(o.stopPropagation(),o.preventDefault(),!o.buttons){r(),i&&i(o);return}t&&t(o)};r=()=>{c.style.display="none",c.removeEventListener("mousemove",n),c.removeEventListener("mouseup",s);for(let o of e)c.classList.remove(o)};for(let o of e)c.classList.add(o);c.style.display="block",t&&c.addEventListener("mousemove",n),i&&c.addEventListener("mouseup",s)}var V=class{static CreateDiv(e="",t,i){return this.Create("div",e,t,i)}static Create(e="",t="",i,r,s){let n=document.createElement(e);if(t&&n.setAttribute("class",t),r&&n.setAttribute(r,""),s){let o=Object.keys(s);for(let a of o)n.setAttribute(a,s[a])}return i&&i.appendChild(n),n}};var Dt=class extends Q{constructor(t){super();this.container=t;this.format=L.Get("0.0");let i=V.CreateDiv("treb-scale-control-2",t);this.input=V.Create("input","treb-scale-input",i);let r=V.CreateDiv("treb-slider-container",i);this.input.addEventListener("keypress",s=>{switch(s.key){case"ArrowUp":case"ArrowDown":s.stopPropagation(),s.preventDefault(),console.info("mark?");break}}),this.input.addEventListener("keydown",s=>{switch(s.key){case"Enter":this.input.blur();break;case"ArrowUp":this.Tick(-1);break;case"ArrowDown":this.Tick(1);break;case"Escape":this.input.value=this.format.Format(this.scale)+"%",this.input.blur();break;default:return}s.stopPropagation(),s.preventDefault()}),this.input.addEventListener("change",()=>{let s=this.input.value;s=s.replace(/%/g,"");let n=ye.TryParse(s);n.type===3?this.UpdateScale(Number(n.value),!0):this.input.value=this.format.Format(this.scale)+"%"}),this.slider=V.Create("input",void 0,r,void 0,{type:"range",min:"50",max:"200",value:"100",step:"2.5"}),this.slider.addEventListener("input",()=>{this.UpdateScale(Number(this.slider.value),!0)}),i.addEventListener("wheel",s=>{s.stopPropagation(),s.preventDefault(),this.Tick(s.deltaY)})}input;slider;scale=0;format;timeout=0;Tick(t){let i=Math.round(this.scale/2.5)*2.5;t>0?this.UpdateScale(i-2.5,!0,!0):t<0&&this.UpdateScale(i+2.5,!0,!0)}UpdateScale(t,i=!1,r=!1){t=Math.max(50,Math.min(200,t)),t!==this.scale&&(this.scale=t,this.input.value=this.format.Format(t)+"%",this.slider.value=t.toFixed(1),i&&(this.timeout||(this.timeout=requestAnimationFrame(()=>{this.timeout=0,this.Publish({type:"scale",value:this.scale/100,keep_focus:r})}))))}};var Lt=class extends Q{constructor(t,i,r,s,n,o){super();this.layout=t;this.model=i;this.view=r;this.options=s;this.theme=n;this.grid_container=o;this.Init(o)}node;container;scale_control;stats_panel;dragging=!1;double_click_data={};_visible=!1;get visible(){return this._visible}set stats_data(t){if(this.stats_panel){this.stats_panel.innerText="";for(let i of t){let r=document.createElement("span");r.classList.add("treb-stats-label"),r.textContent=i.label,this.stats_panel.appendChild(r);let s=document.createElement("span");s.classList.add("treb-stats-value"),s.textContent=i.value,this.stats_panel.appendChild(s)}}}IsDoubleClick(t,i=300){return this.double_click_data.index===t?(clearTimeout(this.double_click_data.timeout),this.double_click_data.index=void 0,this.double_click_data.timeout=void 0,!0):(this.double_click_data.timeout&&clearTimeout(this.double_click_data.timeout),this.double_click_data.index=t,this.double_click_data.timeout=setTimeout(()=>{this.double_click_data.index=void 0,this.double_click_data.timeout=void 0},i),!1)}Hide(){this.Show(!1)}Show(t=!0){!this.container||(this._visible=t,t?(this.grid_container.classList.add("treb-tab-bar-layout"),this.grid_container.parentElement?.classList.add("has-tab-bar"),this.container.style.display="flex"):(this.grid_container.classList.remove("treb-tab-bar-layout"),this.grid_container.parentElement?.classList.remove("has-tab-bar"),this.container.style.display="none"))}SetActive(t,i){i?t.classList.add("selected"):t.classList.remove("selected")}UpdateScale(t){this.scale_control?.UpdateScale(t*100)}Update(){if(this.dragging||!this.node)return;if(this.options.tab_bar==="auto"){if(this.model.sheets.list.reduce((o,a)=>a.visible?o+1:o,0)<=1){this.Show(!1);return}this.Show(!0)}this.grid_container.classList.add("treb-tab-bar-layout"),this.grid_container.parentElement?.classList.add("has-tab-bar");let t=this.node,i=!1,r=Array.prototype.map.call(t.children,n=>n);for(let n of r)n.dataset.preserve?i=!0:t.removeChild(n);if(!i){let n=document.createElement("div");n.classList.add("tab-bar-spacer"),n.dataset.preserve="true",t.appendChild(n),n=document.createElement("div"),n.classList.add("tab-bar-end"),n.dataset.preserve="true",this.options.stats&&(this.stats_panel=document.createElement("div"),this.stats_panel.classList.add("treb-stats-panel"),n.appendChild(this.stats_panel)),this.options.scale_control&&(this.scale_control=new Dt(n),this.scale_control.Subscribe(o=>{this.Publish(o)}),this.UpdateScale(this.options.initial_scale||1)),t.appendChild(n)}if(this.options.delete_tab){let n=document.createElement("div");n.classList.add("delete-tab"),n.innerHTML="<svg viewbox='0 0 16 16'><path d='M4,4 L12,12 M12,4 L4,12'/></svg>",n.style.order=(-1).toString(),n.title="Delete current sheet",n.addEventListener("click",()=>{this.Publish({type:"delete-sheet"})}),t.appendChild(n)}let s=[];for(let n of this.model.sheets.list){if(!n.visible)continue;let o=s.length,a=document.createElement("div");a.classList.add("tab"),a.style.order=(o*2).toString(),this.SetActive(a,n===this.view.active_sheet);let l=u=>{if(u.stopPropagation(),u.preventDefault(),this.IsDoubleClick(o))return;this.Publish({type:"activate-sheet",sheet:n});let h=s.map(v=>v.getBoundingClientRect()),p=o*2-1,f=h[0].left,m=h[h.length-1].right,b=h[0].top,_=h[0].bottom,y=-1,x=(h.length-1)*2+1;for(let v of s)this.SetActive(v,v===a);this.dragging=!0,me(this.layout.mask,[],v=>{let[w,C]=[v.clientX,v.clientY];if(C>b&&C<_){let S=p;if(w<f)S=y;else if(w>m)S=x;else for(let U=0;U<h.length;U++){let J=h[U];if(w>=J.left&&w<=J.right){U!==o&&(w>=J.left+J.width/2?S=U*2+1:S=U*2-1);break}}S!==p&&(p=S,a.style.order=p.toString(),h=s.map(U=>U.getBoundingClientRect()))}},()=>{let v=o,w=(p+1)/2;this.dragging=!1;for(let C=0;C<this.model.sheets.length;C++)this.model.sheets.list[C].visible||(v>=C&&v++,w>=C&&w++);v===w||v===0&&w<=0||v===s.length-1&&w>=s.length-1||this.Publish({type:"reorder-sheet",index:v,move_before:w})})},d=()=>{a.removeEventListener("mousedown",l),a.removeEventListener("dblclick",d),a.contentEditable="true";let u=window.getSelection();if(u){u.removeAllRanges();let h=document.createRange();h.selectNodeContents(a),u.addRange(h)}a.addEventListener("keydown",h=>{switch(h.key){case"Enter":this.Publish({type:"rename-sheet",name:a.innerText.trim(),sheet:n});break;case"Escape":a.innerText=n.name,this.Publish({type:"cancel"});break;default:return}h.stopPropagation(),h.preventDefault()}),a.addEventListener("focusout",()=>{let h=a.innerText.trim();h!==n.name&&this.Publish({type:"rename-sheet",name:h,sheet:n})}),a.focus()};a.textContent=n.name,a.addEventListener("dblclick",d),a.addEventListener("mousedown",l),t.appendChild(a),s.push(a)}if(this.options.add_tab){let n=document.createElement("a");n.classList.add("add-tab"),n.style.order=(this.model.sheets.length*2).toString(),n.innerText="+",n.title="Add sheet",n.addEventListener("click",()=>{this.Publish({type:"add-sheet"})}),t.appendChild(n)}}Init(t){this.container=document.createElement("div"),this.container.classList.add("treb-tab-bar-container"),t.appendChild(this.container),this.node=document.createElement("div"),this.node.classList.add("treb-tab-bar"),this.container.appendChild(this.node)}};var Sr=()=>({target:{row:0,column:0},area:new g({row:0,column:0}),empty:!0});var Ws=100,Te=class{get key(){return this.key_}rect;scaled_rect;layout;data={};type="";temp={};resizable=!0;movable=!0;removable=!0;selectable=!0;move_with_cells=!0;resize_with_cells=!0;view=[];dirty;formula="";extent;key_=Ws++;constructor(e={}){for(let t of Object.keys(this))t!=="layout"&&e[t]&&(this[t]=e[t]);e.layout&&(this.layout=JSON.parse(JSON.stringify(e.layout))),e.rect&&(this.rect=z.Create(e.rect))}toJSON(){let e={};return this.data&&(e.data=this.data),this.formula&&(e.formula=this.formula),this.type&&(e.type=this.type),this.resizable||(e.resizable=this.resizable),this.movable||(e.movable=this.movable),this.removable||(e.removable=this.removable),this.selectable||(e.selectable=this.selectable),this.move_with_cells||(e.move_with_cells=this.move_with_cells),this.resize_with_cells||(e.resize_with_cells=this.resize_with_cells),this.layout&&(e.layout=this.layout),this.extent&&(e.extent=this.extent),e}};var qs=100,Ar=60,Ue=class{default_style_properties;annotations=[];freeze={rows:0,columns:0};visible=!0;default_column_width=100;default_row_height=25;cells=new vt;selection=Sr();scroll_offset={x:0,y:0};name=Ue.default_sheet_name;id_;row_height_=[];column_width_=[];row_headers=[];column_headers=[];row_header_width=100;column_header_height=25;style_map=[];style_json_map=[];sheet_style={};row_styles={};column_styles={};row_pattern=[];cell_style=[];get header_offset(){return{x:this.row_header_width,y:this.column_header_height}}get rows(){return this.cells.rows}get columns(){return this.cells.columns}get id(){return this.id_}set id(e){this.id_=e,this.id>=Ue.base_id&&(Ue.base_id=this.id+1)}constructor(e){this.default_style_properties=e,this.default_column_width=qs,this.row_header_width=Ar,this.UpdateDefaultRowHeight(),this.id_=Ue.base_id++}static Reset(){this.base_id=100}static Blank(e,t,i=30,r=20){let s=new Ue(e);return t&&(s.name=t),i=Math.max(i,1),r=Math.max(r,1),s.cells.EnsureCell({row:i-1,column:r-1}),s}static UpdateStyle(e){if(typeof e.horizontal_align=="number"){let t=[A.HorizontalAlign.None,A.HorizontalAlign.Left,A.HorizontalAlign.Center,A.HorizontalAlign.Right];e.horizontal_align=t[e.horizontal_align]||void 0}if(typeof e.vertical_align=="number"){let t=[A.VerticalAlign.None,A.VerticalAlign.Top,A.VerticalAlign.Bottom,A.VerticalAlign.Middle];e.vertical_align=t[e.vertical_align]||void 0}}static FromJSON(e,t,i){let r=typeof e=="string"?JSON.parse(e):e,s=(l,d)=>{Object.keys(d).forEach(u=>{let h=Number(u)||0;l[h]=d[u]})};i||(i=new Ue(t)),r.default_column_width&&(i.default_column_width=r.default_column_width),r.default_row_height&&(i.default_row_height=r.default_row_height),r.id&&(i.id=r.id),r.name&&(i.name=r.name);let n=l=>{let d=l;this.UpdateStyle(d),(d.font_size_value||d.font_size_unit)&&(d.font_size={unit:d.font_size_unit||"pt",value:d.font_size_value||10},d.font_size_unit=void 0,d.font_size_value=void 0),d.font_bold&&(d.bold=!0,d.font_bold=void 0),d.font_italic&&(d.italic=!0,d.font_italic=void 0),d.font_underline&&(d.underline=!0,d.font_underline=void 0),d.font_strike&&(d.strike=!0,d.font_strike=void 0),d.text_color&&(d.text_color!=="none"&&(d.text={text:d.text_color}),d.text_color=void 0),d.background&&(d.background!=="none"&&(d.fill={text:d.background}),d.background=void 0),d.border_top_color&&(d.border_top_color!=="none"&&(d.border_top_fill={text:d.border_top_color}),d.border_top_color=void 0),d.border_left_color&&(d.border_left_color!=="none"&&(d.border_left_fill={text:d.border_left_color}),d.border_left_color=void 0),d.border_bottom_color&&(d.border_bottom_color!=="none"&&(d.border_bottom_fill={text:d.border_bottom_color}),d.border_bottom_color=void 0),d.border_right_color&&(d.border_right_color!=="none"&&(d.border_right_fill={text:d.border_right_color}),d.border_right_color=void 0)},o=r.styles||r.cell_style_refs||[];for(let l of o)n(l);if(i.cell_style=[],o&&(r.cell_styles||[]).forEach(l=>{typeof l.ref=="number"&&(l.style=JSON.parse(JSON.stringify(o[l.ref])))}),i.cells.FromJSON(r.data),r.rows&&i.cells.EnsureRow(r.rows-1),r.columns&&i.cells.EnsureColumn(r.columns-1),r.data)if(Qe(r.data))for(let l of r.data)l.style_ref&&(i.cell_style[l.column]||(i.cell_style[l.column]=[]),i.cell_style[l.column][l.row]=JSON.parse(JSON.stringify(o[l.style_ref])));else if(ai(r.data))for(let l of r.data){let d=l.row;for(let u of l.cells){let h=u.column;u.style_ref&&(i.cell_style[h]||(i.cell_style[h]=[]),i.cell_style[h][d]=JSON.parse(JSON.stringify(o[u.style_ref])))}}else for(let l of r.data){let d=l.column;for(let u of l.cells){let h=u.row;u.style_ref&&(i.cell_style[d]||(i.cell_style[d]=[]),i.cell_style[d][h]=JSON.parse(JSON.stringify(o[u.style_ref])))}}i.freeze.rows=0,i.freeze.columns=0,r.freeze&&(i.freeze.rows=r.freeze.rows||0,i.freeze.columns=r.freeze.columns||0),i.scroll_offset=r.scroll?{...r.scroll}:{x:0,y:0};for(let l of r.cell_styles||[])if(l.style&&(i.cell_style[l.column]||(i.cell_style[l.column]=[]),i.cell_style[l.column][l.row]=l.style,l.rows))for(let d=1;d<l.rows;d++)i.cell_style[l.column][l.row+d]=JSON.parse(JSON.stringify(l.style));i.sheet_style=r.sheet_style||{},i.column_styles={},i.row_styles={};let a=(l,d)=>{for(let u of Object.keys(l)){let h=Number(u),p=l[h];if(typeof p=="number"){let f=o[p];f&&(d[h]=JSON.parse(JSON.stringify(f)),n(d[h]))}else p&&(d[h]=p,n(d[h]))}};a(r.row_style,i.row_styles),a(r.column_style,i.column_styles),i.row_pattern=r.row_pattern||[],n(i.sheet_style||{});for(let l of i.row_pattern)n(l);return i.row_height_=[],s(i.row_height_,r.row_height||{}),i.row_height_.length&&i.cells.EnsureRow(i.row_height_.length-1),i.column_width_=[],s(i.column_width_,r.column_width||{}),i.column_width_.length&&i.cells.EnsureColumn(i.column_width_.length-1),i.annotations=(r.annotations||[]).map(l=>new Te(l)),r.selection&&(i.selection=JSON.parse(JSON.stringify(r.selection))),i.visible=!0,typeof r.visible<"u"&&(i.visible=!!r.visible),i}MergeCells(e){e=e.Clone(),this.cells.Apply(e,(t,i,r)=>{t.merge_area=e,t.render_clean=[],(i!==e.start.column||r!==e.start.row)&&t.Reset()},!0)}UnmergeCells(e){let t=!0;if(this.cells.Apply(e,i=>{t=t&&!!i.merge_area&&e.Equals(i.merge_area)},!1),!t){console.warn("area mismatch");return}this.cells.Apply(e,i=>{i.merge_area=void 0,i.render_clean=[]},!1)}StyleFontSize(e,t={}){let i=e.font_size?.value||0,r=0;switch(e.font_size?.unit){case"px":i*=75/100;break;case"em":r=e.font_size.value||1;break;case"%":r=(e.font_size.value||100)/100;break}return r&&(i=r*(t.font_size?.value||10),t.font_size?.unit==="px"&&(i*=75/100)),i||10}UpdateDefaultRowHeight(){let e=A.Composite([this.default_style_properties,this.sheet_style]);if(typeof window<"u"){let t=ee.MeasureText(A.Font(e),"M"),i=Math.round(t.height*1.4);this.default_row_height<i&&(this.default_row_height=i)}}SetRowHeaders(e){this.row_headers=e.map(t=>t===void 0?"":t.toString()),this.row_headers&&this.cells.EnsureRow(this.row_headers.length-1)}SetColumnHeaders(e){this.column_headers=e.map(t=>t===void 0?"":t.toString()),e&&this.cells.EnsureColumn(e.length-1)}RowHeader(e){return this.row_headers?this.row_headers.length>e?this.row_headers[e]:"":e+1}ColumnHeader(e){let t="";if(this.column_headers)return this.column_headers.length>e?this.column_headers[e]:"";for(;;){let i=e%26;if(t=String.fromCharCode(65+i)+t,e=Math.floor(e/26),e)e--;else break}return t}GetRowHeight(e){let t=this.row_height_[e];return typeof t>"u"?this.default_row_height:t}SetRowHeight(e,t){return this.row_height_[e]=t,this.cells.EnsureRow(e),t}GetColumnWidth(e){let t=this.column_width_[e];return typeof t>"u"?this.default_column_width:t}SetColumnWidth(e,t){return this.column_width_[e]=t,this.cells.EnsureColumn(e),t}Delta(e,t){let i={},r=[...Object.keys(e),...Object.keys(t)];for(let s of r){let n=e[s],o=t[s];typeof n=="object"&&typeof o=="object"?JSON.stringify(n)!==JSON.stringify(o)&&(i[s]=o):n!==o&&(i[s]=o)}return i}UpdateCellStyle(e,t,i=!0){let{row:r,column:s}=e;this.cell_style[s]||(this.cell_style[s]=[]);let n=this.CompositeStyleForCell(e,!1,!1),o=A.Composite([this.default_style_properties,n,A.Merge(this.cell_style[s][r]||{},t,i)]),a=this.Delta(n,o);this.cell_style[s][r]=a,this.CellData(e).FlushStyle()}Invalidate(e){this.cells.Apply(this.RealArea(e),t=>t.render_clean=[])}UpdateAreaStyle(e,t={},i=!0){if(!!e)if(e.entire_sheet)this.UpdateSheetStyle(t,i);else if(e.entire_column)for(let r=e.start.column;r<=e.end.column;r++)this.UpdateColumnStyle(r,t,i);else if(e.entire_row)for(let r=e.start.row;r<=e.end.row;r++)this.UpdateRowStyle(r,t,i);else e.Array().forEach(r=>this.UpdateCellStyle(r,t,i))}HasCellStyle(e){return!!(this.cell_style[e.column]&&this.cell_style[e.column][e.row]||this.row_styles[e.row]||this.column_styles[e.column]||this.row_pattern.length)}NextVisibleColumn(e){for(++e;this.column_width_[e]===0;e++);return e}PreviousVisibleColumn(e){for(--e;e>=0&&this.column_width_[e]===0;e--);return e}NextVisibleRow(e){for(++e;this.row_height_[e]===0;e++);return e}PreviousVisibleRow(e){for(--e;e>=0&&this.row_height_[e]===0;e--);return e}SurroundingStyle(e){let t=[{},{},{},{},{},{},{},{},{},{}],i=e.column+1,r=e.column-1,s=e.row+1,n=e.row-1;for(;this.column_width_[i]===0;i++);for(;this.row_height_[s]===0;s++);for(;r>=0&&this.column_width_[r]===0;r--);for(;n>=0&&this.row_height_[n]===0;n--);return r>=0&&n>=0&&(t[7]=this.CellStyleData({row:n,column:r})||{}),r>=0&&(t[4]=this.CellStyleData({row:e.row,column:r})||{},t[1]=this.CellStyleData({row:s,column:r})||{}),n>=0&&(t[8]=this.CellStyleData({row:n,column:e.column})||{},t[9]=this.CellStyleData({row:n,column:i})||{}),t[6]=this.CellStyleData({row:e.row,column:i})||{},t[2]=this.CellStyleData({row:s,column:e.column})||{},t[3]=this.CellStyleData({row:s,column:i})||{},t}CellStyleData(e){let t=this.cells.GetCell(e);if(!!t){if(!t.style){let i=this.GetStyleIndex(this.CompositeStyleForCell(e));t.style=this.style_map[i]}return t.style}}GetCopyStyle(e){return this.CompositeStyleForCell(e,!0,!1)}CellData(e){let t=this.cells.EnsureCell(e);if(t.rendered_type)return t;let i,r;if(t.calculated_type?(r=t.calculated,i=t.calculated_type):(r=t.value,i=t.type),!t.style){let s=this.GetStyleIndex(this.CompositeStyleForCell(e));t.style=this.style_map[s]}if(!i||r===null||typeof r>"u")t.formatted="",t.rendered_type=2;else if(i===3)isNaN(r)?t.formatted=typeof t.style.nan>"u"?"NaN":t.style.nan:t.formatted=this.FormatNumber(r,t.style.number_format),t.rendered_type=3;else if(i===6)t.formatted="#"+(r||"ERR?"),t.rendered_type=6;else if(i===4)t.formatted=r.toString().toUpperCase(),t.rendered_type=4;else if(i===1&&t.calculated===void 0)t.formatted="",t.rendered_type=2;else if(i===7){let s=r;if(isNaN(s.real)||isNaN(s.imaginary))t.formatted=typeof t.style.nan>"u"?"NaN":t.style.nan;else{let n=L.Get(t.style.number_format||"",!0);t.formatted=n.FormatComplex(s)}t.rendered_type=7}else if(i===9){if(isNaN(r.value))t.formatted=typeof t.style.nan>"u"?"NaN":t.style.nan,t.formatted+=" "+r.unit;else{let s=L.Get(t.style.number_format||"",!0);t.formatted=s.FormatDimensionedQuantity(r)}t.rendered_type=9}else t.formatted=this.FormatNumber(r,t.style.number_format),t.rendered_type=2;return t}FormatNumber(e,t=""){let i=L.Get(t).FormatParts(e);return i.length?i.length===1&&!i[0].flag?i[0].text||"":i:""}SetHeaderSize(e=Ar,t=this.default_row_height){this.row_header_width=e,this.column_header_height=t}AutoSizeRow(e,t={},i=!0){let r=this.default_row_height,s=9;for(let n=0;n<this.cells.columns;n++){let o=this.CellData({row:e,column:n}),a=o.style,l=o.formatted||"";if(typeof l!="string"&&(l=l.map(d=>d.text).join("")),a&&l&&l.length){let d=l.split(/\n/),u=Math.round(this.StyleFontSize(a,t)*1.5);r=Math.max(r,((u||10)+s)*d.length)}}!i&&this.GetRowHeight(e)>=r||this.SetRowHeight(e,r)}GetStyle(e){return this.style_map[e]}InsertRows(e=0,t=1){if(e)for(let a=0;a<this.cells.columns;a++){let l=this.cells.GetCell({row:e-1,column:a},!1);if(l&&l.area){let d=this.cells.GetCell({row:e,column:a},!1);if(d&&d.area&&d.area.Equals(l.area))return!1}}t<0?this.cells.DeleteRows(e,-t):this.cells.InsertRows(e,t);let i={},r={};for(let a=e;a<this.cells.rows;a++)for(let l=0;l<this.cells.columns;l++){let d=this.cells.GetCell({row:a,column:l},!1);d&&(d.area&&!r[d.area.spreadsheet_label]&&(r[d.area.spreadsheet_label]=d.area),d.merge_area&&!i[d.merge_area.spreadsheet_label]&&(i[d.merge_area.spreadsheet_label]=d.merge_area))}for(let a of Object.keys(r)){let l=r[a],d=new g({row:l.start.row+t,column:l.start.column},{row:l.end.row+t,column:l.end.column});d.Iterate(u=>{let h=this.cells.GetCell(u,!0);h.area=d})}for(let a of Object.keys(i)){let l=i[a],d={row:l.start.row,column:l.start.column};l.start.row>=e&&(d.row+=t);let u=new g(d,{row:l.end.row+t,column:l.end.column});u.Iterate(h=>{let p=this.cells.GetCell(h,!0);p.merge_area=u})}let s=Object.keys(this.row_styles),n={};s.forEach(a=>{let l=Number(a);l<e?n[l]=this.row_styles[l]:t<0&&l<e-t||(n[l+t]=this.row_styles[l])}),this.row_styles=n;let o=[];if(t<0)o=[e,-t];else{o=[e,0];for(let a=0;a<t;a++)o.push(void 0)}return this.cell_style.forEach(a=>{a&&a.length>=e&&a.splice.apply(a,o)}),this.row_height_.splice.apply(this.row_height_,o),this.FlushCellStyles(),!0}InsertColumns(e=0,t=1){if(e)for(let a=0;a<this.cells.rows;a++){let l=this.cells.GetCell({row:a,column:e-1},!1);if(l&&l.area){let d=this.cells.GetCell({row:a,column:e},!1);if(d&&d.area&&d.area.Equals(l.area))return!1}}t<0?this.cells.DeleteColumns(e,-t):this.cells.InsertColumns(e,t);let i={},r={};for(let a=e;a<this.cells.columns;a++)for(let l=0;l<this.cells.rows;l++){let d=this.cells.GetCell({row:l,column:a},!1);d&&(d.area&&!r[d.area.spreadsheet_label]&&(r[d.area.spreadsheet_label]=d.area),d.merge_area&&!i[d.merge_area.spreadsheet_label]&&(i[d.merge_area.spreadsheet_label]=d.merge_area))}for(let a of Object.keys(r)){let l=r[a],d=new g({row:l.start.row,column:l.start.column+t},{row:l.end.row,column:l.end.column+t});d.Iterate(u=>{let h=this.cells.GetCell(u,!0);h.area=d})}for(let a of Object.keys(i)){let l=i[a],d={row:l.start.row,column:l.start.column};l.start.column>=e&&(d.column+=t);let u=new g(d,{row:l.end.row,column:l.end.column+t});u.Iterate(h=>{let p=this.cells.GetCell(h,!0);p.merge_area=u})}let s=Object.keys(this.column_styles),n={};s.forEach(a=>{let l=Number(a);l<e?n[l]=this.column_styles[l]:t<0&&l<e-t||(n[l+t]=this.column_styles[l])}),this.column_styles=n;let o=[];if(t<0)o=[e,-t];else{o=[e,0];for(let a=0;a<t;a++)o.push(void 0)}return this.cell_style.splice.apply(this.cell_style,o),this.column_width_.splice.apply(this.column_width_,o),this.FlushCellStyles(),!0}ClearArea(e){e=this.RealArea(e),this.cells.Apply(e,t=>t.Reset())}SetAreaValues2(e,t){e=this.RealArea(e),this.cells.SetArea(e,t)}SetArrayValue(e,t){e=this.RealArea(e),this.cells.Apply(e,r=>r.SetArray(e),!0),this.cells.GetCell(e.start,!0).SetArrayHead(e,t)}SetCellValue(e,t){this.cells.GetCell(e,!0).Set(t)}RealArea(e,t=!1){let i=e.start,r=e.end;return e.entire_row&&(i.column=0,i.absolute_column=!1,r.column=this.cells.columns-1,r.absolute_column=!1),e.entire_column&&(i.row=0,i.absolute_row=!1,r.row=this.cells.rows-1,r.absolute_row=!1),t&&(r.row>=this.rows&&(r.row=this.rows-1,r.absolute_row=!1),r.column>=this.columns&&(r.column=this.columns-1,r.absolute_column=!1)),new g(i,r)}GetCellStyle(e,t=!1){if(P(e))return this.CompositeStyleForCell(e,!0,!1,t);if(e.start.row===e.end.row&&e.start.column===e.end.column)return this.CompositeStyleForCell(e.start,!0,!1,t);let i=[];for(let r=e.start.row;r<=e.end.row;r++){let s=[];for(let n=e.start.column;n<=e.end.column;n++)s.push(this.CompositeStyleForCell({row:r,column:n},!0,!1,t));i.push(s)}return i}FormattedCellValue(e){let t=this.CellData(e);if(!!t)return typeof t.formatted=="string"?t.formatted:t.formatted?t.formatted.map(i=>{switch(i.flag){case 1:return" ";case 2:return" ";default:return i.text}}).join(""):t.value}GetFormattedRange(e,t=e){if(e.row===t.row&&e.column===t.column)return this.FormattedCellValue(e);let i=[];for(let r=e.row;r<=t.row;r++){let s=[];for(let n=e.column;n<=t.column;n++)s.push(this.FormattedCellValue({row:r,column:n}));i.push(s)}return i}NumberFormatsAndColors(e,t){let i=r=>{r.number_format&&(t[r.number_format]=1),r.text?.text&&r.text.text!=="none"&&(e[r.text.text]=1),r.fill?.text&&(e[r.fill.text]=1),r.border_top_fill?.text&&(e[r.border_top_fill.text]=1),r.border_left_fill?.text&&(e[r.border_left_fill.text]=1),r.border_right_fill?.text&&(e[r.border_right_fill.text]=1),r.border_bottom_fill?.text&&(e[r.border_bottom_fill.text]=1)};i(this.sheet_style);for(let r in this.row_styles)i(this.row_styles[r]);for(let r in this.column_styles)i(this.column_styles[r]);for(let r of this.row_pattern)i(r);for(let r of this.cell_style)if(r)for(let s of r)s&&i(s)}CompressCellStyles(e){let t=[];for(let i=0;i<e.length;i++){let r=e[i];if(r)for(let s=0;s<r.length;s++){let n=r[s];if(n){let o=s+1;for(;o<r.length&&r[o]===n;o++);o>s+1?t.push({row:s,column:i,ref:n,rows:o-s}):t.push({row:s,column:i,ref:n}),s=o-1}}}return t}toJSON(e={}){let t=(w,C)=>{let S={};for(let U=0;U<w.length;U++)typeof w[U]<"u"&&w[U]!==C&&(S[U]=w[U]);if(Object.keys(S).length)return S},i=[{}],r={},s=[],n=JSON.stringify({});for(let w=0;w<this.cell_style.length;w++){let C=this.cell_style[w];if(C){s[w]=[];for(let S=0;S<C.length;S++)if(C[S]){let U=JSON.stringify(C[S]);if(U!==n){let J=r[U];typeof J!="number"&&(r[U]=J=i.length,i.push(C[S])),s[w][S]=J}}}}let o=w=>{let C=JSON.stringify(w);if(C===n)return 0;let S=r[C];return typeof S!="number"&&(r[C]=S=i.length,i.push(w)),S};i=JSON.parse(JSON.stringify(i));let a=JSON.parse(JSON.stringify(this.sheet_style)),l=JSON.parse(JSON.stringify(this.row_pattern)),d={},u={};for(let w of Object.keys(this.column_styles)){let C=Number(w),S=this.column_styles[C];if(S){let U=o(S);U&&(d[C]=U)}}for(let w of Object.keys(this.row_styles)){let C=Number(w),S=this.row_styles[C];if(S){let U=o(S);U&&(u[C]=U)}}let h=(w,C)=>{if(typeof w<"u"&&w!=="none")return w===C?void 0:ee.MeasureColorARGB(w)},p=(w={},C={})=>{let S={...C,...w};if(S.text)return S.text=ee.MeasureColorARGB(S.text),S;if(typeof S.theme=="number")return S};if(e.export_colors){let w=[];for(let C of[i,[a],l])if(Array.isArray(C))for(let S of C)w.push(S);else for(let S of Object.keys(C))w.push(C[S]);for(let C of w){let S=p(C.border_top_fill,A.DefaultProperties.border_top_fill);S!==void 0&&(C.border_top_fill=S),S=p(C.border_left_fill,A.DefaultProperties.border_left_fill),S!==void 0&&(C.border_left_fill=S),S=p(C.border_right_fill,A.DefaultProperties.border_right_fill),S!==void 0&&(C.border_right_fill=S),S=p(C.border_bottom_fill,A.DefaultProperties.border_bottom_fill),S!==void 0&&(C.border_bottom_fill=S),C.fill?.text&&(C.fill.text=ee.MeasureColorARGB(C.fill.text)),C.text&&C.text.text&&C.text.text!=="none"&&(C.text.text=ee.MeasureColorARGB(C.text.text))}}let f={calculated_value:!!e.rendered_values,preserve_type:!!e.preserve_type,expand_arrays:!!e.expand_arrays,decorated_cells:!!e.decorated_cells,nested:!0,cell_style_refs:s},m=this.cells.toJSON(f),b=m.data,{rows:_,columns:y}=m;e.shrink?(_+=2,y+=1):(_=this.rows,y=this.columns);for(let w of this.annotations)w.extent||this.CalculateAnnotationExtent(w),w.extent&&(_=Math.max(_,w.extent.row+1),y=Math.max(y,w.extent.column+1));let x=this.CompressCellStyles(s),v={id:this.id,name:this.name,data:b,sheet_style:a,rows:_,columns:y,cell_styles:x,styles:i,row_style:u,column_style:d,row_pattern:l.length?l:void 0,default_row_height:this.default_row_height,default_column_width:this.default_column_width,row_height:t(this.row_height_,this.default_row_height),column_width:t(this.column_width_,this.default_column_width),selection:JSON.parse(JSON.stringify(this.selection)),annotations:JSON.parse(JSON.stringify(this.annotations))};return this.visible||(v.visible=this.visible),(this.scroll_offset.x||this.scroll_offset.y)&&(v.scroll=this.scroll_offset),(this.freeze.rows||this.freeze.columns)&&(v.freeze=this.freeze),v}FlushCellStyles(){this.style_map=[],this.style_json_map=[],this.cells.FlushCellStyles()}ImportData(e){let t=e.styles,i=e.sheet_style;i&&this.UpdateAreaStyle(new g({row:1/0,column:1/0},{row:1/0,column:1/0}),t[i]);let r=e.column_styles;if(r)for(let n=0;n<r.length;n++)r[n]&&this.UpdateAreaStyle(new g({row:1/0,column:n},{row:1/0,column:n}),t[r[n]]);this.cells.FromJSON(e.cells),e.name&&(this.name=e.name||"");let s=this.cell_style;for(let n of e.cells)n.style_ref&&(s[n.column]||(s[n.column]=[]),s[n.column][n.row]=t[n.style_ref]);for(let n=0;n<e.column_widths.length;n++)typeof e.column_widths[n]<"u"&&this.SetColumnWidth(n,e.column_widths[n]);for(let n=0;n<e.row_heights.length;n++)typeof e.row_heights[n]<"u"&&this.SetRowHeight(n,e.row_heights[n]);for(let n of e.annotations||[])this.annotations.push(new Te(n));e.hidden&&(this.visible=!1)}CalculateAnnotationExtent(e){if(e.layout){e.extent={...e.layout.br.address};return}let t=1e3;e.extent={row:0,column:0};let i=e.rect?.right;if(i&&this.default_column_width){for(let s=0;i>=0&&s<t;s++)if(i-=this.GetColumnWidth(s),i<0){e.extent.column=s;break}}let r=e.rect?.bottom;if(r&&this.default_row_height){for(let s=0;r>=0&&s<t;s++)if(r-=this.GetRowHeight(s),r<0){e.extent.row=s;break}}}UpdateSheetStyle(e,t=!0){this.sheet_style=A.Merge(this.sheet_style,e,t);let i=Object.keys(e);for(let r of this.cell_style)if(r)for(let s of r)s&&i.forEach(n=>delete s[n]);for(let r of Object.keys(this.row_styles))i.forEach(s=>delete this.row_styles[r][s]);for(let r of Object.keys(this.column_styles))i.forEach(s=>delete this.column_styles[r][s]);this.FlushCellStyles()}UpdateRowStyle(e,t,i=!0){this.row_styles[e]=A.Merge(this.row_styles[e]||{},t,i);let r=Object.keys(t);for(let s of this.cell_style)s&&s[e]&&r.forEach(n=>delete s[e][n]);for(let s=0;s<this.cells.columns;s++)if(this.column_styles[s]){let n=this.column_styles[s],o=this.cell_style[s]?this.cell_style[s][e]||{}:{};for(let a of r)typeof n[a]<"u"&&(o[a]=t[a]);Object.keys(o).length&&(this.cell_style[s]||(this.cell_style[s]=[]),this.cell_style[s][e]=JSON.parse(JSON.stringify(o)))}this.cells.Apply(this.RealArea(g.FromRow(e)),s=>s.FlushStyle())}UpdateColumnStyle(e,t,i=!0){this.column_styles[e]=A.Merge(this.column_styles[e]||{},t,i);let r=Object.keys(t);if(this.cell_style[e])for(let s of this.cell_style[e])s&&r.forEach(n=>delete s[n]);this.cells.Apply(this.RealArea(g.FromColumn(e)),s=>s.FlushStyle())}CompositeStyleForCell(e,t=!0,i=!0,r=!0){let{row:s,column:n}=e,o=[];return r&&o.push(this.default_style_properties),o.push(this.sheet_style),i&&this.row_pattern.length&&o.push(this.row_pattern[s%this.row_pattern.length]),this.row_styles[s]&&o.push(this.row_styles[s]),this.column_styles[n]&&o.push(this.column_styles[n]),t&&this.cell_style[n]&&this.cell_style[n][s]&&o.push(this.cell_style[n][s]),A.Composite(o)}GetStyleIndex(e){let t=JSON.stringify(e);for(let r=0;r<this.style_json_map.length;r++)if(t===this.style_json_map[r])return r;let i=this.style_map.length;return this.style_map.push(JSON.parse(t)),this.style_json_map.push(t),i}},j=Ue;E(j,"base_id",100),E(j,"default_sheet_name","Sheet1");var Rr="http://www.w3.org/2000/svg",Vt=class{constructor(e,t){this.model=e;this.view=t;this.mask=V.CreateDiv("treb-mouse-mask"),this.tooltip=V.CreateDiv("treb-tooltip"),this.dropdown_caret=document.createElementNS(Rr,"svg"),this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_caret.setAttribute("viewBox","0 0 24 24"),this.dropdown_caret.tabIndex=-1;let i=document.createElementNS(Rr,"path");i.setAttribute("d","M5,7 L12,17 L19,7"),this.dropdown_caret.appendChild(i),this.dropdown_caret.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),this.grid_cover.classList.remove("nub-select");let s=this.dropdown_caret.getAttribute("class")||"";/active/i.test(s)?this.dropdown_caret.setAttribute("class","treb-dropdown-caret"):(this.dropdown_caret.setAttribute("class","treb-dropdown-caret active"),this.dropdown_list.focus())}),this.dropdown_list=V.CreateDiv("treb-dropdown-list"),this.dropdown_list.setAttribute("tabindex","-1"),this.dropdown_list.addEventListener("keydown",r=>{let s=0;switch(r.key){case"ArrowDown":s=1;break;case"ArrowUp":s=-1;break;case"Escape":break;case"Enter":break;default:console.info(r.key);return}if(r.stopPropagation(),r.preventDefault(),r.key==="Escape"||r.key==="Enter")this.container?.focus(),this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),r.key==="Enter"&&this.dropdown_callback&&this.dropdown_selected&&this.dropdown_callback.call(0,this.dropdown_selected.dropdown_value);else if(s&&this.dropdown_selected)if(s>0&&this.dropdown_selected.nextSibling){this.dropdown_selected.nextSibling.classList.add("selected"),this.dropdown_selected.classList.remove("selected"),this.dropdown_selected=this.dropdown_selected.nextSibling;let n=this.dropdown_selected.offsetTop+this.dropdown_selected.offsetHeight;n>this.dropdown_list.offsetHeight+this.dropdown_list.scrollTop&&(this.dropdown_list.scrollTop=n-this.dropdown_list.offsetHeight)}else s<0&&this.dropdown_selected.previousSibling&&(this.dropdown_selected.previousSibling.classList.add("selected"),this.dropdown_selected.classList.remove("selected"),this.dropdown_selected=this.dropdown_selected.previousSibling,this.dropdown_selected.offsetTop<this.dropdown_list.scrollTop&&(this.dropdown_list.scrollTop=this.dropdown_selected.offsetTop))}),this.dropdown_list.addEventListener("mousedown",r=>{let s=r.target;r.target!==this.dropdown_list&&(r.stopPropagation(),r.preventDefault(),this.container?.focus(),this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_callback&&this.dropdown_callback.call(0,s.dropdown_value))}),this.dropdown_list.addEventListener("mousemove",r=>{let s=r.target;s!==this.dropdown_selected&&(this.grid_cover.classList.remove("nub-select"),this.dropdown_selected&&this.dropdown_selected.classList.remove("selected"),s.classList.add("selected"),this.dropdown_selected=s)}),this.mock_selection=V.CreateDiv("mock-selection-node"),this.mock_selection.innerHTML=" ",this.note_node=V.CreateDiv("treb-note"),this.title_node=V.CreateDiv("treb-hover-title"),this.HideNote()}column_header;row_header;contents;buffer_canvas;corner;corner_canvas;grid_selection;grid_cover;column_header_cover;row_header_cover;annotation_container;mask;mock_selection;container;grid_tiles=[];column_header_tiles=[];row_header_tiles=[];corner_selection;row_header_selection;column_header_selection;corner_annotations;row_header_annotations;column_header_annotations;frozen_row_tiles=[];frozen_column_tiles=[];header_size={width:0,height:0};last_column=0;total_height=0;total_width=0;default_row_height=0;default_column_width=0;header_offset={x:0,y:0};dpr=Math.max(1,self.devicePixelRatio||1);scale=1;scroll_reference_node;get scroll_offset(){return this.scroll_reference_node?{x:this.scroll_reference_node.scrollLeft,y:this.scroll_reference_node.scrollTop}:{x:0,y:0}}set scroll_offset(e){!this.scroll_reference_node||(this.scroll_reference_node.scrollLeft=e.x,this.scroll_reference_node.scrollTop=e.y)}dropdown_caret;trident=typeof navigator<"u"&&navigator.userAgent&&/trident/i.test(navigator.userAgent);default_tile_size={width:1200,height:800};tooltip_state;tooltip;dropdown_list;dropdown_caret_visible=!1;dropdown_callback;dropdown_selected;note_node;title_node;row_cache=[];column_cache=[];initialized=!1;UpdateDPR(){let e=Math.max(1,self.devicePixelRatio||1);return e===this.dpr?!1:(this.dpr=e,!0)}ColumnWidth(e){return Math.round(this.view.active_sheet.GetColumnWidth(e)*this.scale)}RowHeight(e){return Math.round(this.view.active_sheet.GetRowHeight(e)*this.scale)}SetRowHeight(e,t){this.view.active_sheet.SetRowHeight(e,Math.round(t/this.scale))}SetColumnWidth(e,t){this.view.active_sheet.SetColumnWidth(e,Math.round(t/this.scale))}ShowSelections(e=!0){this.grid_selection.style.display=e?"block":"none"}HideTitle(){this.title_node.style.opacity="0"}ShowTitle(e,t){if(this.title_node.textContent=e,!this.title_node.parentElement)return;let i=this.title_node.parentElement.getBoundingClientRect(),r=this.OffsetCellAddressToRectangle(t).Shift(this.header_size.width,this.header_size.height);this.title_node.style.left=i.left+r.left-this.scroll_reference_node.scrollLeft+0+"px",this.title_node.style.top=i.top+r.bottom-this.scroll_reference_node.scrollTop+8+"px",this.title_node.style.opacity="1"}HideNote(){this.note_node.style.opacity="0",this.note_node.style.pointerEvents="none"}ShowNote(e,t,i,r){if(r?this.note_node.innerHTML=r:this.note_node.textContent=e,!this.note_node.parentElement)return;let s=this.note_node.getBoundingClientRect(),n=this.note_node.parentElement.getBoundingClientRect(),o={x:8,y:2},a=this.OffsetCellAddressToRectangle(t).Shift(this.header_size.width,this.header_size.height);this.note_node.style.left=n.left+a.right-this.scroll_reference_node.scrollLeft+o.x+"px",this.note_node.style.top=n.top+a.top-this.scroll_reference_node.scrollTop-s.height/5-o.y+"px",this.note_node.style.opacity="1",this.note_node.style.pointerEvents="auto"}AnnotationLayoutOrder(e,t){let i=-1;for(let s=0;s<this.view.active_sheet.annotations.length;s++)if(this.view.active_sheet.annotations[s]===e){i=s;break}if(i<0)return!1;let r=Math.min(Math.max(0,i+t),this.view.active_sheet.annotations.length-1);if(r===i)return!1;this.view.active_sheet.annotations.splice(i,1),this.view.active_sheet.annotations.splice(r,0,e);for(let s=0;s<this.view.active_sheet.annotations.length;s++){let n=this.view.active_sheet.annotations[s].key,o=this.container?.querySelectorAll(`.annotation[data-key="${n}"]`);if(o)for(let a=0;a<o?.length;a++)o[a].style.zIndex=(s+1).toString()}return!0}PointToAnnotationCorner(e){let t=this.PointToAddress_Grid(e,void 0,!1),i=this.CellAddressToRectangle(t);return{address:t,offset:{x:(e.x-i.left)/i.width,y:(e.y-i.top)/i.height}}}RectToAnnotationLayout(e){return{tl:this.PointToAnnotationCorner({x:(e.left||0)+1,y:(e.top||0)+1}),br:this.PointToAnnotationCorner({x:e.right||e.left||100,y:e.bottom||e.top||100})}}AddressToAnnotationLayout(e,t){let i={tl:this.CellAddressToRectangle(e),br:this.CellAddressToRectangle(t)};return{tl:this.PointToAnnotationCorner({x:i.tl.left||0,y:i.tl.top||0}),br:this.PointToAnnotationCorner({x:i.br.right||i.tl.left||100,y:i.br.bottom||i.tl.left||100})}}AnnotationLayoutToRect(e){let t=this.CellAddressToRectangle(e.tl.address),i=this.CellAddressToRectangle(e.br.address),r=t.left+t.width*e.tl.offset.x-1,s=t.top+t.height*e.tl.offset.y-1;return new z(r,s,i.left+i.width*e.br.offset.x-r,i.top+i.height*e.br.offset.y-s)}UpdateAnnotation(e){Array.isArray(e)||(e=[e]);for(let t of e){let i=t.view[this.view.view_index]||{};if(i.node){if(i.node.dataset.scale=this.scale.toString(),i.node.style.fontSize=`${10*this.scale}pt`,t.rect&&!t.layout&&(t.scaled_rect=t.rect.Scale(this.scale),t.layout=this.RectToAnnotationLayout(t.scaled_rect)),t.layout){let r=this.AnnotationLayoutToRect(t.layout);r.ApplyStyle(i.node),t.scaled_rect=r}i.node.dataset.key=t.key.toString(),(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&this.CloneFrozenAnnotation(t)}}}GetFrozenAnnotations(e){return[this.row_header_annotations,this.column_header_annotations,this.corner_annotations].map(i=>i.querySelector(`.annotation[data-key="${e.key}"]`)).filter(i=>i!==null)}CloneFrozenAnnotations(){for(let e of this.view.active_sheet.annotations)e.view[this.view.view_index]?.node&&e.key&&this.CloneFrozenAnnotation(e)}ClearFrozenAnnotations(){for(let e of[this.row_header_annotations,this.column_header_annotations,this.corner_annotations]){let t=e.querySelectorAll(".annotation");for(let i=0;i<t.length;i++)t[i].parentElement?.removeChild(t[i])}}RemoveFrozenAnnotation(e){for(let t of[this.row_header_annotations,this.column_header_annotations,this.corner_annotations]){let i=t.querySelector(`.annotation[data-key="${e.key}"]`);i&&i.parentElement?.removeChild(i)}}CloneFrozenAnnotation(e){for(let t of[this.row_header_annotations,this.column_header_annotations,this.corner_annotations]){let i=t.querySelector(`.annotation[data-key="${e.key}"]`);i&&i.parentElement?.removeChild(i);let r=e.view[this.view.view_index];if(i=r?.node?.cloneNode(!0),i){let s=i.querySelector(".annotation-move-target"),n=i.querySelector(".annotation-resize-target");i.addEventListener("mousedown",o=>{let a=r.node;requestAnimationFrame(()=>{a?.focus()}),this.AnnotationMouseDown(e,r.node,o,s,n)}),t.appendChild(i)}}}RemoveAnnotation(e){let t=e.view[this.view.view_index]||{};t.node&&t.node.parentElement?.removeChild(t.node),this.RemoveFrozenAnnotation(e)}RemoveAnnotationNodes(){let e=Array.prototype.map.call(this.annotation_container.children,t=>t);for(let t of e)this.annotation_container.removeChild(t);(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&this.ClearFrozenAnnotations()}AddAnnotation(e){let t=e.view[this.view.view_index]||{};if(!t.node)throw new Error("annotation view/node missing");this.annotation_container.appendChild(t.node),this.UpdateAnnotation(e)}AnnotationMouseDown(e,t,i,r,s){let n=e.scaled_rect;return n?new Promise(o=>{let a={left:n.left,top:n.top,width:n.width,height:n.height},l=this.scroll_reference_node,d=l.getBoundingClientRect(),u=t.getBoundingClientRect();if(i.target===r||i.target!==s&&i.altKey){i.stopPropagation(),i.preventDefault(),t.focus();let h={x:u.left+i.offsetX-n.left,y:u.top+i.offsetY-n.top},p=[t,...this.GetFrozenAnnotations(e)],f=25,m=this.CellAddressToRectangle({row:0,column:0}).Combine(this.CellAddressToRectangle({row:this.view.active_sheet.rows-1,column:this.view.active_sheet.columns-1})).Expand(-1,-1);me(this.mask,"move",b=>{if(b.offsetY-d.top<this.header_offset.y){let _=Math.min(f,l.scrollTop);l.scrollTop-=_,h.y+=_}else if(b.offsetY-d.top>=d.height&&l.scrollTop+d.height<m.height){let _=f;l.scrollTop+=_,h.y-=_}if(b.offsetX-d.left<this.header_offset.x){let _=Math.min(f,l.scrollLeft);l.scrollLeft-=_,h.x+=_}else if(b.offsetX-d.left>=d.width&&l.scrollLeft+d.width<m.width){let _=f;l.scrollLeft+=_,h.x-=_}if(n.top=b.offsetY-h.y,n.left=b.offsetX-h.x,b.shiftKey){let _=Math.abs(n.left-a.left),y=Math.abs(n.top-a.top);_<=y?n.left=a.left:n.top=a.top}if(b.ctrlKey){let _=this.ClampToGrid({x:n.left,y:n.top});n.left=_.x,n.top=_.y}for(let _ of p)_.style.top=n.top+"px",_.style.left=n.left+"px"},()=>{e.extent=void 0,e.layout=this.RectToAnnotationLayout(n),o({type:"annotation",annotation:e,event:"move"})});return}else if(i.target===s){i.stopPropagation(),i.preventDefault(),t.focus();let h=0;e.data?.original_size&&e.data.original_size.width&&e.data.original_size.height&&(h=e.data.original_size.width/e.data.original_size.height);let p=t.getBoundingClientRect(),f={x:p.left+i.offsetX-n.width+s.offsetLeft,y:p.top+i.offsetY-n.height+s.offsetTop};me(this.mask,"nw-resize",m=>{let b=[t,...this.GetFrozenAnnotations(e)];if(n.height=m.offsetY-f.y,n.width=m.offsetX-f.x,m.shiftKey&&m.ctrlKey){if(h){let _=Math.abs(n.width-a.width),y=Math.abs(n.height-a.height);_<y?n.width=h*n.height:n.height=n.width/h}}else if(m.shiftKey){let _=Math.abs(n.height-a.height),y=Math.abs(n.width-a.width);_>y?n.width=a.width:n.height=a.height}else if(m.ctrlKey){let _=this.ClampToGrid({x:n.right,y:n.bottom});n.width=_.x-n.left+1,n.height=_.y-n.top+1}for(let _ of b)_.style.height=n.height+"px",_.style.width=n.width+"px"},()=>{e.extent=void 0,e.layout=this.RectToAnnotationLayout(n),o({type:"annotation",annotation:e,event:"resize"})});return}else o()}):(console.info("missing scaled rect!"),Promise.reject())}Initialize(e,t,i,r=!0){this.mask.parentElement||e.appendChild(this.mask),this.tooltip.parentElement||e.appendChild(this.tooltip),this.dropdown_caret.parentElement||e.appendChild(this.dropdown_caret),this.dropdown_list.parentElement||e.appendChild(this.dropdown_list),this.note_node.parentElement||e.appendChild(this.note_node),this.title_node.parentElement||e.appendChild(this.title_node),this.InitializeInternal(e,t),!r&&this.scroll_reference_node&&(this.scroll_reference_node.style.overflow="hidden"),this.dropdown_callback=i,this.initialized=!0}MockSelection(){if(!this.container||this.trident)return;let e=window.getSelection();if(e){let t=document.createRange();t.selectNodeContents(this.mock_selection),e.removeAllRanges(),e.addRange(t)}}CreateTile(e,t,i,r,s,n,o,a=!0){let l=document.createElement("canvas");return l.setAttribute("class",e),l.logical_size=t,l.width=t.width*this.dpr,l.height=t.height*this.dpr,l.style.width=`${t.width}px`,l.style.height=`${t.height}px`,l.tile_position=i,l.first_cell=r,this.UpdateTileGridPosition(l),l.last_cell={row:r.row+s.rows-1,column:r.column+s.columns-1},l.pixel_start=n,l.pixel_end={x:n.x+t.width,y:n.y+t.height},l.dirty=!!a,l.needs_full_repaint=!0,o.appendChild(l),l}ApplyTheme(e){this.row_header.style.backgroundColor=this.column_header.style.backgroundColor=this.corner.style.backgroundColor=e.headers?.fill?fe(e,e.headers.fill):"",this.corner.style.borderColor=e.grid_color||"";for(let t of this.grid_tiles)for(let i of t)i.style.backgroundColor=fe(e,e.grid_cell?.fill)||"#fff";this.dropdown_list.style.font=A.Font(e.grid_cell||{})}UpdateTotalSize(){this.total_height=0;let e=this.view.active_sheet.rows;for(let i=0;i<e;i++)this.total_height+=this.RowHeight(i);this.total_width=0;let t=this.view.active_sheet.columns;for(let i=0;i<t;i++)this.total_width+=this.ColumnWidth(i)}UpdateContentsSize(){let e=this.row_header_tiles.reduce((i,r)=>i+r.logical_size.height,0),t=this.column_header_tiles.reduce((i,r)=>i+r.logical_size.width,0);this.column_header.style.width=this.contents.style.width=`${t}px`,this.row_header.style.height=this.contents.style.height=`${e}px`}HideTooltip(){this.tooltip.style.display="none",this.tooltip_state=void 0,this.tooltip.classList.remove("arrow-up"),this.tooltip.classList.remove("arrow-left")}ShowTooltip(e={}){e.up?(this.tooltip.classList.add("arrow-up"),this.tooltip_state="up"):e.left&&(this.tooltip.classList.add("arrow-left"),this.tooltip_state="left"),this.tooltip.style.display="block",this.UpdateTooltip(e)}ShowDropdownCaret(e,t,i){let r=this.OffsetCellAddressToRectangle(e.start);e.count>1&&(r=r.Combine(this.OffsetCellAddressToRectangle(e.end))),r=r.Shift(this.header_size.width,this.header_size.height);let s=Math.round(this.scale*Math.max(8,Math.min(20,r.height)));this.dropdown_caret.style.height=`${s}px`,this.dropdown_caret.style.width=`${s}px`,this.dropdown_caret.style.left=`${r.right+1}px`,this.dropdown_caret.style.top=`${r.bottom-s}px`,this.dropdown_list.style.top=`${r.bottom+2}px`,this.dropdown_list.style.left=`${r.left+2}px`,this.dropdown_list.style.minWidth=`${r.width}px`,this.dropdown_list.textContent="";for(let n of t){let o=V.CreateDiv(void 0,this.dropdown_list);i===n&&(this.dropdown_selected=o,o.classList.add("selected")),o.dropdown_value=n,o.textContent=n?.toString()||""}this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_caret.style.display="block",this.dropdown_caret_visible=!0}HideDropdownCaret(){this.dropdown_caret_visible&&(this.dropdown_caret.setAttribute("class","treb-dropdown-caret"),this.dropdown_caret_visible=!1,this.dropdown_caret.style.display="none")}GetScrollOffset(){return{x:this.scroll_reference_node.scrollLeft+this.header_offset.x,y:this.scroll_reference_node.scrollTop+this.header_offset.y}}ScrollTo(e,t=!0,i=!0,r=!1){let s=this.CellAddressToRectangle(e);if(r&&!!this.scroll_reference_node.scrollTo){let n={left:this.scroll_reference_node.scrollLeft,top:this.scroll_reference_node.scrollTop},o={left:t?s.left:n.left,top:i?s.top:n.top,behavior:"smooth"};this.scroll_reference_node.scrollTo(o)}else i&&(this.scroll_reference_node.scrollTop=s.top),t&&(this.scroll_reference_node.scrollLeft=s.left)}ScrollIntoView(e){let t=this.CellAddressToRectangle(e),i=this.scroll_reference_node.clientWidth-this.row_header.offsetWidth,r=this.scroll_reference_node.clientHeight-this.column_header.offsetHeight,s={x:0,y:0},n={x:!1,y:!1},o=new z(this.scroll_reference_node.scrollLeft,this.scroll_reference_node.scrollTop,i,r);(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&(this.view.active_sheet.freeze.rows&&e.row>=this.view.active_sheet.freeze.rows?s.y=this.frozen_row_tiles[0].logical_size.height:this.view.active_sheet.freeze.rows&&(n.y=!0),this.view.active_sheet.freeze.columns&&e.column>=this.view.active_sheet.freeze.columns?s.x=this.frozen_column_tiles[0].logical_size.width:this.view.active_sheet.freeze.columns&&(n.x=!0)),e.row!==1/0&&(t.top<o.top+s.y&&!n.y?this.scroll_reference_node.scrollTop=t.top-s.y:t.bottom>o.bottom&&(this.scroll_reference_node.scrollTop=t.bottom-r)),e.column!==1/0&&(t.left<o.left+s.x&&!n.x?this.scroll_reference_node.scrollLeft=t.left-s.x:t.right>o.right&&(this.scroll_reference_node.scrollLeft=t.right-i))}UpdateTooltip(e={}){if(typeof e.text<"u"&&(this.tooltip.textContent=e.text),typeof e.x<"u"){let t=e.x||0;this.tooltip_state==="up"&&(t-=this.tooltip.offsetWidth/2),this.tooltip.style.left=Math.round(t)+"px"}if(typeof e.y<"u"){let t=e.y||0;this.tooltip_state==="left"&&(t-=this.tooltip.offsetHeight/2),this.tooltip.style.top=Math.round(t)+"px"}}CoordinateToRowHeader(e){let t={column:1/0,row:0};if(this.view.active_sheet.freeze.rows&&this.frozen_row_tiles[0].pixel_end.y>=e-this.scroll_reference_node.scrollTop){let i=0;e-=this.scroll_reference_node.scrollTop;for(let r=0;r<this.view.active_sheet.freeze.rows;r++)if(i+=this.RowHeight(r),i>=e)return t.row=r,t}for(let i of this.row_header_tiles)if(i.pixel_end.y>=e){let r=e-i.pixel_start.y,s=0;for(t.row=i.first_cell.row;t.row<=i.last_cell.row;t.row++,r-=s)if(s=this.RowHeight(t.row),s>r)return t;return t}return t}CoordinateToColumnHeader(e){let t={row:1/0,column:0};if(this.view.active_sheet.freeze.columns&&this.frozen_column_tiles[0].pixel_end.x>=e-this.scroll_reference_node.scrollLeft){let i=0;e-=this.scroll_reference_node.scrollLeft;for(let r=0;r<this.view.active_sheet.freeze.columns;r++)if(i+=this.ColumnWidth(r),i>=e)return t.column=r,t}for(let i of this.column_header_tiles)if(i.pixel_end.x>=e){let r=e-i.pixel_start.x,s=0;for(t.column=i.first_cell.column;t.column<=i.last_cell.column;t.column++,r-=s)if(s=this.ColumnWidth(t.column),s>r)return t;return t}return t}PointToAddress_Grid(e,t=!1,i=!0){if(i){if(this.view.active_sheet.freeze.rows){let o=this.frozen_row_tiles[0].logical_size.height;e.y-this.scroll_reference_node.scrollTop<o&&(e.y-=this.scroll_reference_node.scrollTop)}if(this.view.active_sheet.freeze.columns){let o=this.frozen_column_tiles[0].logical_size.width;e.x-this.scroll_reference_node.scrollLeft<o&&(e.x-=this.scroll_reference_node.scrollLeft)}}let r={row:0,column:0},s=this.grid_tiles[this.grid_tiles.length-1],n=s[s.length-1];if(e.y>n.pixel_end.y){let o=e.y-n.pixel_end.y;for(r.row=n.last_cell.row;o>0;)r.row++,o-=this.default_row_height}else for(let o of s)if(o.pixel_start.y<=e.y&&o.pixel_end.y>=e.y){let a=e.y-o.pixel_start.y,l=0;for(r.row=o.first_cell.row;r.row<=o.last_cell.row&&(l=this.RowHeight(r.row),!(l>a));r.row++,a-=l);break}if(e.x>n.pixel_end.x){let o=e.x-n.pixel_end.x;for(r.column=n.last_cell.column;o>0;)r.column++,o-=this.default_column_width}else for(let o of this.grid_tiles)if(o[0].pixel_start.x<=e.x&&o[0].pixel_end.x>=e.x){let a=o[0],l=e.x-a.pixel_start.x,d=0;for(r.column=a.first_cell.column;r.column<=a.last_cell.column&&(d=this.ColumnWidth(r.column),!(d>l));r.column++,l-=d);break}return r}AdjacentTile(e,t=0,i=0){if(!t&&!i)return e;let r=e.tile_position,s=e.tile_position.row+t,n=e.tile_position.column+i;if(!(s<0||n<0)){if(this.grid_tiles[r.column]&&this.grid_tiles[r.column][r.row]===e&&this.grid_tiles[n])return this.grid_tiles[n][s];if(!r.column&&this.frozen_column_tiles[r.row]===e)return this.frozen_column_tiles[s];if(!r.row&&this.frozen_row_tiles[r.column]===e)return this.frozen_row_tiles[n]}}UpdateTiles(){if(!this.container)throw new Error("invalid container");this.grid_tiles.forEach(v=>{v.forEach(w=>{w.parentElement&&w.parentElement.removeChild(w)})});for(let v of[this.column_header_tiles,this.row_header_tiles,this.frozen_row_tiles,this.frozen_column_tiles])for(let w of v)w.parentElement&&w.parentElement.removeChild(w);this.frozen_row_tiles=[],this.frozen_column_tiles=[],this.row_header_tiles=[],this.column_header_tiles=[],this.grid_tiles=[];let e=this.view.active_sheet;this.default_row_height=Math.round(e.default_row_height*this.scale),this.default_column_width=Math.round(e.default_column_width*this.scale),this.header_offset={x:Math.round(e.header_offset.x*this.scale),y:Math.round(e.header_offset.y*this.scale)},this.UpdateContainingGrid();let t=this.view.active_sheet.rows,i=this.view.active_sheet.columns;t||(t=100),i||(i=40);let r=0,s=0;for(let v=0;v<t;v++)r+=this.RowHeight(v);for(let v=0;v<i;v++)s+=this.ColumnWidth(v);if(!s||!r)throw"unexpected missing total size";if(r||(r=this.default_row_height*t),s||(s=this.default_column_width*i),this.container.offsetWidth>s){let v=Math.ceil((this.container.offsetWidth-s)/this.default_column_width);s+=v*this.default_column_width,i+=v}if(this.last_column=i,this.container.offsetHeight>r){let v=Math.ceil((this.container.offsetHeight-r)/this.default_row_height);r+=v*this.default_row_height,t+=v}this.column_header.style.width=this.contents.style.width=`${s}px`,this.row_header.style.height=this.contents.style.height=`${r}px`;let n=[],o=[],a=0,l=0;for(let v=0;v<i;v++){let w=this.ColumnWidth(v);a&&a+w>this.default_tile_size.width&&(n.push(a),o.push(l),l=v,a=0),a+=w}n.push(a),o.push(l);let d=[],u=[],h=0,p=0;for(let v=0;v<t;v++){let w=this.RowHeight(v);h&&h+w>this.default_tile_size.height&&(d.push(h),u.push(p),h=0,p=v),h+=w}d.push(h),u.push(p);let f=n.length,m=d.length,b=0,_=0,y=0,x=0;for(let v=0;v<this.view.active_sheet.freeze.rows;v++)y+=this.RowHeight(v);for(let v=0;v<this.view.active_sheet.freeze.columns;v++)x+=this.ColumnWidth(v);for(let v=0;v<f;v++){let w=[];b=0;let C=v===f-1?i-o[v]:o[v+1]-o[v];this.column_header_tiles.push(this.CreateTile("column-header-tile",{height:this.header_offset.y,width:n[v]},{row:0,column:v},{row:0,column:o[v]},{rows:0,columns:C},{x:_,y:0},this.column_header)),this.view.active_sheet.freeze.rows&&this.frozen_row_tiles.push(this.CreateTile("frozen-row-tile",{height:y,width:n[v]},{row:1,column:v},{row:0,column:o[v]},{rows:0,columns:C},{x:_,y:0},this.column_header));for(let S=0;S<m;S++){let U=S===m-1?t-u[S]:u[S+1]-u[S];v||(this.row_header_tiles.push(this.CreateTile("row-header-tile",{height:d[S],width:this.header_offset.x},{row:S,column:0},{row:u[S],column:0},{rows:U,columns:1},{x:0,y:b},this.row_header)),this.view.active_sheet.freeze.columns&&this.frozen_column_tiles.push(this.CreateTile("frozen-column-tile",{height:d[S],width:x},{row:S,column:1},{row:u[S],column:0},{rows:U,columns:1},{x:0,y:b},this.row_header))),w.push(this.CreateTile("grid-tile",{height:d[S],width:n[v]},{row:S,column:v},{row:u[S],column:o[v]},{rows:U,columns:C},{x:_,y:b},this.contents)),b+=d[S]}this.grid_tiles.push(w),_+=n[v]}this.total_height=r,this.total_width=s,this.ClearLayoutCaches(),this.UpdateGridTemplates(!0,!0)}ClearLayoutCaches(){this.row_cache=[],this.column_cache=[]}TileIndexForColumn(e){for(let t of this.column_header_tiles)if(t.first_cell.column<=e&&t.last_cell.column>=e)return t.tile_position.column;return-1}TileIndexForRow(e){for(let t of this.row_header_tiles)if(t.first_cell.row<=e&&t.last_cell.row>=e)return t.tile_position.row;return-1}DirtyHeaders(e){if(!!e){for(let t of this.column_header_tiles){if(t.dirty)continue;let i=new g({row:e.start.row,column:t.first_cell.column},{row:e.start.row,column:t.last_cell.column});(e.entire_row||i.Intersects(e))&&(t.dirty=!0)}for(let t of this.row_header_tiles){if(t.dirty)continue;let i=new g({column:e.start.column,row:t.first_cell.row},{column:e.start.column,row:t.last_cell.row});(e.entire_column||i.Intersects(e))&&(t.dirty=!0)}}}DirtyAll(){for(let e of this.grid_tiles)for(let t of e)t.dirty=!0}DirtyArea(e){if(!this.initialized)return;let t={row:0,column:0},i={row:this.grid_tiles[0].length-1,column:this.grid_tiles.length-1};e.start.column!==1/0&&(t.column=i.column=this.TileIndexForColumn(e.start.column),e.end.column!==e.start.column&&(i.column=this.TileIndexForColumn(e.end.column))),e.start.row!==1/0&&(t.row=i.row=this.TileIndexForRow(e.start.row),e.end.row!==e.start.row&&(i.row=this.TileIndexForRow(e.end.row)));for(let r=t.column;r<=i.column;r++)for(let s=t.row;s<=i.row;s++)this.grid_tiles[r][s].dirty=!0}VisibleTiles(){let e=[{row:0,column:0},{row:0,column:0}];if(!this.container||!this.grid_tiles.length||!this.grid_tiles[0].length)return new g(e[0],e[1]);let t=this.scroll_reference_node.scrollLeft,i=t+this.scroll_reference_node.offsetWidth,r=this.scroll_reference_node.scrollTop,s=r+this.scroll_reference_node.offsetHeight;for(let n of this.grid_tiles){let o=n[0];if(o.pixel_start.x<=t&&o.pixel_end.x>=t){for(o of n)if(o.pixel_start.y<=r&&o.pixel_end.y>=r){e[0]=o.tile_position;break}}if(n===this.grid_tiles[this.grid_tiles.length-1]||o.pixel_start.x<=i&&o.pixel_end.x>=i){for(o of n)if(o===n[n.length-1]||o.pixel_start.y<=s&&o.pixel_end.y>=s)return e[1]=o.tile_position,new g(e[0],e[1])}}return new g(e[0],e[1])}UpdateTileHeights(e=!0,t=-1){let i=0;for(let r=0;r<this.row_header_tiles.length;r++){let s=this.row_header_tiles[r];if(t>s.last_cell.row){i+=s.logical_size.height;continue}let n=0;for(let a=s.first_cell.row;a<=s.last_cell.row;a++)n+=this.RowHeight(a);let o=s.logical_size.height===n;if(s.pixel_start.y=i,i+=n,s.pixel_end.y=i,!o){if(s.logical_size.height=n,s.style.height=`${n}px`,s.height=this.dpr*n,this.view.active_sheet.freeze.columns){let a=this.frozen_column_tiles[r];a.logical_size.height=n,a.style.height=`${n}px`,a.height=this.dpr*n}e&&(s.dirty=!0,s.needs_full_repaint=!0)}for(let a of this.grid_tiles){let l=a[r];l.pixel_start.y=s.pixel_start.y,l.pixel_end.y=s.pixel_end.y,o||(l.logical_size.height=n,l.style.height=`${n}px`,l.height=this.dpr*n,e&&(l.dirty=!0,l.needs_full_repaint=!0))}}if(this.view.active_sheet.freeze.rows){let r=0;for(let s=0;s<this.view.active_sheet.freeze.rows;s++)r+=this.RowHeight(s);for(let s of this.frozen_row_tiles)s.style.height=`${r}px`,s.height=r*this.dpr;r+=this.header_offset.y,this.corner_canvas.style.height=`${r}px`,this.corner_canvas.height=r*this.dpr;for(let s of this.grid_tiles)s[0].dirty=!0}this.UpdateGridTemplates(!1,!0),this.row_header.style.height=this.contents.style.height=`${i}px`,this.ClearLayoutCaches()}UpdateTileWidths(e=!0,t=-1){let i=0;for(let r=0;r<this.column_header_tiles.length;r++){let s=this.column_header_tiles[r],n=this.grid_tiles[r];if(t>s.last_cell.column){i+=s.logical_size.width;continue}let o=0;for(let l=s.first_cell.column;l<=s.last_cell.column;l++)o+=this.ColumnWidth(l);let a=s.logical_size.width===o;if(s.pixel_start.x=i,i+=o,s.pixel_end.x=i,!a){if(s.logical_size.width=o,s.style.width=`${o}px`,s.width=this.dpr*o,this.view.active_sheet.freeze.rows){let l=this.frozen_row_tiles[r];l.logical_size.width=o,l.style.width=`${o}px`,l.width=this.dpr*o}e&&(s.dirty=!0,s.needs_full_repaint=!0)}for(let l of n)l.pixel_start.x=s.pixel_start.x,l.pixel_end.x=s.pixel_end.x,a||(l.logical_size.width=o,l.style.width=`${o}px`,l.width=this.dpr*o,e&&(l.dirty=!0,l.needs_full_repaint=!0))}if(this.view.active_sheet.freeze.columns){let r=0;for(let s=0;s<this.view.active_sheet.freeze.columns;s++)r+=this.ColumnWidth(s);for(let s of this.frozen_column_tiles)s.style.width=`${r}px`,s.width=r*this.dpr;r+=this.header_offset.x,this.corner_canvas.style.width=`${r}px`,this.corner_canvas.width=r*this.dpr;for(let s of this.grid_tiles[0])s.dirty=!0}this.UpdateGridTemplates(!0,!1),this.column_header.style.width=this.contents.style.width=`${i}px`,this.ClearLayoutCaches()}ClampToGrid(e){let t=this.PointToAddress_Grid(e),i=this.OffsetCellAddressToRectangle(t);return e.x>i.left+i.width/2?e.x=i.left+i.width-1:e.x=i.left-1,e.y>i.top+i.height/2?e.y=i.top+i.height-1:e.y=i.top-1,e}OffsetCellAddressToRectangle(e){let t=this.CellAddressToRectangle(e);return e.column>=0&&e.column<this.view.active_sheet.freeze.columns&&(t=t.Shift(this.scroll_reference_node.scrollLeft,0)),e.row>=0&&e.row<this.view.active_sheet.freeze.rows&&(t=t.Shift(0,this.scroll_reference_node.scrollTop)),t}CellAddressToRectangle(e){let t=e.row===1/0||e.row<0?0:e.row,i=e.column===1/0||e.column<0?0:e.column;if(this.column_cache.length<=i+1){this.column_cache.length||(this.column_cache[0]=0);for(let n=this.column_cache.length-1;n<=i;n++)this.column_cache[n+1]=this.column_cache[n]+this.ColumnWidth(n)}if(this.row_cache.length<=t+1){this.row_cache.length||(this.row_cache[0]=0);for(let n=this.row_cache.length-1;n<=t;n++)this.row_cache[n+1]=this.row_cache[n]+this.RowHeight(n)}let r=this.column_cache[i],s=this.row_cache[t];return new z(r,s,this.column_cache[i+1]-r,this.row_cache[t+1]-s)}ResizeTileWidth(e,t,i=!0){let r=this.column_header_tiles[e],s=t-r.logical_size.width;r.logical_size.width=t,r.style.width=`${t}px`,r.width=this.dpr*t,r.pixel_end.x+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);for(let o=e+1;o<this.column_header_tiles.length;o++){this.column_header_tiles[o].pixel_start.x+=s,this.column_header_tiles[o].pixel_end.x+=s;for(let a of this.grid_tiles[o])a.pixel_start.x+=s,a.pixel_end.x+=s}let n=this.grid_tiles[e];for(r of n)r.logical_size.width=t,r.style.width=`${t}px`,r.width=this.dpr*t,r.pixel_end.x+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);this.UpdateTotalSize(),this.UpdateGridTemplates(!0,!1),this.UpdateContentsSize()}ResizeTileHeight(e,t,i=!0){let r=this.row_header_tiles[e],s=t-r.logical_size.height;r.logical_size.height=t,r.style.height=`${t}px`,r.height=this.dpr*t,r.pixel_end.y+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);for(let n=e+1;n<this.row_header_tiles.length;n++)r=this.row_header_tiles[n],r.pixel_start.y+=s,r.pixel_end.y+=s;for(let n of this.grid_tiles){r=n[e],r.logical_size.height=t,r.style.height=`${t}px`,r.height=this.dpr*t,r.pixel_end.y+=s,i&&(r.dirty=!0,r.needs_full_repaint=!0);for(let o=e+1;o<n.length;o++)n[o].pixel_start.y+=s,n[o].pixel_end.y+=s}this.UpdateTotalSize(),this.UpdateGridTemplates(!1,!0),this.UpdateContentsSize()}};var It="http://www.w3.org/2000/svg",Ft=class extends Vt{constructor(e,t){super(e,t),this.column_header=V.CreateDiv("top-header"),this.row_header=V.CreateDiv("left-header"),this.corner=V.CreateDiv("corner"),this.corner_canvas=document.createElement("canvas"),this.corner.appendChild(this.corner_canvas),this.contents=V.CreateDiv("contents"),this.buffer_canvas=V.Create("canvas","treb-buffer-canvas",this.contents),this.grid_selection=document.createElementNS(It,"svg"),this.grid_selection.classList.add("grid-selection"),this.contents.appendChild(this.grid_selection),this.row_header_selection=document.createElementNS(It,"svg"),this.row_header_selection.classList.add("frozen-selection"),this.row_header_selection.classList.add("frozen-selection-rows"),this.column_header.appendChild(this.row_header_selection),this.row_header_annotations=V.CreateDiv("frozen-annotation-container frozen-annotation-container-rows",this.column_header),this.column_header_selection=document.createElementNS(It,"svg"),this.column_header_selection.classList.add("frozen-selection"),this.column_header_selection.classList.add("frozen-selection-columns"),this.row_header.appendChild(this.column_header_selection),this.column_header_annotations=V.CreateDiv("frozen-annotation-container frozen-annotation-container-columns",this.row_header),this.corner_selection=document.createElementNS(It,"svg"),this.corner_selection.classList.add("frozen-selection"),this.corner.appendChild(this.corner_selection),this.corner_annotations=V.CreateDiv("frozen-annotation-container frozen-annotation-container-corner",this.corner),this.annotation_container=V.CreateDiv("annotation-container"),this.grid_cover=V.CreateDiv("tile-cover grid-cover"),this.column_header_cover=V.CreateDiv("tile-cover column-header-cover"),this.row_header_cover=V.CreateDiv("tile-cover row-header-cover")}InitializeInternal(e,t){this.container=e,this.container.classList.add("grid-layout"),this.scroll_reference_node=this.container,e.appendChild(this.column_header),e.appendChild(this.row_header),e.appendChild(this.corner),e.appendChild(this.contents),e.appendChild(this.annotation_container),e.appendChild(this.grid_cover),e.appendChild(this.column_header_cover),e.appendChild(this.row_header_cover),e.appendChild(this.mock_selection),this.container.addEventListener("scroll",()=>t())}ResizeCursor(e){switch(e){case"row":this.row_header_cover.classList.add("resize");break;case"column":this.column_header_cover.classList.add("resize");break;default:this.row_header_cover.classList.remove("resize"),this.column_header_cover.classList.remove("resize");break}}UpdateTileGridPosition(e){e.style.gridColumn=`${e.tile_position.column+1} / ${e.tile_position.column+2}`,e.style.gridRow=`${e.tile_position.row+1} / ${e.tile_position.row+2}`}UpdateContainingGrid(){if(!this.container)throw new Error("missing container");this.header_size.width=this.header_offset.x,this.header_size.height=this.header_offset.y;let e=this.header_offset.x,t=this.header_offset.y;if(this.view.active_sheet.freeze.columns)for(let i=0;i<this.view.active_sheet.freeze.columns;i++)e+=this.ColumnWidth(i);if(this.view.active_sheet.freeze.rows)for(let i=0;i<this.view.active_sheet.freeze.rows;i++)t+=this.RowHeight(i);this.container.style.gridTemplateColumns=`${this.header_offset.x}px auto`,this.container.style.gridTemplateRows=`${this.header_offset.y}px auto`,this.corner_canvas.setAttribute("width",`${this.dpr*e}`),this.corner_canvas.setAttribute("height",`${this.dpr*t}`),this.column_header.style.height=`${t}px`,this.corner_canvas.style.width=`${e}px`,this.corner_canvas.style.height=`${t}px`}UpdateGridTemplates(e=!0,t=!0){let i=0,r=0;this.column_header.style.gridTemplateColumns=this.contents.style.gridTemplateColumns=this.column_header_tiles.map(l=>(i+=l.logical_size.width,`${l.logical_size.width}px`)).join(" "),this.column_header.style.gridTemplateRows=`${this.header_offset.y}px auto`,this.row_header.style.gridTemplateRows=this.contents.style.gridTemplateRows=this.row_header_tiles.map(l=>(r+=l.logical_size.height,`${l.logical_size.height}px`)).join(" ");let s=this.header_offset.y;if(this.view.active_sheet.freeze.rows)for(let l=0;l<this.view.active_sheet.freeze.rows;l++)s+=this.RowHeight(l);this.column_header.style.height=`${s}px`,this.row_header_selection.style.display="block",this.row_header_selection.style.width=`${i}px`,this.corner_selection.style.height=this.row_header_selection.style.height=`${s}px`,this.corner_selection.style.top=this.row_header_selection.style.top="0px",this.row_header_selection.style.left="0px";let n=this.header_offset.x;if(this.view.active_sheet.freeze.columns)for(let l=0;l<this.view.active_sheet.freeze.columns;l++)n+=this.ColumnWidth(l);this.column_header_selection.style.display="block",this.corner_selection.style.width=this.column_header_selection.style.width=`${n}px`,this.column_header_selection.style.height=`${r}px`,this.column_header_selection.style.top="0px",this.corner_selection.style.left=this.column_header_selection.style.left="0px";let o={x:this.view.active_sheet.header_offset.x*this.scale,y:this.view.active_sheet.header_offset.y*this.scale},a=this.view.active_sheet.freeze;a.rows&&a.columns?(this.row_header_annotations.style.display="block",this.column_header_annotations.style.display="block",this.corner_annotations.style.display="block"):a.rows?(this.row_header_annotations.style.display="block",this.column_header_annotations.style.display="none",this.corner_annotations.style.display="none"):a.columns?(this.row_header_annotations.style.display="none",this.column_header_annotations.style.display="block",this.corner_annotations.style.display="none"):(this.row_header_annotations.style.display="none",this.column_header_annotations.style.display="none",this.corner_annotations.style.display="none"),this.row_header_annotations.style.width=`${i}px`,this.corner_annotations.style.height=this.row_header_annotations.style.height=`${s-o.y}px`,this.corner_annotations.style.top=this.row_header_annotations.style.top=`${o.y}px`,this.column_header_annotations.style.width=this.corner_annotations.style.width=`${n-o.x}px`,this.column_header_annotations.style.height=`${r}px`,this.corner_annotations.style.left=this.column_header_annotations.style.left=`${o.x}px`,this.corner_selection.style.display="block",this.grid_selection.style.width=`${i}px`,this.grid_selection.style.height=`${r}px`,this.grid_selection.style.top=`${this.header_offset.y}px`,this.grid_selection.style.left=`${this.header_offset.x}px`,this.annotation_container.style.width=`${i}px`,this.annotation_container.style.height=`${r}px`,this.annotation_container.style.top=`${this.header_offset.y}px`,this.annotation_container.style.left=`${this.header_offset.x}px`}};var zt=class{function_names=[];argument_separator=T.argument_separator.charCodeAt(0);function_map={};RemoveFunctions(e){Array.isArray(e)||(e=[e]);let t=Object.keys(this.function_map).map(i=>this.function_map[i]);for(let i of e)t=t.filter(r=>r.name!==i.name);this.SetFunctions(t)}AddFunctions(e){Array.isArray(e)||(e=[e]);let t=Object.keys(this.function_map).map(i=>this.function_map[i]).concat(...e);this.SetFunctions(t)}SetFunctions(e){this.function_map={},this.function_names=e.map(t=>(this.function_map[t.name.toLowerCase()]=t,t.name)).sort((t,i)=>t.toLowerCase().localeCompare(i.toLowerCase()))}NormalizeIdentifier(e){let t=this.function_map[e.toLowerCase()];return t?t.name:void 0}Exec(e){if(e.text[0]!=="=")return{};let t,i={};if(e.cursor===e.text.length&&(t=e.text.match(/(?:^|[^A-Za-z_\d])([A-Za-z_][\w\d_.]*)\s*$/),t)){let s=t[1],n=new RegExp("^"+s.replace(".","\\."),"i");i={completions:this.function_names.filter(a=>n.test(a)).map(a=>this.function_map[a.toLowerCase()]),token:s,position:e.cursor-s.length}}let r=this.ParseTooltip(e.text.substr(0,e.cursor));if(r.function){let s=this.function_map[r.function.toLowerCase()];s&&(i.tooltip='<span class="notranslate">'+s.name+"</span>",i.arguments="("+(s.arguments||[]).map((n,o)=>{let a=n.name||"argument";return o===r.argument?`<span class="active-argument">${a}</span>`:a}).join(T.argument_separator+" ")+")",i.description=s.description?`<span class="function-description">${s.description}</span>`:"",i.function_position=r.position||0)}return i}ParseTooltip(e){let t=[],i=0,r="",s=!1,n=0;for(let a of e){let l=a.charCodeAt(0);if(s)l===34&&(s=!1);else switch(l){case 40:t.push({buffer:r.trim(),argument:i,position:n-r.length}),r="",i=0;break;case this.argument_separator:i++;break;case 41:i=t.pop()?.argument||0;break;case 34:r="",s=!0;break;default:l>=97&&l<=122||l>=65&&l<=90||l>=48&&l<=57||l===95||l===46?r+=a:r=""}n++}let o=t.pop();return{function:o?.buffer||void 0,position:o?.position||0,argument:i}}};var Xs=typeof navigator>"u"?"":navigator.appVersion,Se=typeof navigator>"u"?"":navigator.userAgent,Ti=class{is_edge=/Edge/.test(Xs);is_ipad=/iPad|iPhone/.test(Se);is_android=/android|samsung/i.test(Se);is_mobile=this.is_ipad||this.is_android;is_firefox=/firefox/i.test(Se);is_safari=/safari/i.test(Se)&&!/edg/i.test(Se);is_mac=/macintosh/i.test(Se);is_chrome=/Chrome/i.test(Se);is_windows=/win64|win32|windows\s+nt/i.test(Se);is_modern=!this.is_edge&&!(this.is_firefox&&this.is_android)&&/webkit|firefox/i.test(Se)},Ks={is_edge:!1,is_ipad:!1,is_android:!1,is_firefox:!1,is_safari:!1,is_mac:!1,is_chrome:!1,trident:!1,is_windows:!1,is_modern:!0,is_node:!0,is_mobile:!1},te=typeof navigator>"u"?Ks:new Ti;var Ui=class extends Q{constructor(t,i,r,s,n){super();this.parser=t;this.theme=i;this.model=r;this.view=s;this.autocomplete=n;this.measurement_node=document.createElement("div")}active_cell;autocomplete_matcher;measurement_node;selecting_=!1;editor_insert_node;editor_node;container_node;last_parse_string="";last_parse_result;reference_list;dependency_list=[];reference_index_map=[];last_reconstructed_text="";enable_reconstruct=!0;get selecting(){return this.selecting_}selection_={target:{row:0,column:0},area:new g({row:0,column:0})};get selection(){return this.selection_}set selection(t){if(t){let i=t.target||t.area.start;this.selection_={target:{row:i.row,column:i.column},area:new g(t.area.start,t.area.end)}}else{let i={row:0,column:0};this.selection_={target:i,area:new g(i)}}}UpdateTheme(t){}InsertReference(t,i){if(!this.editor_node)return;if(!this.editor_insert_node){let s=window.getSelection();if(s){let n=s.getRangeAt(0);this.editor_insert_node=document.createElement("span"),n.insertNode(this.editor_insert_node),s.collapseToEnd()}}if(this.editor_insert_node&&(this.editor_insert_node.innerText=t,t.length)){let s=window.getSelection();if(s){let n=document.createRange();n.selectNodeContents(this.editor_insert_node),s.removeAllRanges(),s.addRange(n),s.collapseToEnd()}}let r=this.ListDependencies();this.Publish({type:"update",text:this.editor_node.textContent||void 0,dependencies:r})}Autocomplete(t,i){if(!this.container_node)return;let r;i?.nodeType===Node.ELEMENT_NODE?r=i.getBoundingClientRect():r=this.container_node.getBoundingClientRect();let s=new z(Math.round(r.left),Math.round(r.top),r.width,r.height);this.autocomplete.Show(this.AcceptAutocomplete.bind(this),t,s)}FlushReference(){this.editor_insert_node=void 0}SubstringToCaret(t){let i=window.getSelection();if(!i)throw new Error("error getting selection");if(i.rangeCount===0)return console.warn("range count is 0"),"";let r=i.getRangeAt(0),s=r.cloneRange();return s.selectNodeContents(t),s.setEnd(r.endContainer,r.endOffset),this.measurement_node.textContent="",this.measurement_node.appendChild(s.cloneContents()),this.measurement_node.textContent}UpdateSelectState(t=!1){let i=!1,r=!1;if(!this.editor_node)return;let s=this.editor_node.textContent||"";if(s.trim()[0]==="="){r=!0;let o=this.SubstringToCaret(this.editor_node).trim();if(o.length){let a=o[o.length-1];Ui.FormulaChars.some(d=>a===d)&&(i=!0);let l=this.autocomplete_matcher;l&&se().then(()=>{let d=l.Exec({text:s,cursor:o.length}),u=this.NodeAtIndex(d.completions?d.position||0:d.function_position||0);this.Autocomplete(d,u)})}}i!==this.selecting_?(this.selecting_=i,i||this.Reconstruct(),(t||!i)&&this.Publish({type:"end-selection"})):i&&t&&this.Publish({type:"end-selection"});let n=r?this.ListDependencies():void 0;this.Publish({type:"update",text:s,dependencies:n})}NodeAtIndex(t){let i=this.editor_node?.childNodes||[];for(let r=0;r<i.length;r++){let s=i[r].textContent?.length||0;if(s>t)return i[r];t-=s}}Reconstruct(){if(!this.enable_reconstruct||!this.editor_node||(this.ParseDependencies(),!this.reference_list))return;let t=this.editor_node.textContent||"";if(t.trim()[0]!=="="||(this.editor_node.spellcheck=!1,this.selecting)||t.trim()===this.last_reconstructed_text.trim())return;this.last_reconstructed_text=t;let r=this.SubstringToCaret(this.editor_node).length,s=document.createDocumentFragment(),n,o=0,a,l="";if(this.last_parse_result){let d=0,u="",h=0,p=(f,m,b)=>{let _=document.createTextNode(m);if(b==="text")s.appendChild(_);else{let y=document.createElement("span");y.appendChild(_),y.dataset.position=f.toString(),y.dataset.type=b,b==="address"||b==="range"?y.classList.add(`highlight-${this.reference_index_map[h++]%5+1}`):b==="identifier"&&this.model.named_ranges.Get(m)&&y.classList.add(`highlight-${this.reference_index_map[h++]%5+1}`),s.appendChild(y)}return r>=f&&r<f+m.length&&(n=_,o=r-f),_};this.last_parse_result.expression&&this.parser.Walk(this.last_parse_result.expression,f=>{switch(f.type){case"address":case"range":case"call":case"identifier":f.position!==d-1&&p(d,t.substring(d,f.position+1),"text"),f.type==="call"||f.type==="identifier"?u=f.name:u=this.last_parse_string.substring(f.position+1,f.position+f.label.length+1),p(f.position+1,u,f.type),d=f.position+u.length+1;break}return f.type!=="range"}),l=t.substring(d)||"",a=p(d,l,"text")}if(!n)if(t.length===r){let d=document.createElement("span");s.appendChild(d),n=d,o=0}else n=a,o=Math.max(0,l.length-(t.length-r));if(this.editor_node.textContent="",this.editor_node.appendChild(s),n){let d=document.createRange(),u=window.getSelection();u&&(d.setStart(n,o),d.setEnd(n,o),d.collapse(!0),u.removeAllRanges(),u.addRange(d))}}ParseDependencies(){if(!this.editor_node)return;let t=this.editor_node.textContent||"";if(t!==this.last_parse_string||!this.reference_list){let i={};for(let r of this.model.sheets.list)i[r.name.toLowerCase()]=r.id;if(this.dependency_list=[],this.reference_index_map=[],t){let r=this.parser.Parse(t);if(this.last_parse_string=t,this.last_parse_result=r,this.reference_list=[],r.full_reference_list)for(let s of r.full_reference_list)if(s.type==="address"||s.type==="range"){let n=s.type==="address"?s:s.start;n.sheet_id||(n.sheet?n.sheet_id=i[n.sheet.toLowerCase()]||0:n.sheet_id=this.view.active_sheet.id),this.reference_list.push(s)}else{let n=this.model.named_ranges.Get(s.name);n&&(n.count===1?this.reference_list.push({type:"address",...n.start,label:s.name,position:s.position,id:s.id}):this.reference_list.push({type:"range",start:{type:"address",position:s.position,id:s.id,label:s.name,...n.start},end:{type:"address",position:s.position,label:s.name,id:s.id,...n.end},label:s.name,position:s.position,id:s.id}))}if(this.reference_list){this.reference_list.sort((s,n)=>s.position-n.position);for(let s of this.reference_list){let n;s.type==="address"?n=new g({row:s.row,column:s.column,sheet_id:s.sheet_id}):n=new g({row:s.start.row,column:s.start.column,sheet_id:s.start.sheet_id},{row:s.end.row,column:s.end.column});let o=n.spreadsheet_label;this.dependency_list.some((a,l)=>a.spreadsheet_label===o&&a.start.sheet_id===n.start.sheet_id?(this.reference_index_map.push(l),!0):!1)||(this.reference_index_map.push(this.dependency_list.length),this.dependency_list.push(n))}}}else this.reference_list=void 0}}ListDependencies(){return this.ParseDependencies(),this.dependency_list||[]}AcceptAutocomplete(t){if(!this.editor_node)return;let i=window.getSelection(),r=0;if(t.data&&t.data.completions){for(let d of t.data.completions)if(d.name.toLowerCase()===t.value?.toLowerCase()){r=d.type||0;break}}if(!i)throw new Error("error getting selection");let s=i.getRangeAt(0),n=s.cloneRange(),o=document.createElement("div");n.selectNodeContents(this.editor_node),n.setEnd(s.endContainer,s.endOffset),o.appendChild(n.cloneContents());let a=(o.textContent||"").substr(0,t.data?t.data.position:0)+t.value,l=r===1?a:a+"(";this.editor_node.textContent=l,this.autocomplete.Hide(),te.is_firefox||this.Reconstruct(),i=window.getSelection(),s=document.createRange(),this.editor_node?.lastChild&&s.setStartAfter(this.editor_node.lastChild),s.collapse(!0),i?.removeAllRanges(),i?.addRange(s),this.selecting_=!0,t.click&&this.UpdateSelectState()}},Fe=Ui;E(Fe,"FormulaChars",("$^&*(-+={[<>/~%"+T.argument_separator).split(""));var Pt=class extends Fe{constructor(t,i,r,s,n,o){super(i,r,s,n,o);this.container=t;this.edit_container=document.createElement("div"),this.edit_container.classList.add("overlay-container"),this.edit_container.classList.add("notranslate"),this.edit_container.translate=!1,this.edit_node=document.createElement("div"),this.edit_node.classList.add("overlay-editor"),this.edit_node.contentEditable="true",this.edit_node.tabIndex=-1,this.edit_node.spellcheck=!0,this.edit_node.setAttribute("role","gridcell"),te.is_firefox&&this.edit_node.classList.add("firefox"),this.edit_node.inputMode="none";let a=!1;this.edit_node.addEventListener("compositionstart",()=>a=!0),this.edit_node.addEventListener("compositionend",()=>a=!1),this.edit_node.addEventListener("input",l=>{if(a)return;let d=this.edit_node.firstChild;d&&d.tagName==="BR"&&this.edit_node.removeChild(d),this.editing&&(this.Reconstruct(),this.UpdateSelectState())}),this.edit_node.addEventListener("keyup",l=>{if(!(a||!this.editing||this.autocomplete.HandleKey("keyup",l).handled)){if(this.selecting_)switch(l.key){case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"Shift":case"Control":return}this.FlushReference(),this.UpdateSelectState(!0)}}),this.edit_inset=document.createElement("div"),this.edit_inset.classList.add("overlay-inset"),this.edit_container.appendChild(this.edit_node),this.edit_container.appendChild(this.edit_inset),this.edit_inset.appendChild(this.edit_node),t.appendChild(this.edit_container),this.edit_container.style.opacity="0",this.editor_node=this.edit_node,this.container_node=this.edit_container,this.ClearContents()}edit_node;edit_container;edit_inset;scale=1;_editing=!1;get editing(){return this._editing}set editing(t){this._editing!==t&&(this._editing=t,t?(this.edit_container.style.opacity="1",this.edit_container.style.pointerEvents="initial"):(this.edit_container.style.opacity="0",this.edit_container.style.pointerEvents="none"))}UpdateCaption(t=""){this.edit_node.setAttribute("aria-label",t)}Focus(t=""){this.edit_node!==document.activeElement&&(this.edit_container.style.top=`${this.container.scrollTop+this.view.active_sheet.header_offset.y}px`,this.edit_container.style.left=`${this.container.scrollLeft+this.view.active_sheet.header_offset.x}px`),this.edit_node.focus(),this.UpdateCaption(t)}CloseEditor(){this.editing=!1,this.ClearContents(),this.edit_node.spellcheck=!0,this.autocomplete.Hide(),this.active_cell=void 0}ClearContents(){te.is_firefox?this.edit_node.innerHTML="<span></span>":this.edit_node.textContent=""}Edit(t,i,r,s,n){this.Publish({type:"start-editing",editor:"ice"}),this.active_cell=r;let o=r.style||{};switch(this.edit_node.style.font=A.Font(o,this.scale),this.edit_node.style.color=D(this.theme,o.text,1),this.edit_inset.style.backgroundColor=D(this.theme,o.fill,0),o.horizontal_align){case A.HorizontalAlign.Right:this.edit_container.classList.add("align-right"),this.edit_container.classList.remove("align-center"),this.edit_container.classList.remove("align-left");break;case A.HorizontalAlign.Center:this.edit_container.classList.remove("align-right"),this.edit_container.classList.add("align-center"),this.edit_container.classList.remove("align-left");break;default:this.edit_container.classList.remove("align-right"),this.edit_container.classList.remove("align-center"),this.edit_container.classList.add("align-left");break}this.edit_node.style.paddingBottom=`${Math.max(0,(self.devicePixelRatio||1)-1)}px`;let a=s?.toString()||"";if(a&&a[0]==="="&&(this.edit_node.spellcheck=!1),this.autocomplete.ResetBlock(),this.FlushReference(),this.selection=t,typeof s<"u"){let l=a[0]!=="="&&a[a.length-1]==="%",d=a.length;this.edit_node.textContent=a;{let u=document.createRange(),h=window.getSelection();if(!h)throw new Error("invalid selection object");this.edit_node.lastChild&&(l?(u.setStart(this.edit_node.lastChild,d-1),u.setEnd(this.edit_node.lastChild,d-1)):u.setStartAfter(this.edit_node.lastChild)),u.collapse(!0),h.removeAllRanges(),h.addRange(u)}if(!n){let u=this.ListDependencies();this.Publish({type:"update",text:s.toString(),dependencies:u})}}i.ApplyStyle(this.edit_container),this.editing=!0,se().then(()=>{this.last_reconstructed_text="",this.Reconstruct()})}HandleKeyDown(t){if(!this.editing)return 0;let i=this.autocomplete.HandleKey("keydown",t);if(i.accept&&this.AcceptAutocomplete(i),i.handled)return 1;switch(t.key){case"Enter":case"Tab":return this.selecting_=!1,2;case"Escape":case"Esc":return this.selecting_=!1,3;case"ArrowUp":case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"Up":case"Down":case"Left":case"Right":return this.selecting_?0:1}return 1}UpdateTheme(t){this.scale=t}};var Mi=class{canvas;cache={};constructor(){typeof document<"u"&&(this.canvas=document.createElement("canvas"))}Flush(){this.cache={}}Get(e,t=10){let i=e+";"+t,r=this.cache[i];return r||(r=this.Measure(e,t),this.cache[i]=r,r)}Measure(e,t){let i=e.match(/([\d.]+)((?:%|em))/);if(i){let h=i[1]+i[2],p=Number(i[1])*t;i[2]==="%"&&(p/=100),e=e.replace(h,p+"px")}let r=this.canvas.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("invalid context");r.font=e;let s=r.measureText("MMM"),n=Math.ceil(s.width);if(this.canvas.setAttribute("width",n.toString()),this.canvas.setAttribute("height",n.toString()),r=this.canvas.getContext("2d",{willReadFrequently:!0}),!r)throw new Error("invalid context");r.font=e,r.textAlign="center",r.textBaseline="alphabetic",r.fillStyle="#000";let o=Math.round(n*2/3),a=Math.round(n/2);r.clearRect(0,0,n,n);for(let h=32;h<=126;h++){let p=String.fromCharCode(h);r.fillText(p,a,o)}let l=r.getImageData(0,0,this.canvas.width,this.canvas.height).data,d=Math.floor(this.GetFirstIndex(l)/n),u=Math.floor(this.GetLastIndex(l)/n);return{ascender:o-d,descender:u-o,block:u-d+1,paren:r.measureText("(").width,hash:r.measureText("##").width-r.measureText("#").width}}GetFirstIndex(e){for(let t=3,i=e.length;t<i;t+=4)if(e[t]>0)return(t-3)/4;return e.length}GetLastIndex(e){for(let t=e.length-1;t>=3;t-=4)if(e[t]>0)return t/4;return 0}},Nt=new Mi;var Di="bottom",Er=/webkit/i.test(typeof navigator>"u"?"":navigator?.userAgent||"")?1:0,Ot=class{constructor(e,t,i,r,s){this.theme=e;this.layout=t;this.model=i;this.view=r;this.options=s;this.buffer_canvas=t.buffer_canvas,this.buffer_canvas.width=this.buffer_canvas_size.width,this.buffer_canvas.height=this.buffer_canvas_size.height;let n=this.buffer_canvas.getContext("2d",{alpha:!1});if(n){let o=this.layout.dpr;this.buffer_context=n,this.buffer_context.setTransform(o,0,0,o,0,0),this.buffer_context.textAlign="left",this.buffer_context.textBaseline=Di}}cell_edge_buffer=4;overflow_areas=[];buffer_canvas;buffer_context;buffer_canvas_size={width:256,height:256};FlushOverflows(){this.view.active_sheet.cells.IterateAll(t=>{t.renderer_data?.overflowed&&(t.renderer_data=void 0,t.render_clean[this.view.view_index]=!1)});for(let t of this.overflow_areas)t.tile.dirty=!0;this.overflow_areas=[]}MeasureText(e,t){let i=this.layout.grid_tiles[0][0].getContext("2d",{alpha:!1});if(!i)throw new Error("invalid context");return t&&(i.font=t),i.measureText(e)}EnsureBuffer(e=0,t=0,i=0){let r=this.layout.dpr;if(e=e*r,t=t*r,i=i*r,e>this.buffer_canvas_size.width||t>this.buffer_canvas_size.height){this.buffer_canvas_size.width=Math.max(Math.ceil(e/256)*256,this.buffer_canvas_size.width),this.buffer_canvas_size.height=Math.max(Math.ceil(t/256)*256,this.buffer_canvas_size.height),this.buffer_canvas.width=this.buffer_canvas_size.width,this.buffer_canvas.height=this.buffer_canvas_size.height;let s=this.buffer_canvas.getContext("2d",{alpha:!1});s&&(this.buffer_context=s,this.buffer_context.textAlign="left",this.buffer_context.textBaseline=Di)}this.buffer_context.setTransform(r,0,0,r,i,0)}OverflowDirty(e=!1){let t=[];for(let i of this.overflow_areas){let r=i.area.start.row,s=e;if(!s)for(let n=i.area.start.column;!s&&n<=i.area.end.column;n++){let o=this.view.active_sheet.cells.GetCell({row:r,column:n},!1);s=!!(o&&!o.render_clean[this.view.view_index])}if(s){for(let n=i.area.start.column;n<=i.area.end.column;n++){let o=this.view.active_sheet.cells.GetCell({row:r,column:n},!1);o&&(o.render_clean[this.view.view_index]=!1,o.renderer_data&&o.renderer_data.overflowed&&(o.renderer_data=void 0))}i.tile.dirty=!0}else t.push(i)}this.overflow_areas=t}RenderCorner(){let t=this.layout.corner_canvas.getContext("2d",{alpha:!1});if(!t)throw new Error("invalid context");let i=Nt.Get(A.Font(this.theme.headers||{},this.layout.scale)),r=this.layout.dpr,s=this.layout.header_offset,n=s.x;for(let a=0;a<this.view.active_sheet.freeze.columns;a++)n+=this.layout.ColumnWidth(a);let o=s.y;for(let a=0;a<this.view.active_sheet.freeze.rows;a++)o+=this.layout.RowHeight(a);t.setTransform(r,0,0,r,0,0),t.fillStyle=this.theme.headers?.fill?D(this.theme,this.theme.headers.fill):"",t.fillRect(0,0,n,s.y),t.fillRect(0,0,s.x,o),t.strokeStyle=this.theme.headers_grid_color||"",t.beginPath(),t.moveTo(s.x-.5,0),t.lineTo(s.x-.5,s.y),t.moveTo(0,s.y-.5),t.lineTo(s.x,s.y-.5),t.stroke(),!(!this.view.active_sheet.freeze.columns&&!this.view.active_sheet.freeze.rows)&&(t.strokeStyle=this.theme.grid_color||"",t.beginPath(),o!==s.y&&(t.moveTo(s.x-.5,s.y),t.lineTo(s.x-.5,o)),n!==s.x&&(t.moveTo(s.x,s.y-.5),t.lineTo(n,s.y-.5)),t.stroke(),t.strokeStyle=this.theme.headers_grid_color||"",t.textAlign="center",t.textBaseline="middle",t.font=A.Font(this.theme.headers||{},this.layout.scale),t.fillStyle=D(this.theme,this.theme.headers?.text),this.view.active_sheet.freeze.rows&&this.layout.header_offset.x>1&&(t.setTransform(r,0,0,r,0,0),t.translate(0,s.y),t.beginPath(),t.moveTo(0,0-.5),t.lineTo(s.x,0-.5),t.stroke(),this.RenderRowLabels(t,0,this.view.active_sheet.freeze.rows-1,i.block)),this.view.active_sheet.freeze.columns&&this.layout.header_offset.y>1&&(t.setTransform(r,0,0,r,0,0),t.translate(s.x,0),t.beginPath(),t.moveTo(0-.5,0),t.lineTo(0-.5,s.y),t.stroke(),this.RenderColumnLabels(t,0,this.view.active_sheet.freeze.columns-1)))}RenderColumnLabels(e,t,i){let r=this.layout.header_offset.y;for(e.fillStyle=D(this.theme,this.theme.headers?.text,0),e.beginPath();t<=i;t++){let s=this.layout.ColumnWidth(t),n=g.ColumnToLabel(t),o=e.measureText(n);s>o.width&&e.fillText(n,s/2,r/2+1),e.moveTo(s-.5,0),e.lineTo(s-.5,r),e.translate(s,0)}e.stroke()}RenderRowLabels(e,t,i,r){let s=this.layout.header_offset.x;for(e.fillStyle=D(this.theme,this.theme.headers?.text,0),e.beginPath();t<=i;t++){let n=this.layout.RowHeight(t);n>=r*1.2&&e.fillText(`${t+1}`,s/2,n/2+1),e.moveTo(0,n-.5),e.lineTo(s,n-.5),e.translate(0,n)}e.stroke()}RenderHeaders(e,t=!1){let i=this.layout.dpr,r=this.layout.header_offset,s=Nt.Get(A.Font(this.theme.headers||{},this.layout.scale));for(let n=e.start.column;n<=e.end.column;n++){let o=this.layout.column_header_tiles[n];if(o.dirty||t){let a=o.getContext("2d",{alpha:!1});if(!a)continue;a.setTransform(i,0,0,i,0,0),a.textAlign="center",a.textBaseline="middle",a.font=A.Font(this.theme.headers||{},this.layout.scale),a.fillStyle=this.theme.headers?.fill?D(this.theme,this.theme.headers.fill):"",a.fillRect(0,0,o.logical_size.width,this.layout.header_offset.y),a.strokeStyle=this.theme.headers_grid_color||"",a.beginPath(),a.moveTo(0,r.y-.5),a.lineTo(o.logical_size.width,r.y-.5),a.stroke(),a.strokeStyle=this.theme.headers_grid_color||"",this.RenderColumnLabels(a,o.first_cell.column,o.last_cell.column),o.dirty=!1}}for(let n=e.start.row;n<=e.end.row;n++){let o=this.layout.row_header_tiles[n];if(o.dirty||t){let a=o.getContext("2d",{alpha:!1});if(!a)continue;a.fillStyle=this.theme.headers?.fill?D(this.theme,this.theme.headers.fill):"",a.setTransform(i,0,0,i,0,0),a.textAlign="center",a.textBaseline="middle",a.font=A.Font(this.theme.headers||{},this.layout.scale),a.fillRect(0,0,this.layout.header_offset.x,o.logical_size.height),a.strokeStyle=this.theme.headers_grid_color||"",a.beginPath(),a.moveTo(r.x-.5,0),a.lineTo(r.x-.5,o.logical_size.height),a.stroke(),a.strokeStyle=this.theme.headers_grid_color||"",this.RenderRowLabels(a,o.first_cell.row,o.last_cell.row,s.block),o.dirty=!1}}(this.view.active_sheet.freeze.rows||this.view.active_sheet.freeze.columns)&&this.RenderCorner()}CopyToAdjacent(e,t,i,r,s,n,o){let a=this.layout.AdjacentTile(e,r,i);if(!a)return;let l=s,d=n;i>0?l=s-(e.pixel_end.x-e.pixel_start.x)*t:i<0&&(l=s+(a.pixel_end.x-a.pixel_start.x)*t),r>0&&(d=n-(e.pixel_end.y-e.pixel_start.y)*t);let u=a.getContext("2d",{alpha:!1});u&&(u.setTransform(t,0,0,t,l,d),u.drawImage(this.buffer_canvas,0,0,(o.width||0)*t,(o.height||0)*t,o.left||0,0,o.width||0,o.height||0))}Render(e){let t=e.getContext("2d",{alpha:!1});if(!t)return;t.textBaseline=Di;let i=this.layout.dpr;t.setTransform(i,0,0,i,0,0);let r=0,s=0;for(let a=e.first_cell.column;a<=e.last_cell.column;a++){let l=this.layout.ColumnWidth(a);if(!!l){s=0;for(let d=e.first_cell.row;d<=e.last_cell.row;d++){let u=this.layout.RowHeight(d);if(u){t.setTransform(i,0,0,i,r,s);let h=this.view.active_sheet.CellData({row:d,column:a});if(e.needs_full_repaint||!h.render_clean[this.view.view_index]){let p=this.RenderCell(e,h,t,{row:d,column:a},l,u);p.tile_overflow_right&&this.CopyToAdjacent(e,i,1,0,r,s,p),p.tile_overflow_left&&this.CopyToAdjacent(e,i,-1,0,r,s,p),p.tile_overflow_bottom&&this.CopyToAdjacent(e,i,0,1,r,s,p)}}s+=u*i}r+=l*i}}if(!this.view.active_sheet.freeze.rows&&!this.view.active_sheet.freeze.columns)return;let n=0,o=0;if(e.first_cell.row<=this.view.active_sheet.freeze.rows-1)for(let a=e.first_cell.row;a<this.view.active_sheet.freeze.rows&&a<=e.last_cell.row;a++)n+=this.layout.RowHeight(a);if(e.first_cell.column<=this.view.active_sheet.freeze.columns-1)for(let a=e.first_cell.column;a<this.view.active_sheet.freeze.columns&&a<=e.last_cell.column;a++)o+=this.layout.ColumnWidth(a);if(n){let a=this.layout.frozen_row_tiles[e.tile_position.column];if(!a)throw new Error("can't find matching header tile");let l=a.getContext("2d",{alpha:!0});if(!l)throw new Error("header context failed");l.setTransform(i,0,0,i,0,0),l.drawImage(e,0,0,e.logical_size.width*i,n*i,0,0,e.logical_size.width,n)}if(o){let a=this.layout.frozen_column_tiles[e.tile_position.row];if(!a)throw new Error("can't find matching header tile");let l=a.getContext("2d",{alpha:!0});if(!l)throw new Error("header context failed");l.setTransform(i,0,0,i,0,0),l.drawImage(e,0,0,o*i,e.logical_size.height*i,0,0,o,e.logical_size.height)}if(o&&n){let a=this.layout.corner_canvas.getContext("2d",{alpha:"false"});if(!a)throw new Error("corner context failed");a.setTransform(i,0,0,i,this.layout.header_offset.x*i,this.layout.header_offset.y*i),a.drawImage(e,0,0,o*i,n*i,0,0,o,n)}}PrepText(e,t,i,r){let s=[],n=i.style||{},o,a=0,l,d=i.editing?"":i.formatted;if(Array.isArray(d)){for(let u of d){if(u.flag===6){l=u.text;continue}let h=e.measureText(u.text).width,p={width:h,text:u.text,hidden:u.flag===1};s.push(p),u.flag===2?o=p:a+=h}if(o){let u=o.text,h=o.width,p=r-a-2*this.cell_edge_buffer;if(o.width=Math.max(0,p),p>0){let f=Math.floor(p/h);for(let m=1;m<f;m++)o.text+=u;a=r-2*this.cell_edge_buffer}else o.text=""}return{strings:[s],format:l,width:a}}else if(d){i.type===2&&d[0]==="'"&&(d=d.slice(1));let u;this.options.markdown?u=we.instance.Parse(d):(u=we.instance.Dummy(d),e.font=t.base);let h=0,p=r-2*this.cell_edge_buffer,f=[];if(n.wrap)for(let m of u){for(let _=1;_<m.length;_++){let y=m[_].text.match(/^(\s+)/);y&&(m[_-1].text+=y[1],m[_].text=m[_].text.replace(/^\s+/,""))}let b=[];for(let _ of m){this.options.markdown&&(_.strong&&_.emphasis?e.font=t.strong_emphasis:_.strong?e.font=t.strong:_.emphasis?e.font=t.emphasis:e.font=t.base);let y=_.text.match(/\S+\s*/g);if(y&&y.length)for(let x of y){let v=e.measureText(x.trim()).width,w=e.measureText(x).width;b.push({part:_,text:x,trimmed:v,width:w})}}for(;b.length;){let _=b.shift(),y=[_],x=_.trimmed;for(;x<p&&b.length;){let v=b[0],w=x-_.trimmed+_.width+v.trimmed;if(w>=p)break;_=v,y.push(v),x=w,b.shift()}_.text=_.text.trim(),_.width=_.trimmed,f.push(y.map(v=>({...v.part,hidden:!1,width:v.width,text:v.text})))}}else for(let m of u){let b=[],_=0;for(let y of m){this.options.markdown&&(y.strong&&y.emphasis?e.font=t.strong_emphasis:y.strong?e.font=t.strong:y.emphasis?e.font=t.emphasis:e.font=t.base);let x=e.measureText(y.text).width;_+=x,b.push({...y,hidden:!1,width:x})}h=Math.max(h,_),f.push(b)}return{strings:f,width:h}}return{strings:[[{text:"",hidden:!1,width:0}]],width:0}}ResolveColors(e){let t={...e};return t.text={text:D(this.theme,e.text,1)},t}RenderCellBorders(e,t,i,r=0,s=0,n=0,o=0){let a=this.view.active_sheet.SurroundingStyle(e),l=D(this.theme,a[8].fill);l&&(t.fillStyle=l,t.fillRect(r+0,s-1,n,1)),l=D(this.theme,a[4].fill),l&&(t.fillStyle=l,t.fillRect(r-1,s,1,o)),l=D(this.theme,i.fill),l&&(t.fillStyle=l,t.fillRect(r-1,s-1,n+1,o+1)),l=D(this.theme,a[6].fill),l&&(t.fillStyle=l,t.fillRect(r+n-1,s-1,1,o+1)),l=D(this.theme,a[2].fill),l&&(t.fillStyle=l,t.fillRect(r-1,s+o-1,n+1,1)),a[6].border_top&&!a[6].border_left&&(t.fillStyle=D(this.theme,a[6].border_top_fill,1),t.fillRect(r+n-1,s-2+a[6].border_top,1,1)),a[9].border_left&&(t.fillStyle=D(this.theme,a[9].border_left_fill,1),t.fillRect(r+n-1,s-1,1,1)),a[9].border_bottom&&(t.fillStyle=D(this.theme,a[9].border_bottom_fill,1),t.fillRect(r+n-1,s-2+a[9].border_bottom,1,1)),a[4].border_top&&!a[4].border_right&&(t.fillStyle=D(this.theme,a[4].border_right_fill,1),t.fillRect(r-1,s-2+a[4].border_top,1,1)),a[7].border_right&&(t.fillStyle=D(this.theme,a[7].border_right_fill,1),t.fillRect(r-1,s-1,1,1)),a[7].border_bottom&&(t.fillStyle=D(this.theme,a[7].border_bottom_fill,1),t.fillRect(r-1,s-2+a[7].border_bottom,1,1)),a[6].border_bottom&&!a[6].border_left&&(t.fillStyle=D(this.theme,a[6].border_bottom_fill,1),t.fillRect(r+n-1,s+o-a[6].border_bottom,1,1)),a[3].border_left&&(t.fillStyle=D(this.theme,a[3].border_left_fill,1),t.fillRect(r+n-1,s+o-1,1,1)),a[3].border_top&&(t.fillStyle=D(this.theme,a[3].border_top_fill,1),t.fillRect(r+n-1,s+o-a[3].border_top,1,1)),a[4].border_bottom&&!a[4].border_right&&(t.fillStyle=D(this.theme,a[4].border_bottom_fill,1),t.fillRect(r-1,s+o-a[4].border_bottom,1,1)),a[1].border_right&&(t.fillStyle=D(this.theme,a[1].border_right_fill,1),t.fillRect(r-1,s+o-1,1,1)),a[1].border_top&&(t.fillStyle=D(this.theme,a[1].border_top_fill,1),t.fillRect(r-1,s+o-a[1].border_top,1,1)),a[8].border_bottom&&(t.fillStyle=D(this.theme,a[8].border_bottom_fill,1),a[8].border_bottom===2&&(t.fillRect(r-1,s-2,n+1,1),t.fillRect(r-1,s-0,n+1,1),t.fillStyle=D(this.theme,a[8].fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s-1,n+1,1)),a[4].border_right&&(t.fillStyle=D(this.theme,a[4].border_right_fill,1),t.fillRect(r-1,s-1,1,o+1)),a[6].border_left&&(t.fillStyle=D(this.theme,a[4].border_left_fill,1),t.fillRect(r+n-1,s-1,1,o+1)),a[2].border_top&&(t.fillStyle=D(this.theme,a[2].border_top_fill,1),a[2].border_top===2&&(t.fillRect(r-1,s+o-2,n+1,1),t.fillRect(r-1,s+o-0,n+1,1),t.fillStyle=D(this.theme,a[2].fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s+o-1,n+1,1)),i.border_top&&(t.fillStyle=D(this.theme,i.border_top_fill,1),i.border_top===2&&(t.fillRect(r-1,s-2,n+1,1),t.fillRect(r-1,s+0,n+1,1),t.fillStyle=D(this.theme,i.fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s-1,n+1,1)),i.border_left&&(t.fillStyle=D(this.theme,i.border_left_fill,1),t.fillRect(r-1,s-1,1,o+1)),i.border_right&&(t.fillStyle=D(this.theme,i.border_right_fill,1),t.fillRect(r+n-1,s-1,1,o+1)),i.border_bottom&&(t.fillStyle=D(this.theme,i.border_bottom_fill,1),i.border_bottom===2&&(t.fillRect(r-1,s+o-2,n+1,1),t.fillRect(r-1,s+o+0,n+1,1),t.fillStyle=D(this.theme,i.fill)||fe(this.theme,this.theme.grid_cell?.fill)||"#fff"),t.fillRect(r-1,s+o-1,n+1,1))}RenderCellBackground(e,t,i,r,s,n){i.fillStyle=this.theme.grid_color,i.fillRect(0,0,s,n);let o=D(this.theme,r.fill);o?(i.fillStyle=o,i.fillRect(0,0,s-1,n-1)):(i.fillStyle=fe(this.theme,this.theme.grid_cell?.fill)||"#fff",i.fillRect(0,0,s-1,n-1)),e&&(i.fillStyle=this.theme.note_marker_color,i.beginPath(),i.moveTo(s-2,1),i.lineTo(s-2-8,1),i.lineTo(s-2,1+8),i.lineTo(s-2,1),i.fill()),this.RenderCellBorders(t,i,r,0,0,s,n)}RenderCell(e,t,i,r,s,n){let o={},a=!t.render_clean[this.view.view_index];if(t.render_clean[this.view.view_index]=!0,e.needs_full_repaint&&t.renderer_data?.overflowed)return{};let l=t.style?{...t.style}:{};if(t.merge_area)if(r.row===t.merge_area.start.row&&r.column===t.merge_area.start.column){for(let k=t.merge_area.start.column+1;k<=t.merge_area.end.column;k++)s+=this.layout.ColumnWidth(k);for(let k=t.merge_area.start.row+1;k<=t.merge_area.end.row;k++)n+=this.layout.RowHeight(k);if(t.merge_area.count>1){let k=this.view.active_sheet.CellStyleData(t.merge_area.end);k&&(l.border_bottom=k.border_bottom,l.border_right=k.border_right,l.border_bottom_fill=k.border_bottom_fill,l.border_right_fill=k.border_right_fill)}t.merge_area.end.column>e.last_cell.column&&(o.tile_overflow_right=!0),t.merge_area.end.row>e.last_cell.row&&(o.tile_overflow_bottom=!0),(o.tile_overflow_bottom||o.tile_overflow_right)&&this.overflow_areas.push({tile:e,head:{...r},area:new g(t.merge_area.start,t.merge_area.end)})}else return{};let d=!!t.hyperlink;if(t.render_function){this.RenderCellBackground(!!t.note,r,i,l,s,n),i.strokeStyle=i.fillStyle=D(this.theme,l.text,1);let k=this.ResolveColors(l);if(t.render_function.call(void 0,{width:s,height:n,context:i,cell:t,style:k,scale:this.layout.scale||1}).handled)return o}let u={base:A.Font(l,this.layout.scale),strong:A.Font({...l,bold:!0},this.layout.scale),emphasis:A.Font({...l,italic:!0},this.layout.scale),strong_emphasis:A.Font({...l,bold:!0,italic:!0},this.layout.scale)};if(i.font=u.base,a||!t.renderer_data||t.renderer_data.width!==s||t.renderer_data.height!==n){let k=this.PrepText(i,u,t,s);t.renderer_data={text_data:k,width:s,height:n}}let h=t.renderer_data.text_data,p=h.width>s-2*this.cell_edge_buffer,f=s,m=0,b=!1,_=t.type===3||t.calculated_type===3||t.type===7||t.calculated_type===7||t.type===9||t.calculated_type===9,y=l.horizontal_align;y||(y=_?A.HorizontalAlign.Right:A.HorizontalAlign.Left);let x=[];if(p)if(t.type!==3&&t.calculated_type!==3&&!l.wrap&&!t.merge_area){let W=h.width-s+this.cell_edge_buffer,ae=0,Z=0;y===A.HorizontalAlign.Center?ae=Z=W/2:y===A.HorizontalAlign.Right?ae=W:Z=W;let he=r.column,pe=r.column;for(;Z>0&&he<this.layout.last_column;){he++;let $={row:r.row,column:he},F=this.view.active_sheet.CellData($),ie=this.layout.ColumnWidth(he);if(Z-=ie,F&&!F.type&&!F.calculated_type)x.push({address:$,cell:F,grid:new z(f,0,ie,n),background:new z(f-1,0,ie,n-1),border:new z(f,0,ie,n)}),f+=ie,F.render_clean[this.view.view_index]=!0,F.renderer_data={overflowed:!0};else{b=!0;break}}for(he>e.last_cell.column&&(o.tile_overflow_right=!0);ae>0&&pe>=1;){pe--;let $={row:r.row,column:pe},F=this.view.active_sheet.CellData($),ie=this.layout.ColumnWidth(pe);if(ae-=ie,F&&!F.type&&!F.calculated_type)m-=ie,x.push({address:$,cell:F,grid:new z(m,0,ie,n),background:new z(m,0,ie,n-1),border:new z(m,0,ie,n)});else{b=!0;break}}pe<e.first_cell.column&&(o.tile_overflow_left=!0),this.overflow_areas.push({head:{...r},tile:e,area:new g({row:r.row,column:pe},{row:r.row,column:he})})}else b=!_;let v=!1,w=i;(o.tile_overflow_bottom||o.tile_overflow_left||o.tile_overflow_right)&&(v=!0,o.width=f-m,o.height=n,o.left=m,this.EnsureBuffer(o.width+1,n+1,-m),i=this.buffer_context,i.font=u.base),this.RenderCellBackground(!!t.note,r,i,l,s,n);for(let k of x)k.cell.style?.fill&&(k.cell.style.fill.text||k.cell.style.fill.theme||k.cell.style.fill.theme===0)&&!this.options.grid_over_background?(i.fillStyle=fe(this.theme,k.cell.style.fill),i.fillRect(k.grid.left,k.grid.top,k.grid.width,k.grid.height)):(i.fillStyle=this.theme.grid_color||"",i.fillRect(k.grid.left,k.grid.top,k.grid.width,k.grid.height),i.fillStyle=this.theme.grid_cell?.fill?fe(this.theme,this.theme.grid_cell.fill):"",i.fillRect(k.background.left,k.background.top,k.background.width,k.background.height)),k.cell.style&&this.RenderCellBorders(k.address,i,k.cell.style,k.border.left,k.border.top,k.border.width,k.border.height);let C=Nt.Get(u.base,this.theme.grid_cell?.font_size?.value);i.lineWidth=1,i.strokeStyle=i.fillStyle=h.format?h.format:D(this.theme,l.text,1),i.beginPath();let S=this.cell_edge_buffer,U=1.25,J=h.strings.length,oe=J*C.block*U;b=(b||oe>=n)&&!v,b&&(i.save(),i.beginPath(),i.moveTo(m+1.5,0),i.lineTo(m+1.5,n),i.lineTo(f-1.5,n),i.lineTo(f-1.5,0),i.clip()),i.beginPath();let R=Math.round(n-2-C.block*U*(J-1)+Er);switch(l.vertical_align){case A.VerticalAlign.Top:R=Math.round(C.block*U)+1;break;case A.VerticalAlign.Middle:R=Math.round((n-oe)/2+C.block*U);break}if((t.type===3||t.calculated_type===3||t.type===7||t.calculated_type===7)&&p){let k=Math.floor((s-2*this.cell_edge_buffer)/C.hash),W="";for(let Z=0;Z<k;Z++)W+="#";let ae=i.measureText(W).width;y===A.HorizontalAlign.Center?S=Math.round((s-ae)/2):y===A.HorizontalAlign.Right&&(S=s-this.cell_edge_buffer-ae),i.fillText(W,S,R)}else{let k=R,W=0;for(let ae of h.strings){let Z=0;for(let F of ae)Z+=F.width;y===A.HorizontalAlign.Center?S=Math.round((s-Z)/2):y===A.HorizontalAlign.Right&&(S=s-this.cell_edge_buffer-Z);let he=Math.floor(k+1.5-C.descender-Er)+.5,pe=Math.floor(k-C.descender-C.ascender/2)+.5,$=S;for(let F of ae)F.strong&&F.emphasis?i.font=u.strong_emphasis:F.strong?i.font=u.strong:F.emphasis?i.font=u.emphasis:i.font=u.base,F.hidden||(F.text&&i.fillText(F.text,$,k),l.underline&&(i.moveTo($,he),i.lineTo($+F.width,he)),(l.strike||F.strike)&&(i.moveTo($,pe),i.lineTo($+F.width,pe)),d&&(F.left=$,F.top=k-C.block,F.height=C.block)),$+=F.width;W++,k=Math.round(R+W*C.block*U)}}if(i.stroke(),b)i.restore();else if(v){let k=this.layout.dpr;w.drawImage(this.buffer_canvas,0,0,(o.width||0)*k,n*k,m,0,o.width||0,n)}return o}};var Gt=class extends Fe{constructor(t,i,r,s,n,o,a){super(i,r,s,n,a);this.container=t;this.options=o;let l=V.CreateDiv("treb-formula-bar-container notranslate",t),d=V.CreateDiv("treb-formula-bar",l);this.address_label_container=V.CreateDiv("address-label",d),this.address_label=V.CreateDiv("",this.address_label_container),this.InitAddressLabel(),this.options.insert_function_button&&(this.button=V.Create("button","formula-button",d),this.button.addEventListener("click",()=>{let h=this.editor_node&&this.editor_node.textContent||"";this.Publish({type:"formula-button",formula:h})})),this.container_node=V.CreateDiv("editor-container",d),this.editor_node=V.CreateDiv("formula-editor",this.container_node),this.editor_node.setAttribute("contenteditable","true");let u=!1;this.editor_node.spellcheck=!1,this.editor_node.addEventListener("focusin",()=>{if(!this.editor_node)return;let h=this.editor_node.textContent||"";h[0]==="{"&&h[h.length-1]==="}"&&(h=h.substr(1,h.length-2),this.editor_node.textContent=h,this.last_reconstructed_text=""),this.editor_node.spellcheck=h[0]!=="=",this.autocomplete.ResetBlock(),se().then(()=>{this.Reconstruct()});let p=this.ListDependencies();this.Publish([{type:"start-editing",editor:"formula-bar"},{type:"update",text:h,cell:this.active_cell,dependencies:p}]),this.focused_=!0,u=!1}),this.editor_node.addEventListener("focusout",()=>{this.selecting&&console.info("focusout, but selecting..."),this.autocomplete.Hide(),this.Publish([{type:"stop-editing"}]),this.focused_=!1,this.editor_node&&(this.editor_node.spellcheck=!1)}),this.editor_node.addEventListener("keydown",h=>this.FormulaKeyDown(h)),this.editor_node.addEventListener("keyup",h=>this.FormulaKeyUp(h)),this.editor_node.addEventListener("compositionstart",()=>{u=!0}),this.editor_node.addEventListener("compositionsend",()=>{u=!1}),this.editor_node.addEventListener("input",()=>{u||(this.Reconstruct(),this.UpdateSelectState())}),this.options.expand_formula_button&&(this.expand_button=V.Create("button","expand-button",d),this.expand_button.addEventListener("click",h=>{h.stopPropagation(),h.preventDefault(),this.editor_node&&(this.editor_node.scrollTop=0),d.classList.toggle("expanded")}))}focused_=!1;get focused(){return this.focused_}address_label_container;address_label;button;expand_button;drag_corner;lines=1;last_formula="";label_update_timer=0;get formula(){return this.editor_node&&this.editor_node.textContent||""}set formula(t){this.editor_node&&(this.editor_node.textContent=t,this.last_reconstructed_text=""),this.last_formula=t}get label(){return this.address_label?.textContent||""}set label(t){t.trim().length?(this.address_label.textContent=t,this.label_update_timer||(this.label_update_timer=requestAnimationFrame(()=>{this.label_update_timer=0,this.address_label.scrollWidth>this.address_label.offsetWidth?this.address_label.setAttribute("title",t):this.address_label.removeAttribute("title")}))):(this.address_label.innerHTML=" ",this.address_label.removeAttribute("title"))}set editable(t){!this.editor_node||!this.container_node||(this.editor_node.setAttribute("contenteditable",t.toString()),t?this.container_node.classList.remove("locked"):this.container_node.classList.add("locked"))}IsElement(t){return t===this.editor_node}InitAddressLabel(){this.address_label.contentEditable="true",this.address_label.spellcheck=!1,this.address_label.addEventListener("focusin",t=>{requestAnimationFrame(()=>{if(document.body.createTextRange){let i=document.body.createTextRange();i.moveToElementText(this.address_label),i.select()}else{let i=window.getSelection(),r=document.createRange();r.selectNodeContents(this.address_label),i?.removeAllRanges(),i?.addRange(r)}})}),this.address_label.addEventListener("keydown",t=>{switch(t.key){case"Enter":t.stopPropagation(),t.preventDefault(),this.Publish({type:"address-label-event",text:this.address_label.textContent||void 0});break;case"Esc":case"Escape":t.stopPropagation(),t.preventDefault(),this.Publish({type:"address-label-event"});break}})}FocusEditor(){this.editor_node&&this.editor_node.focus()}GetTextContent(t){let i=t.childNodes,r=[];for(let s=0;s<i.length;s++){let n=i[s];switch(n.nodeType){case Node.ELEMENT_NODE:r.push(...this.GetTextContent(n)),n instanceof Element&&n.tagName==="DIV"&&r.push(`
|
|
6
6
|
`);break;case Node.TEXT_NODE:n.nodeValue&&r.push(n.nodeValue);break}}return r}FormulaKeyDown(t){let i=this.autocomplete.HandleKey("keydown",t);if(i.accept&&this.AcceptAutocomplete(i),!i.handled){switch(t.key){case"Enter":case"Tab":{this.selecting_=!1;let r=t.key==="Enter"&&t.ctrlKey&&t.shiftKey,s=(this.editor_node?this.GetTextContent(this.editor_node).join(""):"").trim();this.Publish({type:"commit",selection:this.selection,value:s,event:t,array:r}),this.FlushReference()}break;case"Escape":case"Esc":this.selecting_=!1,this.Publish({type:"discard"}),this.FlushReference();break;default:return}t.stopPropagation(),t.preventDefault()}}FormulaKeyUp(t){this.autocomplete.HandleKey("keyup",t).handled||this.FlushReference()}};var at=class{constructor(e={}){this.options=e;this.completion_list=V.CreateDiv("treb-cell-editor-ac-list treb-autocomplete",e.container||document.body),this.completion_list.addEventListener("mousedown",t=>this.ListMouseDown(t)),this.completion_list.addEventListener("mousemove",t=>this.ListMouseMove(t)),this.tooltip=V.CreateDiv("treb-cell-editor-ac-tooltip treb-autocomplete-tooltip",e.container||document.body)}completion_list_visible=!1;tooltip_visible=!1;last_completion;completion_list;tooltip;selected_index=0;block=!1;autocomplete_data={};callback;active_element;Hide(){this.tooltip.style.top="-1000px",this.completion_list.style.top="-1000px",this.completion_list_visible=!1,this.tooltip_visible=!1,this.active_element=void 0}ResetBlock(){this.block=!1}ListMouseMove(e){let t=e.target;t.tagName==="A"&&t!==this.active_element&&this.active_element&&(this.active_element.classList.remove("selected"),this.active_element=t,this.active_element.classList.add("selected"),this.selected_index=Number(t.dataset.index||"0"),this.last_completion=t.textContent||"")}ListMouseDown(e){e.stopPropagation(),e.preventDefault();let t=e.target;for(;t;){if(t===this.completion_list)return;if(t.tagName==="A")break;t=t.parentElement}!t||(console.info(t),this.callback&&this.callback({handled:!0,accept:!0,value:t.textContent?t.textContent:void 0,data:this.autocomplete_data,click:!0}))}HandleKey(e,t){if(!this.completion_list_visible)return{handled:!1};let i=0,r=!1,s=!1;switch(t.key){case"Up":case"ArrowUp":i=-1;break;case"Down":case"ArrowDown":i=1;break;case"Tab":s=!0;break;case"Escape":case"Esc":r=!0;break;default:return{handled:!1}}if(t.stopPropagation(),t.preventDefault(),e==="keyup")return{handled:!0};if(i){let n=this.completion_list.getBoundingClientRect();this.selected_index+=i,this.selected_index=Math.max(0,this.selected_index);let o=this.completion_list.querySelectorAll("a");this.selected_index=Math.min(this.selected_index,o.length-1);for(let a=0;a<o.length;a++){let l=o[a];if(a===this.selected_index){l.classList.add("selected"),this.active_element=l;let d=l.getBoundingClientRect();d.top<n.top?this.completion_list.scrollBy(0,-d.height):d.bottom>n.bottom&&this.completion_list.scrollBy(0,d.height),this.last_completion=l.textContent||void 0}else l.classList.remove("selected")}return{handled:!0}}else{if(r)return this.block=!0,this.Hide(),{handled:!0};if(s)return{handled:!0,accept:!0,value:this.last_completion,data:this.autocomplete_data}}return{handled:!1}}Show(e,t={},i){if(this.completion_list_visible=!1,this.tooltip_visible=!1,this.autocomplete_data=t,this.callback=e,!this.block)if(t.tooltip?(this.tooltip.innerHTML=t.tooltip+t.arguments+(t.description?`
|
|
7
7
|
`+t.description:""),this.tooltip.style.left=i.left+"px",this.options.tooltip_prefer_top?this.tooltip.style.top=i.top-this.tooltip.offsetHeight-5+"px":this.tooltip.style.top=i.bottom+5+"px",this.tooltip_visible=!0):this.tooltip.style.top="-1000px",t.completions&&t.completions.length){this.tooltip.style.top="-1000px",this.selected_index=0,this.completion_list.innerHTML='<ul class="notranslate">'+t.completions.map((o,a)=>(o.name===this.last_completion&&(this.selected_index=a),`<li><a data-index="${a}">${o.name}</a></li>`)).join(`
|
|
8
|
-
`)+"<ul>";let r=this.completion_list.offsetHeight,s=!1;this.options.autocomplete_prefer_top?s=i.top>=200:document.documentElement&&Math.max(document.documentElement.clientHeight,window.innerHeight||0)-i.bottom<200&&(s=!0),s?this.completion_list.style.top=i.top-r-5+"px":this.completion_list.style.top=i.bottom+5+"px",this.completion_list.style.left=i.left+"px";let n=this.completion_list.querySelectorAll("a");this.active_element=n[this.selected_index],n[this.selected_index].classList.add("selected"),this.last_completion=n[this.selected_index].textContent||void 0,this.completion_list.scrollTop=this.active_element.offsetTop,this.completion_list_visible=!0}else this.completion_list.style.top="-1000px"}};var lt=(R=>(R[R.Null=0]="Null",R[R.InsertRows=1]="InsertRows",R[R.InsertColumns=2]="InsertColumns",R[R.ResizeRows=3]="ResizeRows",R[R.ResizeColumns=4]="ResizeColumns",R[R.Select=5]="Select",R[R.SetRange=6]="SetRange",R[R.UpdateStyle=7]="UpdateStyle",R[R.UpdateBorders=8]="UpdateBorders",R[R.MergeCells=9]="MergeCells",R[R.UnmergeCells=10]="UnmergeCells",R[R.Clear=11]="Clear",R[R.UpdateTheme=12]="UpdateTheme",R[R.SetNote=13]="SetNote",R[R.SetLink=14]="SetLink",R[R.Freeze=15]="Freeze",R[R.SetName=16]="SetName",R[R.ShowHeaders=17]="ShowHeaders",R[R.AddSheet=18]="AddSheet",R[R.DuplicateSheet=19]="DuplicateSheet",R[R.DeleteSheet=20]="DeleteSheet",R[R.ActivateSheet=21]="ActivateSheet",R[R.RenameSheet=22]="RenameSheet",R[R.ReorderSheet=23]="ReorderSheet",R[R.ShowSheet=24]="ShowSheet",R[R.DataValidation=25]="DataValidation",R[R.Reset=26]="Reset",R))(lt||{});var kr={scrollbars:!0,in_cell_editor:!0,formula_bar:!0,add_tab:!1,tab_bar:"auto",insert_function_button:!1,expand_formula_button:!1,expand:!0,repaint_on_cell_change:!0,grid_over_background:!1};var ct=class{grid_events=new Q;command_log=new Q;model;view;get active_sheet(){return this.view.active_sheet}set active_sheet(e){this.view.active_sheet=e}get view_index(){return this.view.view_index}batch=!1;batch_events=[];autocomplete_matcher=new zt;flags={};options;parser;constructor(e={},t,i){this.model=i,this.view={active_sheet:this.model.sheets.list[0],view_index:this.model.view_count++},this.parser=t,this.options={...kr,...e}}UpdateSheets(e,t=!1,i){j.Reset();let r=e.map(s=>j.FromJSON(s,this.model.theme_style_properties));if(r.length===0&&r.push(j.Blank(this.model.theme_style_properties)),this.model.sheets.Assign(r),this.ResetMetadata(),this.active_sheet=r[0],i){let s=this.model.sheets.Find(i);s&&(this.active_sheet=s)}}SetAutocompleteFunctions(e){let t=[];for(let r of this.model.named_expressions.keys())t.push({name:r,type:0});let i=e.slice(0).concat(this.model.named_ranges.List().map(r=>({name:r.name,type:1})),t);this.autocomplete_matcher.SetFunctions(i)}ResetMetadata(){this.model.document_name=void 0,this.model.user_data=void 0}Serialize(e={}){let t=this.model.sheets.list.map(s=>s.toJSON(e)),i;if(this.model.macro_functions.size){i=[];for(let s of this.model.macro_functions.values())i.push({...s,expression:void 0})}let r=[];if(this.model.named_expressions)for(let[s,n]of this.model.named_expressions){this.parser.Walk(n,a=>{if(a.type==="address"||a.type==="range"){let l=a.type==="range"?a.start:a;if(l.absolute_column=l.absolute_row=!0,!l.sheet){if(l.sheet_id){let d=this.model.sheets.Find(l.sheet_id);d&&(l.sheet=d.name)}l.sheet||(l.sheet=this.active_sheet.name)}return a.type==="range"&&(a.end.absolute_column=a.end.absolute_row=!0),!1}return!0});let o=this.parser.Render(n,void 0,"");r.push({name:s,expression:o})}return{sheet_data:t,active_sheet:this.active_sheet.id,named_ranges:this.model.named_ranges.Count()?this.model.named_ranges.Serialize():void 0,macro_functions:i,named_expressions:r.length?r:void 0}}ResizeColumnsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.column;if(typeof i>"u"){i=[];for(let r=0;r<t.columns;r++)i.push(r)}if(typeof i=="number"&&(i=[i]),e.width)for(let r of i)t.SetColumnWidth(r,e.width);else console.error("auto size not supported")}ResizeRowsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.row;if(typeof i>"u"){i=[];for(let r=0;r<t.rows;r++)i.push(r)}if(typeof i=="number"&&(i=[i]),e.height)for(let r of i)t.SetRowHeight(r,e.height);else console.error("auto size not supported")}ResetInternal(){j.Reset(),this.UpdateSheets([],!0),this.model.named_ranges.Reset(),this.model.named_expressions.clear(),this.model.macro_functions.clear()}SetValidationInternal(e){let t,i=this.FindSheet(e.area);if(i&&(t=i.cells.GetCell(e.area,!0)),!t)throw new Error("invalid cell in set validation");e.range?t.validation={type:2,area:e.range,error:!!e.error}:e.list?t.validation={type:0,list:JSON.parse(JSON.stringify(e.list)),error:!!e.error}:t.validation=void 0}GetValidationRange(e){let t,i=this.FindSheet(e);if(i){t=[],e=i.RealArea(new g(e.start,e.end),!0);for(let r=e.start.row;r<=e.end.row;r++)for(let s=e.start.column;s<=e.end.column;s++){let n=i.CellData({row:r,column:s});n&&n.formatted&&(typeof n.formatted=="string"?t.push(n.formatted):t.push(X.FormatPartsAsText(n.formatted)))}}return t}DeleteSheetInternal(e){let t=!1,i=-1,r="",s=!1,n=e.name?e.name.toLowerCase():"",o=this.model.sheets.list.filter((a,l)=>l===e.index||a.id===e.id||a.name.toLowerCase()===n?(t=a===this.active_sheet,this.model.named_ranges.RemoveRangesForSheet(a.id),r=a.name,i=l,!1):!0);if(r&&this.RenameSheetReferences(o,r,"#REF")>0&&(s=!0),!o.length)o.push(j.Blank(this.model.theme_style_properties)),i=0;else if(o.every(a=>!a.visible))o.unshift(j.Blank(this.model.theme_style_properties)),i=0;else for(i>=o.length&&(i=0);!o[i].visible;)i++;return this.model.sheets.Assign(o),t&&this.ActivateSheetInternal({key:21,index:i}),s}RenameSheetInternal(e,t){if(!t||cr.test(t))throw new Error("invalid sheet name");let i=t.toLowerCase();for(let s of this.model.sheets.list)if(s!==e&&s.name.toLowerCase()===i)throw new Error("sheet name already exists");let r=e.name;e.name=t,this.model.sheets.Assign(this.model.sheets.list),this.RenameSheetReferences(this.model.sheets.list,r,t)}SetRangeInternal(e,t={}){let i=P(e.area)?new g(e.area):new g(e.area.start,e.area.end),r=this.FindSheet(i);if(i.start.sheet_id||(i.start.sheet_id=r.id),!i.entire_row&&!i.entire_column&&(i.end.row>=r.rows||i.end.column>=r.columns)&&(r.cells.EnsureCell(i.end),r===this.active_sheet&&(t.layout=!0)),P(e.area)){let s=r.CellData(e.area);if(s.area&&(s.area.rows>1||s.area.columns>1)){this.Error(2);return}let n=Array.isArray(e.value)?Array.isArray(e.value[0])?e.value[0][0]:e.value[0]:e.value;return e.r1c1&&(n=this.TranslateR1C1(e.area,n)),e.array?r.SetArrayValue(i,n):r.SetCellValue(e.area,n),i}else{if(e.array){let s=Array.isArray(e.value)?Array.isArray(e.value[0])?e.value[0][0]:e.value[0]:e.value;e.r1c1&&(s=this.TranslateR1C1(i.start,s)),r.SetArrayValue(i,s)}else{if(e.r1c1){if(Array.isArray(e.value))for(let s=0;s<e.value.length&&s<i.rows;s++){e.value[s]||(e.value[s]=[]);let n=e.value[s];for(let o=0;o<n.length&&o<i.columns;o++){let a={...i.start,row:i.start.row+s,column:i.start.column+o};n[o]=this.TranslateR1C1(a,n[o])}}else if(typeof e.value=="string"&&e.value[0]==="="){let s=[];for(let n=0;n<i.rows;n++){let o=[];for(let a=0;a<i.columns;a++){let l={...i.start,row:i.start.row+n,column:i.start.column+a};o.push(this.TranslateR1C1(l,e.value))}s.push(o)}e.value=s}}r.SetAreaValues2(i,e.value)}return i}}ActivateSheetInternal(e){let t=this.ResolveSheet(e)||this.model.sheets.list[0];if(this.active_sheet===t&&!e.force)return;if(!t.visible)throw new Error("cannot activate hidden sheet");let i=this.active_sheet;this.active_sheet=t,this.grid_events.Publish({type:"sheet-change",deactivate:i,activate:this.active_sheet})}ShowSheetInternal(e){let t=this.ResolveSheet(e);if(!!t&&t.visible!==e.show){if(!e.show){let i=0;for(let r of this.model.sheets.list)(!t.visible||r===t)&&i++;if(i>=this.model.sheets.length)throw new Error("can't hide all sheets")}if(t.visible=e.show,t===this.active_sheet){let i=this.model.sheets.list;for(let r=0;r<i.length;r++)if(i[r]===this.active_sheet){for(let s=r+1;s<i.length;s++)if(i[s].visible){this.ActivateSheetInternal({key:21,index:s});return}for(let s=0;s<i.length;s++)if(i[s].visible){this.ActivateSheetInternal({key:21,index:s});return}throw new Error("no visible sheet")}}}}NormalizeCommands(e){Array.isArray(e)||(e=[e]);let t=this.active_sheet.id;for(let i of e)switch(i.key){case 0:case 17:case 24:case 18:case 19:case 20:case 21:case 22:case 23:case 26:break;case 3:case 4:case 2:case 1:case 15:i.sheet_id||(i.sheet_id=t);break;case 11:case 13:case 14:case 8:case 9:case 10:case 25:case 6:case 7:case 16:case 5:i.area&&(P(i.area)?i.area.sheet_id||(i.area.sheet_id=t):i.area.start.sheet_id||(i.area.start.sheet_id=t));break}return e}AddSheetInternal(e=j.default_sheet_name,t=-1){if(!this.options.add_tab){console.warn("add tab option not set or false");return}for(;this.model.sheets.list.some(r=>r.name===e);){let r=e.match(/^(.*?)(\d+)$/);r?e=r[1]+(Number(r[2])+1):e=e+"2"}let i=j.Blank(this.model.theme_style_properties,e);return t>=0?this.model.sheets.Splice(t,0,i):this.model.sheets.Add(i),i.id}ResolveSheet(e){if(typeof e.index<"u")return this.model.sheets.list[e.index];if(typeof e.name<"u")return this.model.sheets.Find(e.name);if(e.id)return this.model.sheets.Find(e.id)}FindSheet(e){if(e===void 0)return this.active_sheet;let t=typeof e=="number"?e:P(e)?e.sheet_id:e.start.sheet_id;if(!t||t===this.active_sheet.id)return this.active_sheet;let i=this.model.sheets.Find(t);return i||this.active_sheet}PatchFormulasInternal(e,t,i,r,s,n,o){let a=this.parser.Parse(e||""),l=!1;if(a.expression&&(this.parser.Walk(a.expression,d=>{if(d.type==="range"||d.type==="address"){let u=[];d.type==="range"?(d.start.sheet&&d.start.sheet.toLowerCase()===n||!d.start.sheet&&o)&&u.push(d.start,d.end):d.type==="address"&&(d.sheet&&d.sheet.toLowerCase()===n||!d.sheet&&o)&&u.push(d);for(let h of u)i&&h.row>=t&&(i<0&&h.row+i<t?h.column=h.row=-1:h.row+=i,l=!0),s&&h.column>=r&&(s<0&&h.column+s<r?h.column=h.row=-1:h.column+=s,l=!0);return!1}return!0}),l))return"="+this.parser.Render(a.expression,void 0,"")}RenameSheetReferences(e,t,i){let r=0;t=t.toLowerCase();for(let s of e){s.cells.IterateAll(n=>{if(n.ValueIsFormula()){let o=!1,a=this.parser.Parse(n.value||"");a.expression&&(this.parser.Walk(a.expression,l=>(l.type==="address"&&l.sheet&&l.sheet.toLowerCase()===t&&(l.sheet=i,o=!0),!0)),o&&(n.value="="+this.parser.Render(a.expression,void 0,""),r++))}});for(let n of s.annotations)if(n.formula){let o=!1,a=this.parser.Parse(n.formula||"");a.expression&&(this.parser.Walk(a.expression,l=>(l.type==="address"&&l.sheet&&l.sheet.toLowerCase()===t&&(l.sheet=i,o=!0),!0)),o&&(n.formula="="+this.parser.Render(a.expression,void 0,""),r++))}}return r}ApplyBordersInternal(e){let t=e.borders,i=e.borders==="none"?0:e.width,r=new g(e.area.start,e.area.end),s=this.FindSheet(r);r.start.sheet_id=s.id;let n={border_top:i},o={border_bottom:i},a={border_left:i},l={border_right:i},d={border_top:0},u={border_bottom:0},h={border_left:0},p={border_right:0};return e.color&&(n.border_top_fill={...e.color},o.border_bottom_fill={...e.color},a.border_left_fill={...e.color},l.border_right_fill={...e.color}),(t==="none"||t==="all")&&s.UpdateAreaStyle(r,{...n,...o,...a,...l},!0),(t==="top"||t==="outside")&&(r.entire_column||s.UpdateAreaStyle(r.top,{...n},!0)),(t==="none"||t==="all"||t==="outside"||t==="top")&&(r.entire_column||r.start.row&&s.UpdateAreaStyle(new g({row:r.start.row-1,column:r.start.column},{row:r.start.row-1,column:r.end.column}),{...u},!0)),(t==="bottom"||t==="outside")&&(r.entire_column||s.UpdateAreaStyle(r.bottom,{...o},!0)),(t==="none"||t==="all"||t==="outside"||t==="bottom")&&(r.entire_column||s.UpdateAreaStyle(new g({row:r.end.row+1,column:r.start.column},{row:r.end.row+1,column:r.end.column}),{...d},!0)),(t==="left"||t==="outside")&&(r.entire_row||s.UpdateAreaStyle(r.left,{...a},!0)),(t==="none"||t==="all"||t==="outside"||t==="left")&&(r.entire_row||r.start.column&&s.UpdateAreaStyle(new g({row:r.start.row,column:r.start.column-1},{row:r.end.row,column:r.start.column-1}),{...p},!0)),(t==="right"||t==="outside")&&(r.entire_row||s.UpdateAreaStyle(r.right,{...l},!0)),(t==="none"||t==="all"||t==="outside"||t==="right")&&(r.entire_row||s.UpdateAreaStyle(new g({row:r.start.row,column:r.end.column+1},{row:r.end.row,column:r.end.column+1}),{...h},!0)),g.Bleed(r)}TranslateR1C1(e,t){let i=!1,r=this.parser.flags.r1c1;if(this.parser.flags.r1c1=!0,typeof t=="string"&&t[0]==="="){let s=this.parser.Parse(t);s.expression&&(this.parser.Walk(s.expression,n=>(n.type==="address"&&n.r1c1&&(i=!0,n.offset_column&&(n.column=n.column+e.column),n.offset_row&&(n.row=n.row+e.row)),!0)),i&&(this.flags.warned_r1c1||(this.flags.warned_r1c1=!0,console.warn("NOTE: R1C1 support is experimental. the semantics may change in the future.")),t="="+this.parser.Render(s.expression)))}return this.parser.flags.r1c1=r,t}ClearAreaInternal(e){let t=!1;e=this.active_sheet.RealArea(e),this.active_sheet.cells.Apply(e,i=>{i.area&&!e.ContainsArea(i.area)&&(t=!0)}),t?this.Error(2):this.active_sheet.ClearArea(e)}Error(e){this.grid_events.Publish({type:"error",code:e})}DuplicateSheetInternal(e){if(!this.options.add_tab){console.warn("add tab option not set or false");return}let t=this.ResolveSheet(e),i=this.model.sheets.list.reduce((a,l)=>Math.max(a,l.id),0)+1,r=-1;for(let a=0;a<this.model.sheets.length;a++)this.model.sheets.list[a]===t&&(r=a+1);if(!t||r<0)throw new Error("source sheet not found");if(typeof e.insert_before=="number")r=e.insert_before;else if(typeof e.insert_before=="string"){let a=e.insert_before.toLowerCase();for(let l=0;l<this.model.sheets.length;l++)if(this.model.sheets.list[l].name.toLowerCase()===a){r=l;break}}let s={rendered_values:!0},n=j.FromJSON(t.toJSON(s),this.model.theme_style_properties),o=e.new_name||t.name;for(;this.model.sheets.list.some(a=>a.name===o);){let a=o.match(/^(.*?)(\d+)$/);a?o=a[1]+(Number(a[2])+1):o=o+"2"}return n.name=o,n.id=i,this.model.sheets.Splice(r,0,n),n.id}SelectInternal(e){}FreezeInternal(e){let t=this.FindSheet(e.sheet_id||this.active_sheet.id);t.freeze.rows=e.rows,t.freeze.columns=e.columns}InsertRowsInternal(e){let t=this.FindSheet(e.sheet_id);if(!t.InsertRows(e.before_row,e.count))return this.Error(2),{error:!0};this.model.named_ranges.PatchNamedRanges(t.id,0,0,e.before_row,e.count);let i=t.name.toLowerCase();for(let o of this.model.sheets.list){let a=o===t;o.cells.IterateAll(l=>{if(l.ValueIsFormula()){let d=this.PatchFormulasInternal(l.value||"",e.before_row,e.count,0,0,i,a);d&&(l.value=d)}});for(let l of o.annotations)if(l.formula){let d=this.PatchFormulasInternal(l.formula||"",e.before_row,e.count,0,0,i,a);d&&(l.formula=d)}}let r=[],s=[],n=[];if(e.count>0){let o=e.before_row;for(let a of t.annotations)if(a.layout){let[l,d,u]=[a.layout.tl.address.row,a.layout.br.address.row,a.layout.br.offset.y];if(o<=l)a.layout.tl.address.row+=e.count,a.layout.br.address.row+=e.count;else if(o<d||o===d&&u>0)a.layout.br.address.row+=e.count,s.push(a);else continue;r.push(a)}}else if(e.count<0){let o=e.before_row,a=e.before_row-e.count-1;for(let l of t.annotations)if(l.layout){let[d,u,h]=[l.layout.tl.address.row,l.layout.br.address.row,l.layout.br.offset.y];if(o<=d)if(a<d)l.layout.tl.address.row+=e.count,l.layout.br.address.row+=e.count;else if(a<u-1||a===u-1&&h>0)l.layout.tl.address.row=o,l.layout.tl.offset.y=0,l.layout.br.address.row+=e.count,s.push(l);else{n.push(l);continue}else if(o<u||o===u&&h>0)a<u-1||a===u-1&&h>0?(l.layout.br.address.row+=e.count,s.push(l)):(l.layout.br.address.row=o,l.layout.br.offset.y=0,s.push(l));else continue;r.push(l)}}for(let o of n)t.annotations=t.annotations.filter(a=>a!==o);return{update_annotations_list:r,resize_annotations_list:s,delete_annotations_list:n}}InsertColumnsInternal(e){let t=this.FindSheet(e.sheet_id);if(!t.InsertColumns(e.before_column,e.count))return this.Error(2),{error:!0};this.model.named_ranges.PatchNamedRanges(t.id,e.before_column,e.count,0,0);let i=t.name.toLowerCase();for(let o of this.model.sheets.list){let a=o===t;o.cells.IterateAll(l=>{if(l.ValueIsFormula()){let d=this.PatchFormulasInternal(l.value||"",0,0,e.before_column,e.count,i,a);d&&(l.value=d)}});for(let l of o.annotations)if(l.formula){let d=this.PatchFormulasInternal(l.formula,0,0,e.before_column,e.count,i,a);d&&(l.formula=d)}}let r=[],s=[],n=[];if(e.count>0){let o=e.before_column;for(let a of t.annotations)if(a.layout){let[l,d,u]=[a.layout.tl.address.column,a.layout.br.address.column,a.layout.br.offset.x];if(o<=l)a.layout.tl.address.column+=e.count,a.layout.br.address.column+=e.count;else if(o<d||o===d&&u>0)a.layout.br.address.column+=e.count,s.push(a);else continue;r.push(a)}}else if(e.count<0){let o=e.before_column,a=e.before_column-e.count-1;for(let l of t.annotations)if(l.layout){let[d,u,h]=[l.layout.tl.address.column,l.layout.br.address.column,l.layout.br.offset.x];if(o<=d)if(a<d)l.layout.tl.address.column+=e.count,l.layout.br.address.column+=e.count;else if(a<u-1||a===u-1&&h>0)l.layout.tl.address.column=o,l.layout.tl.offset.x=0,l.layout.br.address.column+=e.count,s.push(l);else{n.push(l);continue}else if(o<u||o===u&&h>0)a<u-1||a===u-1&&h>0?(l.layout.br.address.column+=e.count,s.push(l)):(l.layout.br.address.column=o,l.layout.br.offset.x=0,s.push(l));else continue;r.push(l)}}for(let o of n)t.annotations=t.annotations.filter(a=>a!==o);return{update_annotations_list:r,resize_annotations_list:s,delete_annotations_list:n}}ExecCommand(e,t=!0){let i={pending:[]},r=[];e=this.NormalizeCommands(e),t&&this.command_log.Publish({command:e,timestamp:new Date().getTime()});for(let s of e)switch(s.key){case 26:this.ResetInternal();break;case 11:if(s.area){let n=new g(s.area.start,s.area.end);this.ClearAreaInternal(n),i.data_area=g.Join(n,i.data_area),i.formula=!0}break;case 5:this.SelectInternal(s);break;case 15:this.FreezeInternal(s),i.structure_event=!0;break;case 9:{let n=this.FindSheet(s.area);n.MergeCells(new g(s.area.start,s.area.end)),i.structure_event=!0,i.structure_rebuild_required=!0,n===this.active_sheet?(i.data_area=g.Join(s.area,i.data_area),i.render_area=g.Join(s.area,i.render_area)):(i.data_event=!0,i.pending||(i.pending=[]),i.pending.push(n.id))}break;case 10:{let n=this.FindSheet(s.area),o={},a=new g(s.area.start,s.area.end);n.cells.Apply(a,d=>{if(d.merge_area){let u=g.CellAddressToLabel(d.merge_area.start)+":"+g.CellAddressToLabel(d.merge_area.end);o[u]=d.merge_area}},!1);let l=Object.keys(o);for(let d=0;d<l.length;d++)n.UnmergeCells(o[l[d]]);n===this.active_sheet?(i.render_area=g.Join(s.area,i.render_area),i.data_area=g.Join(s.area,i.data_area)):(i.data_event=!0,i.pending||(i.pending=[]),i.pending.push(n.id)),i.structure_event=!0,i.structure_rebuild_required=!0}break;case 7:{let n,o=this.FindSheet(s.area);P(s.area)?(n=new g(s.area),o.UpdateCellStyle(s.area,s.style,!!s.delta)):(n=new g(s.area.start,s.area.end),o.UpdateAreaStyle(n,s.style,!!s.delta)),o===this.active_sheet?(i.style_area=g.Join(n,i.style_area),(!s.delta||s.style.fill||s.style.border_top||s.style.border_left||s.style.border_right||s.style.border_bottom)&&(n=g.Bleed(n),this.active_sheet.Invalidate(n)),i.render_area=g.Join(n,i.render_area)):i.style_event=!0}break;case 25:this.SetValidationInternal(s),(!s.area.sheet_id||s.area.sheet_id===this.active_sheet.id)&&(i.render_area=g.Join(new g(s.area),i.render_area));break;case 16:s.area?(this.model.named_expressions.delete(s.name),this.model.named_ranges.SetName(s.name,new g(s.area.start,s.area.end)),this.autocomplete_matcher.AddFunctions({type:1,name:s.name})):s.expression?(this.model.named_ranges.ClearName(s.name),this.model.named_expressions.set(s.name,s.expression),this.autocomplete_matcher.AddFunctions({type:1,name:s.name})):(this.model.named_ranges.ClearName(s.name),this.model.named_expressions.delete(s.name),this.autocomplete_matcher.RemoveFunctions({type:1,name:s.name})),i.structure_event=!0,i.structure_rebuild_required=!0;break;case 8:{let n=this.ApplyBordersInternal(s);n.start.sheet_id===this.active_sheet.id?(i.render_area=g.Join(n,i.render_area),i.style_area=g.Join(n,i.style_area)):i.style_event=!0}break;case 24:this.ShowSheetInternal(s),i.sheets=!0,i.structure_event=!0;break;case 23:{let n=[],o=this.model.sheets.list[s.index];for(let a=0;a<this.model.sheets.length;a++)a!==s.index&&(a===s.move_before&&n.push(o),n.push(this.model.sheets.list[a]));s.move_before>=this.model.sheets.length&&n.push(o),this.model.sheets.Assign(n),i.sheets=!0,i.structure_event=!0}break;case 22:{let n=this.ResolveSheet(s);n&&(this.RenameSheetInternal(n,s.new_name),i.sheets=!0,i.structure_event=!0)}break;case 3:this.ResizeRowsInternal(s),i.structure_event=!0;break;case 4:this.ResizeColumnsInternal(s),i.structure_event=!0;break;case 17:this.active_sheet.SetHeaderSize(s.show?void 0:1,s.show?void 0:1),this.flags.layout=!0,this.flags.repaint=!0;break;case 1:this.InsertRowsInternal(s),i.structure_event=!0,i.structure_rebuild_required=!0;break;case 2:this.InsertColumnsInternal(s),i.structure_event=!0,i.structure_rebuild_required=!0;break;case 14:case 13:{let n=this.FindSheet(s.area),o=n.cells.GetCell(s.area,!0);if(o){let a;o.merge_area?(a=new g(o.merge_area.start),o=n.cells.GetCell(o.merge_area.start,!0)):a=new g(s.area),s.key===13?o.SetNote(s.note):(o.hyperlink=s.reference||void 0,o.render_clean=[]),n===this.active_sheet?(i.style_area=g.Join(a,i.style_area),i.render_area=g.Join(a,i.render_area)):i.style_event=!0}}break;case 6:{let n=this.SetRangeInternal(s,i);n&&n.start.sheet_id===this.active_sheet.id?(i.data_area=g.Join(n,i.data_area),this.options.repaint_on_cell_change&&(i.render_area=g.Join(n,i.render_area))):i.data_event=!0}break;case 20:this.DeleteSheetInternal(s),i.sheets=!0,i.structure_event=!0,i.structure_rebuild_required=!0;break;case 19:this.DuplicateSheetInternal(s),i.sheets=!0,i.structure_event=!0,i.structure_rebuild_required=!0;break;case 18:{let n=this.AddSheetInternal(s.name,s.insert_index);typeof n=="number"&&s.show&&this.ActivateSheetInternal({key:21,id:n}),i.structure_event=!0,i.sheets=!0,i.structure=!0}break;case 21:this.ActivateSheetInternal(s);break;default:console.warn(`unhandled command: ${lt[s.key]} (${s.key})`)}return i.data_area?(i.data_area.start.sheet_id||i.data_area.SetSheetID(this.active_sheet.id),r.push({type:"data",area:i.data_area})):i.data_event&&r.push({type:"data"}),i.style_area?(i.style_area.start.sheet_id||i.style_area.SetSheetID(this.active_sheet.id),r.push({type:"style",area:i.style_area})):i.style_event&&r.push({type:"style"}),i.structure_event&&r.push({type:"structure",rebuild_required:i.structure_rebuild_required}),this.batch?this.batch_events.push(...r):this.grid_events.Publish(r),i}};var dt=class extends ct{hide_selection=!1;headless=!1;get scale(){return this.layout.scale}set scale(e){this.layout.scale=e,this.UpdateLayout(),this.UpdateAnnotationLayout(),this.layout.UpdateAnnotation(this.active_sheet.annotations),this.layout.ApplyTheme(this.theme),this.overlay_editor?.UpdateTheme(e),this.tab_bar?.UpdateScale(e),this.grid_events.Publish({type:"scale",scale:e});for(let t of this.model.sheets.list)for(let i of t.annotations)i.dirty=!0}theme;language_map;reverse_language_map;hover_data={};editing_state=0;editing_cell={row:-1,column:-1,sheet_id:0};selected_annotation;editing_annotation;grid_container;container;layout;tile_update_pending=!1;scroll_offset_pending;pending_layout_update=new Set;decimal_separator_code=46;overlay_editor;formula_bar;RESIZE_PIXEL_BUFFER=5;select_argument=!1;cell_resize={row:-1,column:-1};render_tiles=new g({row:0,column:0});primary_selection={target:{row:0,column:0},area:new g({row:0,column:0}),empty:!0};active_selection={target:{row:0,column:0},area:new g({row:0,column:0}),empty:!0};nub_select_flag=!1;additional_selections=[];double_click_data={};layout_token=0;render_token=0;tile_renderer;selection_renderer;tab_bar;constructor(e={},t,i,r=wt){super(e,t,i),this.decimal_separator_code=T.decimal_separator.charCodeAt(0),this.theme=JSON.parse(JSON.stringify(r)),this.layout=new Ft(this.model,this.view),e.initial_scale&&(typeof e.initial_scale=="string"&&(e.initial_scale=Number(e.initial_scale)),this.layout.scale=e.initial_scale),this.tile_renderer=new Ot(this.theme,this.layout,this.model,this.view,this.options),this.selection_renderer=new Mt(this.theme,this.layout,this.model,this.view,this.primary_selection,this.additional_selections)}SetLanguageMap(e){if(!e)this.language_map=this.reverse_language_map=void 0;else{let t=Object.keys(e);this.language_map={};for(let i of t)this.language_map[i.toUpperCase()]=e[i];this.reverse_language_map={};for(let i of t){let r=e[i];this.reverse_language_map[r.toUpperCase()]=i}}this.primary_selection.empty||this.Select(this.primary_selection,this.primary_selection.area,this.primary_selection.target)}SetNote(e,t){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.target}this.ExecCommand({key:13,area:e,note:t})}SetLink(e,t){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.target}this.ExecCommand({key:14,area:e,reference:t})}FindAnnotation(e){for(let t of this.active_sheet.annotations)if((t.view[this.view_index]||{}).node===e)return t}CreateAnnotation(e={},t=!0,i=!1,r){let s=new Te(e);if(i)if(!s.layout&&s.scaled_rect&&(s.layout=this.layout.RectToAnnotationLayout(s.scaled_rect)),!s.layout)console.warn("can't offset annotation without layout");else{let n=this.layout.AnnotationLayoutToRect(s.layout).Shift(20,20),o=!0;for(;o;){o=!1;for(let a of this.active_sheet.annotations)if(a!==s&&a.scaled_rect&&a.scaled_rect.top===n.top&&a.scaled_rect.left===n.left){n=n.Shift(20,20),o=!0;break}}s.layout=this.layout.RectToAnnotationLayout(n)}return r&&(z.IsRectangle(r)?(s.layout=void 0,s.rect=z.Create(r)):r.start&&(s.rect=void 0,s.layout=this.layout.AddressToAnnotationLayout(r.start,r.end||r.start))),t&&(this.active_sheet.annotations.some(n=>n===s)||this.active_sheet.annotations.push(s),this.AddAnnotation(s)),s}UpdateAnnotationLayout(){}AddAnnotation(e,t=!1,i=!0){let r=e.view[this.view_index];if(r||(r={},e.view[this.view_index]=r),!r.node){r.node=document.createElement("div"),r.node.dataset.scale=this.layout.scale.toString(),r.node.style.fontSize=`${10*this.layout.scale}pt`,r.content_node=V.CreateDiv("annotation-content",r.node);let s=V.CreateDiv("annotation-move-target",r.node),n=V.CreateDiv("annotation-resize-target",r.node);if(r.node){let o=r.node;o.setAttribute("tabindex","-1"),o.addEventListener("mousedown",a=>{a.button===0&&this.layout.AnnotationMouseDown(e,o,a,s,n).then(l=>{l&&this.grid_events.Publish(l),e.layout&&this.EnsureAddress(e.layout.br.address,1)})}),o.addEventListener("focusin",()=>{for(let a of this.layout.GetFrozenAnnotations(e))a.classList.add("clone-focus");this.selected_annotation=e,this.primary_selection.empty=!0,this.primary_selection.target={row:-1,column:-1,sheet_id:this.active_sheet.id},this.HideGridSelection()}),o.addEventListener("focusout",a=>{for(let l of this.layout.GetFrozenAnnotations(e))l.classList.remove("clone-focus");this.formula_bar&&this.formula_bar.IsElement(a.relatedTarget)?(this.primary_selection.empty=!0,this.RenderSelections(),this.editing_annotation=e,this.layout.ShowSelections(!0)):(this.selected_annotation===e&&(this.selected_annotation=void 0),this.ShowGridSelection())}),o.addEventListener("keydown",a=>{let l=e.scaled_rect;if(!l){console.info("missing scaled rect!");return}let d=[o,...this.layout.GetFrozenAnnotations(e)],u={x:l.left,y:l.top};switch(a.key){case"ArrowUp":case"Up":a.ctrlKey?(this.layout.AnnotationLayoutOrder(e,1)&&this.grid_events.Publish({type:"annotation",event:"move",annotation:e}),o.focus()):u.y--;break;case"ArrowLeft":case"Left":if(a.ctrlKey)return;u.x--;break;case"ArrowRight":case"Right":if(a.ctrlKey)return;u.x++;break;case"ArrowDown":case"Down":a.ctrlKey?(this.layout.AnnotationLayoutOrder(e,-1)&&this.grid_events.Publish({type:"annotation",event:"move",annotation:e}),o.focus()):u.y++;break;case"Escape":case"Esc":this.Focus();break;case"Delete":case"Del":this.Focus(),this.RemoveAnnotation(e);break;default:return}if(a.stopPropagation(),a.preventDefault(),u.x=Math.max(u.x,0),u.y=Math.max(u.y,0),l.left!==u.x||l.top!==u.y){l.left=Math.round(u.x),l.top=Math.round(u.y);for(let h of d)h.style.top=l.top+"px",h.style.left=l.left+"px";e.extent=void 0,this.grid_events.Publish({type:"annotation",event:"move",annotation:e}),e.layout=this.layout.RectToAnnotationLayout(l)}})}}r.node.classList.add("annotation"),i&&(this.layout.AddAnnotation(e),e.layout&&this.EnsureAddress(e.layout.br.address,1)),t||this.grid_events.Publish({type:"annotation",annotation:e,event:"create"})}AnnotationUpdated(e){this.layout.CloneFrozenAnnotation(e)}RemoveAnnotation(e){for(let t=0;t<this.active_sheet.annotations.length;t++)if(e===this.active_sheet.annotations[t]){this.active_sheet.annotations.splice(t,1),this.layout.RemoveAnnotation(e),this.grid_events.Publish({type:"annotation",annotation:e,event:"delete"});return}}RemoveAnnotationNodes(){this.layout.RemoveAnnotationNodes()}Serialize(e={}){return this.active_sheet.selection=JSON.parse(JSON.stringify(this.primary_selection)),this.active_sheet.scroll_offset=this.layout.scroll_offset,super.Serialize(e)}Reset(){this.ExecCommand({key:26})}FromCSV(e){let t=this.parser.decimal_mark===",";t&&(this.parser.argument_separator=",",this.parser.decimal_mark=".");let r=dr(e).map(n=>n.map(o=>{if(o){let a=this.parser.Parse(o);if(a.expression?.type==="complex")return a.expression}return ye.TryParse(o).value}));t&&(this.parser.argument_separator=";",this.parser.decimal_mark=",");let s={row:Math.max(0,r.length-1),column:r.reduce((n,o)=>Math.max(n,Math.max(0,o.length-1)),0)};this.ExecCommand([{key:26},{key:6,area:{start:{row:0,column:0},end:s},value:r}])}ShowHeaders(e=!0){this.ExecCommand({key:17,show:e})}FromImportData(e,t=!1){this.RemoveAnnotationNodes();let i=e.sheets,r=i.map(()=>j.Blank(this.model.theme_style_properties).toJSON()),s;if(typeof e.active_tab=="number")s=r[e.active_tab]?.id;else for(let o=0;o<e.sheets.length;o++)if(!e.sheets[o].hidden){s=r[o].id;break}this.UpdateSheets(r,!0,s);let n={};this.model.macro_functions.clear(),this.ClearSelection(this.primary_selection);for(let o=0;o<i.length;o++){let a=this.model.sheets.list[o];a.ImportData(i[o]),n[a.name]=a.id}if(this.model.sheets.UpdateIndexes(),this.model.named_ranges.Reset(),this.model.named_expressions.clear(),e.names){for(let o of Object.keys(e.names)){let a=this.model.named_ranges.ValidateNamed(o);if(!a){console.warn(`invalid name: ${o}`);continue}let l=e.names[o];if(typeof l!="number"){let d=this.parser.Parse(l);if(d.expression)if(d.expression.type==="range"){let u=n[d.expression.start.sheet||""];u&&(d.expression.start.sheet_id=u,this.model.named_ranges.SetName(a,new g(d.expression.start,d.expression.end),!1))}else if(d.expression.type==="address"){let u=n[d.expression.sheet||""];u&&(d.expression.sheet_id=u,this.model.named_ranges.SetName(a,new g(d.expression),!1))}else{let u=d.expression;this.parser.Walk(u,h=>h.type==="address"||h.type==="range"?(h.type==="range"&&(h=h.start),h.sheet_id||(h.sheet_id=n[h.sheet||""]||0),!1):!0),this.model.named_expressions.set(a,u)}}}this.model.named_ranges.RebuildList()}for(let o of this.active_sheet.annotations)this.AddAnnotation(o,!0);this.QueueLayoutUpdate(),this.StyleDefaultFromTheme(),t&&this.Repaint(!1,!1),this.tab_bar&&this.tab_bar.Update()}NextSheet(e=1){if(this.model.sheets.length===1)return;let t=this.model.sheets.list.map((i,r)=>({sheet:i,index:r})).filter(i=>i.sheet.visible);if(t.length!==1){for(let i=0;i<t.length;i++)if(t[i].sheet===this.active_sheet){let r=(i+e)%t.length;for(;r<0;)r+=t.length;this.ActivateSheet(t[r].index);return}}}InsertSheet(e,t){if(typeof e>"u"&&!this.model.sheets.list.some((i,r)=>i===this.active_sheet?(e=r+1,!0):!1))throw new Error("invalid index");this.ExecCommand({key:18,insert_index:e,name:t,show:!0})}DeleteSheetID(e){this.ExecCommand({key:20,id:e})}DeleteSheet(e){if(typeof e>"u"&&!this.model.sheets.list.some((t,i)=>t===this.active_sheet?(e=i,!0):!1))throw new Error("invalid index");this.ExecCommand({key:20,index:e})}DuplicateSheet(e,t,i){let r={key:19,new_name:t,insert_before:i};typeof e>"u"?r.id=this.active_sheet.id:r.index=e,this.ExecCommand(r)}AddSheet(e){this.ExecCommand({key:18,name:e,show:!0})}ActivateSheet(e){let t=typeof e=="number"?e:void 0,i=typeof e=="string"?e:void 0;this.ExecCommand({key:21,index:t,name:i})}ActivateSheetID(e){this.ExecCommand({key:21,id:e})}ShowAll(){let e=[];for(let t=0;t<this.model.sheets.length;t++)e.push({key:24,index:t,show:!0});this.ExecCommand(e)}ShowSheet(e=0,t=!0){let i={key:24,show:t};typeof e=="string"?i.name=e:i.index=e,this.ExecCommand(i)}UpdateSheets(e,t=!1,i){if(super.UpdateSheets(e,t,i),this.RemoveAnnotationNodes(),this.ClearSelection(this.primary_selection),e[0]&&e[0].primary_selection){let r=e[0].primary_selection;r.empty||this.Select(this.primary_selection,new g(r.area.start,r.area.end),r.target)}else if(!this.active_sheet.selection.empty){let r=this.active_sheet.selection;this.Select(this.primary_selection,new g(r.area.start,r.area.end),r.target)}this.layout.ClearLayoutCaches();for(let r of this.model.sheets.list)for(let s of r.annotations)this.AddAnnotation(s,!0,r===this.active_sheet);this.QueueLayoutUpdate(JSON.parse(JSON.stringify(this.active_sheet.scroll_offset))),this.StyleDefaultFromTheme(),t&&this.Repaint(!1,!1),this.tab_bar&&this.tab_bar.Update()}UpdateLayout(){this.layout.UpdateTiles(),this.render_tiles=this.layout.VisibleTiles(),this.Repaint(!0)}UpdateTheme(e=!1,t){if(!e)for(let r of Object.keys(this.theme))delete this.theme[r];let i=JSON.parse(JSON.stringify(wt));this.grid_container&&(i={...sr(this.grid_container)}),i={...this.theme,...i,...t},Object.assign(this.theme,i),this.StyleDefaultFromTheme(),this.active_sheet.UpdateDefaultRowHeight(),this.active_sheet.FlushCellStyles(),this.layout.ApplyTheme(this.theme),e||(this.UpdateLayout(),this.overlay_editor?.UpdateTheme(this.layout.scale),this.Repaint(!0,!0,!0))}Initialize(e,t=!1){this.grid_container=e,e.classList.add("treb-main"),te.is_windows?e.classList.add("treb-ua-windows"):te.is_mac&&e.classList.add("treb-ua-osx"),e.classList.add("treb-theme"),this.UpdateTheme(!0);let i=document.createElement("div"),r=document.createElement("div");r.classList.add("treb-layout-master"),r.setAttribute("role","grid"),r.appendChild(i),e.appendChild(r);let s;this.options.formula_bar&&(s||(s=new at({theme:this.theme,container:i})),this.InitFormulaBar(e,s)),this.options.tab_bar&&(this.tab_bar=new Lt(this.layout,this.model,this.view,this.options,this.theme,e),this.tab_bar.Subscribe(n=>{switch(n.type){case"cancel":break;case"scale":{let o=this.layout.scale;if(o=Math.round(n.value*1e3)/1e3,o=Math.min(2,Math.max(o,.5)),this.options.persist_scale_key&&localStorage.setItem(this.options.persist_scale_key,JSON.stringify({scale:o})),this.scale=o,n.keep_focus)return}break;case"reorder-sheet":this.ReorderSheet(n.index,n.move_before);break;case"delete-sheet":this.DeleteSheet();break;case"add-sheet":this.AddSheet();break;case"rename-sheet":this.RenameSheet(n.sheet,n.name);break;case"activate-sheet":this.ActivateSheetID(n.sheet.id);break}this.SelectingArgument()||this.Focus()})),this.container=i,this.container.classList.add("treb-grid"),te.is_mac&&te.is_safari&&this.container.classList.add("safari"),this.container.setAttribute("tabindex","-1"),this.layout.Initialize(i,()=>this.OnScroll(),n=>this.OnDropdownSelect(n),this.options.scrollbars),this.selection_renderer.Initialize(),this.layout.UpdateTiles(),s||(s=new at({theme:this.theme,container:i})),this.InitOverlayEditor(s),this.AttachListeners(),this.render_tiles=this.layout.VisibleTiles(),t||(this.tab_bar?.Update(),this.Repaint(!0))}MergeCells(e){!e&&this.primary_selection.empty||(this.layout.HideDropdownCaret(),this.ExecCommand({key:9,area:e||this.primary_selection.area}))}UnmergeCells(e){!e&&this.primary_selection.empty||(this.layout.HideDropdownCaret(),this.ExecCommand({key:10,area:e||this.primary_selection.area}))}Focus(e=""){te.is_mobile?this.container?.focus():this.overlay_editor?.Focus(e)}SetValidation(e,t,i){if(!e){if(this.primary_selection.empty)throw new Error("invalid target in set validation");e=this.primary_selection.target}let r={key:25,area:e,error:i};t&&(Array.isArray(t)?r.list=t:typeof t=="object"&&t.start&&t.end&&P(t.start)&&P(t.end)&&(r.range=t)),this.ExecCommand(r),!this.primary_selection.empty&&(!e.sheet_id||e.sheet_id===this.active_sheet.id)&&this.primary_selection.target.row===e.row&&this.primary_selection.target.column===e.column&&requestAnimationFrame(()=>this.Select(this.primary_selection,this.primary_selection.area,this.primary_selection.target))}SetName(e,t,i){let r=this.model.named_ranges.ValidateNamed(e);if(!r)throw new Error("invalid name");let s=e.trim().toUpperCase();if(this.autocomplete_matcher){for(let o of Object.keys(this.autocomplete_matcher.function_map))if(s===o.toUpperCase()){if(t||i)throw new Error("name already defined");break}}e=r;let n={key:16,name:e};if(t)P(t)&&(t=new g(t)),t.start.sheet_id||(t=new g({...t.start,sheet_id:this.active_sheet.id},t.end)),n.area=new g(t.start,t.end);else if(i){let o=this.parser.Parse(i);if(o.valid&&o.expression)this.parser.Walk(o.expression,a=>{if(a.type==="address"||a.type==="range"){if(a.type==="range"&&(a=a.start),!a.sheet_id&&a.sheet){let l=this.model.sheets.Find(a.sheet);l&&(a.sheet_id=l.id)}return a.sheet_id||(a.sheet_id=this.active_sheet.id),!1}return!0}),n.expression=o.expression;else throw new Error("invalid expression")}this.ExecCommand(n)}SelectAll(){this.Select(this.primary_selection,new g({row:1/0,column:1/0}),void 0,!0),this.RenderSelections()}SelectRange(e){this.Select(this.primary_selection,e),this.RenderSelections()}GetNumberFormat(e){let t=this.active_sheet.CellStyleData(e);if(t&&t.number_format)return L.Get(t.number_format).toString()}GetRangeStyle(e,t=!1){let i=0;if(P(e)?i=e.sheet_id||this.active_sheet.id:i=e.start.sheet_id||this.active_sheet.id,i)return this.model.sheets.Find(i)?.GetCellStyle(e,t)||void 0}GetRange(e,t){if(P(e)){let r=this.model.sheets.Find(e.sheet_id||this.active_sheet.id);return r?t==="formula"?r.cells.RawValue(e):t==="formatted"?r.GetFormattedRange(e):r.cells.GetRange(e):void 0}let i=this.model.sheets.Find(e.start.sheet_id||this.active_sheet.id);if(i)return t==="formula"?i.cells.RawValue(e.start,e.end):t==="formatted"?i.GetFormattedRange(e.start,e.end):i.cells.GetRange(e.start,e.end)}SetRange(e,t,i=!1,r=!1,s=!1,n=!1){if(t=this.UntranslateData(t),!Array.isArray(t))i||s?this.ExecCommand({key:6,area:e,value:t,array:s,r1c1:n}):this.ExecCommand({key:6,area:e.start,value:t,array:s,r1c1:n});else{if(!li(t))if(i){let o=e.entire_column?this.active_sheet.rows:e.rows,a=e.entire_row?this.active_sheet.columns:e.columns,l=o*a;if(l>t.length){let u=t.slice(0),h=Math.ceil(l/u.length);for(let p=1;p<h;p++)u=u.concat(t.slice(0));t=u}let d=[];for(let u=0,h=0;u<a;u++,h+=o)d[u]=t.slice(h,h+o);t=d}else t=[t];r&&(t=this.Transpose(t)),this.ExecCommand({key:6,area:e,value:t,array:s,r1c1:n})}!this.primary_selection.empty&&e.Contains(this.primary_selection.target)&&this.UpdateFormulaBarFormula()}SetRowHeight(e,t,i=!0){this.ExecCommand({key:3,row:e,height:t,shrink:i})}SetColumnWidth(e,t=0){this.ExecCommand({key:4,column:e,width:t})}ApplyStyle(e,t={},i=!0){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.area}j.UpdateStyle(t),this.ExecCommand({key:7,area:e,style:t,delta:i}),this.UpdateFormulaBarFormula()}GetSelection(){return this.primary_selection}Update(e=!1,t){this.DelayedRender(e,t)}ApplyBorders(e,t="none",i,r=1){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.area}t==="none"&&(r=0),this.ExecCommand({key:8,color:{text:i},area:e,borders:t,width:r})}ApplyBorders2(e,t="none",i,r=1){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.area}t==="none"&&(r=0),this.ExecCommand({key:8,color:i,area:e,borders:t,width:r})}GetFreeze(){return{...this.active_sheet.freeze}}Freeze(e=0,t=0,i=!0){this.ExecCommand({key:15,rows:e,columns:t,highlight_transition:i})}Batch(e,t=!0){this.batch=!0,e(),this.batch=!1;let i=this.batch_events.slice(0);return this.batch_events=[],t&&this.DelayedRender(!1),i}InsertColumns(e=0,t=1){this.ExecCommand({key:2,before_column:e,count:t})}ReorderSheet(e,t){this.ExecCommand({key:23,index:e,move_before:t})}RenameSheet(e,t){this.ExecCommand({key:22,new_name:t,id:e.id})}InsertRows(e=0,t=1){this.ExecCommand({key:1,before_row:e,count:t})}ScrollTo(e,t=!0,i=!0,r=!1){this.layout.ScrollTo(e,t,i,r)}ScrollIntoView(e){this.options.scrollbars&&this.layout.ScrollIntoView(e)}GetScrollOffset(){return this.layout.GetScrollOffset()}ScrollOffset(e){if(e)this.layout.scroll_offset=e;else return this.layout.scroll_offset}TranslateInternal(e,t){let i=this.parser.Parse(e);if(i.expression){let r=!1;if(this.parser.Walk(i.expression,s=>{if(s.type==="call"){let n=t[s.name.toUpperCase()];n&&(r=!0,s.name=n)}return!0}),r)return"="+this.parser.Render(i.expression,void 0,"")}return e}TranslateFunction(e){return this.language_map?this.TranslateInternal(e,this.language_map):e}UntranslateFunction(e){return this.reverse_language_map?this.TranslateInternal(e,this.reverse_language_map):e}UntranslateData(e){return Array.isArray(e)?li(e)?e.map(t=>t.map(i=>i&&typeof i=="string"&&i[0]==="="?this.UntranslateFunction(i):i)):e.map(t=>t&&typeof t=="string"&&t[0]==="="?this.UntranslateFunction(t):t):(e&&typeof e=="string"&&e[0]==="="&&(e=this.UntranslateFunction(e)),e)}StyleDefaultFromTheme(){this.model.theme_style_properties.font_face=this.theme.grid_cell?.font_face||"",this.model.theme_style_properties.font_size=this.theme.grid_cell?.font_size||{unit:"pt",value:10}}AutoSizeColumn(e,t,i=!0){let r=12,s=4*2;i||(r=e.GetColumnWidth(t));for(let n=0;n<e.cells.rows;n++){let o=e.CellData({row:n,column:t}),a=o.formatted||"";if(typeof a!="string"&&(a=a.map(l=>l.text).join("")),a&&a.length){let l=this.tile_renderer.MeasureText(a,A.Font(o.style||{}));r=Math.max(r,Math.ceil(l.width)+s)}}e.SetColumnWidth(t,r)}EnsureActiveSheet(e=!1){for(let t of this.model.sheets.list)if(t===this.active_sheet){e&&this.ActivateSheetInternal({key:21,id:t.id,force:!0});return}this.ActivateSheetInternal({key:21,index:0})}ActivateSheetInternal(e){let t=this.SelectingArgument(),i=this.ResolveSheet(e)||this.model.sheets.list[0];if(this.active_sheet===i&&!e.force)return;if(!i.visible)throw new Error("cannot activate hidden sheet");this.HideHoverInfo(),this.active_sheet.selection=JSON.parse(JSON.stringify(this.primary_selection)),this.active_sheet.scroll_offset=this.layout.scroll_offset;let r=this.active_sheet;this.RemoveAnnotationNodes(),this.active_sheet=i,t?this.RenderSelections():(this.ClearSelection(this.primary_selection),i.selection&&!i.selection.empty&&this.Select(this.primary_selection,new g(i.selection.area.start,i.selection.area.end),i.selection.target));let s=this.active_sheet.annotations;for(let n of s)this.AddAnnotation(n,!0);this.QueueLayoutUpdate(),this.pending_layout_update.has(this.active_sheet.id)?(this.Repaint(!0,!0),this.pending_layout_update.delete(this.active_sheet.id)):this.Repaint(!1,!1),this.grid_events.Publish({type:"sheet-change",deactivate:r,activate:this.active_sheet}),this.tab_bar&&this.tab_bar.Update(),this.layout.scroll_offset=this.active_sheet.scroll_offset,this.formula_bar?.selecting&&requestAnimationFrame(()=>this.formula_bar?.FocusEditor())}HighlightFreezeArea(){for(let e of[this.layout.corner_selection,this.layout.row_header_selection,this.layout.column_header_selection])e.classList.add("highlight-area"),setTimeout(()=>{e.classList.remove("highlight-area")},400)}QueueLayoutUpdate(e){this.tile_update_pending=!0,e&&(this.scroll_offset_pending=e)}HandleAddressLabelEvent(e){if(e){let t=(n="")=>{let o=n.toLowerCase();for(let a of this.model.sheets.list)if(a.name.toLowerCase()===o)return a.id;return this.active_sheet.id},i=n=>{for(let o of this.model.sheets.list)if(o.id===n)return o;return this.active_sheet},r,s=this.parser.Parse(e);if(s.expression)switch(s.expression.type){case"address":s.expression.sheet_id=t(s.expression.sheet),r=new g(s.expression);break;case"range":s.expression.start.sheet_id=t(s.expression.start.sheet),r=new g(s.expression.start,s.expression.end);break;case"identifier":r=this.model.named_ranges.Get(s.expression.name),r||this.primary_selection.empty||this.SetName(s.expression.name.toUpperCase(),this.primary_selection.area);break;default:break}if(r){let n=i(r.start.sheet_id);if(n.columns>=r.end.column&&n.rows>=r.end.row){this.ExecCommand({key:5,area:r});return}else console.warn("address out of range")}}this.UpdateAddressLabel(),this.Focus()}InitFormulaBar(e,t){this.formula_bar=new Gt(e,this.parser,this.theme,this.model,this.view,this.options,t),this.formula_bar.autocomplete_matcher=this.autocomplete_matcher,this.formula_bar.Subscribe(i=>{switch(i.type){case"address-label-event":this.HandleAddressLabelEvent(i.text);break;case"stop-editing":this.editing_state=0;break;case"start-editing":this.editing_state=2,this.editing_cell={...this.primary_selection.target};break;case"discard":if(this.editing_state=0,this.editing_annotation){this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection);let r=this.editing_annotation.view[this.view_index]?.node;r&&r.focus(),this.editing_annotation=void 0,this.UpdateFormulaBarFormula(),this.DelayedRender();return}this.container&&this.Focus(),this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection),this.UpdateFormulaBarFormula(),this.DelayedRender();break;case"commit":if(this.active_sheet.id!==this.editing_cell.sheet_id&&this.editing_cell.sheet_id&&this.ActivateSheetID(this.editing_cell.sheet_id),this.editing_state=0,this.editing_annotation){let r=this.editing_annotation;this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection),r.formula=i.value?this.FixFormula(i.value):"";let s=this.editing_annotation.view[this.view_index]?.node;s&&s.focus(),this.grid_events.Publish({type:"annotation",event:"update",annotation:r}),this.editing_annotation=void 0,this.DelayedRender();return}this.container&&this.Focus(),this.SetInferredType(this.primary_selection,i.value,i.array),this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection),this.options.repaint_on_cell_change&&this.DelayedRender(!1,this.primary_selection.area),i.event&&this.OverlayKeyDown(i.event);break;case"update":i.dependencies&&this.HighlightDependencies(i.dependencies);break}})}InitOverlayEditor(e){!this.container||(this.overlay_editor=new Pt(this.container,this.parser,this.theme,this.model,this.view,e),this.overlay_editor.UpdateTheme(this.layout.scale),this.overlay_editor.autocomplete_matcher=this.autocomplete_matcher,this.overlay_editor.Subscribe(t=>{switch(t.type){case"stop-editing":this.editing_state=0;break;case"start-editing":this.editing_state=1,this.editing_cell={...this.primary_selection.target};break;case"update":t.dependencies&&this.HighlightDependencies(t.dependencies);break;case"end-selection":this.ClearSelection(this.active_selection),this.DelayedRender();break}}))}DelayedRender(e=!1,t,i=!1){!this.tile_update_pending&&t?this.layout.DirtyArea(t):!this.tile_update_pending&&e&&this.layout.DirtyAll(),this.render_token||(this.render_token=1,se().then(()=>{this.render_token=0,this.Repaint(e,i)}))}Repaint(e=!1,t=!1,i=!1){if(this.headless)return;if(this.tile_update_pending&&(this.tile_update_pending=!1,this.layout.UpdateTiles(),this.scroll_offset_pending&&(this.layout.scroll_offset=this.scroll_offset_pending,this.scroll_offset_pending=void 0),this.render_tiles=this.layout.VisibleTiles(),this.layout.UpdateAnnotation(this.active_sheet.annotations)),this.layout_token=0,this.tile_renderer.OverflowDirty(t),e)for(let a of this.layout.grid_tiles)for(let l of a)l.dirty=!0;let r=this.render_tiles.start,s=this.render_tiles.end,n=[];for(let a=r.row;a<=s.row;a++)n.push(a);let o=[];for(let a=r.column;a<=s.column;a++)o.push(a);r.row>0&&this.active_sheet.freeze.rows&&n.push(0),r.column>0&&this.active_sheet.freeze.columns&&o.push(0);for(let a of o)for(let l of n){let d=this.layout.grid_tiles[a][l];(e||d.dirty||d.needs_full_repaint)&&(this.tile_renderer.Render(d),d.dirty=d.needs_full_repaint=!1)}this.tile_renderer.RenderHeaders(this.render_tiles,i),this.tile_renderer.RenderCorner(),this.RenderSelections()}MouseMove_RowHeader(e){let t=this.layout.CoordinateToRowHeader(e.offsetY),i=this.layout.OffsetCellAddressToRectangle({row:t.row,column:0});this.hover_data.address&&(this.hover_data.address.row!==-1||this.hover_data.address.column!==-1)&&this.HoverCell({row:-1,column:-1});let r=-1;e.offsetY-i.top<=this.RESIZE_PIXEL_BUFFER&&t.row>0?r=t.row-1:i.bottom-e.offsetY<=this.RESIZE_PIXEL_BUFFER&&(r=t.row),r>=0?this.layout.ResizeCursor("row"):this.cell_resize.row&&(this.cell_resize.row=-1,this.layout.ResizeCursor()),this.cell_resize.row=r}MouseMove_ColumnHeader(e){let t=this.layout.CoordinateToColumnHeader(e.offsetX),i=this.layout.OffsetCellAddressToRectangle({row:0,column:t.column});this.hover_data.address&&(this.hover_data.address.row!==-1||this.hover_data.address.column!==-1)&&this.HoverCell({row:-1,column:-1});let r=-1;e.offsetX-i.left<=this.RESIZE_PIXEL_BUFFER&&t.column>0?r=t.column-1:i.right-e.offsetX<=this.RESIZE_PIXEL_BUFFER&&(r=t.column),r>=0?this.layout.ResizeCursor("column"):this.cell_resize.column&&(this.cell_resize.column=-1,this.layout.ResizeCursor()),this.cell_resize.column=r}MouseDown_RowHeader(e){if(e.button!==0)return;e.stopPropagation(),e.preventDefault();let t=this.layout.CoordinateToRowHeader(e.offsetY),i=this.layout.row_header_cover.getBoundingClientRect(),r={x:i.left,y:i.top};if(this.cell_resize.row>=0){let s=this.cell_resize.row,n=r.y+e.offsetY;if(this.layout.HideDropdownCaret(),this.IsDoubleClick({row:s,column:-1})){let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.rows>1&&this.primary_selection.area.start.column===1/0&&this.primary_selection.area.ContainsRow(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);p=[];for(let m=f.start.row;m<=f.end.row;m++)p.push(m)}this.ExecCommand({key:3,row:p});return}let o=this.layout.RowHeight(s),a=o,l=this.layout.OffsetCellAddressToRectangle({row:s,column:0}),d=r.y+l.bottom;this.layout.ShowTooltip({left:!0,text:`${a}px`,x:Math.round(i.right+10),y:d});let u=[],h=[];for(let p of this.active_sheet.annotations){let f=l.bottom-1;if(!p.scaled_rect||p.scaled_rect.bottom<f)continue;let m=[...this.layout.GetFrozenAnnotations(p)],b=p.view[this.view_index]?.node;b&&m.push(b),f<=p.scaled_rect.top&&p.move_with_cells?u.push({annotation:p,y:p.scaled_rect.top,nodes:m}):f>p.scaled_rect.top&&p.resize_with_cells&&h.push({annotation:p,height:p.scaled_rect.height,nodes:m})}me(this.layout.mask,"row-resize",p=>{let f=Math.max(-o,Math.round(p.offsetY-n));if(f+o!==a){a=f+o,this.layout.SetRowHeight(s,a),this.layout.UpdateTooltip({text:`${a}px`,y:d+f});for(let{annotation:m,y:b}of u)m.scaled_rect&&(m.scaled_rect.top=b+f);for(let{annotation:m,height:b}of h)m.scaled_rect&&(m.scaled_rect.height=b+f);requestAnimationFrame(()=>{for(let{annotation:m,nodes:b}of h)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);for(let{annotation:m,nodes:b}of u)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);this.layout.UpdateTileHeights(!0,s),this.Repaint(!1,!0),this.layout.UpdateAnnotation(this.active_sheet.annotations)})}},()=>{this.layout.HideTooltip(),requestAnimationFrame(()=>{let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.rows>1&&this.primary_selection.area.start.column===1/0&&this.primary_selection.area.ContainsRow(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);p=[];for(let m=f.start.row;m<=f.end.row;m++)p.push(m)}this.ExecCommand({key:3,row:p,height:a});for(let{annotation:f}of u)f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));for(let{annotation:f}of h){f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));let m=f.view[this.view_index];m&&m.resize_callback&&m.resize_callback.call(void 0)}})})}else{let s=this.SelectingArgument()?this.active_selection:this.primary_selection;if(this.SelectingArgument()||this.Focus(),e.shiftKey&&!s.empty){let n=s.target;this.Select(s,new g(s.target,t,!0),void 0,!0),t=n}else this.Select(s,new g(t),{column:0,row:t.row});this.RenderSelections(),me(this.layout.mask,[],n=>{let o=this.layout.CoordinateToRowHeader(n.offsetY-r.y),a=new g(o,t,!0);(s.empty||!a.Equals(s.area))&&(this.Select(s,a,void 0,!0),this.RenderSelections())},()=>{})}}MouseDown_ColumnHeader(e){if(e.button!==0)return;e.stopPropagation(),e.preventDefault();let t=this.layout.CoordinateToColumnHeader(e.offsetX),i=this.layout.column_header_cover.getBoundingClientRect(),r={x:i.left,y:i.top};if(this.cell_resize.column>=0){let s=this.cell_resize.column,n=r.x+e.offsetX;if(this.layout.HideDropdownCaret(),this.IsDoubleClick({row:-1,column:s})){let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.columns>1&&this.primary_selection.area.start.row===1/0&&this.primary_selection.area.ContainsColumn(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);p=[];for(let m=f.start.column;m<=f.end.column;m++)p.push(m)}this.ExecCommand({key:4,column:p});return}let o=this.layout.ColumnWidth(s),a=o,l=this.layout.OffsetCellAddressToRectangle({row:0,column:s}),d=r.x+l.right;this.layout.ShowTooltip({up:!0,text:`${a}px`,x:d,y:Math.round(i.bottom+10)});let u=[],h=[];for(let p of this.active_sheet.annotations){let f=l.right-1;if(!p.scaled_rect||p.scaled_rect.right<f)continue;let m=[...this.layout.GetFrozenAnnotations(p)],b=p.view[this.view_index]?.node;b&&m.push(b),f<=p.scaled_rect.left&&p.move_with_cells?u.push({annotation:p,x:p.scaled_rect.left,nodes:m}):f>p.scaled_rect.left&&p.resize_with_cells&&h.push({annotation:p,width:p.scaled_rect.width,nodes:m})}me(this.layout.mask,"column-resize",p=>{let f=Math.max(-o,Math.round(p.offsetX-n));if(f+o!==a){a=f+o,this.layout.UpdateTooltip({text:`${a}px`,x:d+f}),this.layout.SetColumnWidth(s,a);for(let{annotation:m,x:b}of u)m.scaled_rect&&(m.scaled_rect.left=b+f);for(let{annotation:m,width:b}of h)m.scaled_rect&&(m.scaled_rect.width=b+f);requestAnimationFrame(()=>{for(let{annotation:m,nodes:b}of h)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);for(let{annotation:m,nodes:b}of u)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);this.layout.UpdateTileWidths(!0,s),this.Repaint(!1,!0)})}},()=>{this.layout.HideTooltip(),requestAnimationFrame(()=>{let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.columns>1&&this.primary_selection.area.start.row===1/0&&this.primary_selection.area.ContainsColumn(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);for(let m=f.start.column;m<=f.end.column;m++)p.push(m)}this.ExecCommand({key:4,column:p,width:a});for(let{annotation:f}of u)f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));for(let{annotation:f}of h){f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));let m=f.view[this.view_index];m&&m.resize_callback&&m.resize_callback.call(void 0)}})})}else{let s=this.SelectingArgument()?this.active_selection:this.primary_selection;if(this.SelectingArgument()||this.Focus(),e.shiftKey&&!s.empty){let n=s.target;this.Select(s,new g(s.target,t,!0),void 0,!0),t=n}else this.Select(s,new g(t),{row:0,column:t.column});this.RenderSelections(),me(this.layout.mask,[],n=>{let o=this.layout.CoordinateToColumnHeader(n.offsetX-r.x),a=new g(o,t,!0);(s.empty||!a.Equals(s.area))&&(this.Select(s,a,void 0,!0),this.RenderSelections())})}}HoverCell(e,t){let i=this.active_sheet.cells.GetCell(e,!1);if(i?.merge_area){let r=i.merge_area;e=r.start,i=this.active_sheet.cells.GetCell(e,!1),e={row:r.start.row,column:r.end.column}}if(i?.note){let r=this.options.markdown?we.instance.HTML(we.instance.Parse(i.note)):void 0;this.layout.ShowNote(i.note,e,t,r),this.hover_data.note=!0}else this.hover_data.note&&(this.layout.HideNote(),this.hover_data.note=!1);i?.hyperlink?(this.layout.ShowTitle("Link: "+i.hyperlink,e),this.hover_data.link=!0,this.hover_data.cell=i):this.hover_data.link&&(this.layout.HideTitle(),this.hover_data.cell=void 0),this.hover_data.address={...e}}HideHoverInfo(){this.layout.HideTitle(),this.layout.HideTooltip(),this.hover_data.note=this.hover_data.link=!1,this.hover_data.cell=void 0,this.hover_data.pointer&&this.layout.grid_cover.classList.remove("link-pointer"),this.hover_data.pointer=!1}MouseMove_Grid(e){e.stopPropagation(),e.preventDefault(),(this.cell_resize.row>=0||this.cell_resize.column>=0)&&this.layout.ResizeCursor();let t={x:e.offsetX,y:e.offsetY},i;if(this.overlay_editor?.editing||(i=this.layout.PointToAddress_Grid(t),(!this.hover_data.address||this.hover_data.address.row!==i.row||this.hover_data.address.column!==i.column)&&this.HoverCell(i,e)),this.hover_data.link&&i&&(this.hover_data.point=t,this.hover_data.handler||(this.hover_data.handler=requestAnimationFrame(()=>{let s=this.hover_data.address&&this.hover_data.point&&this.hover_data.cell&&this.PointInTextPart(this.hover_data.address,this.hover_data.point,this.hover_data.cell);s!==!!this.hover_data.pointer&&(this.hover_data.pointer=s,s?this.layout.grid_cover.classList.add("link-pointer"):this.layout.grid_cover.classList.remove("link-pointer")),this.hover_data.handler=void 0}))),this.primary_selection.empty||!this.selection_renderer.nub_rectangle){this.nub_select_flag&&(this.layout.grid_cover.classList.remove("nub-select"),this.nub_select_flag=!1);return}let r=this.selection_renderer.nub_rectangle.Contains(e.offsetX,e.offsetY);r!==this.nub_select_flag&&(r?this.layout.grid_cover.classList.add("nub-select"):this.layout.grid_cover.classList.remove("nub-select"),this.nub_select_flag=r)}ClearDoubleClick(){this.double_click_data.address=void 0}IsDoubleClick(e,t=300){if(this.double_click_data.address&&this.double_click_data.address.row===e.row&&this.double_click_data.address.column===e.column)return clearTimeout(this.double_click_data.timeout),this.double_click_data.address=void 0,this.double_click_data.timeout=void 0,!0;this.double_click_data.timeout&&clearTimeout(this.double_click_data.timeout),this.double_click_data.address={...e},this.double_click_data.timeout=window.setTimeout(()=>{this.double_click_data.address=void 0,this.double_click_data.timeout=void 0},t)}PointInTextPart(e,t,i){let r=this.layout.CellAddressToRectangle(e);i.merge_area&&(r=r.Combine(this.layout.CellAddressToRectangle(i.merge_area.end)));let s=t.x-r.left,n=t.y-r.top,o=i.renderer_data?.text_data?.strings||[];for(let a of o)for(let l of a)if(typeof l.left=="number"&&typeof l.top=="number"&&typeof l.width=="number"&&typeof l.height=="number"&&s>=l.left&&n>=l.top&&s<=l.left+l.width&&n<=l.top+l.height)return!0;return!1}MouseDown_Grid(e){if(e.button!==0)return;e.stopPropagation(),e.preventDefault();let t=this.SelectingArgument();!t&&this.additional_selections.length&&this.ClearAdditionalSelections(),(!t||!this.formula_bar?.selecting)&&this.Focus(),this.overlay_editor?.editing&&!this.overlay_editor?.selecting&&this.DismissEditor();let i={x:e.offsetX,y:e.offsetY},r=this.layout.PointToAddress_Grid(i),s=t?this.active_selection:this.primary_selection;if(!t&&this.IsDoubleClick(r)){te.is_mobile&&this.overlay_editor?.edit_node?.focus(),this.OverlayEditCell({target:r,area:new g(r)},!1);return}let n=this.layout.grid_cover.getBoundingClientRect(),o={x:n.left,y:n.top},a=[],l;if(e.shiftKey&&!s.empty){let u=s.target;this.Select(s,new g(r,s.target,!0),void 0,!0),r=u}else if(this.nub_select_flag)r=s.area.TopLeft(),a.push("nub-select"),l=this.active_sheet.RealArea(s.area);else{let u=r,h=this.active_sheet.CellData(u);if(h.merge_area&&(u=h.merge_area.start,h=this.active_sheet.CellData(h.merge_area.start)),h.hyperlink&&this.PointInTextPart(u,i,h)){let p=h.hyperlink;se().then(()=>{this.grid_events.Publish({type:"cell-event",data:{type:"hyperlink",data:p}})}),this.ClearDoubleClick();return}if(h.click_function){let p=this.layout.CellAddressToRectangle(u);h.merge_area&&(p=p.Combine(this.layout.CellAddressToRectangle(h.merge_area.end)));let f=h.click_function.call(this,{cell:h,x:i.x-p.left,y:i.y-p.top,width:p.width,height:p.height,scale:this.layout.scale});if(f.value&&this.ExecCommand({key:6,value:f.value,area:u}),f.block_selection){this.ClearDoubleClick(),!this.primary_selection.empty&&this.primary_selection.target.row===u.row&&this.primary_selection.target.column===u.column&&this.UpdateFormulaBarFormula();return}}this.Select(s,new g(r),r)}this.RenderSelections(),t&&this.UpdateSelectedArgument(s);let d=this.layout.CellAddressToRectangle({row:0,column:0}).Combine(this.layout.CellAddressToRectangle({row:this.active_sheet.rows-1,column:this.active_sheet.columns-1})).Expand(-1,-1);me(this.layout.mask,a,u=>{let h={x:u.offsetX-o.x,y:u.offsetY-o.y},p=d.Clamp(h.x,h.y),f=this.layout.PointToAddress_Grid(p,!0),m=this.layout.scroll_reference_node,b=!1;this.container&&this.options.scrollbars&&(h.x<m.scrollLeft?(m.scrollLeft-=25,b=!0):h.x>m.scrollLeft+this.container.clientWidth&&(m.scrollLeft+=25,b=!0),h.y<m.scrollTop?(m.scrollTop-=25,b=!0):h.y>m.scrollTop+this.container.clientHeight&&(m.scrollTop+=25,b=!0),b&&(n=this.layout.grid_cover.getBoundingClientRect(),o.x=n.left+document.body.scrollLeft,o.y=n.top+document.body.scrollTop));let _=new g(f,r,!0);if(l&&(_=l.Clone(),_.ConsumeAddress(f),_.rows!==l.rows&&_.columns!==l.columns)){let y={rows:f.row>l.end.row?f.row-l.end.row:l.start.row-f.row,columns:f.column>l.end.column?f.column-l.end.column:l.start.column-f.column};y.rows>=y.columns?_=new g({row:_.start.row,column:l.start.column},{row:_.end.row,column:l.end.column}):_=new g({row:l.start.row,column:_.start.column},{row:l.end.row,column:_.end.column})}(s.empty||!_.Equals(s.area))&&(this.Select(s,_,void 0,!0),this.RenderSelections(),t?this.UpdateSelectedArgument(s):!s.empty&&!s.area.entire_sheet&&(s.area.entire_column?this.UpdateAddressLabel(void 0,s.area.columns+"C"):s.area.entire_row?this.UpdateAddressLabel(void 0,s.area.rows+"R"):s.area.count>1?this.UpdateAddressLabel(void 0,s.area.rows+"R x "+s.area.columns+"C"):this.UpdateAddressLabel(s)))},()=>{this.UpdateAddressLabel(),t?this.overlay_editor?.editing||this.select_argument||this.formula_bar&&this.formula_bar.FocusEditor():l&&this.RecycleNubArea(s.area,l)})}Transpose(e){let t=[],i=e.length,r=e[0].length;for(let s=0;s<r;s++){t[s]=[];for(let n=0;n<i;n++)t[s][n]=e[n][s]}return t}RecycleNubArea(e,t){if(e.Equals(t))return;let i=[];for(let u=0;u<t.rows;u++){i[u]=[];for(let h=0;h<t.columns;h++){let p={row:t.start.row+u,column:t.start.column+h};i[u][h]=this.active_sheet.CellData(p)}}if(i[0][0].area&&i[0][0].area.Equals(t)){this.ExecCommand({key:6,value:i[0][0].value,array:!0,area:e});return}let r=[],s=[],n=t.columns,o=e.rows,a=!1,l=!1;e.columns===t.columns?a=e.start.row<t.start.row:(n=t.rows,o=e.columns,a=e.start.column<t.start.column,i=this.Transpose(i),l=!0);for(let u=0;u<o;u++)r[u]=[],s[u]=[];for(let u=0;u<n;u++){let h=0;if(i.length>1){h=1;let p=[],f=[];for(let m=0;m<i.length;m++){let b=i[m][u];b.ValueIsNumber()&&(f.push(m),p.push(b.value))}if(p.length>1){let m=p.slice(1).map((b,_)=>b-p[_]);m.every(b=>b===m[0])&&(h=m[0])}p.length&&(h+=p[p.length-1]-p[0])}for(let p=0;p<i.length;p++){let f,m=i[p][u];if(m.ValueIsFormula()){let w=this.parser.Parse(m.value);w.expression&&w.full_reference_list?.length&&(f=w.expression)}let b=0,_=p,y=i.length,x=0,v=h;a&&(_=o-i.length+p,y=-i.length,v=-h);for(let w=_;w>=0&&w<o;w+=y,b+=y,x+=v){if(f)r[w][u]="="+this.parser.Render(f,{rows:b,columns:0});else{let C=i[p][u];C.ValueIsNumber()?r[w][u]=C.value+x:r[w][u]=C.value}s[w][u]=i[p][u].style||{}}}}let d=[{key:6,value:l?this.Transpose(r):r,array:!1,area:e}];l&&(s=this.Transpose(s));for(let u=0;u<s.length;u++)for(let h=0;h<s[u].length;h++)d.push({key:7,area:{row:u+e.start.row,column:h+e.start.column},style:s[u][h],delta:!1});this.ExecCommand(d)}UpdateSelectedArgument(e){let t=this.active_sheet.CellData(e.area.start),i=new g(t.merge_area?t.merge_area.start:e.target),r=this.model.named_ranges.MatchSelection(e.area,i);if(!r&&(r=e.area.spreadsheet_label,t.merge_area&&t.merge_area.Equals(e.area)&&(r=g.CellAddressToLabel(t.merge_area.start)),this.active_sheet.id!==this.editing_cell.sheet_id)){let s=this.active_sheet.name;st.test(s)?r=`'${s}'!${r}`:r=`${s}!${r}`}this.overlay_editor?.editing&&this.overlay_editor.selecting?this.overlay_editor.InsertReference(r,0):this.formula_bar&&this.formula_bar.selecting?this.formula_bar.InsertReference(r,0):this.select_argument&&this.grid_events.Publish({type:"alternate-selection",selection:this.active_selection})}SelectingArgument(){return this.overlay_editor?.editing&&this.overlay_editor?.selecting||this.formula_bar&&this.formula_bar.selecting||this.select_argument}OverlayKeyDown(e){let t=!1;if(this.overlay_editor&&this.overlay_editor.editing)switch(t=!0,this.overlay_editor.HandleKeyDown(e)){case 1:return;case 3:this.editing_state=0,this.DismissEditor(),this.DelayedRender();return;case 2:if(this.active_sheet.id!==this.editing_cell.sheet_id&&this.editing_cell.sheet_id&&this.ActivateSheetID(this.editing_cell.sheet_id),this.editing_state=0,this.overlay_editor?.selection){let l=this.overlay_editor?.edit_node.textContent||void 0,d=e.key==="Enter"&&e.ctrlKey&&e.shiftKey;this.SetInferredType(this.overlay_editor.selection,l,d)}this.DismissEditor(),this.options.repaint_on_cell_change&&this.DelayedRender(!1,this.overlay_editor?.selection.area||void 0);break}let i=this.SelectingArgument();if(this.formula_bar&&this.formula_bar.focused&&!i||this.selected_annotation&&!i)return;let r=i?this.active_selection:this.primary_selection,s={rows:0,columns:0},n=!1,o=!1;if(e.ctrlKey||te.is_mac&&e.metaKey){switch(e.key){case"ArrowDown":case"Down":s.rows++;break;case"ArrowUp":case"Up":s.rows--;break;case"ArrowLeft":case"Left":s.columns--;break;case"ArrowRight":case"Right":s.columns++;break;case"Delete":case"Del":{e.stopPropagation(),e.preventDefault();for(let a=0;a<this.model.sheets.length;a++)if(this.model.sheets.list[a]===this.active_sheet){this.DeleteSheet(a);break}return}break;case"/":e.stopPropagation(),e.preventDefault(),this.SelectArray();break;default:if(e.shiftKey)return}if(s.columns||s.rows)if(e.stopPropagation(),e.preventDefault(),!r.empty&&(s.columns||s.rows)){if(this.BlockSelection(r,!!e.shiftKey,s.columns,s.rows))return}else return;else{let a={},l=this.primary_selection.empty?{}:this.active_sheet.CellData(this.primary_selection.target).style||{};switch(e.key.toLowerCase()){case"b":a.bold=!l.bold;break;case"i":a.italic=!l.italic;break;case"u":a.underline=!l.underline;break;case"a":this.SelectAll();break;case"0":if(!e.altKey)return;this.ClearSelection(this.primary_selection),this.RenderSelections();break;default:e.key;return}Object.keys(a).length&&this.ApplyStyle(void 0,a)}}else switch(e.key){case"Tab":e.shiftKey?s.columns--:s.columns++,n=!0;break;case"Enter":e.shiftKey?s.rows--:s.rows++,n=!0;break;case"ArrowDown":case"Down":s.rows++,o=e.shiftKey;break;case"ArrowUp":case"Up":s.rows--,o=e.shiftKey;break;case"ArrowLeft":case"Left":s.columns--,o=e.shiftKey;break;case"ArrowRight":case"Right":s.columns++,o=e.shiftKey;break;case"Delete":case"Del":r.empty||this.DeleteSelection(r);break;case"PageUp":case"PageDown":if(e.shiftKey){this.NextSheet(e.key==="PageUp"?-1:1);break}return;case"Control":case"Shift":case"Alt":return;default:r.empty||this.OverlayEditCell(r,!0,e);return}e.stopPropagation(),e.preventDefault(),(s.rows||s.columns)&&this.AdvanceSelection(s,r,n,o,!t)}SelectArray(){if(this.primary_selection.empty)return;let e=this.active_sheet.CellData(this.primary_selection.target);!e||!e.area||(this.Select(this.primary_selection,e.area,e.area.start),this.RenderSelections())}RenderSelections(e=!0){let t=this.hide_selection?!1:!this.editing_state||this.editing_cell.sheet_id===this.active_sheet.id;this.selection_renderer.RenderSelections(t,e)}BlockSelection(e,t,i,r,s=!0){if(e.empty)return!1;let n={...e.target};r>0?n.row=Math.max(n.row,e.area.end.row):r<0&&(n.row=Math.min(n.row,e.area.start.row)),i>0?n.column=Math.max(n.column,e.area.end.column):i<0&&(n.column=Math.min(n.column,e.area.start.column));let o=this.active_sheet.cells,a=o.GetCell(e.target,!1);if(!a||a.type===0&&!a.area)return!1;let l={...n};for(;;){let d={row:l.row+r,column:l.column+i};if(d.column<0||d.row<0||d.column>=this.active_sheet.columns||d.row>=this.active_sheet.rows)break;let u=!1;if(r)for(let h=e.area.start.column;!u&&h<=e.area.end.column;h++)a=o.GetCell({row:d.row,column:h},!1),u=u||!!a&&(a.type!==0||!!a.area),!u&&a&&a.merge_area&&(a=o.GetCell(a.merge_area.start,!1),u=u||!!a&&(a.type!==0||!!a.area));else for(let h=e.area.start.row;!u&&h<=e.area.end.row;h++)a=o.GetCell({row:h,column:d.column},!1),u=u||!!a&&(a.type!==0||!!a.area),!u&&a&&a.merge_area&&(a=o.GetCell(a.merge_area.start,!1),u=u||!!a&&(a.type!==0||!!a.area));if(!u)break;l=d}if(t){r?(n.row=e.target.row,n.column=e.area.start.column,l.column=e.area.end.column):(n.column=e.target.column,n.row=e.area.start.row,l.row=e.area.end.row);let d=new g(n,l,!0);this.Select(e,d,e.target,!0)}else this.Select(e,new g(l));return this.ScrollIntoView(l),this.SelectingArgument()&&this.UpdateSelectedArgument(e),s&&this.DelayedRender(),!0}DeleteSelection(e){if(e.empty)return;let t=this.active_sheet.RealArea(e.area);this.ExecCommand({key:11,area:t})}SetInferredType(e,t,i=!1,r=!0){let s=e.target||e.area.start,n=this.active_sheet.CellData(s);if(n.area){if(!i&&n.area.count>1||!e.area||!e.area.Equals(n.area)){this.Error(2);return}}else if(i){let u=!1;if(this.active_sheet.cells.Apply(e.area,h=>{h.area&&(u=!0)},!1),u){this.Error(2);return}}if(n.validation&&n.validation.error){let u;if(n.validation.type===0?u=n.validation.list:n.validation.type===2&&(u=this.GetValidationRange(n.validation.area)),u&&u.length){let h=!1;if(t){let p=t.toUpperCase();for(let f of u)if(f&&f.toString().toUpperCase()===p){t=f.toString(),h=!0;break}}if(!h){this.Error(3);return}}}n.merge_area&&(s=n.merge_area.start);let o=typeof t=="string"&&t.trim()[0]==="=",a=[];if(o&&(t=this.FixFormula(t||""),!this.active_sheet.HasCellStyle(s))){let u=this.parser.Parse(t);if(u){if(u.expression?.type==="call"&&(!n.style||!n.style.number_format||L.Equals(n.style.number_format,"General"))){let h=u.expression.name.toLowerCase(),p;switch(h){case"today":p="Short Date";break;case"now":p="Timestamp";break}p&&a.push({key:7,area:i?e.area:s,style:{number_format:p},delta:!0})}if(u.dependencies){let h=u.dependencies;for(let p of Object.keys(h.addresses)){let f=h.addresses[p];if(this.active_sheet.HasCellStyle({...f})){let m=this.active_sheet.CellData({...f});if(m.style&&m.style.number_format){let b={number_format:m.style.number_format};a.push({key:7,area:i?e.area:s,style:b,delta:!0})}break}}}}}let l=this.parser.Parse(t||"").expression;l?.type==="group"&&l.elements.length===1&&l.elements[0].type==="complex"&&(l=l.elements[0]);let d=l&&l.type==="complex"?{type:7,value:{real:l.real,imaginary:l.imaginary}}:ye.TryParse(t);if(!o&&d.type===3){let u="",h=d.hints||0;(!n.style||!n.style.number_format||L.Equals(n.style.number_format,"General"))&&(h&64?u="Short Date":h&2?u="Exponential":h&4?u="Percent":h&8?u="Currency":(h&16||h&32)&&(u="Accounting")),u&&a.push({key:7,area:i?e.area:s,style:{number_format:u},delta:!0})}if(a.push({key:6,area:i?e.area:s,array:i,value:o?this.UntranslateFunction(t||""):d.value}),r)this.ExecCommand(a);else return a}FixFormula(e){if(e.trim()[0]!=="=")return e;e=e.replace(/^\s+/,"");let t=!1,i=!1,r=0,s=!1,n=e.length;for(let o=0;o<n;o++){let a=e[o];if(!s)switch(a){case'"':t?e[o+1]==='"'?o++:t=!1:i||(t=!0);break;case"'":i?i=!1:t||(i=!0);break;case"\\":s=!0;break;case"(":!t&&!i&&r++;break;case")":!t&&!i&&r--;break}}for(t?e+='"':i&&(e+="'");r>0;)e+=")",r--;return e=this.NormalizeFormula(e),e}NormalizeFormula(e){let t=this.parser.Parse(e);return t&&t.expression&&(this.parser.Walk(t.expression,i=>{switch(i.type){case"call":i.name=this.autocomplete_matcher.NormalizeIdentifier(i.name)||i.name;break;case"identifier":this.model.named_ranges.Get(i.name)&&(i.name=i.name.toUpperCase());break}return!0}),e="="+this.parser.Render(t.expression,void 0,"")),e}DismissEditor(){this.overlay_editor?.active_cell&&(this.overlay_editor.active_cell.editing=!1,this.overlay_editor.active_cell.render_clean=[],this.DelayedRender(void 0,this.overlay_editor.selection.area)),this.editing_state=0,this.Focus(),this.overlay_editor?.CloseEditor(),this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection)}NormalizeCellValue(e){let t=e.value;if(e.ValueIsNumber()&&e.style&&e.style.number_format)if(L.Get(e.style.number_format).date_format){let r=Ve(e.value),s=r.getUTCHours()||r.getUTCMinutes()||r.getUTCSeconds()?"Timestamp":"Short Date";t=L.Get(s).Format(t)}else if(/(?:%|percent)/i.test(e.style.number_format)){let r=0,s=e.value.toString().match(/\.(.*?)$/);s&&s[1]&&(r=Math.max(0,s[1].length-2)),t=(e.value*100).toFixed(r)+"%",T.decimal_separator===","&&(t=t.replace(/\./,","))}else t&&T.decimal_separator===","&&(t=e.value.toString().replace(/\./,","));else{if(e.ValueIsBoolean())return e.value.toString().toUpperCase();e.ValueIsNumber()?t&&T.decimal_separator===","&&(t=e.value.toString().replace(/\./,",")):e.ValueIsComplex()?(e.value.imaginary?e.value.real?t=`${e.value.real.toString()}${e.value.imaginary<0?" - ":" + "}${e.value.imaginary===1||e.value.imaginary===-1?"":Math.abs(e.value.imaginary).toString()}i`:e.value.imaginary===1?t="i":e.value.imaginary===-1?t="-i":t=e.value.imaginary.toString()+"i":t=e.value.real.toString(),T.decimal_separator===","&&(t=t.replace(/\./,","))):e.ValueIsFormula()&&(t=this.TranslateFunction(e.value))}return t}IsNumeric(e){return e>=48&&e<=57||e===this.decimal_separator_code||e===45||e===43}OverlayEditCell(e,t=!0,i){if(!this.options.in_cell_editor)return;let r=e.target||e.area.start,s=this.active_sheet.CellData(r),n;if(this.HideHoverInfo(),s.merge_area?(n=this.layout.OffsetCellAddressToRectangle(s.merge_area.start).Combine(this.layout.OffsetCellAddressToRectangle(s.merge_area.end)),r=s.merge_area.start,s=this.active_sheet.CellData(r)):n=this.layout.OffsetCellAddressToRectangle(r),s.style?.locked){console.info("cell is locked for editing");return}n=n.Shift(this.layout.header_size.width,this.layout.header_size.height);let o=s.value;t?(s.type===3||s.rendered_type===3)&&s.style&&s.style.number_format&&/(?:%|percent)/i.test(s.style.number_format)&&(!i||this.IsNumeric(i.key.charCodeAt(0)))?o="%":o=void 0:o=this.NormalizeCellValue(s),this.overlay_editor?.Edit(e,n.Expand(-1,-1),s,o,i),s.editing=!0,s.render_clean=[],this.DelayedRender(!1,e.area)}BoundAddressArea(e,t){e.column>t.end.column?(e.row=this.StepVisibleRows(e.row,1),e.row>t.end.row&&(e.row=t.start.row),e.column=t.start.column):e.column<t.start.column?(e.row=this.StepVisibleRows(e.row,-1),e.row<t.start.row&&(e.row=t.end.row),e.column=t.end.column):e.row>t.end.row?(e.column=this.StepVisibleColumns(e.column,1),e.column>t.end.column&&(e.column=t.start.column),e.row=t.start.row):e.row<t.start.row&&(e.column=this.StepVisibleColumns(e.column,-1),e.column<t.start.column&&(e.column=t.end.column),e.row=t.end.row)}StepVisibleRows(e,t){if(t>0)for(let i=0;i<t;i++)this.layout.RowHeight(++e)||i--;else if(t<0)for(let i=0;i>t;i--)--e>=0&&!this.layout.RowHeight(e)&&i++;return e}StepVisibleColumns(e,t){if(t>0)for(let i=0;i<t;i++)this.layout.ColumnWidth(++e)||i--;else if(t<0)for(let i=0;i>t;i--)--e>=0&&!this.layout.ColumnWidth(e)&&i++;return e}EnsureAddress(e,t=8){let i=!1;if(this.options.expand){if(e.row!==1/0&&e.row>=this.active_sheet.rows){let r=this.active_sheet.rows;for(;e.row>=r;)r+=t;this.active_sheet.cells.EnsureRow(r),i=!0}if(e.column!==1/0&&e.column>=this.active_sheet.columns){let r=this.active_sheet.columns;for(;e.column>=r;)r+=t;this.active_sheet.cells.EnsureColumn(r),i=!0}i&&(this.layout.UpdateTiles(),this.layout.UpdateContentsSize(),this.Repaint(!0,!0))}return i}AdvanceSelection(e,t,i=!1,r=!1,s=!0){let n=this.SelectingArgument();if(t.empty)if(n){let o={row:Math.max(0,this.StepVisibleRows(this.primary_selection.target.row,e.rows)),column:Math.max(0,this.StepVisibleColumns(this.primary_selection.target.column,e.columns))};this.Select(t,new g(o))}else this.Select(t,new g({row:0,column:0}));else{let o=this.active_sheet.CellData(t.target);if(o.merge_area&&i&&(i=!o.merge_area.Equals(t.area)),i&&t.area.count>1){let a=this.active_sheet.RealArea(t.area),l=t.target;for(;;){l.row=this.StepVisibleRows(l.row,e.rows),l.column=this.StepVisibleColumns(l.column,e.columns),this.BoundAddressArea(l,a);let d=this.active_sheet.CellData(l);if(!d.merge_area||d.merge_area.start.row===l.row&&d.merge_area.start.column===l.column)break}this.Select(t,a,l)}else if(r&&t&&t.target){let a=t.area,l=t.target,d=a.start,u=a.end,h={row:1/0,column:1/0};if(e.columns&&(a.columns===1?e.columns>0?(u.column=this.StepVisibleColumns(u.column,1),h.column=u.column):(d.column=this.StepVisibleColumns(d.column,-1),h.column=d.column):a.end.column>l.column?(u.column=this.StepVisibleColumns(u.column,e.columns),h.column=u.column):a.start.column<l.column&&(d.column=this.StepVisibleColumns(d.column,e.columns),h.column=d.column),u.column=Math.max(0,u.column),d.column=Math.max(0,d.column)),e.rows&&(a.rows===1?e.rows>0?(u.row=this.StepVisibleRows(u.row,1),h.row=u.row):(d.row=this.StepVisibleRows(d.row,-1),h.row=d.row):a.end.row>l.row?(u.row=this.StepVisibleRows(u.row,e.rows),h.row=u.row):a.start.row<l.row&&(d.row=this.StepVisibleRows(d.row,e.rows),h.row=d.row),u.row=Math.max(0,u.row),d.row=Math.max(0,d.row)),this.options.expand){for(let p of[d,u,h])p.row!==1/0&&(p.row=Math.max(0,p.row)),p.column!==1/0&&(p.column=Math.max(0,p.column));this.EnsureAddress(u)&&(s=!0),this.ScrollIntoView(h),this.Select(t,new g(d,u),void 0,!0)}else{for(let p of[d,u,h])p.row!==1/0&&(p.row=Math.max(0,Math.min(p.row,this.active_sheet.rows-1))),p.column!==1/0&&(p.column=Math.max(0,Math.min(p.column,this.active_sheet.columns-1)));this.ScrollIntoView(h),this.Select(t,new g(d,u),void 0,!0)}}else{let a=t.target;o.merge_area?(e.columns<0?a.column=this.StepVisibleColumns(o.merge_area.start.column,-1):e.columns>0&&(a.column=this.StepVisibleColumns(o.merge_area.end.column,1)),e.rows<0?a.row=this.StepVisibleRows(o.merge_area.start.row,-1):e.rows>0&&(a.row=this.StepVisibleRows(o.merge_area.end.row,1))):(a.row=this.StepVisibleRows(a.row,e.rows),a.column=this.StepVisibleColumns(a.column,e.columns)),this.EnsureAddress(a)&&(s=!0),this.Select(t,new g({row:Math.min(Math.max(0,a.row),this.active_sheet.rows-1),column:Math.min(Math.max(0,a.column),this.active_sheet.columns-1)})),this.RenderSelections(),this.ScrollIntoView(t.target)}}this.SelectingArgument()&&this.UpdateSelectedArgument(t),s&&this.DelayedRender()}HighlightDependencies(e,t=!0){let i=0;e:for(let r of e)if((r.start.row===1/0||r.start.row<this.active_sheet.rows)&&(r.start.column===1/0||r.start.column<this.active_sheet.columns)){r=this.active_sheet.RealArea(r);let s=r.spreadsheet_label;if(this.additional_selections[i]&&this.additional_selections[i].area.spreadsheet_label===s)i++;else{for(let n=0;n<i;n++)if(this.additional_selections[n].area.spreadsheet_label===s&&this.additional_selections[n].area.start.sheet_id===r.start.sheet_id)continue e;this.additional_selections[i++]={target:r.start,area:r}}}this.additional_selections.splice(i),t&&this.RenderSelections(!1)}AddAdditionalSelection(e,t){let i=t.spreadsheet_label;return this.additional_selections.some(r=>r.area.spreadsheet_label===i)?!1:(this.additional_selections.push({target:e,area:t}),!0)}ClearAdditionalSelections(){this.additional_selections.splice(0,this.additional_selections.length)}ClearSelection(e){this.Select(e)}HideGridSelection(){this.UpdateAddressLabel(void 0,"");let e=this.selected_annotation&&this.selected_annotation.formula?this.selected_annotation.formula:"";this.UpdateFormulaBarFormula(e),this.layout.ShowSelections(!1)}ShowGridSelection(){this.UpdateAddressLabel(),this.UpdateFormulaBarFormula(),this.layout.ShowSelections(!0)}Select(e,t,i,r=!1){if(e.empty||r&&(i=e.target),t){let s=this.active_sheet.RealArea(t);i||(i=s.start);let n=!0;for(;n;)n=!1,this.active_sheet.cells.Apply(s,l=>{l.merge_area&&!s.ContainsArea(l.merge_area)&&(t.ConsumeArea(l.merge_area),s=this.active_sheet.RealArea(t),n=!0)});e.area=new g({...t.start,sheet_id:this.active_sheet.id},t.end),i&&(e.target={...i,sheet_id:this.active_sheet.id}),e.empty=!1;let o=this.active_sheet.CellData(e.target),a="";o.formatted&&(typeof o.formatted=="string"?a=o.formatted:a=o.formatted.map(l=>l.flag===1||l.flag===6?"":l.text).join("")),this.overlay_editor?.UpdateCaption(a)}else e.empty=!0;e===this.primary_selection&&(te.is_edge&&this.Focus(),this.grid_events.Publish({type:"selection",selection:this.primary_selection}),this.UpdateAddressLabel(),this.UpdateFormulaBarFormula(),this.options.stats&&this.UpdateStats())}UpdateFormulaBarFormula(e){if(!!this.formula_bar){if(e){this.formula_bar.formula=e;return}if(this.primary_selection.empty)this.formula_bar.formula="";else{let t=this.active_sheet.CellData(this.primary_selection.target),i=t.merge_area||t.area;i&&(i.start.column!==this.primary_selection.target.column||i.start.row!==this.primary_selection.target.row)&&(t=this.active_sheet.CellData(i.start)),this.formula_bar.editable=!t.style?.locked;let r=this.NormalizeCellValue(t);if(t.validation&&!t.style?.locked){let s;t.validation.type===0?s=t.validation.list:t.validation.type===2&&(s=this.GetValidationRange(t.validation.area)),s&&s.length&&this.layout.ShowDropdownCaret(t.merge_area||new g(this.primary_selection.target),s,t.value)}else this.layout.HideDropdownCaret();t.area?this.formula_bar.formula="{"+(r||"")+"}":this.formula_bar.formula=typeof r<"u"?r.toString():""}}}RenderStats(e){if(!Array.isArray(e))return[];let t=0,i=0,r={real:0,imaginary:0};for(let s of e)for(let n of s)typeof n=="number"?(r.real+=n,i++):ge(n)&&(r.real+=n.real,r.imaginary+=n.imaginary,i++),typeof n<"u"&&t++;if(t>1)if(i>0){let s=L.Get("General");if(r.imaginary){let n={real:r.real/i,imaginary:r.imaginary/i};return[{label:"Count",value:t.toString()},{label:"Sum",value:X.FormatPartsAsText(s.FormatComplex(r))},{label:"Average",value:X.FormatPartsAsText(s.FormatComplex(n))}]}else return[{label:"Count",value:t.toString()},{label:"Sum",value:s.Format(r.real)},{label:"Average",value:s.Format(r.real/i)}]}else return[{label:"Count",value:t.toString()}];return[]}UpdateStats(){if(this.tab_bar){let e=[];typeof this.options.stats=="function"?this.primary_selection.empty||(e=this.options.stats.call(void 0,this.GetRange(this.primary_selection.area))):!this.primary_selection.empty&&this.primary_selection.area.count>1&&(e=this.RenderStats(this.GetRange(this.primary_selection.area))),this.tab_bar.stats_data=e}}UpdateAddressLabel(e=this.primary_selection,t){if(!!this.formula_bar)if(typeof t<"u")this.formula_bar.label=t;else if(e.empty)this.formula_bar.label="";else{let i=this.active_sheet.CellData(this.primary_selection.target),r=new g(i.merge_area?i.merge_area.start:e.target);this.formula_bar.label=this.model.named_ranges.MatchSelection(e.area,r)||g.CellAddressToLabel(r.start)}}OnDropdownSelect(e){if(typeof e<"u"){let r=ye.TryParse(e.toString());r.type===3&&(e=r.value)}let t=this.active_sheet.CellData(this.primary_selection.target),i=t.merge_area?t.merge_area.start:this.primary_selection.target;this.ExecCommand({key:6,area:i,value:e}),this.UpdateFormulaBarFormula()}OnScroll(){let e=this.layout.VisibleTiles();e.Equals(this.render_tiles)||(this.render_tiles=e,this.layout_token||(this.layout_token=requestAnimationFrame(()=>this.Repaint())))}AttachListeners(){if(!this.container)throw new Error("invalid container");this.container.addEventListener("copy",this.HandleCopy.bind(this)),this.container.addEventListener("cut",this.HandleCut.bind(this)),this.container.addEventListener("paste",this.HandlePaste.bind(this)),this.layout.grid_cover.addEventListener("mousedown",e=>this.MouseDown_Grid(e)),this.layout.column_header_cover.addEventListener("mousedown",e=>this.MouseDown_ColumnHeader(e)),this.layout.row_header_cover.addEventListener("mousedown",e=>this.MouseDown_RowHeader(e)),this.layout.column_header_cover.addEventListener("mousemove",e=>this.MouseMove_ColumnHeader(e)),this.layout.row_header_cover.addEventListener("mousemove",e=>this.MouseMove_RowHeader(e)),this.layout.grid_cover.addEventListener("mousemove",e=>this.MouseMove_Grid(e)),this.overlay_editor?.edit_node.addEventListener("keydown",e=>this.OverlayKeyDown(e)),this.layout.corner.addEventListener("dblclick",()=>{this.SelectAll()}),window.addEventListener("resize",()=>{this.layout.UpdateDPR()&&(this.QueueLayoutUpdate(),this.Repaint(!0,!0,!0))})}HandleCopy(e){if(e.stopPropagation(),e.preventDefault(),this.primary_selection.empty){if(e.clipboardData&&e.clipboardData.clearData(),this.selected_annotation&&e.clipboardData){let t=JSON.stringify({data:this.selected_annotation,source:this.active_sheet.id});e.clipboardData.setData("text/x-treb-annotation",t);let i=this.selected_annotation.view[this.view_index];if(i&&i.node){let r=i.node.firstChild;if(r){let s=hr(r).outerHTML,n="text/plain";e.clipboardData.setData(n,s)}}}}else{let t=this.active_sheet.RealArea(this.primary_selection.area),i=t.columns,r=t.rows,s=[],n=[];for(let a=0;a<r;a++){let l=[];for(let d=0;d<i;d++){let u={row:t.start.row+a,column:t.start.column+d},h=this.active_sheet.CellData(u),p="";h.calculated?h.calculated_type===7?p=Ge(h.calculated):p=h.calculated.toString():h.type===7?p=Ge(h.value):p=h.value?.toString()||"",l.push(p);let f={address:u,data:h.value,type:h.type,style:this.active_sheet.GetCopyStyle(u)};h.area&&h.area.start.row===u.row&&h.area.start.column===u.column&&(f.array={rows:h.area.rows,columns:h.area.columns}),n.push(JSON.parse(JSON.stringify(f)))}s.push(l)}let o=s.map(a=>a.join(" ")).join(`
|
|
8
|
+
`)+"<ul>";let r=this.completion_list.offsetHeight,s=!1;this.options.autocomplete_prefer_top?s=i.top>=200:document.documentElement&&Math.max(document.documentElement.clientHeight,window.innerHeight||0)-i.bottom<200&&(s=!0),s?this.completion_list.style.top=i.top-r-5+"px":this.completion_list.style.top=i.bottom+5+"px",this.completion_list.style.left=i.left+"px";let n=this.completion_list.querySelectorAll("a");this.active_element=n[this.selected_index],n[this.selected_index].classList.add("selected"),this.last_completion=n[this.selected_index].textContent||void 0,this.completion_list.scrollTop=this.active_element.offsetTop,this.completion_list_visible=!0}else this.completion_list.style.top="-1000px"}};var lt=(R=>(R[R.Null=0]="Null",R[R.InsertRows=1]="InsertRows",R[R.InsertColumns=2]="InsertColumns",R[R.ResizeRows=3]="ResizeRows",R[R.ResizeColumns=4]="ResizeColumns",R[R.Select=5]="Select",R[R.SetRange=6]="SetRange",R[R.UpdateStyle=7]="UpdateStyle",R[R.UpdateBorders=8]="UpdateBorders",R[R.MergeCells=9]="MergeCells",R[R.UnmergeCells=10]="UnmergeCells",R[R.Clear=11]="Clear",R[R.UpdateTheme=12]="UpdateTheme",R[R.SetNote=13]="SetNote",R[R.SetLink=14]="SetLink",R[R.Freeze=15]="Freeze",R[R.SetName=16]="SetName",R[R.ShowHeaders=17]="ShowHeaders",R[R.AddSheet=18]="AddSheet",R[R.DuplicateSheet=19]="DuplicateSheet",R[R.DeleteSheet=20]="DeleteSheet",R[R.ActivateSheet=21]="ActivateSheet",R[R.RenameSheet=22]="RenameSheet",R[R.ReorderSheet=23]="ReorderSheet",R[R.ShowSheet=24]="ShowSheet",R[R.DataValidation=25]="DataValidation",R[R.Reset=26]="Reset",R))(lt||{});var kr={scrollbars:!0,in_cell_editor:!0,formula_bar:!0,add_tab:!1,tab_bar:"auto",insert_function_button:!1,expand_formula_button:!1,expand:!0,repaint_on_cell_change:!0,grid_over_background:!1};var ct=class{grid_events=new Q;command_log=new Q;model;view;get active_sheet(){return this.view.active_sheet}set active_sheet(e){this.view.active_sheet=e}get view_index(){return this.view.view_index}batch=!1;batch_events=[];autocomplete_matcher=new zt;flags={};options;parser;constructor(e={},t,i){this.model=i,this.view={active_sheet:this.model.sheets.list[0],view_index:this.model.view_count++},this.parser=t,this.options={...kr,...e}}UpdateSheets(e,t=!1,i){j.Reset();let r=e.map(s=>j.FromJSON(s,this.model.theme_style_properties));if(r.length===0&&r.push(j.Blank(this.model.theme_style_properties)),this.model.sheets.Assign(r),this.ResetMetadata(),this.active_sheet=r[0],i){let s=this.model.sheets.Find(i);s&&(this.active_sheet=s)}}SetAutocompleteFunctions(e){let t=[];for(let r of this.model.named_expressions.keys())t.push({name:r,type:0});let i=e.slice(0).concat(this.model.named_ranges.List().map(r=>({name:r.name,type:1})),t);this.autocomplete_matcher.SetFunctions(i)}ResetMetadata(){this.model.document_name=void 0,this.model.user_data=void 0}Serialize(e={}){let t=this.model.sheets.list.map(s=>s.toJSON(e)),i;if(this.model.macro_functions.size){i=[];for(let s of this.model.macro_functions.values())i.push({...s,expression:void 0})}let r=[];if(this.model.named_expressions)for(let[s,n]of this.model.named_expressions){this.parser.Walk(n,a=>{if(a.type==="address"||a.type==="range"){let l=a.type==="range"?a.start:a;if(l.absolute_column=l.absolute_row=!0,!l.sheet){if(l.sheet_id){let d=this.model.sheets.Find(l.sheet_id);d&&(l.sheet=d.name)}l.sheet||(l.sheet=this.active_sheet.name)}return a.type==="range"&&(a.end.absolute_column=a.end.absolute_row=!0),!1}return!0});let o=this.parser.Render(n,void 0,"");r.push({name:s,expression:o})}return{sheet_data:t,active_sheet:this.active_sheet.id,named_ranges:this.model.named_ranges.Count()?this.model.named_ranges.Serialize():void 0,macro_functions:i,named_expressions:r.length?r:void 0}}ResizeColumnsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.column;if(typeof i>"u"){i=[];for(let r=0;r<t.columns;r++)i.push(r)}if(typeof i=="number"&&(i=[i]),e.width)for(let r of i)t.SetColumnWidth(r,e.width);else console.error("auto size not supported")}ResizeRowsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.row;if(typeof i>"u"){i=[];for(let r=0;r<t.rows;r++)i.push(r)}if(typeof i=="number"&&(i=[i]),e.height)for(let r of i)t.SetRowHeight(r,e.height);else console.error("auto size not supported")}ResetInternal(){j.Reset(),this.UpdateSheets([],!0),this.model.named_ranges.Reset(),this.model.named_expressions.clear(),this.model.macro_functions.clear()}SetValidationInternal(e){let t,i=this.FindSheet(e.area);if(i&&(t=i.cells.GetCell(e.area,!0)),!t)throw new Error("invalid cell in set validation");e.range?t.validation={type:2,area:e.range,error:!!e.error}:e.list?t.validation={type:0,list:JSON.parse(JSON.stringify(e.list)),error:!!e.error}:t.validation=void 0}GetValidationRange(e){let t,i=this.FindSheet(e);if(i){t=[],e=i.RealArea(new g(e.start,e.end),!0);for(let r=e.start.row;r<=e.end.row;r++)for(let s=e.start.column;s<=e.end.column;s++){let n=i.CellData({row:r,column:s});n&&n.formatted&&(typeof n.formatted=="string"?t.push(n.formatted):t.push(X.FormatPartsAsText(n.formatted)))}}return t}DeleteSheetInternal(e){let t=!1,i=-1,r="",s=!1,n=e.name?e.name.toLowerCase():"",o=this.model.sheets.list.filter((a,l)=>l===e.index||a.id===e.id||a.name.toLowerCase()===n?(t=a===this.active_sheet,this.model.named_ranges.RemoveRangesForSheet(a.id),r=a.name,i=l,!1):!0);if(r&&this.RenameSheetReferences(o,r,"#REF")>0&&(s=!0),!o.length)o.push(j.Blank(this.model.theme_style_properties)),i=0;else if(o.every(a=>!a.visible))o.unshift(j.Blank(this.model.theme_style_properties)),i=0;else for(i>=o.length&&(i=0);!o[i].visible;)i++;return this.model.sheets.Assign(o),t&&this.ActivateSheetInternal({key:21,index:i}),s}RenameSheetInternal(e,t){if(!t||cr.test(t))throw new Error("invalid sheet name");let i=t.toLowerCase();for(let s of this.model.sheets.list)if(s!==e&&s.name.toLowerCase()===i)throw new Error("sheet name already exists");let r=e.name;e.name=t,this.model.sheets.Assign(this.model.sheets.list),this.RenameSheetReferences(this.model.sheets.list,r,t)}SetRangeInternal(e,t={}){let i=P(e.area)?new g(e.area):new g(e.area.start,e.area.end),r=this.FindSheet(i);if(i.start.sheet_id||(i.start.sheet_id=r.id),!i.entire_row&&!i.entire_column&&(i.end.row>=r.rows||i.end.column>=r.columns)&&(r.cells.EnsureCell(i.end),r===this.active_sheet&&(t.layout=!0)),P(e.area)){let s=r.CellData(e.area);if(s.area&&(s.area.rows>1||s.area.columns>1)){this.Error(2);return}let n=Array.isArray(e.value)?Array.isArray(e.value[0])?e.value[0][0]:e.value[0]:e.value;return e.r1c1&&(n=this.TranslateR1C1(e.area,n)),e.array?r.SetArrayValue(i,n):r.SetCellValue(e.area,n),i}else{if(e.array){let s=Array.isArray(e.value)?Array.isArray(e.value[0])?e.value[0][0]:e.value[0]:e.value;e.r1c1&&(s=this.TranslateR1C1(i.start,s)),r.SetArrayValue(i,s)}else{if(e.r1c1){if(Array.isArray(e.value))for(let s=0;s<e.value.length&&s<i.rows;s++){e.value[s]||(e.value[s]=[]);let n=e.value[s];for(let o=0;o<n.length&&o<i.columns;o++){let a={...i.start,row:i.start.row+s,column:i.start.column+o};n[o]=this.TranslateR1C1(a,n[o])}}else if(typeof e.value=="string"&&e.value[0]==="="){let s=[];for(let n=0;n<i.rows;n++){let o=[];for(let a=0;a<i.columns;a++){let l={...i.start,row:i.start.row+n,column:i.start.column+a};o.push(this.TranslateR1C1(l,e.value))}s.push(o)}e.value=s}}r.SetAreaValues2(i,e.value)}return i}}ActivateSheetInternal(e){let t=this.ResolveSheet(e)||this.model.sheets.list[0];if(this.active_sheet===t&&!e.force)return;if(!t.visible)throw new Error("cannot activate hidden sheet");let i=this.active_sheet;this.active_sheet=t,this.grid_events.Publish({type:"sheet-change",deactivate:i,activate:this.active_sheet})}ShowSheetInternal(e){let t=this.ResolveSheet(e);if(!!t&&t.visible!==e.show){if(!e.show){let i=0;for(let r of this.model.sheets.list)(!t.visible||r===t)&&i++;if(i>=this.model.sheets.length)throw new Error("can't hide all sheets")}if(t.visible=e.show,t===this.active_sheet){let i=this.model.sheets.list;for(let r=0;r<i.length;r++)if(i[r]===this.active_sheet){for(let s=r+1;s<i.length;s++)if(i[s].visible){this.ActivateSheetInternal({key:21,index:s});return}for(let s=0;s<i.length;s++)if(i[s].visible){this.ActivateSheetInternal({key:21,index:s});return}throw new Error("no visible sheet")}}}}NormalizeCommands(e){Array.isArray(e)||(e=[e]);let t=this.active_sheet.id;for(let i of e)switch(i.key){case 0:case 17:case 24:case 18:case 19:case 20:case 21:case 22:case 23:case 26:break;case 3:case 4:case 2:case 1:case 15:i.sheet_id||(i.sheet_id=t);break;case 11:case 13:case 14:case 8:case 9:case 10:case 25:case 6:case 7:case 16:case 5:i.area&&(P(i.area)?i.area.sheet_id||(i.area.sheet_id=t):i.area.start.sheet_id||(i.area.start.sheet_id=t));break}return e}AddSheetInternal(e=j.default_sheet_name,t=-1){if(!this.options.add_tab){console.warn("add tab option not set or false");return}for(;this.model.sheets.list.some(r=>r.name===e);){let r=e.match(/^(.*?)(\d+)$/);r?e=r[1]+(Number(r[2])+1):e=e+"2"}let i=j.Blank(this.model.theme_style_properties,e);return t>=0?this.model.sheets.Splice(t,0,i):this.model.sheets.Add(i),i.id}ResolveSheet(e){if(typeof e.index<"u")return this.model.sheets.list[e.index];if(typeof e.name<"u")return this.model.sheets.Find(e.name);if(e.id)return this.model.sheets.Find(e.id)}FindSheet(e){if(e===void 0)return this.active_sheet;let t=typeof e=="number"?e:P(e)?e.sheet_id:e.start.sheet_id;if(!t||t===this.active_sheet.id)return this.active_sheet;let i=this.model.sheets.Find(t);return i||this.active_sheet}PatchFormulasInternal(e,t,i,r,s,n,o){let a=this.parser.Parse(e||""),l=!1;if(a.expression&&(this.parser.Walk(a.expression,d=>{if(d.type==="range"||d.type==="address"){let u=[];d.type==="range"?(d.start.sheet&&d.start.sheet.toLowerCase()===n||!d.start.sheet&&o)&&u.push(d.start,d.end):d.type==="address"&&(d.sheet&&d.sheet.toLowerCase()===n||!d.sheet&&o)&&u.push(d);for(let h of u)i&&h.row>=t&&(i<0&&h.row+i<t?h.column=h.row=-1:h.row+=i,l=!0),s&&h.column>=r&&(s<0&&h.column+s<r?h.column=h.row=-1:h.column+=s,l=!0);return!1}return!0}),l))return"="+this.parser.Render(a.expression,void 0,"")}RenameSheetReferences(e,t,i){let r=0;t=t.toLowerCase();for(let s of e){s.cells.IterateAll(n=>{if(n.ValueIsFormula()){let o=!1,a=this.parser.Parse(n.value||"");a.expression&&(this.parser.Walk(a.expression,l=>(l.type==="address"&&l.sheet&&l.sheet.toLowerCase()===t&&(l.sheet=i,o=!0),!0)),o&&(n.value="="+this.parser.Render(a.expression,void 0,""),r++))}});for(let n of s.annotations)if(n.formula){let o=!1,a=this.parser.Parse(n.formula||"");a.expression&&(this.parser.Walk(a.expression,l=>(l.type==="address"&&l.sheet&&l.sheet.toLowerCase()===t&&(l.sheet=i,o=!0),!0)),o&&(n.formula="="+this.parser.Render(a.expression,void 0,""),r++))}}return r}ApplyBordersInternal(e){let t=e.borders,i=e.borders==="none"?0:e.width,r=new g(e.area.start,e.area.end),s=this.FindSheet(r);r.start.sheet_id=s.id;let n={border_top:i},o={border_bottom:i},a={border_left:i},l={border_right:i},d={border_top:0},u={border_bottom:0},h={border_left:0},p={border_right:0};return e.color&&(n.border_top_fill={...e.color},o.border_bottom_fill={...e.color},a.border_left_fill={...e.color},l.border_right_fill={...e.color}),(t==="none"||t==="all")&&s.UpdateAreaStyle(r,{...n,...o,...a,...l},!0),(t==="top"||t==="outside")&&(r.entire_column||s.UpdateAreaStyle(r.top,{...n},!0)),(t==="none"||t==="all"||t==="outside"||t==="top")&&(r.entire_column||r.start.row&&s.UpdateAreaStyle(new g({row:r.start.row-1,column:r.start.column},{row:r.start.row-1,column:r.end.column}),{...u},!0)),(t==="bottom"||t==="outside")&&(r.entire_column||s.UpdateAreaStyle(r.bottom,{...o},!0)),(t==="none"||t==="all"||t==="outside"||t==="bottom")&&(r.entire_column||s.UpdateAreaStyle(new g({row:r.end.row+1,column:r.start.column},{row:r.end.row+1,column:r.end.column}),{...d},!0)),(t==="left"||t==="outside")&&(r.entire_row||s.UpdateAreaStyle(r.left,{...a},!0)),(t==="none"||t==="all"||t==="outside"||t==="left")&&(r.entire_row||r.start.column&&s.UpdateAreaStyle(new g({row:r.start.row,column:r.start.column-1},{row:r.end.row,column:r.start.column-1}),{...p},!0)),(t==="right"||t==="outside")&&(r.entire_row||s.UpdateAreaStyle(r.right,{...l},!0)),(t==="none"||t==="all"||t==="outside"||t==="right")&&(r.entire_row||s.UpdateAreaStyle(new g({row:r.start.row,column:r.end.column+1},{row:r.end.row,column:r.end.column+1}),{...h},!0)),g.Bleed(r)}TranslateR1C1(e,t){let i=!1,r=this.parser.flags.r1c1;if(this.parser.flags.r1c1=!0,typeof t=="string"&&t[0]==="="){let s=this.parser.Parse(t);s.expression&&(this.parser.Walk(s.expression,n=>(n.type==="address"&&n.r1c1&&(i=!0,n.offset_column&&(n.column=n.column+e.column),n.offset_row&&(n.row=n.row+e.row)),!0)),i&&(this.flags.warned_r1c1||(this.flags.warned_r1c1=!0,console.warn("NOTE: R1C1 support is experimental. the semantics may change in the future.")),t="="+this.parser.Render(s.expression)))}return this.parser.flags.r1c1=r,t}ClearAreaInternal(e){let t=!1;e=this.active_sheet.RealArea(e),this.active_sheet.cells.Apply(e,i=>{i.area&&!e.ContainsArea(i.area)&&(t=!0)}),t?this.Error(2):this.active_sheet.ClearArea(e)}Error(e){this.grid_events.Publish({type:"error",code:e})}DuplicateSheetInternal(e){if(!this.options.add_tab){console.warn("add tab option not set or false");return}let t=this.ResolveSheet(e),i=this.model.sheets.list.reduce((a,l)=>Math.max(a,l.id),0)+1,r=-1;for(let a=0;a<this.model.sheets.length;a++)this.model.sheets.list[a]===t&&(r=a+1);if(!t||r<0)throw new Error("source sheet not found");if(typeof e.insert_before=="number")r=e.insert_before;else if(typeof e.insert_before=="string"){let a=e.insert_before.toLowerCase();for(let l=0;l<this.model.sheets.length;l++)if(this.model.sheets.list[l].name.toLowerCase()===a){r=l;break}}let s={rendered_values:!0},n=j.FromJSON(t.toJSON(s),this.model.theme_style_properties),o=e.new_name||t.name;for(;this.model.sheets.list.some(a=>a.name===o);){let a=o.match(/^(.*?)(\d+)$/);a?o=a[1]+(Number(a[2])+1):o=o+"2"}return n.name=o,n.id=i,this.model.sheets.Splice(r,0,n),n.id}SelectInternal(e){}FreezeInternal(e){let t=this.FindSheet(e.sheet_id||this.active_sheet.id);t.freeze.rows=e.rows,t.freeze.columns=e.columns}InsertRowsInternal(e){let t=this.FindSheet(e.sheet_id);if(!t.InsertRows(e.before_row,e.count))return this.Error(2),{error:!0};this.model.named_ranges.PatchNamedRanges(t.id,0,0,e.before_row,e.count);let i=t.name.toLowerCase();for(let o of this.model.sheets.list){let a=o===t;o.cells.IterateAll(l=>{if(l.ValueIsFormula()){let d=this.PatchFormulasInternal(l.value||"",e.before_row,e.count,0,0,i,a);d&&(l.value=d)}});for(let l of o.annotations)if(l.formula){let d=this.PatchFormulasInternal(l.formula||"",e.before_row,e.count,0,0,i,a);d&&(l.formula=d)}}let r=[],s=[],n=[];if(e.count>0){let o=e.before_row;for(let a of t.annotations)if(a.layout){let[l,d,u]=[a.layout.tl.address.row,a.layout.br.address.row,a.layout.br.offset.y];if(o<=l)a.layout.tl.address.row+=e.count,a.layout.br.address.row+=e.count;else if(o<d||o===d&&u>0)a.layout.br.address.row+=e.count,s.push(a);else continue;r.push(a)}}else if(e.count<0){let o=e.before_row,a=e.before_row-e.count-1;for(let l of t.annotations)if(l.layout){let[d,u,h]=[l.layout.tl.address.row,l.layout.br.address.row,l.layout.br.offset.y];if(o<=d)if(a<d)l.layout.tl.address.row+=e.count,l.layout.br.address.row+=e.count;else if(a<u-1||a===u-1&&h>0)l.layout.tl.address.row=o,l.layout.tl.offset.y=0,l.layout.br.address.row+=e.count,s.push(l);else{n.push(l);continue}else if(o<u||o===u&&h>0)a<u-1||a===u-1&&h>0?(l.layout.br.address.row+=e.count,s.push(l)):(l.layout.br.address.row=o,l.layout.br.offset.y=0,s.push(l));else continue;r.push(l)}}for(let o of n)t.annotations=t.annotations.filter(a=>a!==o);return{update_annotations_list:r,resize_annotations_list:s,delete_annotations_list:n}}InsertColumnsInternal(e){let t=this.FindSheet(e.sheet_id);if(!t.InsertColumns(e.before_column,e.count))return this.Error(2),{error:!0};this.model.named_ranges.PatchNamedRanges(t.id,e.before_column,e.count,0,0);let i=t.name.toLowerCase();for(let o of this.model.sheets.list){let a=o===t;o.cells.IterateAll(l=>{if(l.ValueIsFormula()){let d=this.PatchFormulasInternal(l.value||"",0,0,e.before_column,e.count,i,a);d&&(l.value=d)}});for(let l of o.annotations)if(l.formula){let d=this.PatchFormulasInternal(l.formula,0,0,e.before_column,e.count,i,a);d&&(l.formula=d)}}let r=[],s=[],n=[];if(e.count>0){let o=e.before_column;for(let a of t.annotations)if(a.layout){let[l,d,u]=[a.layout.tl.address.column,a.layout.br.address.column,a.layout.br.offset.x];if(o<=l)a.layout.tl.address.column+=e.count,a.layout.br.address.column+=e.count;else if(o<d||o===d&&u>0)a.layout.br.address.column+=e.count,s.push(a);else continue;r.push(a)}}else if(e.count<0){let o=e.before_column,a=e.before_column-e.count-1;for(let l of t.annotations)if(l.layout){let[d,u,h]=[l.layout.tl.address.column,l.layout.br.address.column,l.layout.br.offset.x];if(o<=d)if(a<d)l.layout.tl.address.column+=e.count,l.layout.br.address.column+=e.count;else if(a<u-1||a===u-1&&h>0)l.layout.tl.address.column=o,l.layout.tl.offset.x=0,l.layout.br.address.column+=e.count,s.push(l);else{n.push(l);continue}else if(o<u||o===u&&h>0)a<u-1||a===u-1&&h>0?(l.layout.br.address.column+=e.count,s.push(l)):(l.layout.br.address.column=o,l.layout.br.offset.x=0,s.push(l));else continue;r.push(l)}}for(let o of n)t.annotations=t.annotations.filter(a=>a!==o);return{update_annotations_list:r,resize_annotations_list:s,delete_annotations_list:n}}ExecCommand(e,t=!0){let i={pending:[]},r=[];e=this.NormalizeCommands(e),t&&this.command_log.Publish({command:e,timestamp:new Date().getTime()});for(let s of e)switch(s.key){case 26:this.ResetInternal();break;case 11:if(s.area){let n=new g(s.area.start,s.area.end);this.ClearAreaInternal(n),i.data_area=g.Join(n,i.data_area),i.formula=!0}break;case 5:this.SelectInternal(s);break;case 15:this.FreezeInternal(s),i.structure_event=!0;break;case 9:{let n=this.FindSheet(s.area);n.MergeCells(new g(s.area.start,s.area.end)),i.structure_event=!0,i.structure_rebuild_required=!0,n===this.active_sheet?(i.data_area=g.Join(s.area,i.data_area),i.render_area=g.Join(s.area,i.render_area)):(i.data_event=!0,i.pending||(i.pending=[]),i.pending.push(n.id))}break;case 10:{let n=this.FindSheet(s.area),o={},a=new g(s.area.start,s.area.end);n.cells.Apply(a,d=>{if(d.merge_area){let u=g.CellAddressToLabel(d.merge_area.start)+":"+g.CellAddressToLabel(d.merge_area.end);o[u]=d.merge_area}},!1);let l=Object.keys(o);for(let d=0;d<l.length;d++)n.UnmergeCells(o[l[d]]);n===this.active_sheet?(i.render_area=g.Join(s.area,i.render_area),i.data_area=g.Join(s.area,i.data_area)):(i.data_event=!0,i.pending||(i.pending=[]),i.pending.push(n.id)),i.structure_event=!0,i.structure_rebuild_required=!0}break;case 7:{let n,o=this.FindSheet(s.area);P(s.area)?(n=new g(s.area),o.UpdateCellStyle(s.area,s.style,!!s.delta)):(n=new g(s.area.start,s.area.end),o.UpdateAreaStyle(n,s.style,!!s.delta)),o===this.active_sheet?(i.style_area=g.Join(n,i.style_area),(!s.delta||s.style.fill||s.style.border_top||s.style.border_left||s.style.border_right||s.style.border_bottom)&&(n=g.Bleed(n),this.active_sheet.Invalidate(n)),i.render_area=g.Join(n,i.render_area)):i.style_event=!0}break;case 25:this.SetValidationInternal(s),(!s.area.sheet_id||s.area.sheet_id===this.active_sheet.id)&&(i.render_area=g.Join(new g(s.area),i.render_area));break;case 16:s.area?(this.model.named_expressions.delete(s.name),this.model.named_ranges.SetName(s.name,new g(s.area.start,s.area.end)),this.autocomplete_matcher.AddFunctions({type:1,name:s.name})):s.expression?(this.model.named_ranges.ClearName(s.name),this.model.named_expressions.set(s.name,s.expression),this.autocomplete_matcher.AddFunctions({type:1,name:s.name})):(this.model.named_ranges.ClearName(s.name),this.model.named_expressions.delete(s.name),this.autocomplete_matcher.RemoveFunctions({type:1,name:s.name})),i.structure_event=!0,i.structure_rebuild_required=!0;break;case 8:{let n=this.ApplyBordersInternal(s);n.start.sheet_id===this.active_sheet.id?(i.render_area=g.Join(n,i.render_area),i.style_area=g.Join(n,i.style_area)):i.style_event=!0}break;case 24:this.ShowSheetInternal(s),i.sheets=!0,i.structure_event=!0;break;case 23:{let n=[],o=this.model.sheets.list[s.index];for(let a=0;a<this.model.sheets.length;a++)a!==s.index&&(a===s.move_before&&n.push(o),n.push(this.model.sheets.list[a]));s.move_before>=this.model.sheets.length&&n.push(o),this.model.sheets.Assign(n),i.sheets=!0,i.structure_event=!0}break;case 22:{let n=this.ResolveSheet(s);n&&(this.RenameSheetInternal(n,s.new_name),i.sheets=!0,i.structure_event=!0)}break;case 3:this.ResizeRowsInternal(s),i.structure_event=!0;break;case 4:this.ResizeColumnsInternal(s),i.structure_event=!0;break;case 17:this.active_sheet.SetHeaderSize(s.show?void 0:1,s.show?void 0:1),this.flags.layout=!0,this.flags.repaint=!0;break;case 1:this.InsertRowsInternal(s),i.structure_event=!0,i.structure_rebuild_required=!0;break;case 2:this.InsertColumnsInternal(s),i.structure_event=!0,i.structure_rebuild_required=!0;break;case 14:case 13:{let n=this.FindSheet(s.area),o=n.cells.GetCell(s.area,!0);if(o){let a;o.merge_area?(a=new g(o.merge_area.start),o=n.cells.GetCell(o.merge_area.start,!0)):a=new g(s.area),s.key===13?o.SetNote(s.note):(o.hyperlink=s.reference||void 0,o.render_clean=[]),n===this.active_sheet?(i.style_area=g.Join(a,i.style_area),i.render_area=g.Join(a,i.render_area)):i.style_event=!0}}break;case 6:{let n=this.SetRangeInternal(s,i);n&&n.start.sheet_id===this.active_sheet.id?(i.data_area=g.Join(n,i.data_area),this.options.repaint_on_cell_change&&(i.render_area=g.Join(n,i.render_area))):i.data_event=!0}break;case 20:this.DeleteSheetInternal(s),i.sheets=!0,i.structure_event=!0,i.structure_rebuild_required=!0;break;case 19:this.DuplicateSheetInternal(s),i.sheets=!0,i.structure_event=!0,i.structure_rebuild_required=!0;break;case 18:{let n=this.AddSheetInternal(s.name,s.insert_index);typeof n=="number"&&s.show&&this.ActivateSheetInternal({key:21,id:n}),i.structure_event=!0,i.sheets=!0,i.structure=!0}break;case 21:this.ActivateSheetInternal(s);break;default:console.warn(`unhandled command: ${lt[s.key]} (${s.key})`)}return i.data_area?(i.data_area.start.sheet_id||i.data_area.SetSheetID(this.active_sheet.id),r.push({type:"data",area:i.data_area})):i.data_event&&r.push({type:"data"}),i.style_area?(i.style_area.start.sheet_id||i.style_area.SetSheetID(this.active_sheet.id),r.push({type:"style",area:i.style_area})):i.style_event&&r.push({type:"style"}),i.structure_event&&r.push({type:"structure",rebuild_required:i.structure_rebuild_required}),this.batch?this.batch_events.push(...r):this.grid_events.Publish(r),i}};var dt=class extends ct{hide_selection=!1;headless=!1;get scale(){return this.layout.scale}set scale(e){this.layout.scale=e,this.UpdateLayout(),this.UpdateAnnotationLayout(),this.layout.UpdateAnnotation(this.active_sheet.annotations),this.layout.ApplyTheme(this.theme),this.overlay_editor?.UpdateTheme(e),this.tab_bar?.UpdateScale(e),this.grid_events.Publish({type:"scale",scale:e});for(let t of this.model.sheets.list)for(let i of t.annotations)i.dirty=!0}theme;language_map;reverse_language_map;hover_data={};editing_state=0;editing_cell={row:-1,column:-1,sheet_id:0};selected_annotation;editing_annotation;grid_container;container;layout;tile_update_pending=!1;scroll_offset_pending;pending_layout_update=new Set;decimal_separator_code=46;overlay_editor;formula_bar;RESIZE_PIXEL_BUFFER=5;select_argument=!1;cell_resize={row:-1,column:-1};render_tiles=new g({row:0,column:0});primary_selection={target:{row:0,column:0},area:new g({row:0,column:0}),empty:!0};active_selection={target:{row:0,column:0},area:new g({row:0,column:0}),empty:!0};nub_select_flag=!1;additional_selections=[];double_click_data={};layout_token=0;render_token=0;tile_renderer;selection_renderer;tab_bar;constructor(e={},t,i,r=wt){super(e,t,i),this.decimal_separator_code=T.decimal_separator.charCodeAt(0),this.theme=JSON.parse(JSON.stringify(r)),this.layout=new Ft(this.model,this.view),e.initial_scale&&(typeof e.initial_scale=="string"&&(e.initial_scale=Number(e.initial_scale)),this.layout.scale=e.initial_scale),this.tile_renderer=new Ot(this.theme,this.layout,this.model,this.view,this.options),this.selection_renderer=new Mt(this.theme,this.layout,this.model,this.view,this.primary_selection,this.additional_selections)}SetLanguageMap(e){if(!e)this.language_map=this.reverse_language_map=void 0;else{let t=Object.keys(e);this.language_map={};for(let i of t)this.language_map[i.toUpperCase()]=e[i];this.reverse_language_map={};for(let i of t){let r=e[i];this.reverse_language_map[r.toUpperCase()]=i}}this.primary_selection.empty||this.Select(this.primary_selection,this.primary_selection.area,this.primary_selection.target)}SetNote(e,t){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.target}this.ExecCommand({key:13,area:e,note:t})}SetLink(e,t){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.target}this.ExecCommand({key:14,area:e,reference:t})}FindAnnotation(e){for(let t of this.active_sheet.annotations)if((t.view[this.view_index]||{}).node===e)return t}CreateAnnotation(e={},t=!0,i=!1,r){let s=new Te(e);if(i)if(!s.layout&&s.scaled_rect&&(s.layout=this.layout.RectToAnnotationLayout(s.scaled_rect)),!s.layout)console.warn("can't offset annotation without layout");else{let n=this.layout.AnnotationLayoutToRect(s.layout).Shift(20,20),o=!0;for(;o;){o=!1;for(let a of this.active_sheet.annotations)if(a!==s&&a.scaled_rect&&a.scaled_rect.top===n.top&&a.scaled_rect.left===n.left){n=n.Shift(20,20),o=!0;break}}s.layout=this.layout.RectToAnnotationLayout(n)}return r&&(z.IsRectangle(r)?(s.layout=void 0,s.rect=z.Create(r)):r.start&&(s.rect=void 0,s.layout=this.layout.AddressToAnnotationLayout(r.start,r.end||r.start))),t&&(this.active_sheet.annotations.some(n=>n===s)||this.active_sheet.annotations.push(s),this.AddAnnotation(s)),s}UpdateAnnotationLayout(){}AddAnnotation(e,t=!1,i=!0){let r=e.view[this.view_index];if(r||(r={},e.view[this.view_index]=r),!r.node){r.node=document.createElement("div"),r.node.dataset.scale=this.layout.scale.toString(),r.node.style.fontSize=`${10*this.layout.scale}pt`,r.content_node=V.CreateDiv("annotation-content",r.node);let s=V.CreateDiv("annotation-move-target",r.node),n=V.CreateDiv("annotation-resize-target",r.node);if(r.node){let o=r.node;o.setAttribute("tabindex","-1"),o.addEventListener("mousedown",a=>{a.button===0&&this.layout.AnnotationMouseDown(e,o,a,s,n).then(l=>{l&&this.grid_events.Publish(l),e.layout&&this.EnsureAddress(e.layout.br.address,1)})}),o.addEventListener("focusin",()=>{for(let a of this.layout.GetFrozenAnnotations(e))a.classList.add("clone-focus");this.selected_annotation=e,this.primary_selection.empty=!0,this.primary_selection.target={row:-1,column:-1,sheet_id:this.active_sheet.id},this.HideGridSelection()}),o.addEventListener("focusout",a=>{for(let l of this.layout.GetFrozenAnnotations(e))l.classList.remove("clone-focus");this.formula_bar&&this.formula_bar.IsElement(a.relatedTarget)?(this.primary_selection.empty=!0,this.RenderSelections(),this.editing_annotation=e,this.layout.ShowSelections(!0)):(this.selected_annotation===e&&(this.selected_annotation=void 0),this.ShowGridSelection())}),o.addEventListener("keydown",a=>{let l=e.scaled_rect;if(!l){console.info("missing scaled rect!");return}let d=[o,...this.layout.GetFrozenAnnotations(e)],u={x:l.left,y:l.top};switch(a.key){case"ArrowUp":case"Up":a.ctrlKey?(this.layout.AnnotationLayoutOrder(e,1)&&this.grid_events.Publish({type:"annotation",event:"move",annotation:e}),o.focus()):u.y--;break;case"ArrowLeft":case"Left":if(a.ctrlKey)return;u.x--;break;case"ArrowRight":case"Right":if(a.ctrlKey)return;u.x++;break;case"ArrowDown":case"Down":a.ctrlKey?(this.layout.AnnotationLayoutOrder(e,-1)&&this.grid_events.Publish({type:"annotation",event:"move",annotation:e}),o.focus()):u.y++;break;case"Escape":case"Esc":this.Focus();break;case"Delete":case"Del":this.Focus(),this.RemoveAnnotation(e);break;default:return}if(a.stopPropagation(),a.preventDefault(),u.x=Math.max(u.x,0),u.y=Math.max(u.y,0),l.left!==u.x||l.top!==u.y){l.left=Math.round(u.x),l.top=Math.round(u.y);for(let h of d)h.style.top=l.top+"px",h.style.left=l.left+"px";e.extent=void 0,this.grid_events.Publish({type:"annotation",event:"move",annotation:e}),e.layout=this.layout.RectToAnnotationLayout(l)}})}}r.node.classList.add("annotation"),i&&(this.layout.AddAnnotation(e),e.layout&&this.EnsureAddress(e.layout.br.address,1)),t||this.grid_events.Publish({type:"annotation",annotation:e,event:"create"})}AnnotationUpdated(e){this.layout.CloneFrozenAnnotation(e)}RemoveAnnotation(e){for(let t=0;t<this.active_sheet.annotations.length;t++)if(e===this.active_sheet.annotations[t]){this.active_sheet.annotations.splice(t,1),this.layout.RemoveAnnotation(e),this.grid_events.Publish({type:"annotation",annotation:e,event:"delete"});return}}RemoveAnnotationNodes(){this.layout.RemoveAnnotationNodes()}Serialize(e={}){return this.active_sheet.selection=JSON.parse(JSON.stringify(this.primary_selection)),this.active_sheet.scroll_offset=this.layout.scroll_offset,super.Serialize(e)}Reset(){this.ExecCommand({key:26})}FromCSV(e){let t=this.parser.decimal_mark===",";t&&(this.parser.argument_separator=",",this.parser.decimal_mark=".");let r=dr(e).map(n=>n.map(o=>{if(o){let a=this.parser.Parse(o);if(a.expression?.type==="complex")return a.expression}return ye.TryParse(o).value}));t&&(this.parser.argument_separator=";",this.parser.decimal_mark=",");let s={row:Math.max(0,r.length-1),column:r.reduce((n,o)=>Math.max(n,Math.max(0,o.length-1)),0)};this.ExecCommand([{key:26},{key:6,area:{start:{row:0,column:0},end:s},value:r}])}ShowHeaders(e=!0){this.ExecCommand({key:17,show:e})}FromImportData(e,t=!1){this.RemoveAnnotationNodes();let i=e.sheets,r=i.map(()=>j.Blank(this.model.theme_style_properties).toJSON()),s;if(typeof e.active_tab=="number")s=r[e.active_tab]?.id;else for(let o=0;o<e.sheets.length;o++)if(!e.sheets[o].hidden){s=r[o].id;break}this.UpdateSheets(r,!0,s);let n={};this.model.macro_functions.clear(),this.ClearSelection(this.primary_selection);for(let o=0;o<i.length;o++){let a=this.model.sheets.list[o];a.ImportData(i[o]),n[a.name]=a.id}if(this.model.sheets.UpdateIndexes(),this.model.named_ranges.Reset(),this.model.named_expressions.clear(),e.names){for(let o of Object.keys(e.names)){let a=this.model.named_ranges.ValidateNamed(o);if(!a){console.warn(`invalid name: ${o}`);continue}let l=e.names[o];if(typeof l!="number"){let d=this.parser.Parse(l);if(d.expression)if(d.expression.type==="range"){let u=n[d.expression.start.sheet||""];u&&(d.expression.start.sheet_id=u,this.model.named_ranges.SetName(a,new g(d.expression.start,d.expression.end),!1))}else if(d.expression.type==="address"){let u=n[d.expression.sheet||""];u&&(d.expression.sheet_id=u,this.model.named_ranges.SetName(a,new g(d.expression),!1))}else{let u=d.expression;this.parser.Walk(u,h=>h.type==="address"||h.type==="range"?(h.type==="range"&&(h=h.start),h.sheet_id||(h.sheet_id=n[h.sheet||""]||0),!1):!0),this.model.named_expressions.set(a,u)}}}this.model.named_ranges.RebuildList()}for(let o of this.active_sheet.annotations)this.AddAnnotation(o,!0);this.QueueLayoutUpdate(),this.StyleDefaultFromTheme(),t&&this.Repaint(!1,!1),this.tab_bar&&this.tab_bar.Update()}NextSheet(e=1){if(this.model.sheets.length===1)return;let t=this.model.sheets.list.map((i,r)=>({sheet:i,index:r})).filter(i=>i.sheet.visible);if(t.length!==1){for(let i=0;i<t.length;i++)if(t[i].sheet===this.active_sheet){let r=(i+e)%t.length;for(;r<0;)r+=t.length;this.ActivateSheet(t[r].index);return}}}InsertSheet(e,t){if(typeof e>"u"&&!this.model.sheets.list.some((i,r)=>i===this.active_sheet?(e=r+1,!0):!1))throw new Error("invalid index");this.ExecCommand({key:18,insert_index:e,name:t,show:!0})}DeleteSheetID(e){this.ExecCommand({key:20,id:e})}DeleteSheet(e){if(typeof e>"u"&&!this.model.sheets.list.some((t,i)=>t===this.active_sheet?(e=i,!0):!1))throw new Error("invalid index");this.ExecCommand({key:20,index:e})}DuplicateSheet(e,t,i){let r={key:19,new_name:t,insert_before:i};typeof e>"u"?r.id=this.active_sheet.id:r.index=e,this.ExecCommand(r)}AddSheet(e){this.ExecCommand({key:18,name:e,show:!0})}ActivateSheet(e){let t=typeof e=="number"?e:void 0,i=typeof e=="string"?e:void 0;this.ExecCommand({key:21,index:t,name:i})}ActivateSheetID(e){this.ExecCommand({key:21,id:e})}ShowAll(){let e=[];for(let t=0;t<this.model.sheets.length;t++)e.push({key:24,index:t,show:!0});this.ExecCommand(e)}ShowSheet(e=0,t=!0){let i={key:24,show:t};typeof e=="string"?i.name=e:i.index=e,this.ExecCommand(i)}UpdateSheets(e,t=!1,i){if(super.UpdateSheets(e,t,i),this.RemoveAnnotationNodes(),this.ClearSelection(this.primary_selection),e[0]&&e[0].primary_selection){let r=e[0].primary_selection;r.empty||this.Select(this.primary_selection,new g(r.area.start,r.area.end),r.target)}else if(!this.active_sheet.selection.empty){let r=this.active_sheet.selection;this.Select(this.primary_selection,new g(r.area.start,r.area.end),r.target)}this.layout.ClearLayoutCaches();for(let r of this.model.sheets.list)for(let s of r.annotations)this.AddAnnotation(s,!0,r===this.active_sheet);this.QueueLayoutUpdate(JSON.parse(JSON.stringify(this.active_sheet.scroll_offset))),this.StyleDefaultFromTheme(),t&&this.Repaint(!1,!1),this.tab_bar&&this.tab_bar.Update()}UpdateLayout(){this.layout.UpdateTiles(),this.render_tiles=this.layout.VisibleTiles(),this.Repaint(!0)}UpdateTheme(e=!1,t){if(!e)for(let r of Object.keys(this.theme))delete this.theme[r];let i=JSON.parse(JSON.stringify(wt));this.grid_container&&(i={...sr(this.grid_container)}),i={...this.theme,...i,...t},Object.assign(this.theme,i),this.StyleDefaultFromTheme(),this.active_sheet.UpdateDefaultRowHeight(),this.active_sheet.FlushCellStyles(),this.layout.ApplyTheme(this.theme),e||(this.UpdateLayout(),this.overlay_editor?.UpdateTheme(this.layout.scale),this.Repaint(!0,!0,!0))}Initialize(e,t=!1){this.grid_container=e,e.classList.add("treb-main"),te.is_windows?e.classList.add("treb-ua-windows"):te.is_mac&&e.classList.add("treb-ua-osx"),e.classList.add("treb-theme"),this.UpdateTheme(!0);let i=document.createElement("div"),r=document.createElement("div");r.classList.add("treb-layout-master"),r.setAttribute("role","grid"),r.appendChild(i),e.appendChild(r);let s;this.options.formula_bar&&(s||(s=new at({theme:this.theme,container:i})),this.InitFormulaBar(e,s)),this.options.tab_bar&&(this.tab_bar=new Lt(this.layout,this.model,this.view,this.options,this.theme,e),this.tab_bar.Subscribe(n=>{switch(n.type){case"cancel":break;case"scale":{let o=this.layout.scale;if(o=Math.round(n.value*1e3)/1e3,o=Math.min(2,Math.max(o,.5)),this.options.persist_scale_key&&localStorage.setItem(this.options.persist_scale_key,JSON.stringify({scale:o})),this.scale=o,n.keep_focus)return}break;case"reorder-sheet":this.ReorderSheet(n.index,n.move_before);break;case"delete-sheet":this.DeleteSheet();break;case"add-sheet":this.AddSheet();break;case"rename-sheet":this.RenameSheet(n.sheet,n.name);break;case"activate-sheet":this.ActivateSheetID(n.sheet.id);break}this.SelectingArgument()||this.Focus()})),this.container=i,this.container.classList.add("treb-grid"),te.is_mac&&te.is_safari&&this.container.classList.add("safari"),this.container.setAttribute("tabindex","-1"),this.layout.Initialize(i,()=>this.OnScroll(),n=>this.OnDropdownSelect(n),this.options.scrollbars),this.selection_renderer.Initialize(),this.layout.UpdateTiles(),s||(s=new at({theme:this.theme,container:i})),this.InitOverlayEditor(s),this.AttachListeners(),this.render_tiles=this.layout.VisibleTiles(),t||(this.tab_bar?.Update(),this.Repaint(!0))}MergeCells(e){!e&&this.primary_selection.empty||(this.layout.HideDropdownCaret(),this.ExecCommand({key:9,area:e||this.primary_selection.area}))}UnmergeCells(e){!e&&this.primary_selection.empty||(this.layout.HideDropdownCaret(),this.ExecCommand({key:10,area:e||this.primary_selection.area}))}Focus(e=""){te.is_mobile?this.container?.focus():this.overlay_editor?.Focus(e)}SetValidation(e,t,i){if(!e){if(this.primary_selection.empty)throw new Error("invalid target in set validation");e=this.primary_selection.target}let r={key:25,area:e,error:i};t&&(Array.isArray(t)?r.list=t:typeof t=="object"&&t.start&&t.end&&P(t.start)&&P(t.end)&&(r.range=t)),this.ExecCommand(r),!this.primary_selection.empty&&(!e.sheet_id||e.sheet_id===this.active_sheet.id)&&this.primary_selection.target.row===e.row&&this.primary_selection.target.column===e.column&&requestAnimationFrame(()=>this.Select(this.primary_selection,this.primary_selection.area,this.primary_selection.target))}SetName(e,t,i){let r=this.model.named_ranges.ValidateNamed(e);if(!r)throw new Error("invalid name");let s=e.trim().toUpperCase();if(this.autocomplete_matcher){for(let o of Object.keys(this.autocomplete_matcher.function_map))if(s===o.toUpperCase()){if(t||i)throw new Error("name already defined");break}}e=r;let n={key:16,name:e};if(t)P(t)&&(t=new g(t)),t.start.sheet_id||(t=new g({...t.start,sheet_id:this.active_sheet.id},t.end)),n.area=new g(t.start,t.end);else if(i){let o=this.parser.Parse(i);if(o.valid&&o.expression)this.parser.Walk(o.expression,a=>{if(a.type==="address"||a.type==="range"){if(a.type==="range"&&(a=a.start),!a.sheet_id&&a.sheet){let l=this.model.sheets.Find(a.sheet);l&&(a.sheet_id=l.id)}return a.sheet_id||(a.sheet_id=this.active_sheet.id),!1}return!0}),n.expression=o.expression;else throw new Error("invalid expression")}this.ExecCommand(n)}SelectAll(){this.Select(this.primary_selection,new g({row:1/0,column:1/0}),void 0,!0),this.RenderSelections()}SelectRange(e){this.Select(this.primary_selection,e),this.RenderSelections()}GetNumberFormat(e){let t=this.active_sheet.CellStyleData(e);if(t&&t.number_format)return L.Get(t.number_format).toString()}GetRangeStyle(e,t=!1){let i=0;if(P(e)?i=e.sheet_id||this.active_sheet.id:i=e.start.sheet_id||this.active_sheet.id,i)return this.model.sheets.Find(i)?.GetCellStyle(e,t)||void 0}GetRange(e,t){if(P(e)){let r=this.model.sheets.Find(e.sheet_id||this.active_sheet.id);return r?t==="formula"?r.cells.RawValue(e):t==="formatted"?r.GetFormattedRange(e):r.cells.GetRange(e):void 0}let i=this.model.sheets.Find(e.start.sheet_id||this.active_sheet.id);if(i)return t==="formula"?i.cells.RawValue(e.start,e.end):t==="formatted"?i.GetFormattedRange(e.start,e.end):i.cells.GetRange(e.start,e.end)}SetRange(e,t,i=!1,r=!1,s=!1,n=!1){if(t=this.UntranslateData(t),!Array.isArray(t))i||s?this.ExecCommand({key:6,area:e,value:t,array:s,r1c1:n}):this.ExecCommand({key:6,area:e.start,value:t,array:s,r1c1:n});else{if(!li(t))if(i){let o=e.entire_column?this.active_sheet.rows:e.rows,a=e.entire_row?this.active_sheet.columns:e.columns,l=o*a;if(l>t.length){let u=t.slice(0),h=Math.ceil(l/u.length);for(let p=1;p<h;p++)u=u.concat(t.slice(0));t=u}let d=[];for(let u=0,h=0;u<a;u++,h+=o)d[u]=t.slice(h,h+o);t=d}else t=[t];r&&(t=this.Transpose(t)),this.ExecCommand({key:6,area:e,value:t,array:s,r1c1:n})}!this.primary_selection.empty&&e.Contains(this.primary_selection.target)&&this.UpdateFormulaBarFormula()}SetRowHeight(e,t,i=!0){this.ExecCommand({key:3,row:e,height:t,shrink:i})}SetColumnWidth(e,t=0){this.ExecCommand({key:4,column:e,width:t})}ApplyStyle(e,t={},i=!0){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.area}j.UpdateStyle(t),this.ExecCommand({key:7,area:e,style:t,delta:i}),this.UpdateFormulaBarFormula()}GetSelection(){return this.primary_selection}Update(e=!1,t){this.DelayedRender(e,t)}ApplyBorders(e,t="none",i,r=1){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.area}t==="none"&&(r=0),this.ExecCommand({key:8,color:{text:i},area:e,borders:t,width:r})}ApplyBorders2(e,t="none",i,r=1){if(!e){if(this.primary_selection.empty)return;e=this.primary_selection.area}t==="none"&&(r=0),this.ExecCommand({key:8,color:i,area:e,borders:t,width:r})}GetFreeze(){return{...this.active_sheet.freeze}}Freeze(e=0,t=0,i=!0){this.ExecCommand({key:15,rows:e,columns:t,highlight_transition:i})}Batch(e,t=!0){this.batch=!0,e(),this.batch=!1;let i=this.batch_events.slice(0);return this.batch_events=[],t&&this.DelayedRender(!1),i}InsertColumns(e=0,t=1){this.ExecCommand({key:2,before_column:e,count:t})}ReorderSheet(e,t){this.ExecCommand({key:23,index:e,move_before:t})}RenameSheet(e,t){this.ExecCommand({key:22,new_name:t,id:e.id})}InsertRows(e=0,t=1){this.ExecCommand({key:1,before_row:e,count:t})}ScrollTo(e,t=!0,i=!0,r=!1){this.layout.ScrollTo(e,t,i,r)}ScrollIntoView(e){this.options.scrollbars&&this.layout.ScrollIntoView(e)}GetScrollOffset(){return this.layout.GetScrollOffset()}ScrollOffset(e){if(e)this.layout.scroll_offset=e;else return this.layout.scroll_offset}TranslateInternal(e,t){let i=this.parser.Parse(e);if(i.expression){let r=!1;if(this.parser.Walk(i.expression,s=>{if(s.type==="call"){let n=t[s.name.toUpperCase()];n&&(r=!0,s.name=n)}return!0}),r)return"="+this.parser.Render(i.expression,void 0,"")}return e}TranslateFunction(e){return this.language_map?this.TranslateInternal(e,this.language_map):e}UntranslateFunction(e){return this.reverse_language_map?this.TranslateInternal(e,this.reverse_language_map):e}UntranslateData(e){return Array.isArray(e)?li(e)?e.map(t=>t.map(i=>i&&typeof i=="string"&&i[0]==="="?this.UntranslateFunction(i):i)):e.map(t=>t&&typeof t=="string"&&t[0]==="="?this.UntranslateFunction(t):t):(e&&typeof e=="string"&&e[0]==="="&&(e=this.UntranslateFunction(e)),e)}StyleDefaultFromTheme(){this.model.theme_style_properties.font_face=this.theme.grid_cell?.font_face||"",this.model.theme_style_properties.font_size=this.theme.grid_cell?.font_size||{unit:"pt",value:10}}AutoSizeColumn(e,t,i=!0){let r=12,s=4*2;i||(r=e.GetColumnWidth(t));for(let n=0;n<e.cells.rows;n++){let o=e.CellData({row:n,column:t}),a=o.formatted||"";if(typeof a!="string"&&(a=a.map(l=>l.text).join("")),a&&a.length){let l=this.tile_renderer.MeasureText(a,A.Font(o.style||{}));r=Math.max(r,Math.ceil(l.width)+s)}}e.SetColumnWidth(t,r)}EnsureActiveSheet(e=!1){for(let t of this.model.sheets.list)if(t===this.active_sheet){e&&this.ActivateSheetInternal({key:21,id:t.id,force:!0});return}this.ActivateSheetInternal({key:21,index:0})}ActivateSheetInternal(e){let t=this.SelectingArgument(),i=this.ResolveSheet(e)||this.model.sheets.list[0];if(this.active_sheet===i&&!e.force)return;if(!i.visible)throw new Error("cannot activate hidden sheet");this.HideHoverInfo(),this.active_sheet.selection=JSON.parse(JSON.stringify(this.primary_selection)),this.active_sheet.scroll_offset=this.layout.scroll_offset;let r=this.active_sheet;this.RemoveAnnotationNodes(),this.active_sheet=i,t?this.RenderSelections():(this.ClearSelection(this.primary_selection),i.selection&&!i.selection.empty&&this.Select(this.primary_selection,new g(i.selection.area.start,i.selection.area.end),i.selection.target));let s=this.active_sheet.annotations;for(let n of s)this.AddAnnotation(n,!0);this.QueueLayoutUpdate(),this.pending_layout_update.has(this.active_sheet.id)?(this.Repaint(!0,!0),this.pending_layout_update.delete(this.active_sheet.id)):this.Repaint(!1,!1),this.grid_events.Publish({type:"sheet-change",deactivate:r,activate:this.active_sheet}),this.tab_bar&&this.tab_bar.Update(),this.layout.scroll_offset=this.active_sheet.scroll_offset,this.formula_bar?.selecting&&requestAnimationFrame(()=>this.formula_bar?.FocusEditor())}HighlightFreezeArea(){for(let e of[this.layout.corner_selection,this.layout.row_header_selection,this.layout.column_header_selection])e.classList.add("highlight-area"),setTimeout(()=>{e.classList.remove("highlight-area")},400)}QueueLayoutUpdate(e){this.tile_update_pending=!0,e&&(this.scroll_offset_pending=e)}HandleAddressLabelEvent(e){if(e){let t=(n="")=>{let o=n.toLowerCase();for(let a of this.model.sheets.list)if(a.name.toLowerCase()===o)return a.id;return this.active_sheet.id},i=n=>{for(let o of this.model.sheets.list)if(o.id===n)return o;return this.active_sheet},r,s=this.parser.Parse(e);if(s.expression)switch(s.expression.type){case"address":s.expression.sheet_id=t(s.expression.sheet),r=new g(s.expression);break;case"range":s.expression.start.sheet_id=t(s.expression.start.sheet),r=new g(s.expression.start,s.expression.end);break;case"identifier":r=this.model.named_ranges.Get(s.expression.name),r||this.primary_selection.empty||this.SetName(s.expression.name.toUpperCase(),this.primary_selection.area);break;default:break}if(r){let n=i(r.start.sheet_id);if(n.columns>=r.end.column&&n.rows>=r.end.row){this.ExecCommand({key:5,area:r});return}else console.warn("address out of range")}}this.UpdateAddressLabel(),this.Focus()}InitFormulaBar(e,t){this.formula_bar=new Gt(e,this.parser,this.theme,this.model,this.view,this.options,t),this.formula_bar.autocomplete_matcher=this.autocomplete_matcher,this.formula_bar.Subscribe(i=>{switch(i.type){case"address-label-event":this.HandleAddressLabelEvent(i.text);break;case"stop-editing":this.editing_state=0;break;case"start-editing":this.editing_state=2,this.editing_cell={...this.primary_selection.target};break;case"discard":if(this.editing_state=0,this.editing_annotation){this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection);let r=this.editing_annotation.view[this.view_index]?.node;r&&r.focus(),this.editing_annotation=void 0,this.UpdateFormulaBarFormula(),this.DelayedRender();return}this.container&&this.Focus(),this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection),this.UpdateFormulaBarFormula(),this.DelayedRender();break;case"commit":if(this.active_sheet.id!==this.editing_cell.sheet_id&&this.editing_cell.sheet_id&&this.ActivateSheetID(this.editing_cell.sheet_id),this.editing_state=0,this.editing_annotation){let r=this.editing_annotation;this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection),r.formula=i.value?this.FixFormula(i.value):"";let s=this.editing_annotation.view[this.view_index]?.node;s&&s.focus(),this.grid_events.Publish({type:"annotation",event:"update",annotation:r}),this.editing_annotation=void 0,this.DelayedRender();return}this.container&&this.Focus(),this.SetInferredType(this.primary_selection,i.value,i.array),this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection),this.options.repaint_on_cell_change&&this.DelayedRender(!1,this.primary_selection.area),i.event&&this.OverlayKeyDown(i.event);break;case"update":i.dependencies&&this.HighlightDependencies(i.dependencies);break}})}InitOverlayEditor(e){!this.container||(this.overlay_editor=new Pt(this.container,this.parser,this.theme,this.model,this.view,e),this.overlay_editor.UpdateTheme(this.layout.scale),this.overlay_editor.autocomplete_matcher=this.autocomplete_matcher,this.overlay_editor.Subscribe(t=>{switch(t.type){case"stop-editing":this.editing_state=0;break;case"start-editing":this.editing_state=1,this.editing_cell={...this.primary_selection.target};break;case"update":t.dependencies&&this.HighlightDependencies(t.dependencies);break;case"end-selection":this.ClearSelection(this.active_selection),this.DelayedRender();break}}))}DelayedRender(e=!1,t,i=!1){!this.tile_update_pending&&t?this.layout.DirtyArea(t):!this.tile_update_pending&&e&&this.layout.DirtyAll(),this.render_token||(this.render_token=1,se().then(()=>{this.render_token=0,this.Repaint(e,i)}))}Repaint(e=!1,t=!1,i=!1){if(this.headless)return;if(this.tile_update_pending&&(this.tile_update_pending=!1,this.layout.UpdateTiles(),this.scroll_offset_pending&&(this.layout.scroll_offset=this.scroll_offset_pending,this.scroll_offset_pending=void 0),this.render_tiles=this.layout.VisibleTiles(),this.layout.UpdateAnnotation(this.active_sheet.annotations)),this.layout_token=0,this.tile_renderer.OverflowDirty(t),e)for(let a of this.layout.grid_tiles)for(let l of a)l.dirty=!0;let r=this.render_tiles.start,s=this.render_tiles.end,n=[];for(let a=r.row;a<=s.row;a++)n.push(a);let o=[];for(let a=r.column;a<=s.column;a++)o.push(a);r.row>0&&this.active_sheet.freeze.rows&&n.push(0),r.column>0&&this.active_sheet.freeze.columns&&o.push(0);for(let a of o)for(let l of n){let d=this.layout.grid_tiles[a][l];(e||d.dirty||d.needs_full_repaint)&&(this.tile_renderer.Render(d),d.dirty=d.needs_full_repaint=!1)}this.tile_renderer.RenderHeaders(this.render_tiles,i),this.tile_renderer.RenderCorner(),this.RenderSelections()}MouseMove_RowHeader(e){let t=this.layout.CoordinateToRowHeader(e.offsetY),i=this.layout.OffsetCellAddressToRectangle({row:t.row,column:0});this.hover_data.address&&(this.hover_data.address.row!==-1||this.hover_data.address.column!==-1)&&this.HoverCell({row:-1,column:-1});let r=-1;e.offsetY-i.top<=this.RESIZE_PIXEL_BUFFER&&t.row>0?r=t.row-1:i.bottom-e.offsetY<=this.RESIZE_PIXEL_BUFFER&&(r=t.row),r>=0?this.layout.ResizeCursor("row"):this.cell_resize.row&&(this.cell_resize.row=-1,this.layout.ResizeCursor()),this.cell_resize.row=r}MouseMove_ColumnHeader(e){let t=this.layout.CoordinateToColumnHeader(e.offsetX),i=this.layout.OffsetCellAddressToRectangle({row:0,column:t.column});this.hover_data.address&&(this.hover_data.address.row!==-1||this.hover_data.address.column!==-1)&&this.HoverCell({row:-1,column:-1});let r=-1;e.offsetX-i.left<=this.RESIZE_PIXEL_BUFFER&&t.column>0?r=t.column-1:i.right-e.offsetX<=this.RESIZE_PIXEL_BUFFER&&(r=t.column),r>=0?this.layout.ResizeCursor("column"):this.cell_resize.column&&(this.cell_resize.column=-1,this.layout.ResizeCursor()),this.cell_resize.column=r}MouseDown_RowHeader(e){if(e.button!==0)return;e.stopPropagation(),e.preventDefault();let t=this.layout.CoordinateToRowHeader(e.offsetY),i=this.layout.row_header_cover.getBoundingClientRect(),r={x:i.left,y:i.top};if(this.cell_resize.row>=0){let s=this.cell_resize.row,n=r.y+e.offsetY;if(this.layout.HideDropdownCaret(),this.IsDoubleClick({row:s,column:-1})){let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.rows>1&&this.primary_selection.area.start.column===1/0&&this.primary_selection.area.ContainsRow(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);p=[];for(let m=f.start.row;m<=f.end.row;m++)p.push(m)}this.ExecCommand({key:3,row:p});return}let o=this.layout.RowHeight(s),a=o,l=this.layout.OffsetCellAddressToRectangle({row:s,column:0}),d=r.y+l.bottom;this.layout.ShowTooltip({left:!0,text:`${a}px`,x:Math.round(i.right+10),y:d});let u=[],h=[];for(let p of this.active_sheet.annotations){let f=l.bottom-1;if(!p.scaled_rect||p.scaled_rect.bottom<f)continue;let m=[...this.layout.GetFrozenAnnotations(p)],b=p.view[this.view_index]?.node;b&&m.push(b),f<=p.scaled_rect.top&&p.move_with_cells?u.push({annotation:p,y:p.scaled_rect.top,nodes:m}):f>p.scaled_rect.top&&p.resize_with_cells&&h.push({annotation:p,height:p.scaled_rect.height,nodes:m})}me(this.layout.mask,"row-resize",p=>{let f=Math.max(-o,Math.round(p.offsetY-n));if(f+o!==a){a=f+o,this.layout.SetRowHeight(s,a),this.layout.UpdateTooltip({text:`${a}px`,y:d+f});for(let{annotation:m,y:b}of u)m.scaled_rect&&(m.scaled_rect.top=b+f);for(let{annotation:m,height:b}of h)m.scaled_rect&&(m.scaled_rect.height=b+f);requestAnimationFrame(()=>{for(let{annotation:m,nodes:b}of h)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);for(let{annotation:m,nodes:b}of u)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);this.layout.UpdateTileHeights(!0,s),this.Repaint(!1,!0),this.layout.UpdateAnnotation(this.active_sheet.annotations)})}},()=>{this.layout.HideTooltip(),requestAnimationFrame(()=>{let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.rows>1&&this.primary_selection.area.start.column===1/0&&this.primary_selection.area.ContainsRow(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);p=[];for(let m=f.start.row;m<=f.end.row;m++)p.push(m)}this.ExecCommand({key:3,row:p,height:a});for(let{annotation:f}of u)f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));for(let{annotation:f}of h){f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));let m=f.view[this.view_index];m&&m.resize_callback&&m.resize_callback.call(void 0)}})})}else{let s=this.SelectingArgument()?this.active_selection:this.primary_selection;if(this.SelectingArgument()||this.Focus(),e.shiftKey&&!s.empty){let n=s.target;this.Select(s,new g(s.target,t,!0),void 0,!0),t=n}else this.Select(s,new g(t),{column:0,row:t.row});this.RenderSelections(),me(this.layout.mask,[],n=>{let o=this.layout.CoordinateToRowHeader(n.offsetY-r.y),a=new g(o,t,!0);(s.empty||!a.Equals(s.area))&&(this.Select(s,a,void 0,!0),this.RenderSelections())},()=>{})}}MouseDown_ColumnHeader(e){if(e.button!==0)return;e.stopPropagation(),e.preventDefault();let t=this.layout.CoordinateToColumnHeader(e.offsetX),i=this.layout.column_header_cover.getBoundingClientRect(),r={x:i.left,y:i.top};if(this.cell_resize.column>=0){let s=this.cell_resize.column,n=r.x+e.offsetX;if(this.layout.HideDropdownCaret(),this.IsDoubleClick({row:-1,column:s})){let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.columns>1&&this.primary_selection.area.start.row===1/0&&this.primary_selection.area.ContainsColumn(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);p=[];for(let m=f.start.column;m<=f.end.column;m++)p.push(m)}this.ExecCommand({key:4,column:p});return}let o=this.layout.ColumnWidth(s),a=o,l=this.layout.OffsetCellAddressToRectangle({row:0,column:s}),d=r.x+l.right;this.layout.ShowTooltip({up:!0,text:`${a}px`,x:d,y:Math.round(i.bottom+10)});let u=[],h=[];for(let p of this.active_sheet.annotations){let f=l.right-1;if(!p.scaled_rect||p.scaled_rect.right<f)continue;let m=[...this.layout.GetFrozenAnnotations(p)],b=p.view[this.view_index]?.node;b&&m.push(b),f<=p.scaled_rect.left&&p.move_with_cells?u.push({annotation:p,x:p.scaled_rect.left,nodes:m}):f>p.scaled_rect.left&&p.resize_with_cells&&h.push({annotation:p,width:p.scaled_rect.width,nodes:m})}me(this.layout.mask,"column-resize",p=>{let f=Math.max(-o,Math.round(p.offsetX-n));if(f+o!==a){a=f+o,this.layout.UpdateTooltip({text:`${a}px`,x:d+f}),this.layout.SetColumnWidth(s,a);for(let{annotation:m,x:b}of u)m.scaled_rect&&(m.scaled_rect.left=b+f);for(let{annotation:m,width:b}of h)m.scaled_rect&&(m.scaled_rect.width=b+f);requestAnimationFrame(()=>{for(let{annotation:m,nodes:b}of h)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);for(let{annotation:m,nodes:b}of u)if(m.scaled_rect)for(let _ of b)m.scaled_rect.ApplyStyle(_);this.layout.UpdateTileWidths(!0,s),this.Repaint(!1,!0)})}},()=>{this.layout.HideTooltip(),requestAnimationFrame(()=>{let p=[s];if(!this.primary_selection.empty&&this.primary_selection.area.columns>1&&this.primary_selection.area.start.row===1/0&&this.primary_selection.area.ContainsColumn(s)){let f=this.active_sheet.RealArea(this.primary_selection.area);for(let m=f.start.column;m<=f.end.column;m++)p.push(m)}this.ExecCommand({key:4,column:p,width:a});for(let{annotation:f}of u)f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));for(let{annotation:f}of h){f.scaled_rect&&(f.layout=this.layout.RectToAnnotationLayout(f.scaled_rect));let m=f.view[this.view_index];m&&m.resize_callback&&m.resize_callback.call(void 0)}})})}else{let s=this.SelectingArgument()?this.active_selection:this.primary_selection;if(this.SelectingArgument()||this.Focus(),e.shiftKey&&!s.empty){let n=s.target;this.Select(s,new g(s.target,t,!0),void 0,!0),t=n}else this.Select(s,new g(t),{row:0,column:t.column});this.RenderSelections(),me(this.layout.mask,[],n=>{let o=this.layout.CoordinateToColumnHeader(n.offsetX-r.x),a=new g(o,t,!0);(s.empty||!a.Equals(s.area))&&(this.Select(s,a,void 0,!0),this.RenderSelections())})}}HoverCell(e,t){let i=this.active_sheet.cells.GetCell(e,!1);if(i?.merge_area){let r=i.merge_area;e=r.start,i=this.active_sheet.cells.GetCell(e,!1),e={row:r.start.row,column:r.end.column}}if(i?.note){let r=this.options.markdown?we.instance.HTML(we.instance.Parse(i.note)):void 0;this.layout.ShowNote(i.note,e,t,r),this.hover_data.note=!0}else this.hover_data.note&&(this.layout.HideNote(),this.hover_data.note=!1);i?.hyperlink?(this.layout.ShowTitle("Link: "+i.hyperlink,e),this.hover_data.link=!0,this.hover_data.cell=i):this.hover_data.link&&(this.layout.HideTitle(),this.hover_data.cell=void 0),this.hover_data.address={...e}}HideHoverInfo(){this.layout.HideTitle(),this.layout.HideTooltip(),this.hover_data.note=this.hover_data.link=!1,this.hover_data.cell=void 0,this.hover_data.pointer&&this.layout.grid_cover.classList.remove("link-pointer"),this.hover_data.pointer=!1}MouseMove_Grid(e){e.stopPropagation(),e.preventDefault(),(this.cell_resize.row>=0||this.cell_resize.column>=0)&&this.layout.ResizeCursor();let t={x:e.offsetX,y:e.offsetY},i;if(this.overlay_editor?.editing||(i=this.layout.PointToAddress_Grid(t),(!this.hover_data.address||this.hover_data.address.row!==i.row||this.hover_data.address.column!==i.column)&&this.HoverCell(i,e)),this.hover_data.link&&i&&(this.hover_data.point=t,this.hover_data.handler||(this.hover_data.handler=requestAnimationFrame(()=>{let s=this.hover_data.address&&this.hover_data.point&&this.hover_data.cell&&this.PointInTextPart(this.hover_data.address,this.hover_data.point,this.hover_data.cell);s!==!!this.hover_data.pointer&&(this.hover_data.pointer=s,s?this.layout.grid_cover.classList.add("link-pointer"):this.layout.grid_cover.classList.remove("link-pointer")),this.hover_data.handler=void 0}))),this.primary_selection.empty||!this.selection_renderer.nub_rectangle){this.nub_select_flag&&(this.layout.grid_cover.classList.remove("nub-select"),this.nub_select_flag=!1);return}let r=this.selection_renderer.nub_rectangle.Contains(e.offsetX,e.offsetY);r!==this.nub_select_flag&&(r?this.layout.grid_cover.classList.add("nub-select"):this.layout.grid_cover.classList.remove("nub-select"),this.nub_select_flag=r)}ClearDoubleClick(){this.double_click_data.address=void 0}IsDoubleClick(e,t=300){if(this.double_click_data.address&&this.double_click_data.address.row===e.row&&this.double_click_data.address.column===e.column)return clearTimeout(this.double_click_data.timeout),this.double_click_data.address=void 0,this.double_click_data.timeout=void 0,!0;this.double_click_data.timeout&&clearTimeout(this.double_click_data.timeout),this.double_click_data.address={...e},this.double_click_data.timeout=window.setTimeout(()=>{this.double_click_data.address=void 0,this.double_click_data.timeout=void 0},t)}PointInTextPart(e,t,i){let r=this.layout.CellAddressToRectangle(e);i.merge_area&&(r=r.Combine(this.layout.CellAddressToRectangle(i.merge_area.end)));let s=t.x-r.left,n=t.y-r.top,o=i.renderer_data?.text_data?.strings||[];for(let a of o)for(let l of a)if(typeof l.left=="number"&&typeof l.top=="number"&&typeof l.width=="number"&&typeof l.height=="number"&&s>=l.left&&n>=l.top&&s<=l.left+l.width&&n<=l.top+l.height)return!0;return!1}MouseDown_Grid(e){if(e.button!==0)return;e.stopPropagation(),e.preventDefault();let t=this.SelectingArgument();!t&&this.additional_selections.length&&this.ClearAdditionalSelections(),(!t||!this.formula_bar?.selecting)&&this.Focus(),this.overlay_editor?.editing&&!this.overlay_editor?.selecting&&this.DismissEditor();let i={x:e.offsetX,y:e.offsetY},r=this.layout.PointToAddress_Grid(i),s=t?this.active_selection:this.primary_selection;if(!t&&this.IsDoubleClick(r)){te.is_mobile&&this.overlay_editor?.edit_node?.focus(),this.OverlayEditCell({target:r,area:new g(r)},!1);return}let n=this.layout.grid_cover.getBoundingClientRect(),o={x:n.left,y:n.top},a=[],l;if(e.shiftKey&&!s.empty){let u=s.target;this.Select(s,new g(r,s.target,!0),void 0,!0),r=u}else if(this.nub_select_flag)r=s.area.TopLeft(),a.push("nub-select"),l=this.active_sheet.RealArea(s.area);else{let u=r,h=this.active_sheet.CellData(u);if(h.merge_area&&(u=h.merge_area.start,h=this.active_sheet.CellData(h.merge_area.start)),h.hyperlink&&this.PointInTextPart(u,i,h)){let p=h.hyperlink;se().then(()=>{this.grid_events.Publish({type:"cell-event",data:{type:"hyperlink",data:p}})}),this.ClearDoubleClick();return}if(h.click_function){let p=this.layout.CellAddressToRectangle(u);h.merge_area&&(p=p.Combine(this.layout.CellAddressToRectangle(h.merge_area.end)));let f=h.click_function.call(this,{cell:h,x:i.x-p.left,y:i.y-p.top,width:p.width,height:p.height,scale:this.layout.scale});if(f.value&&this.ExecCommand({key:6,value:f.value,area:u}),f.block_selection){this.ClearDoubleClick(),!this.primary_selection.empty&&this.primary_selection.target.row===u.row&&this.primary_selection.target.column===u.column&&this.UpdateFormulaBarFormula();return}}this.Select(s,new g(r),r)}this.RenderSelections(),t&&this.UpdateSelectedArgument(s);let d=this.layout.CellAddressToRectangle({row:0,column:0}).Combine(this.layout.CellAddressToRectangle({row:this.active_sheet.rows-1,column:this.active_sheet.columns-1})).Expand(-1,-1);me(this.layout.mask,a,u=>{let h={x:u.offsetX-o.x,y:u.offsetY-o.y},p=d.Clamp(h.x,h.y),f=this.layout.PointToAddress_Grid(p,!0),m=this.layout.scroll_reference_node,b=!1;this.container&&this.options.scrollbars&&(h.x<m.scrollLeft?(m.scrollLeft-=25,b=!0):h.x>m.scrollLeft+this.container.clientWidth&&(m.scrollLeft+=25,b=!0),h.y<m.scrollTop?(m.scrollTop-=25,b=!0):h.y>m.scrollTop+this.container.clientHeight&&(m.scrollTop+=25,b=!0),b&&(n=this.layout.grid_cover.getBoundingClientRect(),o.x=n.left+document.body.scrollLeft,o.y=n.top+document.body.scrollTop));let _=new g(f,r,!0);if(l&&(_=l.Clone(),_.ConsumeAddress(f),_.rows!==l.rows&&_.columns!==l.columns)){let y={rows:f.row>l.end.row?f.row-l.end.row:l.start.row-f.row,columns:f.column>l.end.column?f.column-l.end.column:l.start.column-f.column};y.rows>=y.columns?_=new g({row:_.start.row,column:l.start.column},{row:_.end.row,column:l.end.column}):_=new g({row:l.start.row,column:_.start.column},{row:l.end.row,column:_.end.column})}(s.empty||!_.Equals(s.area))&&(this.Select(s,_,void 0,!0),this.RenderSelections(),t?this.UpdateSelectedArgument(s):!s.empty&&!s.area.entire_sheet&&(s.area.entire_column?this.UpdateAddressLabel(void 0,s.area.columns+"C"):s.area.entire_row?this.UpdateAddressLabel(void 0,s.area.rows+"R"):s.area.count>1?this.UpdateAddressLabel(void 0,s.area.rows+"R x "+s.area.columns+"C"):this.UpdateAddressLabel(s)))},()=>{this.UpdateAddressLabel(),t?this.overlay_editor?.editing||this.select_argument||this.formula_bar&&this.formula_bar.FocusEditor():l&&this.RecycleNubArea(s.area,l)})}Transpose(e){let t=[],i=e.length,r=e[0].length;for(let s=0;s<r;s++){t[s]=[];for(let n=0;n<i;n++)t[s][n]=e[n][s]}return t}RecycleNubArea(e,t){if(e.Equals(t))return;let i=[];for(let u=0;u<t.rows;u++){i[u]=[];for(let h=0;h<t.columns;h++){let p={row:t.start.row+u,column:t.start.column+h};i[u][h]=this.active_sheet.CellData(p)}}if(i[0][0].area&&i[0][0].area.Equals(t)){this.ExecCommand({key:6,value:i[0][0].value,array:!0,area:e});return}let r=[],s=[],n=t.columns,o=e.rows,a=!1,l=!1;e.columns===t.columns?a=e.start.row<t.start.row:(n=t.rows,o=e.columns,a=e.start.column<t.start.column,i=this.Transpose(i),l=!0);for(let u=0;u<o;u++)r[u]=[],s[u]=[];for(let u=0;u<n;u++){let h=0;if(i.length>1){h=1;let p=[],f=[];for(let m=0;m<i.length;m++){let b=i[m][u];b.ValueIsNumber()&&(f.push(m),p.push(b.value))}if(p.length>1){let m=p.slice(1).map((b,_)=>b-p[_]);m.every(b=>b===m[0])&&(h=m[0])}p.length&&(h+=p[p.length-1]-p[0])}for(let p=0;p<i.length;p++){let f,m=i[p][u];if(m.ValueIsFormula()){let w=this.parser.Parse(m.value);w.expression&&w.full_reference_list?.length&&(f=w.expression)}let b=0,_=p,y=i.length,x=0,v=h;a&&(_=o-i.length+p,y=-i.length,v=-h);for(let w=_;w>=0&&w<o;w+=y,b+=y,x+=v){if(f)r[w][u]="="+this.parser.Render(f,{rows:b,columns:0});else{let C=i[p][u];C.ValueIsNumber()?r[w][u]=C.value+x:r[w][u]=C.value}s[w][u]=i[p][u].style||{}}}}let d=[{key:6,value:l?this.Transpose(r):r,array:!1,area:e}];l&&(s=this.Transpose(s));for(let u=0;u<s.length;u++)for(let h=0;h<s[u].length;h++)d.push({key:7,area:{row:u+e.start.row,column:h+e.start.column},style:s[u][h],delta:!1});this.ExecCommand(d)}UpdateSelectedArgument(e){let t=this.active_sheet.CellData(e.area.start),i=new g(t.merge_area?t.merge_area.start:e.target),r=this.model.named_ranges.MatchSelection(e.area,i);if(!r&&(r=e.area.spreadsheet_label,t.merge_area&&t.merge_area.Equals(e.area)&&(r=g.CellAddressToLabel(t.merge_area.start)),this.active_sheet.id!==this.editing_cell.sheet_id)){let s=this.active_sheet.name;st.test(s)?r=`'${s}'!${r}`:r=`${s}!${r}`}this.overlay_editor?.editing&&this.overlay_editor.selecting?this.overlay_editor.InsertReference(r,0):this.formula_bar&&this.formula_bar.selecting?this.formula_bar.InsertReference(r,0):this.select_argument&&this.grid_events.Publish({type:"alternate-selection",selection:this.active_selection})}SelectingArgument(){return this.overlay_editor?.editing&&this.overlay_editor?.selecting||this.formula_bar&&this.formula_bar.selecting||this.select_argument}OverlayKeyDown(e){let t=!1;if(this.overlay_editor&&this.overlay_editor.editing)switch(t=!0,this.overlay_editor.HandleKeyDown(e)){case 1:return;case 3:this.editing_state=0,this.DismissEditor(),this.DelayedRender();return;case 2:if(this.active_sheet.id!==this.editing_cell.sheet_id&&this.editing_cell.sheet_id&&this.ActivateSheetID(this.editing_cell.sheet_id),this.editing_state=0,this.overlay_editor?.selection){let l=this.overlay_editor?.edit_node.textContent||void 0,d=e.key==="Enter"&&e.ctrlKey&&e.shiftKey;this.SetInferredType(this.overlay_editor.selection,l,d)}this.DismissEditor(),this.options.repaint_on_cell_change&&this.DelayedRender(!1,this.overlay_editor?.selection.area||void 0);break}let i=this.SelectingArgument();if(this.formula_bar&&this.formula_bar.focused&&!i||this.selected_annotation&&!i)return;let r=i?this.active_selection:this.primary_selection,s={rows:0,columns:0},n=!1,o=!1;if(e.ctrlKey||te.is_mac&&e.metaKey){switch(e.key){case"ArrowDown":case"Down":s.rows++;break;case"ArrowUp":case"Up":s.rows--;break;case"ArrowLeft":case"Left":s.columns--;break;case"ArrowRight":case"Right":s.columns++;break;case"Delete":case"Del":{e.stopPropagation(),e.preventDefault();for(let a=0;a<this.model.sheets.length;a++)if(this.model.sheets.list[a]===this.active_sheet){this.DeleteSheet(a);break}return}break;case"/":e.stopPropagation(),e.preventDefault(),this.SelectArray();break;default:if(e.shiftKey)return}if(s.columns||s.rows)if(e.stopPropagation(),e.preventDefault(),!r.empty&&(s.columns||s.rows)){if(this.BlockSelection(r,!!e.shiftKey,s.columns,s.rows))return}else return;else{let a={},l=this.primary_selection.empty?{}:this.active_sheet.CellData(this.primary_selection.target).style||{};switch(e.key.toLowerCase()){case"b":a.bold=!l.bold;break;case"i":a.italic=!l.italic;break;case"u":a.underline=!l.underline;break;case"a":this.SelectAll();break;case"0":if(!e.altKey)return;this.ClearSelection(this.primary_selection),this.RenderSelections();break;default:e.key;return}Object.keys(a).length&&this.ApplyStyle(void 0,a)}}else switch(e.key){case"Tab":e.shiftKey?s.columns--:s.columns++,n=!0;break;case"Enter":e.shiftKey?s.rows--:s.rows++,n=!0;break;case"ArrowDown":case"Down":s.rows++,o=e.shiftKey;break;case"ArrowUp":case"Up":s.rows--,o=e.shiftKey;break;case"ArrowLeft":case"Left":s.columns--,o=e.shiftKey;break;case"ArrowRight":case"Right":s.columns++,o=e.shiftKey;break;case"Delete":case"Del":r.empty||this.DeleteSelection(r);break;case"PageUp":case"PageDown":if(e.shiftKey){this.NextSheet(e.key==="PageUp"?-1:1);break}return;case"Control":case"Shift":case"Alt":return;default:r.empty||this.OverlayEditCell(r,!0,e);return}e.stopPropagation(),e.preventDefault(),(s.rows||s.columns)&&this.AdvanceSelection(s,r,n,o,!t)}SelectArray(){if(this.primary_selection.empty)return;let e=this.active_sheet.CellData(this.primary_selection.target);!e||!e.area||(this.Select(this.primary_selection,e.area,e.area.start),this.RenderSelections())}RenderSelections(e=!0){let t=this.hide_selection?!1:!this.editing_state||this.editing_cell.sheet_id===this.active_sheet.id;this.selection_renderer.RenderSelections(t,e)}BlockSelection(e,t,i,r,s=!0){if(e.empty)return!1;let n={...e.target};r>0?n.row=Math.max(n.row,e.area.end.row):r<0&&(n.row=Math.min(n.row,e.area.start.row)),i>0?n.column=Math.max(n.column,e.area.end.column):i<0&&(n.column=Math.min(n.column,e.area.start.column));let o=this.active_sheet.cells,a=o.GetCell(e.target,!1);if(!a||a.type===0&&!a.area)return!1;let l={...n};for(;;){let d={row:l.row+r,column:l.column+i};if(d.column<0||d.row<0||d.column>=this.active_sheet.columns||d.row>=this.active_sheet.rows)break;let u=!1;if(r)for(let h=e.area.start.column;!u&&h<=e.area.end.column;h++)a=o.GetCell({row:d.row,column:h},!1),u=u||!!a&&(a.type!==0||!!a.area),!u&&a&&a.merge_area&&(a=o.GetCell(a.merge_area.start,!1),u=u||!!a&&(a.type!==0||!!a.area));else for(let h=e.area.start.row;!u&&h<=e.area.end.row;h++)a=o.GetCell({row:h,column:d.column},!1),u=u||!!a&&(a.type!==0||!!a.area),!u&&a&&a.merge_area&&(a=o.GetCell(a.merge_area.start,!1),u=u||!!a&&(a.type!==0||!!a.area));if(!u)break;l=d}if(t){r?(n.row=e.target.row,n.column=e.area.start.column,l.column=e.area.end.column):(n.column=e.target.column,n.row=e.area.start.row,l.row=e.area.end.row);let d=new g(n,l,!0);this.Select(e,d,e.target,!0)}else this.Select(e,new g(l));return this.ScrollIntoView(l),this.SelectingArgument()&&this.UpdateSelectedArgument(e),s&&this.DelayedRender(),!0}DeleteSelection(e){if(e.empty)return;let t=this.active_sheet.RealArea(e.area);this.ExecCommand({key:11,area:t})}SetInferredType(e,t,i=!1,r=!0){let s=e.target||e.area.start,n=this.active_sheet.CellData(s);if(n.area){if(!i&&n.area.count>1||!e.area||!e.area.Equals(n.area)){this.Error(2);return}}else if(i){let u=!1;if(this.active_sheet.cells.Apply(e.area,h=>{h.area&&(u=!0)},!1),u){this.Error(2);return}}if(n.validation&&n.validation.error){let u;if(n.validation.type===0?u=n.validation.list:n.validation.type===2&&(u=this.GetValidationRange(n.validation.area)),u&&u.length){let h=!1;if(t){let p=t.toUpperCase();for(let f of u)if(f&&f.toString().toUpperCase()===p){t=f.toString(),h=!0;break}}if(!h){this.Error(3);return}}}n.merge_area&&(s=n.merge_area.start);let o=typeof t=="string"&&t.trim()[0]==="=",a=[];if(o&&(t=this.FixFormula(t||""),!this.active_sheet.HasCellStyle(s))){let u=this.parser.Parse(t);if(u){if(u.expression?.type==="call"&&(!n.style||!n.style.number_format||L.Equals(n.style.number_format,"General"))){let h=u.expression.name.toLowerCase(),p;switch(h){case"today":p="Short Date";break;case"now":p="Timestamp";break}p&&a.push({key:7,area:i?e.area:s,style:{number_format:p},delta:!0})}if(u.dependencies){let h=u.dependencies;for(let p of Object.keys(h.addresses)){let f=h.addresses[p];if(this.active_sheet.HasCellStyle({...f})){let m=this.active_sheet.CellData({...f});if(m.style&&m.style.number_format){let b={number_format:m.style.number_format};a.push({key:7,area:i?e.area:s,style:b,delta:!0})}break}}}}}let l=this.parser.Parse(t||"").expression;l?.type==="group"&&l.elements.length===1&&l.elements[0].type==="complex"&&(l=l.elements[0]);let d=l&&l.type==="complex"?{type:7,value:{real:l.real,imaginary:l.imaginary}}:ye.TryParse(t);if(!o&&d.type===3){let u="",h=d.hints||0;(!n.style||!n.style.number_format||L.Equals(n.style.number_format,"General"))&&(h&64?u="Short Date":h&2?u="Exponential":h&4?u="Percent":h&8?u="Currency":(h&16||h&32)&&(u="Accounting")),u&&a.push({key:7,area:i?e.area:s,style:{number_format:u},delta:!0})}if(a.push({key:6,area:i?e.area:s,array:i,value:o?this.UntranslateFunction(t||""):d.value}),r)this.ExecCommand(a);else return a}FixFormula(e){if(e.trim()[0]!=="=")return e;e=e.replace(/^\s+/,"");let t=!1,i=!1,r=0,s=!1,n=e.length;for(let o=0;o<n;o++){let a=e[o];if(!s)switch(a){case'"':t?e[o+1]==='"'?o++:t=!1:i||(t=!0);break;case"'":i?i=!1:t||(i=!0);break;case"\\":s=!0;break;case"(":!t&&!i&&r++;break;case")":!t&&!i&&r--;break}}for(t?e+='"':i&&(e+="'");r>0;)e+=")",r--;return e=this.NormalizeFormula(e),e}NormalizeFormula(e){let t=this.parser.Parse(e);return t.error&&console.warn(t.error),t&&t.expression&&(this.parser.Walk(t.expression,i=>{switch(i.type){case"call":i.name=this.autocomplete_matcher.NormalizeIdentifier(i.name)||i.name;break;case"identifier":this.model.named_ranges.Get(i.name)&&(i.name=i.name.toUpperCase());break}return!0}),e="="+this.parser.Render(t.expression,void 0,"")),e}DismissEditor(){this.overlay_editor?.active_cell&&(this.overlay_editor.active_cell.editing=!1,this.overlay_editor.active_cell.render_clean=[],this.DelayedRender(void 0,this.overlay_editor.selection.area)),this.editing_state=0,this.Focus(),this.overlay_editor?.CloseEditor(),this.ClearAdditionalSelections(),this.ClearSelection(this.active_selection)}NormalizeCellValue(e){let t=e.value;if(e.ValueIsNumber()&&e.style&&e.style.number_format)if(L.Get(e.style.number_format).date_format){let r=Ve(e.value),s=r.getUTCHours()||r.getUTCMinutes()||r.getUTCSeconds()?"Timestamp":"Short Date";t=L.Get(s).Format(t)}else if(/(?:%|percent)/i.test(e.style.number_format)){let r=0,s=e.value.toString().match(/\.(.*?)$/);s&&s[1]&&(r=Math.max(0,s[1].length-2)),t=(e.value*100).toFixed(r)+"%",T.decimal_separator===","&&(t=t.replace(/\./,","))}else t&&T.decimal_separator===","&&(t=e.value.toString().replace(/\./,","));else{if(e.ValueIsBoolean())return e.value.toString().toUpperCase();e.ValueIsNumber()?t&&T.decimal_separator===","&&(t=e.value.toString().replace(/\./,",")):e.ValueIsComplex()?(e.value.imaginary?e.value.real?t=`${e.value.real.toString()}${e.value.imaginary<0?" - ":" + "}${e.value.imaginary===1||e.value.imaginary===-1?"":Math.abs(e.value.imaginary).toString()}i`:e.value.imaginary===1?t="i":e.value.imaginary===-1?t="-i":t=e.value.imaginary.toString()+"i":t=e.value.real.toString(),T.decimal_separator===","&&(t=t.replace(/\./,","))):e.ValueIsFormula()&&(t=this.TranslateFunction(e.value))}return t}IsNumeric(e){return e>=48&&e<=57||e===this.decimal_separator_code||e===45||e===43}OverlayEditCell(e,t=!0,i){if(!this.options.in_cell_editor)return;let r=e.target||e.area.start,s=this.active_sheet.CellData(r),n;if(this.HideHoverInfo(),s.merge_area?(n=this.layout.OffsetCellAddressToRectangle(s.merge_area.start).Combine(this.layout.OffsetCellAddressToRectangle(s.merge_area.end)),r=s.merge_area.start,s=this.active_sheet.CellData(r)):n=this.layout.OffsetCellAddressToRectangle(r),s.style?.locked){console.info("cell is locked for editing");return}n=n.Shift(this.layout.header_size.width,this.layout.header_size.height);let o=s.value;t?(s.type===3||s.rendered_type===3)&&s.style&&s.style.number_format&&/(?:%|percent)/i.test(s.style.number_format)&&(!i||this.IsNumeric(i.key.charCodeAt(0)))?o="%":o=void 0:o=this.NormalizeCellValue(s),this.overlay_editor?.Edit(e,n.Expand(-1,-1),s,o,i),s.editing=!0,s.render_clean=[],this.DelayedRender(!1,e.area)}BoundAddressArea(e,t){e.column>t.end.column?(e.row=this.StepVisibleRows(e.row,1),e.row>t.end.row&&(e.row=t.start.row),e.column=t.start.column):e.column<t.start.column?(e.row=this.StepVisibleRows(e.row,-1),e.row<t.start.row&&(e.row=t.end.row),e.column=t.end.column):e.row>t.end.row?(e.column=this.StepVisibleColumns(e.column,1),e.column>t.end.column&&(e.column=t.start.column),e.row=t.start.row):e.row<t.start.row&&(e.column=this.StepVisibleColumns(e.column,-1),e.column<t.start.column&&(e.column=t.end.column),e.row=t.end.row)}StepVisibleRows(e,t){if(t>0)for(let i=0;i<t;i++)this.layout.RowHeight(++e)||i--;else if(t<0)for(let i=0;i>t;i--)--e>=0&&!this.layout.RowHeight(e)&&i++;return e}StepVisibleColumns(e,t){if(t>0)for(let i=0;i<t;i++)this.layout.ColumnWidth(++e)||i--;else if(t<0)for(let i=0;i>t;i--)--e>=0&&!this.layout.ColumnWidth(e)&&i++;return e}EnsureAddress(e,t=8){let i=!1;if(this.options.expand){if(e.row!==1/0&&e.row>=this.active_sheet.rows){let r=this.active_sheet.rows;for(;e.row>=r;)r+=t;this.active_sheet.cells.EnsureRow(r),i=!0}if(e.column!==1/0&&e.column>=this.active_sheet.columns){let r=this.active_sheet.columns;for(;e.column>=r;)r+=t;this.active_sheet.cells.EnsureColumn(r),i=!0}i&&(this.layout.UpdateTiles(),this.layout.UpdateContentsSize(),this.Repaint(!0,!0))}return i}AdvanceSelection(e,t,i=!1,r=!1,s=!0){let n=this.SelectingArgument();if(t.empty)if(n){let o={row:Math.max(0,this.StepVisibleRows(this.primary_selection.target.row,e.rows)),column:Math.max(0,this.StepVisibleColumns(this.primary_selection.target.column,e.columns))};this.Select(t,new g(o))}else this.Select(t,new g({row:0,column:0}));else{let o=this.active_sheet.CellData(t.target);if(o.merge_area&&i&&(i=!o.merge_area.Equals(t.area)),i&&t.area.count>1){let a=this.active_sheet.RealArea(t.area),l=t.target;for(;;){l.row=this.StepVisibleRows(l.row,e.rows),l.column=this.StepVisibleColumns(l.column,e.columns),this.BoundAddressArea(l,a);let d=this.active_sheet.CellData(l);if(!d.merge_area||d.merge_area.start.row===l.row&&d.merge_area.start.column===l.column)break}this.Select(t,a,l)}else if(r&&t&&t.target){let a=t.area,l=t.target,d=a.start,u=a.end,h={row:1/0,column:1/0};if(e.columns&&(a.columns===1?e.columns>0?(u.column=this.StepVisibleColumns(u.column,1),h.column=u.column):(d.column=this.StepVisibleColumns(d.column,-1),h.column=d.column):a.end.column>l.column?(u.column=this.StepVisibleColumns(u.column,e.columns),h.column=u.column):a.start.column<l.column&&(d.column=this.StepVisibleColumns(d.column,e.columns),h.column=d.column),u.column=Math.max(0,u.column),d.column=Math.max(0,d.column)),e.rows&&(a.rows===1?e.rows>0?(u.row=this.StepVisibleRows(u.row,1),h.row=u.row):(d.row=this.StepVisibleRows(d.row,-1),h.row=d.row):a.end.row>l.row?(u.row=this.StepVisibleRows(u.row,e.rows),h.row=u.row):a.start.row<l.row&&(d.row=this.StepVisibleRows(d.row,e.rows),h.row=d.row),u.row=Math.max(0,u.row),d.row=Math.max(0,d.row)),this.options.expand){for(let p of[d,u,h])p.row!==1/0&&(p.row=Math.max(0,p.row)),p.column!==1/0&&(p.column=Math.max(0,p.column));this.EnsureAddress(u)&&(s=!0),this.ScrollIntoView(h),this.Select(t,new g(d,u),void 0,!0)}else{for(let p of[d,u,h])p.row!==1/0&&(p.row=Math.max(0,Math.min(p.row,this.active_sheet.rows-1))),p.column!==1/0&&(p.column=Math.max(0,Math.min(p.column,this.active_sheet.columns-1)));this.ScrollIntoView(h),this.Select(t,new g(d,u),void 0,!0)}}else{let a=t.target;o.merge_area?(e.columns<0?a.column=this.StepVisibleColumns(o.merge_area.start.column,-1):e.columns>0&&(a.column=this.StepVisibleColumns(o.merge_area.end.column,1)),e.rows<0?a.row=this.StepVisibleRows(o.merge_area.start.row,-1):e.rows>0&&(a.row=this.StepVisibleRows(o.merge_area.end.row,1))):(a.row=this.StepVisibleRows(a.row,e.rows),a.column=this.StepVisibleColumns(a.column,e.columns)),this.EnsureAddress(a)&&(s=!0),this.Select(t,new g({row:Math.min(Math.max(0,a.row),this.active_sheet.rows-1),column:Math.min(Math.max(0,a.column),this.active_sheet.columns-1)})),this.RenderSelections(),this.ScrollIntoView(t.target)}}this.SelectingArgument()&&this.UpdateSelectedArgument(t),s&&this.DelayedRender()}HighlightDependencies(e,t=!0){let i=0;e:for(let r of e)if((r.start.row===1/0||r.start.row<this.active_sheet.rows)&&(r.start.column===1/0||r.start.column<this.active_sheet.columns)){r=this.active_sheet.RealArea(r);let s=r.spreadsheet_label;if(this.additional_selections[i]&&this.additional_selections[i].area.spreadsheet_label===s)i++;else{for(let n=0;n<i;n++)if(this.additional_selections[n].area.spreadsheet_label===s&&this.additional_selections[n].area.start.sheet_id===r.start.sheet_id)continue e;this.additional_selections[i++]={target:r.start,area:r}}}this.additional_selections.splice(i),t&&this.RenderSelections(!1)}AddAdditionalSelection(e,t){let i=t.spreadsheet_label;return this.additional_selections.some(r=>r.area.spreadsheet_label===i)?!1:(this.additional_selections.push({target:e,area:t}),!0)}ClearAdditionalSelections(){this.additional_selections.splice(0,this.additional_selections.length)}ClearSelection(e){this.Select(e)}HideGridSelection(){this.UpdateAddressLabel(void 0,"");let e=this.selected_annotation&&this.selected_annotation.formula?this.selected_annotation.formula:"";this.UpdateFormulaBarFormula(e),this.layout.ShowSelections(!1)}ShowGridSelection(){this.UpdateAddressLabel(),this.UpdateFormulaBarFormula(),this.layout.ShowSelections(!0)}Select(e,t,i,r=!1){if(e.empty||r&&(i=e.target),t){let s=this.active_sheet.RealArea(t);i||(i=s.start);let n=!0;for(;n;)n=!1,this.active_sheet.cells.Apply(s,l=>{l.merge_area&&!s.ContainsArea(l.merge_area)&&(t.ConsumeArea(l.merge_area),s=this.active_sheet.RealArea(t),n=!0)});e.area=new g({...t.start,sheet_id:this.active_sheet.id},t.end),i&&(e.target={...i,sheet_id:this.active_sheet.id}),e.empty=!1;let o=this.active_sheet.CellData(e.target),a="";o.formatted&&(typeof o.formatted=="string"?a=o.formatted:a=o.formatted.map(l=>l.flag===1||l.flag===6?"":l.text).join("")),this.overlay_editor?.UpdateCaption(a)}else e.empty=!0;e===this.primary_selection&&(te.is_edge&&this.Focus(),this.grid_events.Publish({type:"selection",selection:this.primary_selection}),this.UpdateAddressLabel(),this.UpdateFormulaBarFormula(),this.options.stats&&this.UpdateStats())}UpdateFormulaBarFormula(e){if(!!this.formula_bar){if(e){this.formula_bar.formula=e;return}if(this.primary_selection.empty)this.formula_bar.formula="";else{let t=this.active_sheet.CellData(this.primary_selection.target),i=t.merge_area||t.area;i&&(i.start.column!==this.primary_selection.target.column||i.start.row!==this.primary_selection.target.row)&&(t=this.active_sheet.CellData(i.start)),this.formula_bar.editable=!t.style?.locked;let r=this.NormalizeCellValue(t);if(t.validation&&!t.style?.locked){let s;t.validation.type===0?s=t.validation.list:t.validation.type===2&&(s=this.GetValidationRange(t.validation.area)),s&&s.length&&this.layout.ShowDropdownCaret(t.merge_area||new g(this.primary_selection.target),s,t.value)}else this.layout.HideDropdownCaret();t.area?this.formula_bar.formula="{"+(r||"")+"}":this.formula_bar.formula=typeof r<"u"?r.toString():""}}}RenderStats(e){if(!Array.isArray(e))return[];let t=0,i=0,r={real:0,imaginary:0};for(let s of e)for(let n of s)typeof n=="number"?(r.real+=n,i++):ge(n)&&(r.real+=n.real,r.imaginary+=n.imaginary,i++),typeof n<"u"&&t++;if(t>1)if(i>0){let s=L.Get("General");if(r.imaginary){let n={real:r.real/i,imaginary:r.imaginary/i};return[{label:"Count",value:t.toString()},{label:"Sum",value:X.FormatPartsAsText(s.FormatComplex(r))},{label:"Average",value:X.FormatPartsAsText(s.FormatComplex(n))}]}else return[{label:"Count",value:t.toString()},{label:"Sum",value:s.Format(r.real)},{label:"Average",value:s.Format(r.real/i)}]}else return[{label:"Count",value:t.toString()}];return[]}UpdateStats(){if(this.tab_bar){let e=[];typeof this.options.stats=="function"?this.primary_selection.empty||(e=this.options.stats.call(void 0,this.GetRange(this.primary_selection.area))):!this.primary_selection.empty&&this.primary_selection.area.count>1&&(e=this.RenderStats(this.GetRange(this.primary_selection.area))),this.tab_bar.stats_data=e}}UpdateAddressLabel(e=this.primary_selection,t){if(!!this.formula_bar)if(typeof t<"u")this.formula_bar.label=t;else if(e.empty)this.formula_bar.label="";else{let i=this.active_sheet.CellData(this.primary_selection.target),r=new g(i.merge_area?i.merge_area.start:e.target);this.formula_bar.label=this.model.named_ranges.MatchSelection(e.area,r)||g.CellAddressToLabel(r.start)}}OnDropdownSelect(e){if(typeof e<"u"){let r=ye.TryParse(e.toString());r.type===3&&(e=r.value)}let t=this.active_sheet.CellData(this.primary_selection.target),i=t.merge_area?t.merge_area.start:this.primary_selection.target;this.ExecCommand({key:6,area:i,value:e}),this.UpdateFormulaBarFormula()}OnScroll(){let e=this.layout.VisibleTiles();e.Equals(this.render_tiles)||(this.render_tiles=e,this.layout_token||(this.layout_token=requestAnimationFrame(()=>this.Repaint())))}AttachListeners(){if(!this.container)throw new Error("invalid container");this.container.addEventListener("copy",this.HandleCopy.bind(this)),this.container.addEventListener("cut",this.HandleCut.bind(this)),this.container.addEventListener("paste",this.HandlePaste.bind(this)),this.layout.grid_cover.addEventListener("mousedown",e=>this.MouseDown_Grid(e)),this.layout.column_header_cover.addEventListener("mousedown",e=>this.MouseDown_ColumnHeader(e)),this.layout.row_header_cover.addEventListener("mousedown",e=>this.MouseDown_RowHeader(e)),this.layout.column_header_cover.addEventListener("mousemove",e=>this.MouseMove_ColumnHeader(e)),this.layout.row_header_cover.addEventListener("mousemove",e=>this.MouseMove_RowHeader(e)),this.layout.grid_cover.addEventListener("mousemove",e=>this.MouseMove_Grid(e)),this.overlay_editor?.edit_node.addEventListener("keydown",e=>this.OverlayKeyDown(e)),this.layout.corner.addEventListener("dblclick",()=>{this.SelectAll()}),window.addEventListener("resize",()=>{this.layout.UpdateDPR()&&(this.QueueLayoutUpdate(),this.Repaint(!0,!0,!0))})}HandleCopy(e){if(e.stopPropagation(),e.preventDefault(),this.primary_selection.empty){if(e.clipboardData&&e.clipboardData.clearData(),this.selected_annotation&&e.clipboardData){let t=JSON.stringify({data:this.selected_annotation,source:this.active_sheet.id});e.clipboardData.setData("text/x-treb-annotation",t);let i=this.selected_annotation.view[this.view_index];if(i&&i.node){let r=i.node.firstChild;if(r){let s=hr(r).outerHTML,n="text/plain";e.clipboardData.setData(n,s)}}}}else{let t=this.active_sheet.RealArea(this.primary_selection.area),i=t.columns,r=t.rows,s=[],n=[];for(let a=0;a<r;a++){let l=[];for(let d=0;d<i;d++){let u={row:t.start.row+a,column:t.start.column+d},h=this.active_sheet.CellData(u),p="";h.calculated?h.calculated_type===7?p=Ge(h.calculated):p=h.calculated.toString():h.type===7?p=Ge(h.value):p=h.value?.toString()||"",l.push(p);let f={address:u,data:h.value,type:h.type,style:this.active_sheet.GetCopyStyle(u)};h.area&&h.area.start.row===u.row&&h.area.start.column===u.column&&(f.array={rows:h.area.rows,columns:h.area.columns}),n.push(JSON.parse(JSON.stringify(f)))}s.push(l)}let o=s.map(a=>a.join(" ")).join(`
|
|
9
9
|
`);e.clipboardData&&(e.clipboardData.clearData(),e.clipboardData.setData("text/plain",o),e.clipboardData.setData("text/x-treb",JSON.stringify({source:t,data:n})))}}HandleCut(e){if(e.stopPropagation(),e.preventDefault(),this.HandleCopy(e),this.primary_selection.empty)this.selected_annotation&&this.RemoveAnnotation(this.selected_annotation);else{let t=this.active_sheet.RealArea(this.primary_selection.area);this.ExecCommand({key:11,area:t})}}RecyclePasteAreas(e,t){let i=[];if(e.count===1)for(let r=t.start.row;r<=t.end.row;r++)for(let s=t.start.column;s<=t.end.column;s++)i.push(new g({row:r,column:s}));else if(e.columns===t.columns&&t.rows>=e.rows&&t.rows%e.rows===0)for(let r=t.start.row;r<=t.end.row;r+=e.rows)i.push(new g({row:r,column:t.start.column},{row:r+e.rows-1,column:t.end.column}));else if(e.rows===t.rows&&t.columns>=e.columns&&t.columns%e.columns===0)for(let r=t.start.column;r<=t.end.column;r+=e.columns)i.push(new g({column:r,row:t.start.row},{column:r+e.columns-1,row:t.end.row}));else i.push(t.Clone().Resize(e.rows,e.columns));return i}HandlePaste(e){if(this.overlay_editor?.editing||(e.stopPropagation(),e.preventDefault(),!e.clipboardData))return;let t=e.clipboardData.getData("text/x-treb-annotation");if(t){try{let n=JSON.parse(t);if(n.source&&n.source!==this.active_sheet.id&&n.data&&n.data.formula){let l="",d=this.model.sheets.Find(n.source);if(d&&(l=d.name),l){let u=this.parser.Parse(n.data.formula);u.expression&&(this.parser.Walk(u.expression,h=>h.type==="range"?(!h.start.sheet_id&&!h.start.sheet&&(h.start.sheet=l),!1):(h.type==="address"&&!h.sheet_id&&!h.sheet&&(h.sheet=l),!0)),n.data.formula="="+this.parser.Render(u.expression,void 0,""))}}let a=this.CreateAnnotation(n.data,!0,!0).view[this.view_index];if(a&&a.node){let l=a.node;setTimeout(()=>{l.focus()},1)}}catch(n){console.error(n)}return}if(this.primary_selection.empty)return;let i=this.active_sheet.RealArea(this.primary_selection.area),r=[],s=e.clipboardData.getData("text/x-treb");if(s)try{let n=JSON.parse(s),o=new g(n.source.start,n.source.end),a=this.RecyclePasteAreas(o,i);a.length===1&&i.Resize(a[0].rows,a[0].columns);let l=[];for(let d of a){this.active_sheet.cells.EnsureCell(d.end),r.push({key:11,area:d});let u={rows:d.start.row-o.start.row,columns:d.start.column-o.start.column};n.data.forEach(h=>{let p=h.data,f={row:h.address.row-o.start.row+d.start.row,column:h.address.column-o.start.column+d.start.column};if(h.type===1){let m=this.parser.Parse(p);m.expression&&(p="="+this.parser.Render(m.expression,u,""))}if(h.array){let m={start:{...f},end:{row:f.row+h.array.rows-1,column:f.column+h.array.columns-1}},b={key:6,value:p,array:!0,area:m};l.push(new g(m.start,m.end)),r.push(b)}else{let m=!1;for(let b of l)if(b.Contains(f)){m=!0;break}m||r.push({key:6,value:p,area:f})}r.push({key:7,style:h.style||{},area:f})})}}catch(n){console.error("invalid treb data on clipboard"),console.info(n);return}else{let n=e.clipboardData.getData("text/plain");if(!n)return!0;let a=n.trim().split(`
|
|
10
|
-
`).map(d=>d.split(" ").map(u=>u.trim())),l=this.RecyclePasteAreas(new g({row:0,column:0},{row:a.length-1,column:a[0].length-1}),i);l.length===1&&(i.Resize(a.length,a[0].length),i.Resize(l[0].rows,l[0].columns));for(let d of l)for(let u=0;u<a.length;u++)for(let h=0;h<a[0].length;h++){let p=new g({row:u+d.start.row,column:h+d.start.column});if(this.active_sheet.cells.EnsureCell(p.end),a[u][h]){let f=this.SetInferredType({area:p,target:p.start,empty:!1},a[u][h],!1,!1);if(f)for(let m of f)r.push(m)}else{let f=this.active_sheet.cells.GetCell(p.start,!1);f&&f.type!==0&&r.push({key:11,area:p.Clone()})}}}this.ExecCommand(r),this.Select(this.primary_selection,i)}AllSelections(e=!1){let t=[this.primary_selection,this.active_selection].concat(this.additional_selections);return e?t:t.filter(i=>!i.empty)}InsertRowsInternal(e){let t=super.InsertRowsInternal(e);if(t.error)return t;let i=this.FindSheet(e.sheet_id);if(i===this.active_sheet){if(e.count<0)for(let r of this.AllSelections())r.empty=!0;else for(let r of this.AllSelections())r.target.row>=e.before_row&&(r.target.row+=e.count),r.area.entire_column||(r.area.start.row>=e.before_row?r.area.Shift(e.count,0):r.area.end.row>=e.before_row&&r.area.ConsumeAddress({row:r.area.end.row+e.count,column:r.area.end.column}));for(let r of t.delete_annotations_list||[])this.layout.RemoveAnnotation(r);if(this.QueueLayoutUpdate(),this.Repaint(),t.update_annotations_list?.length){this.layout.UpdateAnnotation(t.update_annotations_list);for(let r of t.resize_annotations_list||[]){let s=r.view[this.view_index];s?.resize_callback&&s.resize_callback.call(void 0)}}}else this.pending_layout_update.add(i.id);return t}InsertColumnsInternal(e){let t=super.InsertColumnsInternal(e);if(t.error)return t;let i=this.FindSheet(e.sheet_id);if(i===this.active_sheet){if(e.count<0)for(let r of this.AllSelections())r.empty=!0;else for(let r of this.AllSelections())r.target.column>=e.before_column&&(r.target.column+=e.count),r.area.entire_row||(r.area.start.column>=e.before_column?r.area.Shift(0,e.count):r.area.end.column>=e.before_column&&r.area.ConsumeAddress({row:r.area.end.row,column:r.area.end.column+e.count}));for(let r of t.delete_annotations_list||[])this.layout.RemoveAnnotation(r);if(this.tile_renderer.FlushOverflows(),this.QueueLayoutUpdate(),this.DelayedRender(!0,void 0,!0),t.update_annotations_list?.length){this.layout.UpdateAnnotation(t.update_annotations_list);for(let r of t.resize_annotations_list||[]){let s=r.view[this.view_index];s?.resize_callback&&s.resize_callback.call(void 0)}}}else this.pending_layout_update.add(i.id);return t}ResetInternal(){super.ResetInternal(),this.RemoveAnnotationNodes(),this.ClearSelection(this.primary_selection),this.ScrollIntoView({row:0,column:0}),this.QueueLayoutUpdate(),this.layout.HideNote()}ResizeColumnsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.column;if(typeof i>"u"){i=[];for(let n=0;n<t.columns;n++)i.push(n)}typeof i=="number"&&(i=[i]);let r=typeof e.width!="number",s=Math.round(e.width||0/this.scale);if(r)for(let n of i)this.AutoSizeColumn(t,n,!1);else for(let n of i)t.SetColumnWidth(n,s);t===this.active_sheet?(this.layout.UpdateTotalSize(),this.layout.container&&this.layout.container.offsetWidth&&this.layout.container.offsetWidth>this.layout.total_width?this.UpdateLayout():(this.layout.UpdateTileWidths(!0),this.render_tiles=this.layout.VisibleTiles(),this.Repaint(!1,!0)),this.layout.UpdateAnnotation(this.active_sheet.annotations),this.RenderSelections()):this.pending_layout_update.add(t.id)}ResizeRowsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.row;if(typeof i>"u"){i=[];for(let o=0;o<t.rows;o++)i.push(o)}typeof i=="number"&&(i=[i]);let r=typeof e.shrink=="boolean"?e.shrink:!0,s=typeof e.height!="number",n=Math.round(e.height||0/this.scale);if(s)for(let o of i)t.AutoSizeRow(o,this.theme.grid_cell,r);else for(let o of i)t.SetRowHeight(o,n);t===this.active_sheet?(this.layout.UpdateTotalSize(),this.layout.container&&this.layout.container.offsetHeight&&this.layout.container.offsetHeight>this.layout.total_height?this.UpdateLayout():(this.layout.UpdateTileHeights(!0),this.render_tiles=this.layout.VisibleTiles(),this.Repaint(!1,!0)),this.layout.UpdateAnnotation(this.active_sheet.annotations),this.RenderSelections()):this.pending_layout_update.add(t.id)}SelectInternal(e){e.area?(e.area.start.sheet_id&&e.area.start.sheet_id!==this.active_sheet.id&&this.ActivateSheetInternal({key:21,id:e.area.start.sheet_id}),this.Select(this.primary_selection,new g(e.area.start,e.area.end)),this.RenderSelections()):this.ClearSelection(this.primary_selection)}FreezeInternal(e){let t=this.FindSheet(e.sheet_id||this.active_sheet.id),i=(typeof e.highlight_transition=="boolean"?e.highlight_transition:!0)&&t===this.active_sheet;if(e.rows===t.freeze.rows&&e.columns===t.freeze.columns){i&&this.HighlightFreezeArea();return}t.freeze.rows=e.rows,t.freeze.columns=e.columns,t===this.active_sheet?(this.QueueLayoutUpdate(),this.Repaint(),i&&this.HighlightFreezeArea(),e.rows||e.columns?this.layout.CloneFrozenAnnotations():this.layout.ClearFrozenAnnotations()):this.pending_layout_update.add(t.id)}ExecCommand(e,t=!0){let i=super.ExecCommand(e,t);this.batch||i.render_area&&this.DelayedRender(!1,i.render_area),i.repaint&&this.Repaint();for(let r of i.pending||[])this.pending_layout_update.add(r);return i.layout&&this.QueueLayoutUpdate(),i.sheets&&this.tab_bar&&this.tab_bar.Update(),i.formula&&this.UpdateFormulaBarFormula(),i}};var ut=class{forward={};backward=[];Count(){return this.backward.length}Serialize(){return JSON.parse(JSON.stringify(this.Map()))}Deserialize(e){if(this.Reset(),e){for(let t of Object.keys(e))this.SetName(t,new g(e[t].start,e[t].end),!1);this.RebuildList()}}MatchSelection(e,t){if(!e.start.sheet_id)throw new Error("match selection without sheet id");let i;for(let r of this.List())if(r.range.start.sheet_id===e.start.sheet_id&&(r.range.Equals(e)&&(i=r.name),t?.Equals(r.range)))return r.name;return i}SetName(e,t,i=!0){let r=this.ValidateNamed(e);return r?t.entire_column||t.entire_row?(console.warn("invalid range"),!1):(this.forward[r]=t,i&&this.RebuildList(),!0):(console.warn("invalid name"),!1)}SetNames(e){for(let t of Object.keys(e)){let i=e[t];this.SetName(t,new g(i.start,i.end),!1)}this.RebuildList()}ClearName(e,t=!0){delete this.forward[e],t&&this.RebuildList()}RemoveRangesForSheet(e,t=!0){let i={},r=this.List();for(let s of r)s.range.start.sheet_id!==e&&(i[s.name]=s.range);this.forward=i,t&&this.RebuildList()}Reset(){this.forward={},this.backward=[]}Get(e){return this.forward[e.toUpperCase()]}Map(){return this.forward}List(){return this.backward}ValidateNamed(e){return e=e.trim(),!e.length||/^[A-Za-z]{1,3}\d+$/.test(e)||/[^A-Za-z\d_.]/.test(e)||/^[^A-Za-z_]/.test(e)?!1:e.toUpperCase()}PatchNamedRanges(e,t,i,r,s){let n=this.List().slice(0);for(let o of n){let a=o.name,l=o.range;if(l.start.sheet_id!==e){console.info("skipping name",a);continue}if(i&&t<=l.end.column){if(i>0)t<=l.start.column?l.Shift(0,i):t>l.start.column&&t<=l.end.column?l.ConsumeAddress({row:l.end.row,column:l.end.column+i}):console.warn("PNR X case 1",t,i,JSON.stringify(l));else if(i<0)if(t-i<=l.start.column)l.Shift(0,i);else if(t<=l.start.column&&t-i>l.end.column)this.ClearName(a,!1);else if(t<=l.start.column){let d=t-i-1;this.SetName(a,new g({row:l.start.row,column:d+1+i,sheet_id:e},{row:l.end.row,column:l.end.column+i}),!1)}else t<=l.end.column?t-i-1>=l.end.column?this.SetName(a,new g({row:l.start.row,column:l.start.column,sheet_id:e},{row:l.end.row,column:t-1}),!1):this.SetName(a,new g({row:l.start.row,column:l.start.column,sheet_id:e},{row:l.end.row,column:l.start.column+l.columns+i-1}),!1):console.warn("PNR X case 2",t,i,JSON.stringify(l))}if(s&&r<=l.end.row){if(s>0)r<=l.start.row?l.Shift(s,0):r>l.start.row&&r<=l.end.row?l.ConsumeAddress({row:l.end.row+s,column:l.end.column}):console.warn("PNR X case 3",r,s,JSON.stringify(l));else if(s<0)if(r-s<=l.start.row)l.Shift(s,0);else if(r<=l.start.row&&r-s>l.end.row)this.ClearName(a,!1);else if(r<=l.start.row){let d=r-s-1;this.SetName(a,new g({column:l.start.column,row:d+1+s,sheet_id:e},{column:l.end.column,row:l.end.row+s}),!1)}else r<=l.end.row?r-s-1>=l.end.row?this.SetName(a,new g({column:l.start.column,row:l.start.row,sheet_id:e},{column:l.end.column,row:r-1}),!1):this.SetName(a,new g({column:l.start.column,row:l.start.row,sheet_id:e},{column:l.end.column,row:l.start.row+l.rows+s-1}),!1):console.warn("PNR X case 4",r,s,JSON.stringify(l))}}this.RebuildList()}RebuildList(){this.backward=[];for(let e of Object.keys(this.forward))this.backward.push({name:e,range:this.forward[e]})}};var Li=class{get list(){return this.sheets_.slice(0)}get length(){return this.sheets_.length}names=new Map;ids=new Map;sheets_=[];Assign(e){this.sheets_=[...e],this.UpdateIndexes()}Add(e){this.sheets_.push(e),this.UpdateIndexes()}Splice(e,t,...i){this.sheets_.splice(e,t,...i),this.UpdateIndexes()}Find(e){return typeof e=="string"?this.names.get(e.toLocaleUpperCase()):this.ids.get(e)}Name(e){return this.ids.get(e)?.name||void 0}ID(e){return this.names.get(e.toLocaleUpperCase())?.id||void 0}UpdateIndexes(){this.names.clear(),this.ids.clear();for(let e of this.sheets_){let t=e.name.toLocaleUpperCase();this.names.set(t,e),this.ids.set(e.id,e)}}},ht=class{document_name;user_data;sheets=new Li;named_ranges=new ut;macro_functions=new Map;named_expressions=new Map;view_count=0;theme_style_properties=JSON.parse(JSON.stringify(A.DefaultProperties))};var Vi=class{type=Vi.type;color=0;edges_in=new Set;edges_out=new Set;get has_inbound_edges(){return this.edges_in.size>0}get has_outbound_edges(){return this.edges_out.size>0}Reset(){for(let e of this.edges_out)e.RemoveDependency(this);for(let e of this.edges_in)e.RemoveDependent(this);this.edges_out.clear(),this.edges_in.clear()}ClearDependencies(){for(let e of this.edges_in)e.RemoveDependent(this);this.edges_in.clear()}AddDependent(e){e!==this&&(this.edges_out.has(e)||this.edges_out.add(e))}RemoveDependent(e){this.edges_out.delete(e)}AddDependency(e){e!==this&&(this.edges_in.has(e)||this.edges_in.add(e))}RemoveDependency(e){this.edges_in.delete(e)}LinkTo(e){this.AddDependent(e),e.AddDependency(this)}DependsOn(e){this.AddDependency(e),e.AddDependent(this)}LoopCheck(){let e=[this];for(;e.length;){let t=e[e.length-1],i=!0;if(t.color!==2){t.color=1;for(let r of t.edges_out){if(r.color===1)return this.color=0,!0;r.color===0&&r.edges_out.size&&(e.push(r),i=!1)}}i&&(t.color=2,e.pop())}return this.color=2,!1}},pt=Vi;E(pt,"type","vertex");var Je=class extends pt{dirty=!1};var Fi=class extends Je{reference;error=0;address;result={type:0};expression={type:"missing",id:-1};expression_error=!1;short_circuit=!1;type=Fi.type;get array_head(){return this.address?!!this.reference&&!!this.reference.area&&this.reference.area.start.column===this.address.column&&this.reference.area.start.row===this.address.row:!1}TakeReferenceValue(){this.reference&&(this.result=q(this.reference.GetValue()))}Calculate(e){if(!!this.dirty){if(this.color===0&&this.LoopCheck()&&(this.dirty=!1,this.edges_in.size)){this.reference&&(this.array_head||this.reference.type===1)&&this.reference.SetCalculationError("LOOP");for(let t of this.edges_out)t.Calculate(e);return}for(let t of this.edges_in)if(t.dirty)return;if(this.reference){if(this.reference.type===1){this.short_circuit=!1;let t=e.CalculationCallback.call(e,this);if(this.result=t.value,this.short_circuit)return;t.volatile&&e.volatile_list.push(this)}else this.result=this.reference.GetValue4();if(this.array_head)e.SpreadCallback.call(e,this,this.result);else if(this.reference.type===1){let t=this.result.type===8?this.result.value[0][0]:this.result;this.reference.SetCalculatedValue(t.value,t.type)}}else console.info("skip dirty constant? [or dangling...]");this.dirty=!1;for(let t of this.edges_out)t.dirty&&e.calculation_list.push(t)}}},Me=Fi;E(Me,"type","spreadsheet-vertex");var ze=class extends Je{type=ze.type;area;static GetVertex(e){for(let t of this.list)if(t.area.start.sheet_id===e.start.sheet_id&&t.area.Equals(e))return[t,!1];return[new ze(e),!0]}static Clear(){this.list=[]}static GetContainingArrays(e){let t=[];for(let i of this.list)i.area.start.sheet_id===e.sheet_id&&i.area.Contains(e)&&t.push(i);return t}static CreateImplicitEdges(e,t){for(let i of this.list)i.area.start.sheet_id===t.sheet_id&&i.area.Contains(t)&&i.DependsOn(e)}constructor(e){super(),this.area=e.Clone(),ze.list.push(this)}RemoveDependent(e){super.RemoveDependent(e),this.edges_out.size||(this.Reset(),ze.list=ze.list.filter(t=>t!==this))}Calculate(e){if(!!this.dirty){if(this.color===0&&this.LoopCheck()&&(this.dirty=!1,this.edges_in.size)){for(let t of this.edges_out)t.Calculate(e);return}for(let t of this.edges_in)if(t.dirty)return;this.dirty=!1;for(let t of this.edges_out)t.Calculate(e)}}},Ae=ze;E(Ae,"type","array-vertex"),E(Ae,"list",[]);var Ht=class{vertices=[[]];volatile_list=[];calculation_list=[];loop_hint;leaf_vertices=[];dirty_list=[];loop_check_required=!1;IsSpreadsheetVertex(e){return e.type===Me.type}FlushTree(){this.dirty_list=[],this.volatile_list=[],this.vertices=[[]],this.leaf_vertices=[],Ae.Clear()}ResolveArrayHead(e){if(!e.sheet_id)throw new Error("resolve array head with no sheet id");let t=this.model.sheets.Find(e.sheet_id)?.cells;if(!t)throw new Error("no cells? sheet id "+e.sheet_id);let i=t.data[e.row];if(i){let r=i[e.column];if(r&&r.area){let s={row:r.area.start.row,column:r.area.start.column,sheet_id:e.sheet_id};return console.info("array head",e,s),s}}return e}GetVertex(e,t){if(!e.sheet_id)throw console.info({address:e,create:t}),new Error("getvertex with no sheet id");let i=this.model.sheets.Find(e.sheet_id)?.cells;if(!i)throw new Error("no cells? sheet id "+e.sheet_id);if(!this.vertices[e.sheet_id]){if(!t)return;this.vertices[e.sheet_id]=[]}if(this.vertices[e.sheet_id][e.column]){let s=this.vertices[e.sheet_id][e.column][e.row];if(s)return s;if(!t)return}else{if(!t)return;this.vertices[e.sheet_id][e.column]=[]}let r=new Me;return r.address={row:e.row,column:e.column,absolute_row:e.absolute_row,absolute_column:e.absolute_column,sheet_id:e.sheet_id},r.reference=i.EnsureCell(e),this.vertices[e.sheet_id][e.column][e.row]=r,Ae.CreateImplicitEdges(r,e),r}RemoveVertex(e){if(!e.sheet_id)throw new Error("removevertex with no sheet id");let t=this.GetVertex(e,!1);!t||(t.Reset(),this.vertices[e.sheet_id][e.column][e.row]=void 0)}ResetVertex(e){let t=this.GetVertex(e,!1);t&&t.Reset()}RIBcount=0;ResetInbound(e,t=!1,i=!0,r=!1){this.RIBcount++;let s=this.GetVertex(e,i);if(!s){if(t){let o=Ae.GetContainingArrays(e);for(let a of o)this.SetVertexDirty(a)}return}let n=[];if(r&&(n=Array.from(s.edges_in)),s.ClearDependencies(),t&&this.SetVertexDirty(s),r){s.has_outbound_edges||this.RemoveVertex(e);for(let o of n)if(!o.has_inbound_edges&&!o.has_outbound_edges){let a=o;a.address&&this.RemoveVertex(a.address)}}}ResetLoopState(){for(let e of this.vertices)if(e){for(let t of e)if(t)for(let i of t)i&&(i.color=i.edges_out.size?0:2)}for(let e of this.leaf_vertices)e.color=2}LoopCheck(e=!1){if(!this.loop_check_required&&!e)return!1;let t=[];for(let r of this.vertices)if(r){for(let s of r)if(s)for(let n of s)n&&(n.color=n.edges_out.size?0:2,t.push(n))}let i=[];for(let r of t)if(r.color===0){for(r.color=1,i.push(r);i.length;){let s=i[i.length-1],n=!0;if(s.color!==2)for(let o of s.edges_out){if(o.color===1)return this.loop_hint=this.RenderAddress(r.address),console.info("loop detected @",this.loop_hint),!0;o.color===0&&(i.push(o),n=!1)}n&&(i.pop(),s.color=2)}r.color=2}return this.loop_check_required=!1,this.loop_hint=void 0,!1}RenderAddress(e){if(!e)return"undefined";let t="";if(e.sheet_id){let r=this.model.sheets.Find(e.sheet_id);r&&(t=r.name+"!")}let i=new g(e);return t+i.spreadsheet_label}AddArrayEdge(e,t){if(!e.start.sheet_id)throw new Error("AddArrayEdge called without sheet ID");let i=this.GetVertex(t,!0),[r,s]=Ae.GetVertex(e);if(i.DependsOn(r),this.loop_check_required=!0,!s)return;let n=this.vertices[e.start.sheet_id];if(!!n)if(e.entire_row){for(let o=0;o<n.length;o++)if(n[o])for(let a=e.start.row;a<=e.end.row;a++){let l=n[o][a];l&&r.DependsOn(l)}}else if(e.entire_column){for(let o=e.start.column;o<=e.end.column;o++)if(n[o])for(let a of n[o])a?.address&&r.DependsOn(a)}else for(let o=e.start.row;o<=e.end.row;o++)for(let a=e.start.column;a<=e.end.column;a++){let l=n[a][o];l&&r.DependsOn(l)}}AddEdge(e,t,i){let r=this.GetVertex(e,!0);this.GetVertex(t,!0).DependsOn(r),r.reference&&r.reference.area&&!r.array_head&&this.AddEdge({...e,row:r.reference.area.start.row,column:r.reference.area.start.column},t,"implicit"),this.loop_check_required=!0}RemoveEdge(e,t){let i=this.GetVertex(e,!1),r=this.GetVertex(t,!1);!i||!r||(i.RemoveDependent(r),r.RemoveDependency(i))}SetAreaDirty(e){if(e.start.column===1/0||e.end.column===1/0||e.start.row===1/0||e.end.row===1/0)throw new Error("don't iterate over infinite area");let t=e.start.sheet_id;if(!t)throw new Error("invalid area, missing sheet id");for(let i=e.start.column;i<=e.end.column;i++)for(let r=e.start.row;r<=e.end.row;r++){let s={row:r,column:i,sheet_id:t};this.GetVertex(s,!1)&&this.SetDirty(s)}}SetVertexDirty(e){if(!e.dirty){this.dirty_list.push(e),e.dirty=!0;for(let t of e.edges_out)this.SetVertexDirty(t)}}SetDirty(e){let t=this.GetVertex(e,!0);this.SetVertexDirty(t)}AddLeafVertex(e){for(let t of this.leaf_vertices)if(t===e)return;this.leaf_vertices.push(e)}RemoveLeafVertex(e){this.leaf_vertices=this.leaf_vertices.filter(t=>t!==e)}AddLeafVertexEdge(e,t){let i=this.GetVertex(e,!0);return t.DependsOn(i),0}RemoveLeafVertexEdge(e,t){let i=this.GetVertex(e,!1);!i||(i.RemoveDependent(t),t.RemoveDependency(i))}InitializeGraph(){for(let e of this.dirty_list)this.IsSpreadsheetVertex(e)&&(e.TakeReferenceValue(),this.CheckVolatile(e)&&this.volatile_list.push(e)),e.dirty=!1;this.dirty_list=[]}Recalculate(){for(let e of this.volatile_list)this.SetVertexDirty(e);this.calculation_list=this.dirty_list.slice(0),this.volatile_list=[],this.dirty_list=[],this.loop_check_required&&(this.ResetLoopState(),this.loop_check_required=!1);for(let e=0;e<this.calculation_list.length;e++)this.calculation_list[e].Calculate(this);this.calculation_list=[]}};var Mr={error:"NOTIMPL"},Re=()=>({type:6,value:"N/A"}),Ee=()=>({type:6,value:"EXPR"});var We=()=>({type:6,value:"DIV/0"}),K=()=>({type:6,value:"ARG"}),I=()=>({type:6,value:"VALUE"}),Y=()=>({type:6,value:"REF"}),zi=()=>({type:6,value:"NAME"}),$t=()=>({type:6,value:"UNK"});var Qs=c=>{let e={m:c,n:c,array:[]};for(let t=0;t<c;t++){let i=[];for(let r=0;r<c;r++)i.push({real:0,imaginary:0});e.array.push(i)}return e};var en=c=>{let{r:e,theta:t}=c,i=e*Math.cos(t),r=e*Math.sin(t);return{real:i,imaginary:r}},Bt=c=>{let e=Math.sqrt(c.real*c.real+c.imaginary*c.imaginary),t=Math.atan2(c.imaginary,c.real);return{r:e,theta:t}},ue=(c,e)=>({real:c.real*e.real-c.imaginary*e.imaginary,imaginary:c.real*e.imaginary+c.imaginary*e.real}),tn=(c,e)=>{let t=[];for(let i=0;i<c.m;i++){let r=[];for(let s=0;s<c.n;s++)r.push(c.array[i][s]+e.array[i][s]);t.push(r)}return{m:c.m,n:c.n,array:t}},Pi=(c,e)=>{let t=[];for(let i=0;i<c.m;i++){let r=[];for(let s=0;s<e.n;s++){let n=0;for(let o=0;o<c.n;o++)n+=c.array[i][o]*e.array[o][s];r.push(n)}t.push(r)}return{array:t,m:c.m,n:e.n}},Lr=(c,e)=>{let t=[];for(let i=0;i<c.m;i++){let r=[];for(let s=0;s<e.n;s++){let n={real:0,imaginary:0};for(let o=0;o<c.n;o++)n.real+=c.array[i][o].real*e.array[o][s].real-c.array[i][o].imaginary*e.array[o][s].imaginary,n.imaginary+=c.array[i][o].real*e.array[o][s].imaginary+c.array[i][o].imaginary*e.array[o][s].real;r.push(n)}t.push(r)}return t},jt=c=>{let e={real:0,imaginary:0},t=c.n;if(t==2){let r=ue(c.array[0][0],c.array[1][1]),s=ue(c.array[1][0],c.array[0][1]);return{real:r.real-s.real,imaginary:r.imaginary-s.imaginary}}let i=Qs(c.n);for(let r=0;r<t;r++){let s=0;for(let a=1;a<t;a++){let l=0;for(let d=0;d<t;d++)d!=r&&(i.array[s][l]={...c.array[a][d]},l++);s++}i.m=i.n=t-1;let n=Math.pow(-1,r),o=ue({real:c.array[0][r].real*n,imaginary:c.array[0][r].imaginary*n},jt(i));e.real+=o.real,e.imaginary+=o.imaginary}return e};var rn=c=>{let e={real_values:!1,imaginary_values:!1,square:c.m===c.n,unit_diagonal:!0},t={m:c.m,n:c.n,array:[]},i={m:c.m,n:c.n,array:[]};for(let r=0;r<c.m;r++){let s=c.array[r],n=[],o=[];for(let a=0;a<c.n;a++)s[a].real&&(e.real_values=!0),s[a].imaginary&&(e.imaginary_values=!0),a===r&&e.unit_diagonal&&(s[a].real!==1||s[a].imaginary!==0)&&(e.unit_diagonal=!1),n.push(s[a].real),o.push(s[a].imaginary);t.array.push(n),i.array.push(o)}return{real:t,imaginary:i,flags:e}},sn=c=>{let e=c.array.map(t=>t.slice(0));return{m:c.m,n:c.n,array:e}},Dr=c=>{if(c.m!==c.n)return;let e=sn(c),t=e.array,i=0,r=0,s=0,n=0,o=c.m;for(r=1;r<o;r++)t[0][r]/=t[0][0];for(r=1;r<o;r++){for(s=r;s<o;s++){for(i=0,n=0;n<r;n++)i+=t[s][n]*t[n][r];t[s][r]-=i}if(r!=o-1)for(s=r+1;s<o;s++){for(i=0,n=0;n<r;n++)i+=t[r][n]*t[n][s];t[r][s]=(t[r][s]-i)/t[r][r]}}for(r=0;r<o;r++)for(s=r;s<o;s++){let a=1;if(r!=s)for(a=0,n=r;n<s;n++)a-=t[s][n]*t[n][r];t[s][r]=a/t[s][s]}for(r=0;r<o;r++)for(s=r;s<o;s++)if(r!=s){for(i=0,n=r;n<s;n++)i+=t[n][s]*(r==n?1:t[r][n]);t[r][s]=-i}for(r=0;r<o;r++)for(s=0;s<o;s++){for(i=0,n=r>s?r:s;n<o;n++)i+=(s==n?1:t[s][n])*t[n][r];t[s][r]=i}return e},Vr=c=>{let e=[];if(c.m!==c.n)return;let{real:t,imaginary:i,flags:r}=rn(c),s=Dr(t);if(!s)return;if(!r.imaginary_values){for(let u=0;u<c.m;u++){let h=[];for(let p=0;p<c.n;p++)h.push({real:s.array[u][p],imaginary:0});e.push(h)}return e}let n=Pi(s,i),o=Pi(i,n),a=tn(t,o),l=Dr(a);if(!l)return;let d=Pi(n,l);for(let u=0;u<c.m;u++){let h=[];for(let p=0;p<c.n;p++)h.push({real:l.array[u][p],imaginary:-d.array[u][p]});e.push(h)}return e},Ir=(c,e)=>{let t={real:e.real,imaginary:-e.imaginary},i=ue(c,t),r=ue(e,t);return{real:i.real/r.real,imaginary:i.imaginary/r.real}},Ni=c=>{let e=c.real||0,t=c.imaginary||0;return ue({real:Math.exp(e),imaginary:0},{real:Math.cos(t),imaginary:Math.sin(t)})},nn=c=>{let e=Bt(c);return{real:Math.log(e.r),imaginary:e.theta}},Pe=(c,e)=>{if(e.imaginary)return Ni(ue(e,nn(c)));{let t=Bt(c);return en({r:Math.pow(t.r,e.real),theta:t.theta*e.real})}};var Fr=(c,e=0)=>c&&c.type===7?c:{type:7,value:{real:e,imaginary:0}},ft=c=>c.imaginary?{type:7,value:c}:{type:3,value:c.real},qe=(c,e)=>{if(c.type===6)return[0,0,c];if(e.type===6)return[0,0,e];let t=[0,0];switch(c.type){case 3:t[0]=c.value;break;case 4:t[0]=c.value?1:0;break;case 0:break;case 7:t[3]=c;break;default:return[0,0,I()]}switch(e.type){case 3:t[1]=e.value;break;case 4:t[1]=e.value?1:0;break;case 0:break;case 7:t[4]=e;break;default:return[0,0,I()]}return(t[3]||t[4])&&(t[3]=Fr(t[3],t[0]),t[4]=Fr(t[4],t[1])),t},on=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?ft({real:s.value.real+n.value.real,imaginary:s.value.imaginary+n.value.imaginary}):{value:t+i,type:3})},Hi=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?ft({real:s.value.real-n.value.real,imaginary:s.value.imaginary-n.value.imaginary}):{value:t-i,type:3})},zr=(c,e)=>{let[t,i,r,s,n]=qe(c,e);if(r)return r;if(s&&n)return ft(Pe(s.value,n.value));let o=Math.pow(t,i);return isNaN(o)?I():{type:3,value:o}},an=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?ft(ue(s.value,n.value)):{value:t*i,type:3})},ln=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?n.value.real===0&&n.value.imaginary===0?We():ft(Ir(s.value,n.value)):i===0?We():{value:t/i,type:3})},cn=(c,e)=>{let[t,i,r]=qe(c,e);return r||(i===0?We():{value:t%i,type:3})},dn=(c,e)=>c.type===6?c:e.type===6?e:{type:2,value:`${c.type===0?"":c.value}${e.type===0?"":e.value}`},Gi=(c,e)=>{if(c.type===6)return c;if(e.type===6)return e;if(c.type===0&&(e.value===""||e.value===0||e.type===7&&e.value.real===0&&e.value.imaginary===0)||e.type===0&&(c.value===""||c.value===0||c.type===7&&c.value.real===0&&c.value.imaginary===0))return{type:4,value:!0};if(c.type===7||e.type===7){let t=!1;return c.type===e.type?t=c.value.real==e.value.real&&c.value.imaginary==e.value.imaginary:c.type===3?t=e.value.real==c.value&&!e.value.imaginary:e.type===3&&(t=c.value.real==e.value&&!c.value.imaginary),{type:4,value:t}}return{type:4,value:c.value==e.value}},Pr=(c,e)=>{let t=Gi(c,e);return t.type===6?t:{type:4,value:!t.value}},un=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:(c.value||0)>(e.value||0)},hn=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:c.value>=e.value},pn=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:c.value<e.value},fn=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:c.value<=e.value},Nr=c=>{switch(c){case"&":return dn;case"+":return on;case"-":return Hi;case"*":return an;case"/":return ln;case"^":return zr;case"**":return zr;case"%":return cn;case"=":return Gi;case"==":return Gi;case"!=":return Pr;case"<>":return Pr;case">":return un;case">=":return hn;case"<":return pn;case"<=":return fn}};var Or=c=>!Array.isArray(c)&&c.type===5&&!!c.value.type,Wt=c=>c.type===5&&c.key==="metadata",Jt=class{constructor(e,t){this.library=e;this.parser=t}context={address:{row:-1,column:-1},volatile:!1,call_index:0};call_index=0;named_range_map={};data_model;SetModel(e){this.data_model=e,this.named_range_map=e.named_ranges.Map(),this.context.model=e}Calculate(e,t,i=!1){return i||(this.context.address=t,this.context.volatile=!1,this.context.call_index=0,this.call_index=0),{value:this.CalculateExpression(e),volatile:this.context.volatile}}CellFunction2(e){if(!e.sheet_id)if(e.sheet)e.sheet_id=this.data_model.sheets.ID(e.sheet)||0;else return()=>Y();let t=this.data_model.sheets.Find(e.sheet_id)?.cells;if(!t)return console.warn("missing cells reference @ "+e.sheet_id),()=>Y();let i=t.GetCell(e);return i?()=>i.GetValue4():()=>({type:0,value:void 0})}CellFunction4(e,t){return e.sheet_id?this.data_model.sheets.Find(e.sheet_id)?.cells?.GetRange4(e,t,!0)||Y():Y()}GetMetadata(e,t){let i,r;switch(e.type){case"address":i=e;break;case"range":r=e;break;case"identifier":{let s=this.named_range_map[e.name.toUpperCase()];s&&(s.count===1?i=s.start:r=s)}break;case"call":{let s=this.CalculateExpression(e,!0);if(Or(s))if(s.value.type==="address")i=s.value;else if(s.value.type==="range")r=s.value;else return s;else return s}break;default:return this.CalculateExpression(e)}if(i){let s;if(i.sheet_id&&(s=this.data_model.sheets.Find(i.sheet_id)),!s)return console.error("missing sheet [ac8]"),Y();let n=s.CellData(i),o=n.calculated_type?n.calculated:n.value,a={type:"metadata",address:{...i},value:o,format:n.style?n.style.number_format:void 0,...t(n,i)};return{type:5,value:a,key:"metadata"}}else if(r){if(r.start.row===1/0||r.start.column===1/0)return Y();let s;if(r.start.sheet_id&&(s=this.data_model.sheets.Find(r.start.sheet_id)),!s)throw new Error("missing sheet [ac9]");let n=[];for(let o=r.start.column;o<=r.end.column;o++){let a=[];for(let l=r.start.row;l<=r.end.row;l++){let d=s.CellData({row:l,column:o});i={...r.start,row:l,column:o};let u=d.calculated_type?d.calculated:d.value,h={type:"metadata",address:i,value:u,format:d.style?d.style.number_format:void 0,...t(d,i)};a.push({type:5,value:h,key:"metadata"})}n.push(a)}return{type:8,value:n}}return this.CalculateExpression(e)}RewriteMacro(e,t){let i;switch(e.type){case"identifier":if(i=t[e.name.toUpperCase()],i)return JSON.parse(JSON.stringify(i));break;case"binary":e.left=this.RewriteMacro(e.left,t),e.right=this.RewriteMacro(e.right,t);break;case"unary":e.operand=this.RewriteMacro(e.operand,t);break;case"group":e.elements=e.elements.map(r=>this.RewriteMacro(r,t));break;case"call":e.args=e.args.map(r=>this.RewriteMacro(r,t));break}return e}CallMacro(e,t){if(!t.expression)return()=>Ee();let i=JSON.stringify(t.expression),r={},s=t.argument_names?.map(n=>n.toUpperCase())||[];return n=>{let o=JSON.parse(i);for(let a=0;a<s.length;a++)r[s[a]]=n.args[a]||{type:"missing",id:0};return this.CalculateExpression(this.RewriteMacro(o,r))}}CallExpression(e,t=!1){let i=this.library.Get(e.name);return i?r=>{let s=this.call_index++;this.context.volatile=this.context.volatile||!!i.volatile;let n=e.name.toLowerCase()==="if",o=-1,a,l=i.arguments||[],d=r.args.map((u,h)=>{if(a)return;let p=l[Math.min(h,l.length-1)]||{};if(h===o)return p.boxed?{type:0}:void 0;if(typeof u>"u")return n&&h===0&&(o=1),p.boxed?{type:0}:void 0;if(p.address)return p.boxed?{type:2,value:this.parser.Render(u).replace(/\$/g,"")}:this.parser.Render(u).replace(/\$/g,"");if(p.metadata)return this.GetMetadata(u,()=>({}));{let f=this.CalculateExpression(u);if(f.type===6){if(p.allow_error)return f;a=f;return}if(n&&h===0&&f.type!==8){let m=!1;if(f.type===2){let b=f.value.toLowerCase().trim();m=b!=="false"&&b!=="f"}else m=!!f.value;o=m?2:1}return p.boxed?f:f.type===8?f.value.map(m=>m.map(b=>b.value)):f.value}});if(a)return a;if(this.context.call_index=s,i.return_type===1){let u=i.fn.apply(null,d);if(t)return u;if(Or(u)){if(u.value.type==="address")return this.CellFunction2(u.value)();if(u.value.type==="range")return this.CellFunction4(u.value.start,u.value.end)}return u}return i.fn.apply(null,d)}:()=>zi()}ResolveDimensionedQuantity(){return e=>{let t=this.CalculateExpression(e.expression);return{type:9,value:{value:t.value,unit:e.unit.name}}}}UnaryExpression(e){switch(e.operator){case"+":return t=>this.CalculateExpression(t.operand);case"-":{let t=Hi,i={type:3,value:0};return r=>{let s=this.CalculateExpression(r.operand);return s.type===8?{type:8,value:s.value.map(n=>n.map(o=>t(i,o)))}:t(i,s)}}default:return()=>(console.warn("unexpected unary operator:",e.operator),Ee())}}RecycleArray(e,t,i){if(e[0].length<i){let r=e[0].length;for(let s of e)for(let n=r;n<i;n++)s[n]=s[n%r]}if(e.length<t){let r=e.length;for(let s=r;s<t;s++)e[s]=e[s%r].slice(0)}return e}ElementwiseBinaryExpression(e,t,i){let r=Math.max(t.value.length,i.value.length),s=Math.max(t.value[0].length,i.value[0].length),n=this.RecycleArray(t.value,r,s),o=this.RecycleArray(i.value,r,s),a=[];for(let l=0;l<r;l++){let d=[];for(let u=0;u<s;u++)d[u]=e(n[l][u],o[l][u]);a.push(d)}return{type:8,value:a}}BinaryExpression(e){let t=Nr(e.operator);return t?i=>{let r=this.CalculateExpression(i.left),s=this.CalculateExpression(i.right);return r.type===8?s.type===8?this.ElementwiseBinaryExpression(t,r,s):this.ElementwiseBinaryExpression(t,r,{type:8,value:[[s]]}):s.type===8?this.ElementwiseBinaryExpression(t,{type:8,value:[[r]]},s):t(r,s)}:()=>(console.info(`(unexpected binary operator: ${e.operator})`),Ee())}Identifier(e){let t=e.name;if(t[0]==="#")return()=>Y();let i=t.toUpperCase();switch(i){case"FALSE":case"F":return()=>({value:!1,type:4});case"TRUE":case"T":return()=>({value:!0,type:4});case"UNDEFINED":return()=>({value:void 0,type:0})}return()=>{let r=this.named_range_map[i];if(r)return r.count===1?this.CellFunction4(r.start,r.start):this.CellFunction4(r.start,r.end);let s=this.data_model.named_expressions.get(i);return s?this.CalculateExpression(s):zi()}}GroupExpression(e){return!e.elements||e.elements.length!==1?(console.warn("Can't handle group !== 1"),()=>Ee()):t=>this.CalculateExpression(t.elements[0])}CalculateExpression(e,t=!1){if(e.user_data)return e.user_data(e);switch(e.type){case"call":{let i=this.data_model.macro_functions.get(e.name.toUpperCase());return i?(e.user_data=this.CallMacro(e,i))(e):(e.user_data=this.CallExpression(e,t))(e)}case"address":return(e.user_data=this.CellFunction2(e))();case"range":return(e.user_data=i=>this.CellFunction4(i.start,i.end))(e);case"binary":return(e.user_data=this.BinaryExpression(e))(e);case"unary":return(e.user_data=this.UnaryExpression(e))(e);case"identifier":return(e.user_data=this.Identifier(e))();case"missing":return(e.user_data=()=>({value:void 0,type:0}))();case"dimensioned":return(e.user_data=this.ResolveDimensionedQuantity())(e);case"literal":{let i={value:e.value,type:re(e.value)};return(e.user_data=()=>i)()}case"group":return(e.user_data=this.GroupExpression(e))(e);case"complex":{let i={value:{real:e.real,imaginary:e.imaginary},type:7};return(e.user_data=()=>i)()}case"array":return(e.user_data=()=>({type:8,value:e.values.map(i=>(Array.isArray(i)?i:[i]).map(r=>({type:re(r),value:r})))}))();default:return console.warn("Unhandled parse expr:",e),$t()}}};var sh=1e3*60*60*24;var qt=c=>{let e=[],t=c.length,i=c[0].length;for(let r=0;r<i;r++){e[r]=[];for(let s=0;s<t;s++)e[r][s]=c[s][r]}return e};var De=c=>{let e=[];for(let t of c)if(t.type===8)for(let i of t.value)e=e.concat(De(i));else e.push(t);return e},O=c=>Array.isArray(c)?c.reduce((e,t)=>typeof t>"u"?e:Array.isArray(t)?e.concat(O(t)):t instanceof Float32Array||t instanceof Float64Array?e.concat(Array.from(t)):e.concat([t]),[]):[c];var G=c=>(e,...t)=>Array.isArray(e)?(console.info("AAA 71823"),{type:8,value:e.map(i=>i.map(r=>c(r,...t)))}):typeof e=="object"&&!!e&&e.type===8?{type:8,value:e.value.map(i=>i.map(r=>c(r,...t)))}:c(e,...t),Ne=c=>(e,t,...i)=>{let r=!1,s=!1;return!!e&&typeof e=="object"&&e.type===8?(e=e.value,r=!0):r=Array.isArray(e),!!t&&typeof t=="object"&&t.type===8?(t=t.value,s=!0):s=Array.isArray(t),r?s?{type:8,value:e.map((n,o)=>n.map((a,l)=>c(a,t[o][l],...i)))}:{type:8,value:e.map(n=>n.map(o=>c(o,t,...i)))}:s?{type:8,value:t.map(n=>n.map(o=>c(e,o,...i)))}:c(e,t,...i)};var Xt=class{functions={};Register(...e){for(let t of e)for(let i of Object.keys(t)){if(/[^a-zA-Z0-9._]/.test(i))throw new Error("invalid function name (invalid character)");if(i.length>255)throw new Error("invalid function name (too long, > 255)");if(/^[^a-zA-Z]/.test(i))throw new Error("invalid function name (start with an ascii letter)");let r=i.toLowerCase();if(this.functions[r])throw new Error(`function name (${r}) is already in use`);let s=t[i];s.canonical_name=i,this.functions[r]=s}}Get(e){let t=e.toLowerCase();return this.functions[t]}List(){let e={};for(let t of Object.keys(this.functions))e[t]=this.functions[t];return e}Alias(e,t){let i=this.Get(t);if(!i)throw new Error(`referenced function ${t} does not exist`);this.Register({[e]:{...i}})}};var Ke=class{static UnpackValues(e){if(Array.isArray(e)){let t=e[0];return Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array?e.reduce((i,r)=>i.concat(this.UnpackValues(r)),[]):e.map(i=>isNaN(i)?void 0:i)}else{if(e instanceof Float32Array||e instanceof Float64Array)return Array.prototype.slice.call(e);if(e&&typeof e=="object"){let i=Object.keys(e).length;if(typeof e[0]<"u"&&typeof e[(i-1).toString()]<"u"){let r=[];for(let s=0;s<i;s++)r[s]=e[s.toString()];return r}}}return[]}static SparklineCommon(e,t){let i=[],r=t.text?.text||this.default_color,s=[r,r];return Array.isArray(e.calculated)&&(i=this.UnpackValues(e.calculated[0]),typeof e.calculated[1]=="string"&&(s[0]=e.calculated[1]),typeof e.calculated[2]=="string"&&(s[1]=e.calculated[2])),{values:i,colors:s}}static RenderLine(e,t,i,r,s){let{values:n,colors:o}=this.SparklineCommon(r,s),a=.05,l=.1,d=1;Array.isArray(r.calculated)&&typeof r.calculated[2]=="number"&&(d=r.calculated[2]);let u=0,h=0,p=-1;for(let f=0;f<n.length;f++){let m=n[f];typeof m=="number"&&(p>=0?(u=Math.min(u,m),h=Math.max(h,m)):(p=f,u=h=m))}if(u!==h){let f=e*(1-2*a)/(n.length-1),m=h-u,b=t*(1-2*l),_=t*l;i.strokeStyle=o[0],i.lineWidth=d,i.lineCap="round",i.lineJoin="round",i.beginPath();let y=0;for(let x=p;x<n.length;x++){let v=n[x];if(typeof v=="number"){let w=e*a+f*x,C=t-(v-u)*b/m-_;y===0?(i.moveTo(w,C),y=1):i.lineTo(w,C)}else y=0}i.stroke()}}static RenderColumn(e,t,i,r,s){let{values:n,colors:o}=this.SparklineCommon(r,s),a=3,l=2.5,d=0,u=0,h=!1;for(let p of n)typeof p=="number"&&(h?(d=Math.min(d,p),u=Math.max(u,p)):(h=!0,d=u=p));if(n.length){let p=(e-2*a-2)/(n.length-0),f=t-2*l,m=l;if(d!==u)if(d<0&&u>0){let b=u-d,_=m+u/b*f;for(let y=0;y<n.length;y++){let x=n[y];if(typeof x=="number"){let v=a+y*p,w=Math.abs(x)/b*f;if(x>=0){i.fillStyle=o[0];let C=_-w;i.fillRect(v+2,C,p-2,w)}else{i.fillStyle=o[1];let C=_;i.fillRect(v+2,C,p-2,w)}}}}else if(u>0){i.fillStyle=o[0];let b=u-d;for(let _=0;_<n.length;_++){let y=n[_];if(typeof y=="number"){let x=a+_*p,v=Math.max(1,(y-d)/b*f),w=t-m-v;i.fillRect(x+2,w,p-2,v)}}}else{i.fillStyle=o[1];let b=u-d;for(let _=0;_<n.length;_++){let y=n[_];if(typeof y=="number"){let x=a+_*p,v=Math.max(1,Math.abs(u-y)/b*f),w=m;i.fillRect(x+2,w,p-2,v)}}}}}};E(Ke,"default_color","#888");var Gr=c=>{let{x:e,y:t,width:i,height:r,cell:s}=c,n={},o=3,a=Math.round(16*(c.scale||1));if(s&&i&&r&&e&&t){let l={x:o,y:r-o-a};if(s.style){switch(s.style.vertical_align){case A.VerticalAlign.Top:l.y=o;break;case A.VerticalAlign.Middle:l.y=Math.round((r-a)/2);break}switch(s.style.horizontal_align){case A.HorizontalAlign.Right:l.x=Math.round(i-o-a);break;case A.HorizontalAlign.Center:l.x=Math.round((i-a)/2);break}}e>=l.x&&e<=l.x+a&&t>=l.y&&t<=l.y+a&&(n.value=`=Checkbox(${s.calculated?"FALSE":"TRUE"})`,n.block_selection=!0)}return n},Hr=c=>{let{context:e,width:t,height:i,cell:r}=c,s=c.scale||1;e.lineJoin="round",e.lineCap="round";let n=3*s,o=16*s,a=n,l=i-n-o;if(r.style){switch(r.style.vertical_align){case A.VerticalAlign.Top:l=n;break;case A.VerticalAlign.Middle:l=(i-o)/2;break}switch(r.style.horizontal_align){case A.HorizontalAlign.Right:a=t-n-o;break;case A.HorizontalAlign.Center:a=(t-o)/2;break}}a=Math.floor(a)+.5,l=Math.floor(l)+.5;let d=Math.floor(a+o)+.5,u=Math.floor(l+o)+.5;if(r&&r.calculated){e.lineWidth=.5,e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(a,l),e.lineTo(a+16*s,l),e.lineTo(a+16*s,l+16*s),e.lineTo(a,l+16*s),e.closePath(),e.moveTo(a+15*s,l+4*s);for(let h of[[13.59,2.58],[6,10.17],[2.41,6.59],[1,8],[6,13]])e.lineTo(a+h[0]*s,l+h[1]*s);e.closePath(),e.fill()}else e.lineWidth=1,e.lineJoin="round",e.beginPath(),e.moveTo(a,l),e.lineTo(d,l),e.lineTo(d,u),e.lineTo(a,u),e.closePath(),e.stroke();return{handled:!0}};var $r=c=>{let e=.254829592,t=-.284496736,i=1.421413741,r=-1.453152027,s=1.061405429,n=.3275911;c=Math.abs(c);let o=1/(1+n*c);return 1-((((s*o+r)*o+i)*o+t)*o+e)*o*Math.exp(-1*c*c)},bn=Math.sqrt(2*Math.PI),Br=c=>{if(c===.5)return 0;let e=c<1&&c>.5?1-c:c,t=Math.sqrt(Math.log(1/Math.pow(e,2))),i=t-(2.515517+.802853*t+.010328*Math.pow(t,2))/(1+1.432788*t+.189269*Math.pow(t,2)+.001308*Math.pow(t,3));return c>.5?i:-i},mt={Int:{fn:c=>({type:3,value:Math.floor(c)})},Rand:{volatile:!0,fn:()=>({type:3,value:Math.random()})},RandBetween:{arguments:[{name:"min"},{name:"max"}],volatile:!0,fn:(c=0,e=1)=>{if(c>e){let t=c;c=e,e=t}return{type:3,value:Math.floor(Math.random()*(e+1-c)+c)}}},Sum:{description:"Adds arguments and ranges",arguments:[{boxed:!0,name:"values or ranges"}],fn:(...c)=>{let e={real:0,imaginary:0},t=De(c);for(let i of t)switch(i.type){case 3:e.real+=i.value;break;case 4:e.real+=i.value?1:0;break;case 7:e.real+=i.value.real,e.imaginary+=i.value.imaginary;break;case 6:return i}return be(e)}},Now:{description:"Returns current time",volatile:!0,fn:()=>({type:3,value:je(new Date().getTime())})},Date:{description:"Constructs a Lotus date from parts",arguments:[{name:"year"},{name:"month"},{name:"day"}],fn:(c,e,t)=>{let i=new Date;return i.setMilliseconds(0),i.setSeconds(0),i.setMinutes(0),i.setHours(0),c<0||c>1e4?K():(c<1899&&(c+=1900),i.setFullYear(c),e<1||e>12?K():(i.setMonth(e-1),t<1||t>31?K():(i.setDate(t),{type:3,value:je(i.getTime())})))}},Today:{description:"Returns current day",volatile:!0,fn:()=>{let c=new Date;return c.setMilliseconds(0),c.setSeconds(0),c.setMinutes(0),c.setHours(12),{type:3,value:je(c.getTime())}}},IfError:{description:"Returns the original value, or the alternate value if the original value contains an error",arguments:[{name:"original value",allow_error:!0,boxed:!0},{name:"alternate value"}],fn:(c,e=0)=>c&&c.type===6?{value:e,type:re(e)}:c},IsError:{description:"Checks if another cell contains an error",arguments:[{name:"reference",allow_error:!0,boxed:!0}],fn:(...c)=>{let e=De(c);for(let t of e)if(t.type===6)return{type:4,value:!0};return{type:4,value:!1}}},Cell:{description:"Returns data about a cell",arguments:[{name:"type",description:"Type of data to return"},{name:"reference",description:"Cell reference",metadata:!0}],fn:(c,e)=>{if(!Wt(e))return Y();if(c)switch(c.toString().toLowerCase()){case"format":return e.value.format?{type:2,value:e.value.format}:Y();case"address":return{type:2,value:e.value.address.label.replace(/\$/g,"")}}return{type:6,value:Mr.error}}},Year:{description:"Returns year from date",arguments:[{name:"date"}],fn:c=>q(new Date(Ve(c)).getUTCFullYear())},Month:{description:"Returns month from date",arguments:[{name:"date"}],fn:c=>q(new Date(Ve(c)).getUTCMonth()+1)},Day:{description:"Returns day of month from date",arguments:[{name:"date"}],fn:c=>q(new Date(Ve(c)).getUTCDate())},Radians:{description:"Converts degrees to radians",arguments:[{name:"Degrees",description:"Angle in degrees"}],fn:G(c=>q(c*Math.PI/180))},Degrees:{description:"Converts radians to degrees",arguments:[{name:"Radians",description:"Angle in radians"}],fn:G(c=>q(c/Math.PI*180))},CountA:{description:"Counts cells that are not empty",fn:(...c)=>q(O(c).reduce((e,t)=>typeof t>"u"?e:e+1,0))},Count:{description:"Counts cells that contain numbers",fn:(...c)=>q(O(c).reduce((e,t)=>typeof t=="number"?e+1:e,0))},Or:{fn:(...c)=>{let e=!1;c=O(c);for(let t of c)e=e||!!t;return q(e)}},And:{fn:(...c)=>{let e=!0;c=O(c);for(let t of c)e=e&&!!t;return q(e)}},Not:{fn:(...c)=>c.length===0?K():c.length===1?q(!c[0]):q(!0)},If:{arguments:[{name:"test value",boxed:!0},{name:"value if true",boxed:!0,allow_error:!0},{name:"value if false",boxed:!0,allow_error:!0}],fn:(c,e={type:4,value:!0},t={type:4,value:!1})=>{let i=e.type===8,r=t.type===8;return c.type===8?{type:8,value:c.value.map((n,o)=>n.map((a,l)=>(a.type===2?a.value.toLowerCase()!=="false"&&a.value.toLowerCase()!=="f":!!a.value)?i?e.value[o][l]:e:r?t.value[o][l]:t))}:(c.type===2?c.value.toLowerCase()!=="false"&&c.value.toLowerCase()!=="f":!!c.value)?e:t}},Fact:{description:"Returns the factorial of a number",arguments:[{name:"number"}],fn:G(c=>{c=Math.floor(c);let e=1;for(;c>1;)e*=c,c--;return{type:3,value:e}})},Power:{description:"Returns base raised to the given power",arguments:[{name:"base",boxed:!0},{name:"exponent",boxed:!0}],fn:Ne((c,e)=>{if(c.type===7||e.type===7){let t=c.type===7?c.value:{real:c.value||0,imaginary:0},i=e.type===7?e.value:{real:e.value||0,imaginary:0},r=Pe(t,i);return be(r)}else{let t=Math.pow(c.value,e.value);return isNaN(t)?I():{type:3,value:t}}})},Mod:{fn:Ne((c,e)=>e?q(c%e):We())},Sort:{arguments:[{name:"values"}],fn:(...c)=>(c=O(c),c.every(e=>typeof e=="number")?c.sort((e,t)=>e-t):c.sort(),{type:8,value:[c.map(e=>q(e))]})},Transpose:{description:"Returns transpose of input matrix",arguments:[{name:"matrix",boxed:!0}],fn:c=>c.type===8?{type:8,value:qt(c.value)}:c},Max:{fn:(...c)=>({type:3,value:Math.max.apply(0,O(c).filter(e=>typeof e=="number"))})},Min:{fn:(...c)=>({type:3,value:Math.min.apply(0,O(c).filter(e=>typeof e=="number"))})},SumProduct:{description:"Returns the sum of pairwise products of two or more ranges",fn:(...c)=>{let e=c.map(r=>O(r)),t=Math.max.apply(0,e.map(r=>r.length)),i=0;for(let r=0;r<t;r++)i+=e.reduce((s,n)=>s*(n[r]||0),1);return{type:3,value:i}}},VLookup:{fn:(c,e,t,i=!0)=>{if(t=Math.max(0,t-1),i){let r=Math.abs(c-e[0][0]),s=e[t][0];for(let n=1;n<e[0].length;n++){let o=Math.abs(e[0][n]-c);o<r&&(r=o,s=e[t][n])}return q(s)}else{for(let r=1;r<e[0].length;r++)if(e[0][r]==c)return e[t][r];return Re()}}},Product:{arguments:[{boxed:!0}],fn:(...c)=>{let e={real:1,imaginary:0};c=De(c);for(let t of c)t.type===7?e=ue(e,t.value):t.type===3&&(e.real*=t.value,e.imaginary*=t.value);return be(e)}},Log:{fn:Ne((c,e=10)=>({type:3,value:Math.log(c)/Math.log(e)}))},Log10:{fn:G(c=>({type:3,value:Math.log(c)/Math.log(10)}))},Ln:{fn:G(c=>({type:3,value:Math.log(c)}))},Round:{fn:Ne((c,e=0)=>{let t=Math.pow(10,e);return{type:3,value:Math.round(t*c)/t}})},RoundDown:{fn:Ne((c,e=0)=>{let t=Math.pow(10,e),i=c>=0;return{type:3,value:i?Math.floor(t*c)/t:Math.ceil(t*c)/t}})},Reverse:{arguments:[{boxed:!0}],fn:c=>c.type===8?(c.value.length===1?c.value[0].reverse():c.value.reverse(),c):{type:2,value:c.value.toString().split("").reverse().join("")}},Exp:{arguments:[{boxed:!0}],fn:G(c=>{if(c.type===7){let e=Ni(c.value);return be(e)}return{type:3,value:Math.exp(c.value||0)}})},Abs:{arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:3,value:Math.sqrt(c.value.real*c.value.real+c.value.imaginary*c.value.imaginary)}:{type:3,value:Math.abs(c.value||0)})},Simplify:{arguments:[{name:"value"},{name:"significant digits"}],fn:Ne((c,e=2)=>{if(e=e||2,c===0)return{type:3,value:c};let t=c<0?-1:1;c*=t;let i=Math.pow(10,Math.floor(Math.log10(c))+1-e);return{type:3,value:Math.round(c/i)*i*t}})},Erf:{fn:c=>({type:3,value:$r(c)})},NormsInv:{description:"Inverse of the normal cumulative distribution",arguments:[{name:"probability"}],fn:c=>({type:3,value:Br(c)})},"Norm.Inv":{description:"Inverse of the normal cumulative distribution",arguments:[{name:"probability"},{name:"mean",default:0},{name:"standard deviation",default:1}],xlfn:!0,fn:(c,e=0,t=1)=>({type:3,value:Br(c)*t+e})},"Norm.Dist":{description:"Cumulative normal distribution",arguments:[{name:"value"},{name:"mean",default:0},{name:"standard deviation",default:1},{name:"cumulative",default:!0}],xlfn:!0,fn:(c,e=0,t=1,i=!0)=>{let r=0;if(i){let s=c<e?-1:1;r=.5*(1+s*$r(Math.abs(c-e)/(t*Math.sqrt(2))))}else r=Math.exp(-1/2*Math.pow((c-e)/t,2))/(t*bn);return{type:3,value:r}}},Sqrt:{description:"Returns the square root of the argument",arguments:[{boxed:!0}],fn:G(c=>{if(c.type===7){let e=Pe(c.value,{real:.5,imaginary:0});return be(e)}else{if(c.type===0||!c.value)return{type:3,value:0};{let e=Math.sqrt(c.value);return isNaN(e)?I():{type:3,value:e}}}})},HexToDec:{arguments:[{description:"hexadecimal string"}],fn:c=>({type:3,value:parseInt(c,16)})},DecToHex:{arguments:[{description:"number"}],fn:c=>({type:2,value:c.toString(16)})},Checkbox:{arguments:[{name:"checked"}],click:Gr,render:Hr,fn:c=>({value:!!c,type:4})},"Sparkline.Column":{arguments:[{name:"data"},{name:"color"},{name:"negative color"}],render:c=>(Ke.RenderColumn(c.width,c.height,c.context,c.cell,c.style),{handled:!0}),fn:(...c)=>({type:5,value:c,key:"sparkline-data"})},"Sparkline.Line":{arguments:[{name:"data"},{name:"color"},{name:"line width"}],render:c=>(Ke.RenderLine(c.width,c.height,c.context,c.cell,c.style),{handled:!0}),fn:(...c)=>({type:5,value:c,key:"sparkline-data"})}},jr={};for(let c of Object.keys(mt))jr[c.toLowerCase()]=c;var yn=["pow"],Jr={};for(let c of yn)Jr[c.toLowerCase()]=c;for(let c of Object.getOwnPropertyNames(Math)){let e=c.toLowerCase();if(jr[e]||Jr[e])continue;let t=Object.getOwnPropertyDescriptor(Math,c);if(!t)continue;let i=t.value,r=typeof i;switch(r){case"number":mt[c]={fn:()=>({type:3,value:i}),category:["Math Functions"]};break;case"function":mt[c]={fn:(...s)=>q(i(...s)),category:["Math Functions"]};break;default:console.info("unexpected type:",r,c);break}}Math.log10||(Math.log10=c=>Math.log(c)/Math.log(10));var _t=(c,e,t=0,i=0,r=0)=>r?-(t*(c/(1-Math.pow(1+c,-e))))/(1+c)-i*(1/((1+c)*((Math.pow(1+c,e)-1)/c))):-(t*c*Math.pow(1+c,e)+i*c)/(Math.pow(1+c,e)-1),qr=(c,e,t,i=0,r=0)=>r?(1+c)*-t/c*(Math.pow(1+c,e)-1)-i*Math.pow(1+c,e):-t/c*(Math.pow(1+c,e)-1)-i*Math.pow(1+c,e),$i=(c,e,t,i=0,r=0,s=0)=>{if(e<1)return NaN;if(e===1&&s)return 0;let n=_t(c,t,i,r,s),o=qr(c,e-1,n,i,s)*c;return s?o/(1+c):o},Wr=(c,e,t,i=0,r=0,s=0)=>_t(c,t,i,r,s)-$i(c,e,t,i,r,s),Xr={NPV:{description:"Returns the present value of a series of future cashflows",arguments:[{name:"Rate"},{name:"Cashflow"}],fn:(c=0,...e)=>{let t=0,i=O(e);for(let r=0;r<i.length;r++){let s=i[r];typeof s=="number"&&(t+=Math.pow(1+c,-(r+1))*s)}return{type:3,value:t}}},IRR:{description:"Calculates the internal rate of return of a series of cashflows",arguments:[{name:"Cashflows"},{name:"Guess",default:.1}],fn:(c,e=.1)=>{let t=O(c).map(s=>typeof s=="number"?s:0),i=.1,r=[{found:!1,value:0},{found:!1,value:0}];for(let s=0;s<50;s++){let n=0;for(let o=0;o<t.length;o++)n+=Math.pow(1+e,-(o+1))*t[o];if(Math.abs(n)<=.00125)return{type:3,value:e};if(n>0){if(r[0].value=r[0].found?Math.max(r[0].value,e):e,r[0].found=!0,!r[1].found){e+=i;continue}}else if(r[1].value=r[1].found?Math.min(r[1].value,e):e,r[1].found=!0,!r[0].found){e-=i;continue}e=r[0].value+(r[1].value-r[0].value)/2}return{type:6,value:"NUM"}}},CUMPRINC:{description:"Returns cumulative principal paid on a loan between two periods",arguments:[{name:"Rate"},{name:"Periods"},{name:"Present Value"},{name:"Start Period"},{name:"End Period"},{name:"Type",default:0}],fn:(c,e,t,i,r,s=0)=>{let n=0;for(let o=i;o<=r;o++)n+=Wr(c,o,e,t,0,s);return{type:3,value:n}}},CUMIPMT:{description:"Returns cumulative interest paid on a loan between two periods",arguments:[{name:"Rate"},{name:"Periods"},{name:"Present Value"},{name:"Start Period"},{name:"End Period"},{name:"Type",default:0}],fn:(c,e,t,i,r,s=0)=>{let n=0;for(let o=i;o<=r;o++)n+=$i(c,o,e,t,0,s);return{type:3,value:n}}},IPMT:{description:"Returns the interest portion of a payment",arguments:[{name:"Rate"},{name:"Period"},{name:"Periods"},{name:"Present Value",default:0},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0,s=0)=>({type:3,value:$i(c,e,t,i,r,s)})},PPMT:{description:"Returns the principal portion of a payment",arguments:[{name:"Rate"},{name:"Period"},{name:"Periods"},{name:"Present Value",default:0},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0,s=0)=>({type:3,value:Wr(c,e,t,i,r,s)})},Rate:{description:"Returns the interest rate of a loan",arguments:[{name:"Periods"},{name:"Payment"},{name:"Present Value",default:0},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t=0,i=0,r=0)=>{let s=.25,n=[-1,1],o=32,a=1e-6;for(let l=0;l<o;l++){let d=_t(s,c,t,i,r);if(Math.abs(d-e)<=a)return{type:3,value:s};let u=_t(n[1],c,t,i,r);e>=d&&e<=u||e>=u&&e<=d?n[0]=s:n[1]=s,s=n[0]+(n[1]-n[0])/2}return{type:3,value:s}}},FV:{description:"Returns the future value of an investment",arguments:[{name:"Rate"},{name:"Periods"},{name:"Payment"},{name:"Present Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0)=>({type:3,value:qr(c,e,t,i,r)})},PV:{description:"Returns the present value of an investment",arguments:[{name:"Rate"},{name:"Periods"},{name:"Payment"},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0)=>r?(t+=i*(1/((1+c)*((Math.pow(1+c,e)-1)/c))),{type:3,value:-(t+t/c*(1-Math.pow(1+c,-(e-1))))}):{type:3,value:-(i+t/c*(Math.pow(1+c,e)-1))/Math.pow(1+c,e)}},NPER:{description:"Returns the number of periods of an investment",arguments:[{name:"Rate"},{name:"Payment"},{name:"Present Value"},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t=0,i=0,r=0)=>r?{type:3,value:1+(-Math.log(1+c*(1-t/-e))+Math.log(1+i*c/(-e*(1+c))))/Math.log(1+c)}:{type:3,value:(Math.log(Math.pow(1-t*c/-e,-1))+Math.log(1+i*c/-e))/Math.log(1+c)}},PMT:{description:"Returns the periodic payment of a loan",arguments:[{name:"Rate"},{name:"Periods"},{name:"Present Value"},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0)=>({type:3,value:_t(c,e,t,i,r)})}};var gn=c=>{let e=[],t=c.length,i="[\\^$.|?*+()";for(let r=0;r<t;r++){let s=c[r];switch(s){case"*":e.push(".","*");break;case"?":e.push(".");break;case"~":s=c[++r]||"";default:for(let n=0;n<i.length;n++)if(s===i[n]){e.push("\\");break}e.push(s);break}}return e.join("")},Kr={Char:{arguments:[{name:"number"}],fn:c=>({type:2,value:String.fromCodePoint(c||32)}),category:["text"]},Code:{arguments:[{name:"string"}],fn:c=>({type:3,value:c.codePointAt(0)||0}),category:["text"]},Value:{arguments:[{name:"text"}],fn:c=>{let e=ye.TryParse(c);return e.type===3?{type:3,value:e.value}:K()},category:["text"]},Text:{arguments:[{name:"value"},{name:"number format"}],fn:(c,e="0.00####")=>({type:2,value:L.Get(e).Format(c||0)}),category:["text"]},Left:{arguments:[{name:"string"},{name:"count"}],fn:(c,e=1)=>({type:2,value:c.substr(0,e)}),category:["text"]},Right:{arguments:[{name:"string"},{name:"count"}],fn:(c,e=1)=>({type:2,value:c.slice(-e)}),category:["text"]},Mid:{arguments:[{name:"string"},{name:"left"},{name:"count"}],fn:(c,e=0,t=1)=>({type:2,value:c.substr(Math.max(0,e-1),t)}),category:["text"]},Search:{description:"Find a string (needle) in another string (haystack). Case-insensitive.",arguments:[{name:"Needle"},{name:"Haystack"},{name:"Start",default:1}],fn:(c,e,t=1)=>{if(t>=1){if(!c)return{type:3,value:t};let i=gn(c),r=new RegExp(i,"i").exec(e.substr(t-1));if(r)return{type:3,value:r.index+t}}return I()}},Find:{description:"Find a string (needle) in another string (haystack). Case-sensitive.",arguments:[{name:"Needle"},{name:"Haystack"},{name:"Start",default:1}],fn:(c,e,t=1)=>{if(t>=1){if(!c)return{type:3,value:t};let i=new RegExp(c).exec(e.substr(t-1));if(i)return{type:3,value:i.index+t}}return I()}},Concat:{description:"Pastes strings together",fn:(...c)=>{let t=O(c).map(i=>{let r=i?.toString()||"";return typeof i=="number"&&T.decimal_separator===","?r.replace(/\./,","):r}).join("");return{type:2,value:t}}}},Bi={Concatenate:"Concat"};var Yr={IsBlank:{description:"Returns true if the reference is blank",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:!c?.value||typeof c.value.value>"u"}))},IsNumber:{description:"Returns true if the reference is a number",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&typeof c.value.value=="number"}))},IsLogical:{description:"Returns true if the reference is a logical TRUE or FALSE",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&typeof c.value.value=="boolean"}))},IsText:{description:"Returns true if the reference is text",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&typeof c.value.value=="string"}))}};var Kt=(c,e=!1)=>{let t=c.length,i=0,r=0;for(let s=0;s<t;s++)i+=c[s];i/=t;for(let s=0;s<t;s++){let n=c[s]-i;r+=n*n}return e?r/(t-1):r/t},Zr={StDev:{description:"Returns the standard deviation of a set of values, corresponding to a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Math.sqrt(Kt(O(c),!1))})},"StDev.S":{description:"Returns the standard deviation of a set of values, corresponding to a sample of a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Math.sqrt(Kt(O(c),!0))})},Var:{description:"Returns the variance of a set of values, corresponding to a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Kt(O(c),!1)})},"Var.S":{description:"Returns the variance of a set of values, corresponding to a sample of a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Kt(O(c),!0)})},Covar:{description:"Returns the covariance between two ranges of values",arguments:[{name:"A"},{name:"B"}],fn:(c,e)=>{if(!Array.isArray(c)||!Array.isArray(e))return I();if(!Array.isArray(c[0])||!Array.isArray(e[0]))return I();if(c.length!==e.length)return K();let t=0,i=0,r={x:0,y:0},s={x:[],y:[]};for(let n=0;n<c.length;n++){if(!c[n]||!e[n])continue;if(c[n].length!==e[n].length)return K();let o=c[n].length;i+=o;for(let a=0;a<o;a++)r.x+=c[n][a],r.y+=e[n][a],s.x.push(c[n][a]),s.y.push(e[n][a])}if(i===0)return Re();r.x/=i,r.y/=i;for(let n=0;n<i;n++)t+=(s.x[n]-r.x)*(s.y[n]-r.y);return{type:3,value:t/i}}},Correl:{description:"Returns the correlation between two ranges of values",arguments:[{name:"A"},{name:"B"}],fn:(c,e)=>{if(!Array.isArray(c)||!Array.isArray(e))return I();if(!Array.isArray(c[0])||!Array.isArray(e[0]))return I();let t=0,i=0,r=0,s=0,n=0,o=0,a=0;for(let l=0;l<c.length;l++){if(!c[l]||!e[l])continue;let d=c[l].length;for(let u=0;u<d;u++){let h=Number(c[l][u]),p=Number(e[l][u]);isNaN(h)||isNaN(p)||(i+=h*p,r+=h,s+=p,n+=h*h,o+=p*p,a++)}}return t=a*i-r*s,t&&(t/=Math.sqrt((a*n-r*r)*(a*o-s*s))),{type:3,value:t}}},GeoMean:{description:"Returns the geometric mean of all numeric arguments",arguments:[{boxed:!0}],fn:(...c)=>{c=De(c);let e=0,t={real:1,imaginary:0},i=!1,r=!1;for(let s of c)s.type===7?(i=!0,t=ue(t,s.value),e++):s.type===3&&(s.value<0&&(r=!0),e++,t.real*=s.value,t.imaginary*=s.value);if(i){let s=Pe(t,{real:1/e,imaginary:0});return s.imaginary?{type:7,value:s}:{type:3,value:s.real}}else return r?I():{type:3,value:Math.pow(t.real,1/e)}}},Average:{description:"Returns the arithmetic mean of all numeric arguments",arguments:[{boxed:!0}],fn:(...c)=>{c=De(c);let e={real:0,imaginary:0},t=0;for(let i of c){if(i.type===6)return i;i.type===3&&(e.real+=i.value,t++),i.type===7&&(e.real+=i.value.real,e.imaginary+=i.value.imaginary,t++)}return e.real/=t,e.imaginary/=t,e.imaginary?{type:7,value:e}:{type:3,value:e.real}}},Percentile:{description:"Returns the kth percentile value from the range of data",arguments:[{name:"range"},{name:"percentile"}],fn:(c,e)=>{let t=O(c).filter(a=>typeof a=="number");t.sort((a,l)=>a-l);let i=t.length,r=Math.pow(10,8),s=Math.round((1+(i-1)*e)*r)/r,n=Math.floor(s),o=Math.ceil(s);return{type:3,value:(t[n-1]+t[o-1])/2}}},Median:{description:"Returns the median value of the range of data",arguments:[{name:"range"}],fn:(...c)=>{let e=O(c).filter(n=>typeof n=="number");e.sort((n,o)=>n-o);let t=e.length,i=1+(t-1)*.5,r=Math.floor(i),s=Math.ceil(i);return{type:3,value:(e[r-1]+e[s-1])/2}}}},ji={Mean:"Average","StDev.P":"StDev","Var.P":"Var"};var Qr={IsComplex:{description:"Returns true if the reference is a complex number",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&ge(c.value.value)}))},Real:{description:"Returns the real part of a complex number",arguments:[{boxed:!0}],fn:G(c=>c.type===3?{...c}:c.type===7?{type:3,value:c.value.real||0}:c.type===0||c.type===2&&c.value===""?{type:3,value:0}:I())},Imaginary:{description:"Returns the imaginary part of a complex number (as real)",arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:3,value:c.value.imaginary||0}:c.type===3||c.type===0||c.type===2&&c.value===""?{type:3,value:0}:I())},Conjugate:{description:"Returns the conjugate of a complex number",arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:7,value:{real:c.value.real,imaginary:-c.value.imaginary}}:c.type===3||c.type===0||!c.value?{type:3,value:c.value||0}:I())},Arg:{description:"Returns the principal argument of a complex number (in radians)",arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:3,value:Math.atan2(c.value.imaginary,c.value.real)}:c.type===3||c.type===0||c.type===2&&c.value===""?{type:3,value:Math.atan2(0,c.value||0)}:I())},Rectangular:{description:"Converts a complex number in polar form to rectangular form",arguments:[{name:"r"},{name:"\u03B8 in radians"}],fn:(c=0,e=0)=>({type:7,value:{real:c*Math.cos(e),imaginary:c*Math.sin(e)}})},Complex:{description:"Ensures that the given value will be treated as a complex number",arguments:[{boxed:!0}],fn:G(c=>c.type===7?c:c.type===3||c.type===0||!c.value?{type:7,value:{imaginary:0,real:c.value||0}}:I())},ComplexLog:{description:"Returns the principal value Log(z) of a complex number z",arguments:[{boxed:!0}],fn:G(c=>{if(c.type===3){if(!c.value)return I();c={type:7,value:{real:c.value,imaginary:0}}}else if(c.type===0||c.type===2&&c.value==="")return I();if(c.type===7){let e=Bt(c.value),t={real:Math.log(e.r),imaginary:e.theta};return t.imaginary?{type:7,value:t}:{type:3,value:t.real}}return I()})}};var Yt=c=>{let e=[];c.type===8?e=c.value:e=[[c.value]];let t=e.length,i=t?e[0].length:0,r=[];if(!t||!i)return{m:t,n:i,array:r};for(let s=0;s<t;s++){let n=[];for(let o=0;o<i;o++){let a=e[s][o];if(a.type===7)n.push({...a.value});else if(a.type===3)n.push({real:a.value,imaginary:0});else if(a.type===0||a.value==="")n.push({real:0,imaginary:0});else return{m:t,n:i,error:!0,array:[]}}r.push(n)}return{m:t,n:i,array:r}},es={MDeterm:{description:"Returns the determinant of a matrix",arguments:[{name:"matrix",boxed:!0}],fn:c=>{let e=Yt(c);if(!e.array||!e.m||!e.n||e.m!==e.n||e.error)return I();let t=jt(e);return t?be(t):I()}},MInverse:{description:"Returns the inverse matrix",arguments:[{name:"matrix",boxed:!0}],fn:c=>{let e=Yt(c);if(!e.array||!e.m||!e.n||e.m!==e.n||e.error)return I();let t=jt(e);if(t&&t.real===0&&t?.imaginary===0)return I();let i=Vr(e);return i?{type:8,value:i.map(r=>r.map(s=>be(s)))}:I()}},MMult:{description:"Returns the dot product of A and B",arguments:[{name:"A",boxed:!0},{name:"B",boxed:!0}],fn:(c,e)=>{let t=Yt(c),i=Yt(e);if(!t.array||t.error||!i.array||i.error)return I();if(t.m!==i.n)return I();let r=Lr(i,t);return{type:8,value:r.map(s=>s.map(n=>be(n)))}}}};var Ji=class extends Me{state_id=0;type=Ji.type;color=2;state_representation="";UpdateState(){let e=JSON.stringify(Array.from(this.edges_in).map(t=>t.result));e!==this.state_representation&&(this.state_representation=e,this.state_id++)}Calculate(e){if(!!this.dirty){for(let t of this.edges_in)if(t.dirty)return;this.UpdateState(),this.dirty=!1}}AddDependent(e){throw new Error("leaf vertex cannot have dependents")}},Ye=Ji;E(Ye,"type","leaf-vertex");var Zt=class extends Ht{constructor(t){super();this.model=t;this.UpdateLocale(),this.library.Register(mt,Kr,Zr,Xr,Yr,Qr,es);for(let i of Object.keys(ji))this.library.Alias(i,ji[i]);for(let i of Object.keys(Bi))this.library.Alias(i,Bi[i]);this.library.Register({CountIf:{arguments:[{name:"range"},{name:"criteria"}],fn:(i,r)=>{let s=O(i);typeof r!="string"?r="="+(r||0).toString():(r=r.trim(),/^[=<>]/.test(r)||(r="="+r));let n=this.parser.Parse("{}"+r),o=n.expression;if(n.error||!o)return Ee();if(o.type!=="binary")return Ee();if(o.left.type!=="array")return Ee();o.left.values=[s];let a=this.CalculateExpression(o);if(a.type===8){let l=0;for(let d of a.value)for(let u of d)u.value&&l++;return{type:3,value:l}}return a}},Offset:{arguments:[{name:"reference",description:"Base reference",metadata:!0},{name:"rows",description:"number of rows to offset"},{name:"columns",description:"number of columns to offset"}],return_type:1,volatile:!0,fn:((i,r=0,s=0,n=1,o=1)=>{if(!i)return K();if(!Wt(i))return Y();let a=this.DynamicDependencies(i.value.address,this.expression_calculator.context.address,!0,r,s,o,n);if(!a)return Y();if(a.dirty){let l=this.GetVertex(this.expression_calculator.context.address,!0);return l.short_circuit=!0,{type:0,value:void 0}}if(a.area){let l={type:"address",...a.area.start,label:"",position:0,id:0},d={type:"address",...a.area.end,label:"",position:0,id:0},u=a.area.count===1?l:{type:"range",start:l,end:d,label:"",position:0,id:0};return{type:5,value:u}}return I()}).bind(this)},Indirect:{arguments:[{name:"reference",description:"Cell reference (string)"}],return_type:1,volatile:!0,fn:(i=>{if(!i||typeof i!="string")return K();let r=this.parser.Parse(i);if(r.error||!r.expression||r.expression.type!=="address"&&r.expression.type!=="range")return Y();let s=this.DynamicDependencies(r.expression,this.expression_calculator.context.address);if(!s)return Y();if(s.dirty){let n=this.GetVertex(this.expression_calculator.context.address,!0);return n.short_circuit=!0,{type:0,value:void 0}}return{type:5,value:r.expression}}).bind(this)},Match:{arguments:[{name:"value",boxed:!0},{name:"range",boxed:!0},{name:"type"}],fn:(i,r,s=0)=>{if(s)return console.warn("inexact match not supported",{value:i,range:r,type:s}),Re();if(r.type===8){if(r.value.length===1){let n=r.value[0];for(let o=0;o<n.length;o++)if(i.type==n[o].type&&i.value===n[o].value)return{type:3,value:o+1}}else for(let n=0;n<r.value.length;n++){let o=r.value[n];if(o.length!==1)return Re();if(i.type==o[0].type&&i.value===o[0].value)return{type:3,value:n+1}}return Re()}else return i.type===r.type&&i.value===r.value?{type:3,value:1}:Re();return K()}},Index:{arguments:[{name:"range",boxed:!0},{name:"row"},{name:"column"}],volatile:!1,fn:(i,r,s)=>{if(i&&i.type!==8&&(i={type:8,value:[[i]]}),r&&s){let n=i.value[s-1];if(n){let o=n[r-1];if(o)return o}}else if(r){let n=[];for(let o of i.value){if(!o[r-1])return K();n.push([o[r-1]])}return{type:8,value:n}}else if(s){let n=i.value[s-1];if(n)return{type:8,value:[n]}}return K()}},Rows:{arguments:[{name:"reference",description:"Array or reference"}],volatile:!1,fn:i=>{if(!i)return K();if(Array.isArray(i)){let r=i[0];return Array.isArray(r)?{type:3,value:r.length}:I()}return{type:3,value:1}}},Columns:{arguments:[{name:"reference",description:"Array or reference"}],volatile:!1,fn:i=>i?Array.isArray(i)?{type:3,value:i.length}:{type:3,value:1}:K()},IsFormula:{description:"Returns true if the reference is a formula",arguments:[{name:"Reference",metadata:!0}],fn:G(i=>{let r=this.model.sheets.Find(i?.value?.address?.sheet_id||0);if(r){let s=r.cells.GetCell(i.value.address,!1);return{type:4,value:s?.type===1}}return{type:4,value:!1}})}})}parser=new $e;library=new Xt;registered_libraries={};expression_calculator=new Jt(this.library,this.parser);full_rebuild_required=!1;ExportCalculatedValues(){let t={};for(let i of this.model.sheets.list){let r=i.cells.toJSON({calculated_value:!0}).data;t[i.id]=r.filter(s=>s.calculated!==void 0)}return t}ApplyCalculatedValues(t){for(let i of this.model.sheets.list){let r=t[i.id];if(!r)console.info("mismatch",i.id);else for(let s of r)i.cells.data[s.row][s.column].SetCalculatedValue(s.calculated)}}SpreadCallback(t,i){if(!t.address||!t.address.sheet_id)throw new Error("spread callback called without sheet id");let r=this.model.sheets.Find(t.address.sheet_id)?.cells;if(!r)throw new Error("spread callback called without cells");if(!t||!t.reference)return;let s=t.reference.area;if(s){let n=s.rows,o=s.columns;if(i.type===8){let a=qt(i.value);for(let l=0;l<n;l++)if(a[l]){let d=0;for(;d<o&&d<a[l].length;d++)r.data[l+s.start.row][d+s.start.column].SetCalculatedValue(a[l][d].value,a[l][d].type);for(;d<o;d++)r.data[l+s.start.row][d+s.start.column].SetCalculatedValue(void 0,0)}else for(let d=0;d<o;d++)r.data[l+s.start.row][d+s.start.column].SetCalculatedValue(void 0,0)}else for(let a=0;a<n;a++)for(let l=0;l<o;l++)r.data[a+s.start.row][l+s.start.column].SetCalculatedValue(i.value,i.type)}}CalculationCallback(t){if(!t.address)throw new Error("vertex missing address");return t.expression_error?{value:$t()}:this.expression_calculator.Calculate(t.expression,t.address)}DynamicDependencies(t,i,r=!1,s=0,n=0,o=1,a=1){let l=this.ResolveExpressionAddress(t,i);if(!l)return;let d=!1,u;if(t.type==="address"||t.type==="range"){let p=t.type==="range"?t.start:t;p.sheet_id?u=this.model.sheets.Find(p.sheet_id):p.sheet&&(u=this.model.sheets.Find(p.sheet))}if(!u&&i?.sheet_id&&(u=this.model.sheets.Find(i.sheet_id)),!u)throw new Error("missing sheet in dynamic dependencies [b21]");l=u.RealArea(l);let h=l.start.sheet_id;r&&(l=new g({column:l.start.column+n,row:l.start.row+s,sheet_id:l.start.sheet_id},{column:l.start.column+n+o-1,row:l.start.row+s+a-1,sheet_id:l.end.sheet_id}));for(let p=l.start.row;p<=l.end.row;p++)for(let f=l.start.column;f<=l.end.column;f++){let m=this.GetVertex({row:p,column:f,sheet_id:h},!1);m&&m.dirty&&(this.AddEdge({row:p,column:f,sheet_id:h},this.expression_calculator.context.address),d=!0)}return{dirty:d,area:l}}UpdateLocale(){T.decimal_separator===","?(this.parser.decimal_mark=",",this.parser.argument_separator=";"):(this.parser.decimal_mark=".",this.parser.argument_separator=",")}SupportedFunctions(){let t=this.library.List(),i=Object.keys(t).map(r=>{let s=t[r].canonical_name;return s||(s=r.replace(/_/g,".")),{name:s,description:t[r].description,arguments:(t[r].arguments||[]).map(n=>({name:n.name||""}))}});for(let r of this.model.macro_functions.values())i.push({name:r.name,description:r.description,arguments:(r.argument_names||[]).map(s=>({name:s}))});return i}RegisterLibrary(t,i){return this.registered_libraries[t]?!1:(this.RegisterFunction(i),this.registered_libraries[t]=!0,!0)}RegisterFunction(t){for(let i of Object.keys(t)){let r=t[i],s=r.fn;r.fn=(...n)=>s.apply({address:{...this.expression_calculator.context.address}},n),this.library.Register({[i]:r})}}AttachModel(){this.expression_calculator.SetModel(this.model)}Calculate(t){if(this.AttachModel(),t&&!t.start.sheet_id)throw new Error("CalculateInternal called with subset w/out sheet ID");this.full_rebuild_required&&(t=void 0,this.UpdateAnnotations(),this.full_rebuild_required=!1),this.RebuildGraph(t);try{this.Recalculate()}catch(i){console.error(i),console.info("calculation error trapped")}}Reset(){this.FlushTree(),this.AttachModel(),this.full_rebuild_required=!0}DecoratedFunctionList(){let t={},i=this.library.List();for(let r of Object.keys(i)){let s=i[r];s.xlfn?t[r]="_xlfn":s.extension&&(t[r]="_xll")}return t}ResolveArea(t,i){let r=this.ResolveAddress(t,i);return P(r)?new g(r):new g(r.start,r.end)}ResolveAddress(t,i){if(typeof t=="string"){let r=this.parser.Parse(t);if(r.expression&&r.expression.type==="address")return this.ResolveSheetID(r.expression,void 0,i),{row:r.expression.row,column:r.expression.column,sheet_id:r.expression.sheet_id};if(r.expression&&r.expression.type==="range")return this.ResolveSheetID(r.expression,void 0,i),{start:{row:r.expression.start.row,column:r.expression.start.column,sheet_id:r.expression.start.sheet_id},end:{row:r.expression.end.row,column:r.expression.end.column}};if(r.expression&&r.expression.type==="identifier"){let s=this.model.named_ranges.Get(r.expression.name);if(s)return s}return{row:0,column:0}}return t}Evaluate(t,i){let r=this.parser.Parse(t);if(r&&r.expression){this.parser.Walk(r.expression,n=>((n.type==="address"||n.type==="range")&&this.ResolveSheetID(n,void 0,i),!0));let s=this.CalculateExpression(r.expression);return s.type===8?s.value.map(n=>n.map(o=>o.value)):s.value}throw r.error?new Error(r.error):new Error("invalid expression")}CalculateExpression(t,i={row:-1,column:-1},r=!1){return this.expression_calculator.Calculate(t,i,r).value}RebuildClean(t=!1){this.full_rebuild_required=!1,this.AttachModel(),this.RebuildGraph(),this.UpdateAnnotations(),this.InitializeGraph(),t&&this.volatile_list.length&&this.Recalculate()}FlattenCellList(t){let i={},r=[];for(let s of t){let n={column:s.column,row:s.row,sheet_id:s.sheet_id},o=g.CellAddressToLabel(n,!0);i[o]||(i[o]=o,r.push(n))}return r}RemoveAnnotation(t){let i=t.temp.vertex;!i||(i.Reset(),this.RemoveLeafVertex(i))}UpdateAnnotations(t,i){if(!t){for(let r of this.model.sheets.list)this.UpdateAnnotations(r.annotations,r);return}if(!i)throw new Error("invalid call to UpdateAnnotations with list but no sheet");typeof t<"u"&&!Array.isArray(t)&&(t=[t]);for(let r of t)if(r.formula){r.temp.vertex||(r.temp.vertex=new Ye);let s=r.temp.vertex;this.AddLeafVertex(s),this.UpdateLeafVertex(s,r.formula,i)}}ResolveSheetID(t,i,r){let s=t.type==="address"?t:t.start;if(s.sheet_id)return!0;if(s.sheet){let n=this.model.sheets.Find(s.sheet);if(n)return s.sheet_id=n.id,!0}else{if(i?.sheet_id)return s.sheet_id=i.sheet_id,!0;if(r?.id)return s.sheet_id=r.id,!0}return!1}ResolveExpressionAddress(t,i){switch(t.type){case"address":if(this.ResolveSheetID(t,i))return new g(t);break;case"range":if(this.ResolveSheetID(t,i))return new g(t.start,t.end);break;case"identifier":{let r=this.model.named_ranges.Get(t.name.toUpperCase());if(r)return new g(r.start,r.end)}break}}NamedRangeToAddressUnit(t){let i=t.name.toUpperCase(),r=this.model.named_ranges.Get(i);if(r)return r.count===1?this.ConstructAddressUnit(r.start,i,t.id,t.position):{type:"range",start:this.ConstructAddressUnit(r.start,i,t.id,t.position),end:this.ConstructAddressUnit(r.end,i,t.id,t.position),label:i,id:t.id,position:t.position}}ConstructAddressUnit(t,i,r,s){return{type:"address",row:t.row,column:t.column,sheet_id:t.sheet_id,label:i,id:r,position:s}}RebuildDependencies(t,i,r,s={addresses:{},ranges:{}}){if(!r){let n=this.model.sheets.Find(i);n&&(r=n.name)}switch(t.type){case"literal":case"missing":case"operator":break;case"identifier":{let n=t.name.toUpperCase();if(this.model.named_expressions.has(n)){let o=this.model.named_expressions.get(n);o&&this.RebuildDependencies(o,i,r,s)}else{let o=this.NamedRangeToAddressUnit(t);o&&(o.type==="address"?s.addresses[o.label]=o:s.ranges[o.label]=o)}}break;case"address":if(!t.sheet_id)if(t.sheet){let n=this.model.sheets.Find(t.sheet);n&&(t.sheet_id=n.id)}else t.sheet_id=i,t.sheet=r;t.sheet_id?s.addresses[t.sheet_id+"!"+t.label]=t:console.warn("invalid address in range [9d]");break;case"range":if(!t.start.sheet_id)if(t.start.sheet){let n=this.model.sheets.Find(t.start.sheet);n&&(t.start.sheet_id=n.id)}else t.start.sheet_id=i,t.start.sheet=r;t.start.sheet_id?s.ranges[t.start.sheet_id+"!"+t.start.label+":"+t.end.label]=t:console.warn("invalid sheet in range",t);break;case"unary":this.RebuildDependencies(t.operand,i,r,s);break;case"binary":this.RebuildDependencies(t.left,i,r,s),this.RebuildDependencies(t.right,i,r,s);break;case"group":t.elements.forEach(n=>this.RebuildDependencies(n,i,r,s));break;case"call":{let n=t.args.slice(0),o=this.library.Get(t.name);o&&o.arguments&&o.arguments.forEach((a,l)=>{a&&a.address&&(this.RebuildDependencies(n[l],i,r,void 0),n[l]={type:"missing",id:-1})}),n.forEach(a=>this.RebuildDependencies(a,i,r,s))}break}return s}UpdateLeafVertex(t,i,r){t.Reset();let s=this.parser.Parse(i);if(s.expression){let n=this.RebuildDependencies(s.expression,r.id,r.name);for(let o of Object.keys(n.ranges)){let a=n.ranges[o];new g(a.start,a.end).Iterate(d=>{this.AddLeafVertexEdge(d,t)})}for(let o of Object.keys(n.addresses)){let a=n.addresses[o];this.AddLeafVertexEdge(a,t)}}t.expression=s.expression||{type:"missing",id:-1},t.expression_error=!s.valid}RebuildGraphCell(t,i){if(t.area&&t.area.start.column===i.column&&t.area.start.row===i.row){let{start:r,end:s}=t.area,n=r.sheet_id||i.sheet_id;r.sheet_id||(r.sheet_id=n);for(let o=r.column;o<=s.column;o++)for(let a=r.row;a<=s.row;a++)this.ResetInbound({column:o,row:a,sheet_id:n},!0,!1);this.SetDirty(i);for(let o=r.column;o<=s.column;o++)for(let a=r.row;a<=s.row;a++)a===r.row&&o===r.column||this.AddEdge(r,{...r,row:a,column:o})}if(t.type===1){this.ResetInbound(i,!0);let r=this.parser.Parse(t.value);if(r.expression){if(r.expression.type==="call"){let o=this.library.Get(r.expression.name);o&&(o.render||o.click)&&(t.render_function=o.render,t.click_function=o.click)}let n=this.RebuildDependencies(r.expression,i.sheet_id,"");for(let o of Object.keys(n.ranges)){let a=n.ranges[o],l=new g(a.start,a.end);l.entire_row||l.entire_column?this.AddArrayEdge(l,i):l.Iterate(d=>this.AddEdge(d,i))}for(let o of Object.keys(n.addresses)){let a=n.addresses[o];this.AddEdge(a,i)}}let s=this.GetVertex(i,!0);s&&(s.expression=r.expression||{type:"missing",id:-1},s.expression_error=!r.valid)}else t.value!==t.calculated?this.ResetInbound(i,!0,!1):t.type===0&&this.ResetInbound(i,!0,!1,!0)}RebuildGraph(t){if(t){if(!t.start.sheet_id)throw new Error("subset missing sheet id");let i=this.model.sheets.Find(t.start.sheet_id)?.cells;if(i)for(let r=t.start.row;r<=t.end.row;r++){let s=i.data[r];if(s)for(let n=t.start.column;n<=t.end.column;n++){let o=s[n];o&&this.RebuildGraphCell(o,{row:r,column:n,sheet_id:t.start.sheet_id})}}}else for(let i of this.model.sheets.list||[]){let r=i.cells.data.length;for(let s=0;s<r;s++){let n=i.cells.data[s];if(n){let o=n.length;for(let a=0;a<o;a++){let l=n[a];l&&this.RebuildGraphCell(l,{row:s,column:a,sheet_id:i.id})}}}}}IsNativeOrTypedArray(t){return Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array}CheckVolatile(t){if(!t.expression||t.expression_error)return!1;let i=!1;return this.parser.Walk(t.expression,r=>{if(r.type==="call"){let s=this.library.Get(r.name);s&&s.volatile&&(i=!0)}return!i}),i}};var Wi=class{constructor(e){this.parent_node=e;let t="treb-leaf-gradient-"+Wi.unique_id;if(!document.querySelector("#"+t)){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true"),r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.overflow="hidden";let s=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");s.setAttribute("id",t),s.setAttribute("gradientUnits","userSpaceOnUse"),s.setAttribute("x1","0.6729"),s.setAttribute("y1","32"),s.setAttribute("x2","63.3271"),s.setAttribute("y2","32");let n=document.createElementNS("http://www.w3.org/2000/svg","stop");n.setAttribute("offset","0"),n.style.stopColor="#D4D400",s.appendChild(n),n=document.createElementNS("http://www.w3.org/2000/svg","stop"),n.setAttribute("offset","1"),n.style.stopColor="#AD4500",s.appendChild(n),r.appendChild(s),document.body.appendChild(r)}this.model=Et`<div id='mask' class='treb-embed-mask'><div id='dialog' class='treb-embed-dialog'><div id='left'><a href='https://treb.app' target='_blank'><svg alt='TREB logo (a leaf)' width=48 height=48 viewBox='0 0 64 64'>${""}<path fill="URL(#${t})" d="M37.913,14.323c-2.042,0-7.067,2.558-8.72,3.481c-0.959-1.012-1.065-2.522-1.243-4.475c-0.959,0.994-0.337,4.014,0,5.115c-4.19,3.125-7.707,6.357-11.295,10.016c-1.225-1.936-2.06-3.517-2.344-7.033c-1.243,2.664,0.355,6.163,1.278,8.098c-3.96,4.991-7.885,10.354-11.064,15.486C-10.001,14.323,34.344-3.916,63.327,8.641C45.372,20.593,40.736,58.313,9.197,48.28c-2.22,3.196-3.712,7.37-5.541,11.081c-1.527,0.107-2.593-0.674-2.983-1.277c3.072-7.441,7.033-13.995,11.082-20.459c4.387,0.125,8.737,0.195,12.36-0.426c-3.144-0.834-6.908-0.319-10.655-1.278c2.291-4.387,5.63-7.726,8.95-11.082c3.605,0.32,7.264,1.314,11.082,0.426c-3.32-0.586-6.535-0.799-9.377-1.705C27.223,20.131,33.438,16.401,37.913,14.323z"/></svg></a></div><div id='middle'><div id='title' class='treb-embed-dialog-title'></div><div id='message' class='treb-embed-dialog-message'></div><div id='about' class='treb-embed-dialog-body'>TREB version ${"21.6.2"}${""}<div class='smaller'><a target=_blank href='https://treb.app'>http://treb.app</a></div></div></div><button type='button' title='Close dialog' id='close' class='close-box'><svg viewBox='0 0 16 16'><path d='M11.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708-.708l7-7a.5.5 0 0 1 .708 0z'/><path d='M4.146 4.146a.5.5 0 0 0 0 .708l7 7a.5.5 0 0 0 .708-.708l-7-7a.5.5 0 0 0-.708 0z'/></svg></button></div></div>`,this.model.close.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),this.HideDialog()}),e.appendChild(this.model.mask)}model;visible_=!1;timeout;pending_dialog_resoltion=[];options_={type:"initial"};set options(e){if(e.type==="about"&&(e.close_box=!0,e.icon=!0),this.options_.icon!==e.icon&&(this.model.left.style.display=e.icon?"block":"none"),this.options_.close_box!==e.close_box&&(this.model.close.style.display=e.close_box?"block":"none"),this.options_.message!==e.message&&(this.model.message.textContent=e.message||"",this.model.message.style.display=e.message?"block":"none"),this.options_.title!==e.title&&(this.model.title.textContent=e.title||"",this.model.title.style.display=e.title?"block":"none"),this.options_.type!==e.type){let t=this.model.dialog.className.replace(/dialog-type-\S+/g,"").trim();e.type&&(t+=` dialog-type-${e.type}`),this.model.dialog.className=t,e.type==="about"?this.model.about.style.display="block":this.model.about.style.display="none"}this.options_=e}event_handler=e=>{(e.key==="Escape"||e.key==="Esc")&&(e.stopPropagation(),e.preventDefault(),this.visible=!1)};get visible(){return this.visible_}set visible(e){if(e!==this.visible_)if(this.visible_=e,e)this.parent_node.classList.add("masked"),this.model.mask.classList.add("visible"),window.addEventListener("keydown",this.event_handler);else{this.parent_node.classList.remove("masked"),this.model.mask.classList.remove("visible"),window.removeEventListener("keydown",this.event_handler);let t=this.pending_dialog_resoltion.slice(0);this.pending_dialog_resoltion=[],Promise.resolve().then(()=>{for(let i of t)i()})}}Div(e,t){let i=document.createElement("div");return e&&i.setAttribute("class",e),t&&t.appendChild(i),i}Update(e,t=!0){t&&(e={...this.options_,...e}),this.options=e}HideDialog(){this.visible=!1}ShowDialog(e){return new Promise(t=>{this.pending_dialog_resoltion.push(t),this.options=e,this.visible=!0,this.timeout&&(clearTimeout(this.timeout),this.timeout=0),e.timeout&&(this.timeout=setTimeout(()=>this.HideDialog(),e.timeout))})}},bt=Wi;E(bt,"unique_id",Math.random().toString(36).substring(2,15));var Qt=class{constructor(e){this.container=e;this.node=document.createElement("div"),this.node.classList.add("treb-spinner"),this.node.innerHTML="<div><div></div><div></div><div></div><div></div></div>",e.appendChild(this.node)}node;visible=!1;Show(){this.node.classList.add("visible")}Hide(){this.node.classList.remove("visible")}};var ei={formula_bar:!0,in_cell_editor:!0,undo:!0,scrollbars:!0,headers:!0,export:!0,popout:!1,tab_bar:"auto",resizable:!0,hyperlinks:"_blank",max_file_size:94208,dnd:!1,add_tab:!1,expand_formula_button:!1,delete_tab:!1,expand:!1,markdown:!1,spinner:!1};var ti=class extends Q{constructor(t,i,r){super();this.container=t;this.options=i;this.theme=r;this.outer_container=t.parentElement;let s=T.decimal_separator;for(let h of[0,128,192,212,256])this.colors.push(`rgb(${h}, ${h}, ${h})`);for(let h of["red","orange","yellow","green","blue","indigo","violet"])this.colors.push(h);this.model=Et`<div id='root' class='treb-toolbar'><div class='group narrow'><button id='text-align' data-command='align-left' title='Align left'><div class='treb-toolbar-icon treb-icon-text-align-left'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button id='align-left-drop' data-command='align-left' title='Align left', data-replace='text-align'><div class='treb-toolbar-icon treb-icon-text-align-left'/></button></li><li><button id='align-center-drop' data-command='align-center' title='Align center', data-replace='text-align'><div class='treb-toolbar-icon treb-icon-text-align-center'/></button></li><li><button id='align-right-drop' data-command='align-right' title='Align right', data-replace='text-align'><div class='treb-toolbar-icon treb-icon-text-align-right'/></button></li></ul></div></div><div class='group narrow'><button id='vertical-align' data-command='align-top' title='Align top'><div class='treb-toolbar-icon treb-icon-text-align-top'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button id='align-top-drop' data-command='align-top' title='Align top', data-replace='vertical-align'><div class='treb-toolbar-icon treb-icon-text-align-top'/></button></li><li><button id='align-middle-drop' data-command='align-middle' title='Align middle', data-replace='vertical-align'><div class='treb-toolbar-icon treb-icon-text-align-middle'/></button></li><li><button id='align-bottom-drop' data-command='align-bottom' title='Align bottom', data-replace='vertical-align'><div class='treb-toolbar-icon treb-icon-text-align-bottom'/></button></li></ul></div></div>${i.file_menu?"<div class='group wide'><button title='File options' class='drop-button'><div class='treb-toolbar-icon treb-icon-file-menu'/></button><div class='drop-menu' tabindex='-1'><ul><li><button class='text' data-command='reset'>New Document</button></li><hr/><li><button class='text' data-command='import-desktop'>Open File</button></li><li><button class='text' data-command='save-json'>Save JSON</button></li><hr/><li><button class='text' data-command='export-xlsx'>Export XLSX</button></li></ul></div></div>":""}<div class='group wide'><button id='align-left' title='Align left' data-command='align-left'><div class='treb-toolbar-icon treb-icon-text-align-left'/></button><button id='align-center' title='Align center' data-command='align-center'><div class='treb-toolbar-icon treb-icon-text-align-center'/></button><button id='align-right' title='Align right' data-command='align-right'><div class='treb-toolbar-icon treb-icon-text-align-right'/></button></div><div class='group wide'><button id='align-top' data-command='align-top' title='Align top'><div class='treb-toolbar-icon treb-icon-text-align-top'/></button><button id='align-middle' data-command='align-middle' title='Align middle'><div class='treb-toolbar-icon treb-icon-text-align-middle'/></button><button id='align-bottom' data-command='align-bottom' title='Align bottom'><div class='treb-toolbar-icon treb-icon-text-align-bottom'/></button></div><div class='group'><button id='wrap' data-command='wrap' title='Wrap text'><div class='treb-toolbar-icon treb-icon-wrap-text'/></button><button id='merge' data-command='merge' title='Merge cells'><div class='active-icon treb-toolbar-icon treb-icon-unmerge-cells'></div><div class='inactive-icon treb-toolbar-icon treb-icon-merge-cells'></div></button><button id='lock' data-command='lock'><div class='treb-toolbar-icon treb-icon-lock'/></button><button id='comment' class='drop-button' title='Comment'><div class='treb-toolbar-icon treb-icon-comment'/></button><div class='drop-menu' tabindex='-1'><div class='comment-editor'><div class='label' id='comment-label'></div><textarea id='comment-text' class='comment-textarea'></textarea><div class='comment-buttons'><button data-command='clear-comment'>Clear</button><button id='update-comment' data-command='update-comment'>Save</button></div></div></div></div><div class='group'><button class='color-button' data-command='background-color' title='Background color'><div class='treb-toolbar-icon treb-icon-fill-color'></div><div id='background-color-bar' class='color-bar' ></div></button><button class='drop'></button><div class='drop-menu color-chooser' data-target='background' tabindex='-1'></div></div><div class='group'><button class='color-button' data-command='foreground-color' title='Text color'><div class='treb-toolbar-icon treb-icon-text-color'></div><div id='foreground-color-bar' class='color-bar' ></div></button><button class='drop'></button><div class='drop-menu color-chooser' data-target='foreground' tabindex='-1'></div></div>${i.font_scale?`<div class='group wide'><div class='container font-size'><input value='' id='font-size-input' title='Font scale'></div><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button class='text' data-command='font-scale' data-scale='0.80'>0${s}80</button></li><li><button class='text' data-command='font-scale' data-scale='0.90'>0${s}90</button></li><li><button class='text' data-command='font-scale' data-scale='1.00'>1${s}00</button></li><li><button class='text' data-command='font-scale' data-scale='1.10'>1${s}10</button></li><li><button class='text' data-command='font-scale' data-scale='1.20'>1${s}20</button></li><li><button class='text' data-command='font-scale' data-scale='1.50'>1${s}50</button></li><li><button class='text' data-command='font-scale' data-scale='2.00'>2${s}00</button></li></ul></div></div>`:""}<div class='group'><button id='update-border' data-command='border-bottom' title='Bottom border'><div class='treb-toolbar-icon treb-icon-border-bottom'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button id='border-top' data-command='border-top' title='Top border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-top'/></button></li><li><button id='border-left' data-command='border-left' title='Left border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-left'/></button></li><li><button id='border-right' data-command='border-right' title='Right border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-right'/></button></li><li><button id='border-bottom' data-command='border-bottom' title='Bottom border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-bottom'/></button></li><li><button id='border-double-bottom' data-command='border-double-bottom' title='Double bottom border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-double-bottom'/></button></li><li><button id='border-all' data-command='border-all' title='All borders' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-all'/></button></li><li><button id='border-outside' data-command='border-outside' title='Outside borders' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-outer'/></button></li><li><button id='border-none' data-command='border-none' title='Remove borders' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-none'/></button></li><hr/><li><button id='border-color' class='color-button drop-button' data-position='horizontal' title='Border color'><div class='treb-toolbar-icon treb-icon-palette'></div><div id='border-color-bar' class='color-bar'></div></button><div class='drop-menu color-chooser' data-target='border' tabindex='-1'></div></li></ul></div></div><div class='group'><button id='layout' class='drop-button' title='Rows/columns'><div class='treb-toolbar-icon treb-icon-layout'/></button><div class='drop-menu' tabindex='-1'><ul><li><button class='text' data-command='insert-row'>Insert row</button></li><li><button class='text' data-command='insert-column'>Insert column</button></li><li><button class='text' data-command='delete-row'>Delete row</button></li><li><button class='text' data-command='delete-column'>Delete column</button></li></ul>${i.add_tab?"<ul><hr/><li><button class='text' data-command='insert-sheet'>Insert sheet</button></li><li><button class='text' data-command='delete-sheet'>Delete sheet</button></li></ul>":""}</div></div><div class='group'><button id='freeze' data-command='freeze'><div class='treb-toolbar-icon treb-icon-freeze'/></button></div><div class='group'><div class='container'><input value='General' id='number-format-input' title='Number format'></div><button class='drop'></button><div class='drop-menu scroll' tabindex='-1' data-number-formats></div></div><div class='split-button'><button data-command='decrease-decimal' title='Decrease precision'><div>0${s}0</div></button><button data-command='increase-decimal' title='Increase precision'><div>0${s}00</div></button></div><div class='group'><button id='insert-annotation' data-command='column-chart' title='Insert column chart'><div class='treb-toolbar-icon treb-icon-column-chart'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button title='Insert column chart' id='column-chart' data-command='column-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-column-chart'/></button></li><li><button title='Insert donut chart' id='donut-chart' data-command='donut-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-donut-chart'/></button></li><li><button title='Insert bar chart' id='bar-chart' data-command='bar-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-bar-chart'/></button></li><li><button title='Insert line chart' id='line-chart' data-command='line-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-line-chart'/></button></li><hr/><li><button id='insert-image' data-command='insert-image' title='Insert image' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-image'/></button></li></ul></div></div>${i.toolbar_recalculate_button?"<div class='group end-group'><button data-command='recalculate' title='Recalculate'><div class='treb-toolbar-icon treb-icon-recalculate'></div></button></div>":""}<div class='staging'><div id='color-chooser' class='color-chooser-main'><div class='color-header'>Theme colors</div><div id='theme-color-list' class='color-list'></div><div class='color-header other-colors'>Other colors</div><div id='color-list' class='color-list'></div><div class='new-color'><input id='color-input' placeholder='New Color'><button id='color-button'><div class='treb-toolbar-icon treb-icon-check'></div></button></div></div></div></div>`,this.model["background-color-bar"].style.color="yellow",this.model["foreground-color-bar"].style.color="blue",this.model["border-color-bar"].style.color="#333";let n=this.model["color-button"],o=this.model["color-input"];this.UpdateTheme(r),n.addEventListener("click",()=>{this.CommitColor({text:o.value||""})}),o.addEventListener("keydown",h=>{h.key==="Enter"&&this.CommitColor({text:o.value||""})}),o.addEventListener("input",()=>{n.style.backgroundColor="";let h=o.value||"";n.style.backgroundColor=h;let p=ee.MeasureColor(h),f=et.RGBToHSL(p[0],p[1],p[2]);n.style.color=f.l>.5?"":"#fff"}),this.model["comment-text"].addEventListener("keydown",h=>{if(h.key==="Enter"&&h.ctrlKey){h.stopPropagation(),h.preventDefault(),this.model["update-comment"].click();return}});let a="",l=this.model["font-size-input"];l&&(l.addEventListener("focus",()=>a=l.value||""),l.addEventListener("keydown",h=>{switch(h.key){case"Enter":if(l.value){let p=l.value;T.decimal_separator!=="."&&(p=p.replace(new RegExp(T.decimal_separator,"g"),".")),this.Publish({type:"font-size",style:A.ParseFontSize(p)})}else this.Publish({type:"font-size",style:{font_size:void 0}});break;case"Escape":u.value=d,this.Publish({type:"cancel"});break;default:return}h.stopPropagation(),h.preventDefault()}));let d="",u=this.model["number-format-input"];u.addEventListener("focus",()=>d=u.value||""),u.addEventListener("keydown",h=>{switch(h.key){case"Enter":this.Publish({type:"format",format:u.value||""});break;case"Escape":u.value=d,this.Publish({type:"cancel"});break;default:return}h.stopPropagation(),h.preventDefault()}),this.model.root.addEventListener("click",h=>{this.HandleClick(h)}),/narrow/i.test((i.toolbar||"").toString())&&this.model.root.classList.add("narrow"),t.appendChild(this.model.root)}model;number_formats=[];date_formats=[];colors=[];color_target;state;background_color={text:"yellow"};foreground_color={text:"blue"};border_color=void 0;outer_container;menu_map={};menu_index=1;HandleClick(t){let i=this.model["color-button"],r=this.model["color-input"],s=t.target,n=s?.dataset?.command;if(n){let o={};if(/^border-/.test(n))o.border=n,o.color=this.border_color,n="border";else switch(n){case"font-scale":o.scale=s?.dataset?.scale||1;break;case"clear-comment":case"update-comment":this.state?.selection&&!this.state.selection.empty&&(o.address={...this.state.selection.target}),o.comment=this.model["comment-text"].value||"";break;case"background-color":o.target="background",o.color=this.background_color;break;case"foreground-color":o.target="foreground",o.color=this.foreground_color;break;case"border-color":o.target="border",o.color=this.border_color;break}this.Publish({type:"button",command:n,data:o});return}if(s?.classList?.contains("drop")||s?.classList?.contains("drop-button")){let o=s.parentElement;for(;o&&!o.classList.contains("group");){if(o===this.model.root)return;o=o.parentElement}if(o||s.dataset.position==="horizontal"){let a,l;if(s.dataset.menu_target)l=this.menu_map[s.dataset.menu_target];else{l=s.nextSibling;let d=(this.menu_index++).toString();this.menu_map[d]=l,s.dataset.menu_target=d,l.style.position="absolute",l.classList.add("treb-toolbar-drop-menu"),s.dataset.position!=="horizontal"&&this.outer_container?.appendChild(l)}if(l?.classList?.contains("drop-menu"))if(s===this.model.comment&&(this.model["comment-label"].textContent=this.state?.selection?.target?g.CellAddressToLabel(this.state?.selection.target):"",this.model["comment-text"].value=this.state?.comment||"",a=this.model["comment-text"]),l.dataset.numberFormats!==void 0&&this.RenderNumberFormats(l),l.classList.contains("color-chooser")&&(this.color_target=l.dataset?.target||"",this.RenderColors(this.model["color-list"]),r.value="",i.style.backgroundColor="",i.style.color="",l.appendChild(this.model["color-chooser"])),s.dataset?.position==="horizontal")this.Focus(l,s.offsetWidth+12,s.offsetTop-8,a);else{let d=(s.classList.contains("drop-button")?s:o)?.getBoundingClientRect()||{x:0},u=this.outer_container?.getBoundingClientRect()||{x:0,right:0},h=d.x-u.x,p=l.offsetWidth;p>0&&h+p>u.right&&(h=Math.max(0,u.right-p-10)),this.Focus(l,h,s.offsetHeight+4,a)}}return}}ResolveColor(t,i){return D(this.theme,t||i)||""}CommitColor(t){switch(this.color_target){case"background":this.model["background-color-bar"].style.color=this.ResolveColor(t,{theme:0}),this.background_color=t?{...t}:void 0;break;case"border":this.model["border-color-bar"].style.color=this.ResolveColor(t,{theme:1}),this.border_color=t?{...t}:void 0;break;case"foreground":t||(t={theme:1}),this.model["foreground-color-bar"].style.color=this.ResolveColor(t,{theme:1}),this.foreground_color=t?{...t}:void 0;break}this.Publish({type:"button",command:"color",data:{color:t?{...t}:void 0,target:this.color_target||""}})}Focus(t,i,r,s){t.style.left=i+"px",t.style.top=r+"px",t.classList.add("enabled"),requestAnimationFrame(()=>t.classList.add("visible"));let n=d=>{d.key==="Escape"&&(d.stopPropagation(),d.preventDefault(),this.Publish({type:"cancel"}))};window.addEventListener("keydown",n);let o=d=>{let u=d.target;if(u.dataset?.replace){let h=this.model[u.dataset.replace];h.innerHTML=u.innerHTML,h.setAttribute("title",u.getAttribute("title")||""),h.dataset.command=u.dataset.command||void 0}if(u.dataset?.command==="number-format"){let h=u.textContent||"General";this.model["number-format-input"].value=u.textContent||"",this.Publish({type:"format",format:h})}else if(u.dataset?.command||u.classList?.contains("drop-button")){this.HandleClick(d);return}else if(u.classList?.contains("color-swatch"))if(typeof u?.dataset?.theme<"u"){let h=Number(u?.dataset?.theme);isNaN(h)&&(h=0);let p={theme:h||0};if(u?.dataset?.tint){let f=Number(u.dataset.tint);f&&!isNaN(f)&&(p.tint=f)}this.CommitColor(p)}else{let h=u?.dataset?.color||"";this.CommitColor(h?{text:h}:void 0)}d.stopPropagation()};t.addEventListener("click",o);let a=()=>{t.classList.contains("visible")||(t.style.left="",t.style.top=""),t.removeEventListener("transitionend",a)},l=d=>{let u=d.relatedTarget;u&&t.contains(u)||(t.classList.remove("visible"),t.removeEventListener("focusout",l),t.removeEventListener("click",o),window.removeEventListener("keydown",n),t.addEventListener("transitionend",a))};t.addEventListener("focusout",l),requestAnimationFrame(()=>(s||t).focus())}UpdateState(t){this.state=t;let i={"align-center":t.style&&t.style?.horizontal_align===A.HorizontalAlign.Center,"align-left":t.style&&t.style?.horizontal_align===A.HorizontalAlign.Left,"align-right":t.style&&t.style?.horizontal_align===A.HorizontalAlign.Right,"align-top":t.style&&t.style?.vertical_align===A.VerticalAlign.Top,"align-middle":t.style&&t.style?.vertical_align===A.VerticalAlign.Middle,"align-bottom":t.style&&t.style?.vertical_align===A.VerticalAlign.Bottom,wrap:t.style&&!!t.style.wrap,comment:!!t.comment},r=this.model.freeze;t.frozen?(r.classList.add("active"),r.setAttribute("title","Unfreeze panes")):(r.classList.remove("active"),r.setAttribute("title","Freeze panes")),t.style?.locked?(this.model.lock.classList.add("active"),this.model.lock.setAttribute("title","Unlock cells")):(this.model.lock.classList.remove("active"),this.model.lock.setAttribute("title","Lock cells"));let s=this.model.merge;t.merge?(s.classList.add("active"),s.dataset.command="unmerge",s.setAttribute("title","Unmerge cells")):(s.classList.remove("active"),s.dataset.command="merge",s.setAttribute("title","Merge cells"));let n=this.model["font-size-input"];if(n){let a=A.RelativeFontSize(t.style||{},this.theme.grid_cell||{}).toFixed(2);a=a.replace(/\./g,T.decimal_separator),n.value=a}let o=t.style?.number_format||"";this.model["number-format-input"].value=L.SymbolicName(o)||o,Object.keys(i).forEach(a=>{i[a]?this.model[a]?.classList.add("active"):this.model[a]?.classList.remove("active")})}UpdateTheme(t){let i=this.model["theme-color-list"],r=[],s=["Background","Text","Background","Text","Accent","Accent","Accent","Accent","Accent","Accent"],n=0;if(t.theme_colors)if(this.options.tint_theme_colors)for(let a of[.5,.25,0,-.25,-.5]){for(r.push("<div class='color-list-row'>"),n=0;n<10;n++){let l=t.theme_colors[n]||"#000";if(a){let u=Math.round(Math.abs(a)*100),h=a>0?"lighter":"darker";l+=` (${u}% ${h})`}let d=this.ResolveColor({theme:n,tint:a},{});r.push(`<button data-color='${d}' class='color-swatch' data-tint=${a} data-theme=${n} title='${s[n]}: ${l}' ></button>`)}r.push("</div>")}else{for(r.push("<div class='color-list-row'>"),n=0;n<10;n++){let a=t.theme_colors[n]||"#000";r.push(`<button data-color='${a}' class='color-swatch' data-theme=${n} title='${s[n]}: ${a}' ></button>`)}r.push("</div>")}i.innerHTML=r.join("");let o=i.querySelectorAll("button[data-color]");for(let a=0;a<o.length;a++)o[a].style.backgroundColor=o[a].dataset.color||""}RenderColors(t){let i=["<div class='color-list-row'>","<button class='color-swatch default-color' data-color='' title='Default color'></button>"],r=0;for(;r<9&&r<this.colors.length;r++){let n=this.colors[r];i.push(`<button class='color-swatch' data-color='${n}' title='${n}' ></button>`)}for(i.push("</div>");r<this.colors.length;){i.push("<div class='color-list-row'>");let n=r+10;for(;r<this.colors.length&&r<n;r++){let o=this.colors[r];i.push(`<button class='color-swatch' data-color='${o}' title='${o}' ></button>`)}i.push("</div>")}t.innerHTML=i.join("");let s=t.querySelectorAll("button.color-swatch");for(let n=0;n<s.length;n++){let o=s[n];o.style.background=o.dataset.color||""}}RenderNumberFormats(t){t.innerHTML=`<ul>${this.number_formats.map(i=>Rt`<li><button data-command='number-format' class='text'>${i}</button></li>`).join(`
|
|
10
|
+
`).map(d=>d.split(" ").map(u=>u.trim())),l=this.RecyclePasteAreas(new g({row:0,column:0},{row:a.length-1,column:a[0].length-1}),i);l.length===1&&(i.Resize(a.length,a[0].length),i.Resize(l[0].rows,l[0].columns));for(let d of l)for(let u=0;u<a.length;u++)for(let h=0;h<a[0].length;h++){let p=new g({row:u+d.start.row,column:h+d.start.column});if(this.active_sheet.cells.EnsureCell(p.end),a[u][h]){let f=this.SetInferredType({area:p,target:p.start,empty:!1},a[u][h],!1,!1);if(f)for(let m of f)r.push(m)}else{let f=this.active_sheet.cells.GetCell(p.start,!1);f&&f.type!==0&&r.push({key:11,area:p.Clone()})}}}this.ExecCommand(r),this.Select(this.primary_selection,i)}AllSelections(e=!1){let t=[this.primary_selection,this.active_selection].concat(this.additional_selections);return e?t:t.filter(i=>!i.empty)}InsertRowsInternal(e){let t=super.InsertRowsInternal(e);if(t.error)return t;let i=this.FindSheet(e.sheet_id);if(i===this.active_sheet){if(e.count<0)for(let r of this.AllSelections())r.empty=!0;else for(let r of this.AllSelections())r.target.row>=e.before_row&&(r.target.row+=e.count),r.area.entire_column||(r.area.start.row>=e.before_row?r.area.Shift(e.count,0):r.area.end.row>=e.before_row&&r.area.ConsumeAddress({row:r.area.end.row+e.count,column:r.area.end.column}));for(let r of t.delete_annotations_list||[])this.layout.RemoveAnnotation(r);if(this.QueueLayoutUpdate(),this.Repaint(),t.update_annotations_list?.length){this.layout.UpdateAnnotation(t.update_annotations_list);for(let r of t.resize_annotations_list||[]){let s=r.view[this.view_index];s?.resize_callback&&s.resize_callback.call(void 0)}}}else this.pending_layout_update.add(i.id);return t}InsertColumnsInternal(e){let t=super.InsertColumnsInternal(e);if(t.error)return t;let i=this.FindSheet(e.sheet_id);if(i===this.active_sheet){if(e.count<0)for(let r of this.AllSelections())r.empty=!0;else for(let r of this.AllSelections())r.target.column>=e.before_column&&(r.target.column+=e.count),r.area.entire_row||(r.area.start.column>=e.before_column?r.area.Shift(0,e.count):r.area.end.column>=e.before_column&&r.area.ConsumeAddress({row:r.area.end.row,column:r.area.end.column+e.count}));for(let r of t.delete_annotations_list||[])this.layout.RemoveAnnotation(r);if(this.tile_renderer.FlushOverflows(),this.QueueLayoutUpdate(),this.DelayedRender(!0,void 0,!0),t.update_annotations_list?.length){this.layout.UpdateAnnotation(t.update_annotations_list);for(let r of t.resize_annotations_list||[]){let s=r.view[this.view_index];s?.resize_callback&&s.resize_callback.call(void 0)}}}else this.pending_layout_update.add(i.id);return t}ResetInternal(){super.ResetInternal(),this.RemoveAnnotationNodes(),this.ClearSelection(this.primary_selection),this.ScrollIntoView({row:0,column:0}),this.QueueLayoutUpdate(),this.layout.HideNote()}ResizeColumnsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.column;if(typeof i>"u"){i=[];for(let n=0;n<t.columns;n++)i.push(n)}typeof i=="number"&&(i=[i]);let r=typeof e.width!="number",s=Math.round(e.width||0/this.scale);if(r)for(let n of i)this.AutoSizeColumn(t,n,!1);else for(let n of i)t.SetColumnWidth(n,s);t===this.active_sheet?(this.layout.UpdateTotalSize(),this.layout.container&&this.layout.container.offsetWidth&&this.layout.container.offsetWidth>this.layout.total_width?this.UpdateLayout():(this.layout.UpdateTileWidths(!0),this.render_tiles=this.layout.VisibleTiles(),this.Repaint(!1,!0)),this.layout.UpdateAnnotation(this.active_sheet.annotations),this.RenderSelections()):this.pending_layout_update.add(t.id)}ResizeRowsInternal(e){let t=e.sheet_id?this.FindSheet(e.sheet_id):this.active_sheet,i=e.row;if(typeof i>"u"){i=[];for(let o=0;o<t.rows;o++)i.push(o)}typeof i=="number"&&(i=[i]);let r=typeof e.shrink=="boolean"?e.shrink:!0,s=typeof e.height!="number",n=Math.round(e.height||0/this.scale);if(s)for(let o of i)t.AutoSizeRow(o,this.theme.grid_cell,r);else for(let o of i)t.SetRowHeight(o,n);t===this.active_sheet?(this.layout.UpdateTotalSize(),this.layout.container&&this.layout.container.offsetHeight&&this.layout.container.offsetHeight>this.layout.total_height?this.UpdateLayout():(this.layout.UpdateTileHeights(!0),this.render_tiles=this.layout.VisibleTiles(),this.Repaint(!1,!0)),this.layout.UpdateAnnotation(this.active_sheet.annotations),this.RenderSelections()):this.pending_layout_update.add(t.id)}SelectInternal(e){e.area?(e.area.start.sheet_id&&e.area.start.sheet_id!==this.active_sheet.id&&this.ActivateSheetInternal({key:21,id:e.area.start.sheet_id}),this.Select(this.primary_selection,new g(e.area.start,e.area.end)),this.RenderSelections()):this.ClearSelection(this.primary_selection)}FreezeInternal(e){let t=this.FindSheet(e.sheet_id||this.active_sheet.id),i=(typeof e.highlight_transition=="boolean"?e.highlight_transition:!0)&&t===this.active_sheet;if(e.rows===t.freeze.rows&&e.columns===t.freeze.columns){i&&this.HighlightFreezeArea();return}t.freeze.rows=e.rows,t.freeze.columns=e.columns,t===this.active_sheet?(this.QueueLayoutUpdate(),this.Repaint(),i&&this.HighlightFreezeArea(),e.rows||e.columns?this.layout.CloneFrozenAnnotations():this.layout.ClearFrozenAnnotations()):this.pending_layout_update.add(t.id)}ExecCommand(e,t=!0){let i=super.ExecCommand(e,t);this.batch||i.render_area&&this.DelayedRender(!1,i.render_area),i.repaint&&this.Repaint();for(let r of i.pending||[])this.pending_layout_update.add(r);return i.layout&&this.QueueLayoutUpdate(),i.sheets&&this.tab_bar&&this.tab_bar.Update(),i.formula&&this.UpdateFormulaBarFormula(),i}};var ut=class{forward={};backward=[];Count(){return this.backward.length}Serialize(){return JSON.parse(JSON.stringify(this.Map()))}Deserialize(e){if(this.Reset(),e){for(let t of Object.keys(e))this.SetName(t,new g(e[t].start,e[t].end),!1);this.RebuildList()}}MatchSelection(e,t){if(!e.start.sheet_id)throw new Error("match selection without sheet id");let i;for(let r of this.List())if(r.range.start.sheet_id===e.start.sheet_id&&(r.range.Equals(e)&&(i=r.name),t?.Equals(r.range)))return r.name;return i}SetName(e,t,i=!0){let r=this.ValidateNamed(e);return r?t.entire_column||t.entire_row?(console.warn("invalid range"),!1):(this.forward[r]=t,i&&this.RebuildList(),!0):(console.warn("invalid name"),!1)}SetNames(e){for(let t of Object.keys(e)){let i=e[t];this.SetName(t,new g(i.start,i.end),!1)}this.RebuildList()}ClearName(e,t=!0){delete this.forward[e],t&&this.RebuildList()}RemoveRangesForSheet(e,t=!0){let i={},r=this.List();for(let s of r)s.range.start.sheet_id!==e&&(i[s.name]=s.range);this.forward=i,t&&this.RebuildList()}Reset(){this.forward={},this.backward=[]}Get(e){return this.forward[e.toUpperCase()]}Map(){return this.forward}List(){return this.backward}ValidateNamed(e){return e=e.trim(),!e.length||/^[A-Za-z]{1,3}\d+$/.test(e)||/[^A-Za-z\d_.]/.test(e)||/^[^A-Za-z_]/.test(e)?!1:e.toUpperCase()}PatchNamedRanges(e,t,i,r,s){let n=this.List().slice(0);for(let o of n){let a=o.name,l=o.range;if(l.start.sheet_id!==e){console.info("skipping name",a);continue}if(i&&t<=l.end.column){if(i>0)t<=l.start.column?l.Shift(0,i):t>l.start.column&&t<=l.end.column?l.ConsumeAddress({row:l.end.row,column:l.end.column+i}):console.warn("PNR X case 1",t,i,JSON.stringify(l));else if(i<0)if(t-i<=l.start.column)l.Shift(0,i);else if(t<=l.start.column&&t-i>l.end.column)this.ClearName(a,!1);else if(t<=l.start.column){let d=t-i-1;this.SetName(a,new g({row:l.start.row,column:d+1+i,sheet_id:e},{row:l.end.row,column:l.end.column+i}),!1)}else t<=l.end.column?t-i-1>=l.end.column?this.SetName(a,new g({row:l.start.row,column:l.start.column,sheet_id:e},{row:l.end.row,column:t-1}),!1):this.SetName(a,new g({row:l.start.row,column:l.start.column,sheet_id:e},{row:l.end.row,column:l.start.column+l.columns+i-1}),!1):console.warn("PNR X case 2",t,i,JSON.stringify(l))}if(s&&r<=l.end.row){if(s>0)r<=l.start.row?l.Shift(s,0):r>l.start.row&&r<=l.end.row?l.ConsumeAddress({row:l.end.row+s,column:l.end.column}):console.warn("PNR X case 3",r,s,JSON.stringify(l));else if(s<0)if(r-s<=l.start.row)l.Shift(s,0);else if(r<=l.start.row&&r-s>l.end.row)this.ClearName(a,!1);else if(r<=l.start.row){let d=r-s-1;this.SetName(a,new g({column:l.start.column,row:d+1+s,sheet_id:e},{column:l.end.column,row:l.end.row+s}),!1)}else r<=l.end.row?r-s-1>=l.end.row?this.SetName(a,new g({column:l.start.column,row:l.start.row,sheet_id:e},{column:l.end.column,row:r-1}),!1):this.SetName(a,new g({column:l.start.column,row:l.start.row,sheet_id:e},{column:l.end.column,row:l.start.row+l.rows+s-1}),!1):console.warn("PNR X case 4",r,s,JSON.stringify(l))}}this.RebuildList()}RebuildList(){this.backward=[];for(let e of Object.keys(this.forward))this.backward.push({name:e,range:this.forward[e]})}};var Li=class{get list(){return this.sheets_.slice(0)}get length(){return this.sheets_.length}names=new Map;ids=new Map;sheets_=[];Assign(e){this.sheets_=[...e],this.UpdateIndexes()}Add(e){this.sheets_.push(e),this.UpdateIndexes()}Splice(e,t,...i){this.sheets_.splice(e,t,...i),this.UpdateIndexes()}Find(e){return typeof e=="string"?this.names.get(e.toLocaleUpperCase()):this.ids.get(e)}Name(e){return this.ids.get(e)?.name||void 0}ID(e){return this.names.get(e.toLocaleUpperCase())?.id||void 0}UpdateIndexes(){this.names.clear(),this.ids.clear();for(let e of this.sheets_){let t=e.name.toLocaleUpperCase();this.names.set(t,e),this.ids.set(e.id,e)}}},ht=class{document_name;user_data;sheets=new Li;named_ranges=new ut;macro_functions=new Map;named_expressions=new Map;view_count=0;theme_style_properties=JSON.parse(JSON.stringify(A.DefaultProperties))};var Vi=class{type=Vi.type;color=0;edges_in=new Set;edges_out=new Set;get has_inbound_edges(){return this.edges_in.size>0}get has_outbound_edges(){return this.edges_out.size>0}Reset(){for(let e of this.edges_out)e.RemoveDependency(this);for(let e of this.edges_in)e.RemoveDependent(this);this.edges_out.clear(),this.edges_in.clear()}ClearDependencies(){for(let e of this.edges_in)e.RemoveDependent(this);this.edges_in.clear()}AddDependent(e){e!==this&&(this.edges_out.has(e)||this.edges_out.add(e))}RemoveDependent(e){this.edges_out.delete(e)}AddDependency(e){e!==this&&(this.edges_in.has(e)||this.edges_in.add(e))}RemoveDependency(e){this.edges_in.delete(e)}LinkTo(e){this.AddDependent(e),e.AddDependency(this)}DependsOn(e){this.AddDependency(e),e.AddDependent(this)}LoopCheck(){let e=[this];for(;e.length;){let t=e[e.length-1],i=!0;if(t.color!==2){t.color=1;for(let r of t.edges_out){if(r.color===1)return this.color=0,!0;r.color===0&&r.edges_out.size&&(e.push(r),i=!1)}}i&&(t.color=2,e.pop())}return this.color=2,!1}},pt=Vi;E(pt,"type","vertex");var Je=class extends pt{dirty=!1};var Fi=class extends Je{reference;error=0;address;result={type:0};expression={type:"missing",id:-1};expression_error=!1;short_circuit=!1;type=Fi.type;get array_head(){return this.address?!!this.reference&&!!this.reference.area&&this.reference.area.start.column===this.address.column&&this.reference.area.start.row===this.address.row:!1}TakeReferenceValue(){this.reference&&(this.result=q(this.reference.GetValue()))}Calculate(e){if(!!this.dirty){if(this.color===0&&this.LoopCheck()&&(this.dirty=!1,this.edges_in.size)){this.reference&&(this.array_head||this.reference.type===1)&&this.reference.SetCalculationError("LOOP");for(let t of this.edges_out)t.Calculate(e);return}for(let t of this.edges_in)if(t.dirty)return;if(this.reference){if(this.reference.type===1){this.short_circuit=!1;let t=e.CalculationCallback.call(e,this);if(this.result=t.value,this.short_circuit)return;t.volatile&&e.volatile_list.push(this)}else this.result=this.reference.GetValue4();if(this.array_head)e.SpreadCallback.call(e,this,this.result);else if(this.reference.type===1){let t=this.result.type===8?this.result.value[0][0]:this.result;this.reference.SetCalculatedValue(t.value,t.type)}}else console.info("skip dirty constant? [or dangling...]");this.dirty=!1;for(let t of this.edges_out)t.dirty&&e.calculation_list.push(t)}}},Me=Fi;E(Me,"type","spreadsheet-vertex");var ze=class extends Je{type=ze.type;area;static GetVertex(e){for(let t of this.list)if(t.area.start.sheet_id===e.start.sheet_id&&t.area.Equals(e))return[t,!1];return[new ze(e),!0]}static Clear(){this.list=[]}static GetContainingArrays(e){let t=[];for(let i of this.list)i.area.start.sheet_id===e.sheet_id&&i.area.Contains(e)&&t.push(i);return t}static CreateImplicitEdges(e,t){for(let i of this.list)i.area.start.sheet_id===t.sheet_id&&i.area.Contains(t)&&i.DependsOn(e)}constructor(e){super(),this.area=e.Clone(),ze.list.push(this)}RemoveDependent(e){super.RemoveDependent(e),this.edges_out.size||(this.Reset(),ze.list=ze.list.filter(t=>t!==this))}Calculate(e){if(!!this.dirty){if(this.color===0&&this.LoopCheck()&&(this.dirty=!1,this.edges_in.size)){for(let t of this.edges_out)t.Calculate(e);return}for(let t of this.edges_in)if(t.dirty)return;this.dirty=!1;for(let t of this.edges_out)t.Calculate(e)}}},Ae=ze;E(Ae,"type","array-vertex"),E(Ae,"list",[]);var Ht=class{vertices=[[]];volatile_list=[];calculation_list=[];loop_hint;leaf_vertices=[];dirty_list=[];loop_check_required=!1;IsSpreadsheetVertex(e){return e.type===Me.type}FlushTree(){this.dirty_list=[],this.volatile_list=[],this.vertices=[[]],this.leaf_vertices=[],Ae.Clear()}ResolveArrayHead(e){if(!e.sheet_id)throw new Error("resolve array head with no sheet id");let t=this.model.sheets.Find(e.sheet_id)?.cells;if(!t)throw new Error("no cells? sheet id "+e.sheet_id);let i=t.data[e.row];if(i){let r=i[e.column];if(r&&r.area){let s={row:r.area.start.row,column:r.area.start.column,sheet_id:e.sheet_id};return console.info("array head",e,s),s}}return e}GetVertex(e,t){if(!e.sheet_id)throw console.info({address:e,create:t}),new Error("getvertex with no sheet id");let i=this.model.sheets.Find(e.sheet_id)?.cells;if(!i)throw new Error("no cells? sheet id "+e.sheet_id);if(!this.vertices[e.sheet_id]){if(!t)return;this.vertices[e.sheet_id]=[]}if(this.vertices[e.sheet_id][e.column]){let s=this.vertices[e.sheet_id][e.column][e.row];if(s)return s;if(!t)return}else{if(!t)return;this.vertices[e.sheet_id][e.column]=[]}let r=new Me;return r.address={row:e.row,column:e.column,absolute_row:e.absolute_row,absolute_column:e.absolute_column,sheet_id:e.sheet_id},r.reference=i.EnsureCell(e),this.vertices[e.sheet_id][e.column][e.row]=r,Ae.CreateImplicitEdges(r,e),r}RemoveVertex(e){if(!e.sheet_id)throw new Error("removevertex with no sheet id");let t=this.GetVertex(e,!1);!t||(t.Reset(),this.vertices[e.sheet_id][e.column][e.row]=void 0)}ResetVertex(e){let t=this.GetVertex(e,!1);t&&t.Reset()}RIBcount=0;ResetInbound(e,t=!1,i=!0,r=!1){this.RIBcount++;let s=this.GetVertex(e,i);if(!s){if(t){let o=Ae.GetContainingArrays(e);for(let a of o)this.SetVertexDirty(a)}return}let n=[];if(r&&(n=Array.from(s.edges_in)),s.ClearDependencies(),t&&this.SetVertexDirty(s),r){s.has_outbound_edges||this.RemoveVertex(e);for(let o of n)if(!o.has_inbound_edges&&!o.has_outbound_edges){let a=o;a.address&&this.RemoveVertex(a.address)}}}ResetLoopState(){for(let e of this.vertices)if(e){for(let t of e)if(t)for(let i of t)i&&(i.color=i.edges_out.size?0:2)}for(let e of this.leaf_vertices)e.color=2}LoopCheck(e=!1){if(!this.loop_check_required&&!e)return!1;let t=[];for(let r of this.vertices)if(r){for(let s of r)if(s)for(let n of s)n&&(n.color=n.edges_out.size?0:2,t.push(n))}let i=[];for(let r of t)if(r.color===0){for(r.color=1,i.push(r);i.length;){let s=i[i.length-1],n=!0;if(s.color!==2)for(let o of s.edges_out){if(o.color===1)return this.loop_hint=this.RenderAddress(r.address),console.info("loop detected @",this.loop_hint),!0;o.color===0&&(i.push(o),n=!1)}n&&(i.pop(),s.color=2)}r.color=2}return this.loop_check_required=!1,this.loop_hint=void 0,!1}RenderAddress(e){if(!e)return"undefined";let t="";if(e.sheet_id){let r=this.model.sheets.Find(e.sheet_id);r&&(t=r.name+"!")}let i=new g(e);return t+i.spreadsheet_label}AddArrayEdge(e,t){if(!e.start.sheet_id)throw new Error("AddArrayEdge called without sheet ID");let i=this.GetVertex(t,!0),[r,s]=Ae.GetVertex(e);if(i.DependsOn(r),this.loop_check_required=!0,!s)return;let n=this.vertices[e.start.sheet_id];if(!!n)if(e.entire_row){for(let o=0;o<n.length;o++)if(n[o])for(let a=e.start.row;a<=e.end.row;a++){let l=n[o][a];l&&r.DependsOn(l)}}else if(e.entire_column){for(let o=e.start.column;o<=e.end.column;o++)if(n[o])for(let a of n[o])a?.address&&r.DependsOn(a)}else for(let o=e.start.row;o<=e.end.row;o++)for(let a=e.start.column;a<=e.end.column;a++){let l=n[a][o];l&&r.DependsOn(l)}}AddEdge(e,t,i){let r=this.GetVertex(e,!0);this.GetVertex(t,!0).DependsOn(r),r.reference&&r.reference.area&&!r.array_head&&this.AddEdge({...e,row:r.reference.area.start.row,column:r.reference.area.start.column},t,"implicit"),this.loop_check_required=!0}RemoveEdge(e,t){let i=this.GetVertex(e,!1),r=this.GetVertex(t,!1);!i||!r||(i.RemoveDependent(r),r.RemoveDependency(i))}SetAreaDirty(e){if(e.start.column===1/0||e.end.column===1/0||e.start.row===1/0||e.end.row===1/0)throw new Error("don't iterate over infinite area");let t=e.start.sheet_id;if(!t)throw new Error("invalid area, missing sheet id");for(let i=e.start.column;i<=e.end.column;i++)for(let r=e.start.row;r<=e.end.row;r++){let s={row:r,column:i,sheet_id:t};this.GetVertex(s,!1)&&this.SetDirty(s)}}SetVertexDirty(e){if(!e.dirty){this.dirty_list.push(e),e.dirty=!0;for(let t of e.edges_out)this.SetVertexDirty(t)}}SetDirty(e){let t=this.GetVertex(e,!0);this.SetVertexDirty(t)}AddLeafVertex(e){for(let t of this.leaf_vertices)if(t===e)return;this.leaf_vertices.push(e)}RemoveLeafVertex(e){this.leaf_vertices=this.leaf_vertices.filter(t=>t!==e)}AddLeafVertexEdge(e,t){let i=this.GetVertex(e,!0);return t.DependsOn(i),0}RemoveLeafVertexEdge(e,t){let i=this.GetVertex(e,!1);!i||(i.RemoveDependent(t),t.RemoveDependency(i))}InitializeGraph(){for(let e of this.dirty_list)this.IsSpreadsheetVertex(e)&&(e.TakeReferenceValue(),this.CheckVolatile(e)&&this.volatile_list.push(e)),e.dirty=!1;this.dirty_list=[]}Recalculate(){for(let e of this.volatile_list)this.SetVertexDirty(e);this.calculation_list=this.dirty_list.slice(0),this.volatile_list=[],this.dirty_list=[],this.loop_check_required&&(this.ResetLoopState(),this.loop_check_required=!1);for(let e=0;e<this.calculation_list.length;e++)this.calculation_list[e].Calculate(this);this.calculation_list=[]}};var Mr={error:"NOTIMPL"},Re=()=>({type:6,value:"N/A"}),Ee=()=>({type:6,value:"EXPR"});var We=()=>({type:6,value:"DIV/0"}),K=()=>({type:6,value:"ARG"}),I=()=>({type:6,value:"VALUE"}),Y=()=>({type:6,value:"REF"}),zi=()=>({type:6,value:"NAME"}),$t=()=>({type:6,value:"UNK"});var Qs=c=>{let e={m:c,n:c,array:[]};for(let t=0;t<c;t++){let i=[];for(let r=0;r<c;r++)i.push({real:0,imaginary:0});e.array.push(i)}return e};var en=c=>{let{r:e,theta:t}=c,i=e*Math.cos(t),r=e*Math.sin(t);return{real:i,imaginary:r}},Bt=c=>{let e=Math.sqrt(c.real*c.real+c.imaginary*c.imaginary),t=Math.atan2(c.imaginary,c.real);return{r:e,theta:t}},ue=(c,e)=>({real:c.real*e.real-c.imaginary*e.imaginary,imaginary:c.real*e.imaginary+c.imaginary*e.real}),tn=(c,e)=>{let t=[];for(let i=0;i<c.m;i++){let r=[];for(let s=0;s<c.n;s++)r.push(c.array[i][s]+e.array[i][s]);t.push(r)}return{m:c.m,n:c.n,array:t}},Pi=(c,e)=>{let t=[];for(let i=0;i<c.m;i++){let r=[];for(let s=0;s<e.n;s++){let n=0;for(let o=0;o<c.n;o++)n+=c.array[i][o]*e.array[o][s];r.push(n)}t.push(r)}return{array:t,m:c.m,n:e.n}},Lr=(c,e)=>{let t=[];for(let i=0;i<c.m;i++){let r=[];for(let s=0;s<e.n;s++){let n={real:0,imaginary:0};for(let o=0;o<c.n;o++)n.real+=c.array[i][o].real*e.array[o][s].real-c.array[i][o].imaginary*e.array[o][s].imaginary,n.imaginary+=c.array[i][o].real*e.array[o][s].imaginary+c.array[i][o].imaginary*e.array[o][s].real;r.push(n)}t.push(r)}return t},jt=c=>{let e={real:0,imaginary:0},t=c.n;if(t==2){let r=ue(c.array[0][0],c.array[1][1]),s=ue(c.array[1][0],c.array[0][1]);return{real:r.real-s.real,imaginary:r.imaginary-s.imaginary}}let i=Qs(c.n);for(let r=0;r<t;r++){let s=0;for(let a=1;a<t;a++){let l=0;for(let d=0;d<t;d++)d!=r&&(i.array[s][l]={...c.array[a][d]},l++);s++}i.m=i.n=t-1;let n=Math.pow(-1,r),o=ue({real:c.array[0][r].real*n,imaginary:c.array[0][r].imaginary*n},jt(i));e.real+=o.real,e.imaginary+=o.imaginary}return e};var rn=c=>{let e={real_values:!1,imaginary_values:!1,square:c.m===c.n,unit_diagonal:!0},t={m:c.m,n:c.n,array:[]},i={m:c.m,n:c.n,array:[]};for(let r=0;r<c.m;r++){let s=c.array[r],n=[],o=[];for(let a=0;a<c.n;a++)s[a].real&&(e.real_values=!0),s[a].imaginary&&(e.imaginary_values=!0),a===r&&e.unit_diagonal&&(s[a].real!==1||s[a].imaginary!==0)&&(e.unit_diagonal=!1),n.push(s[a].real),o.push(s[a].imaginary);t.array.push(n),i.array.push(o)}return{real:t,imaginary:i,flags:e}},sn=c=>{let e=c.array.map(t=>t.slice(0));return{m:c.m,n:c.n,array:e}},Dr=c=>{if(c.m!==c.n)return;let e=sn(c),t=e.array,i=0,r=0,s=0,n=0,o=c.m;for(r=1;r<o;r++)t[0][r]/=t[0][0];for(r=1;r<o;r++){for(s=r;s<o;s++){for(i=0,n=0;n<r;n++)i+=t[s][n]*t[n][r];t[s][r]-=i}if(r!=o-1)for(s=r+1;s<o;s++){for(i=0,n=0;n<r;n++)i+=t[r][n]*t[n][s];t[r][s]=(t[r][s]-i)/t[r][r]}}for(r=0;r<o;r++)for(s=r;s<o;s++){let a=1;if(r!=s)for(a=0,n=r;n<s;n++)a-=t[s][n]*t[n][r];t[s][r]=a/t[s][s]}for(r=0;r<o;r++)for(s=r;s<o;s++)if(r!=s){for(i=0,n=r;n<s;n++)i+=t[n][s]*(r==n?1:t[r][n]);t[r][s]=-i}for(r=0;r<o;r++)for(s=0;s<o;s++){for(i=0,n=r>s?r:s;n<o;n++)i+=(s==n?1:t[s][n])*t[n][r];t[s][r]=i}return e},Vr=c=>{let e=[];if(c.m!==c.n)return;let{real:t,imaginary:i,flags:r}=rn(c),s=Dr(t);if(!s)return;if(!r.imaginary_values){for(let u=0;u<c.m;u++){let h=[];for(let p=0;p<c.n;p++)h.push({real:s.array[u][p],imaginary:0});e.push(h)}return e}let n=Pi(s,i),o=Pi(i,n),a=tn(t,o),l=Dr(a);if(!l)return;let d=Pi(n,l);for(let u=0;u<c.m;u++){let h=[];for(let p=0;p<c.n;p++)h.push({real:l.array[u][p],imaginary:-d.array[u][p]});e.push(h)}return e},Ir=(c,e)=>{let t={real:e.real,imaginary:-e.imaginary},i=ue(c,t),r=ue(e,t);return{real:i.real/r.real,imaginary:i.imaginary/r.real}},Ni=c=>{let e=c.real||0,t=c.imaginary||0;return ue({real:Math.exp(e),imaginary:0},{real:Math.cos(t),imaginary:Math.sin(t)})},nn=c=>{let e=Bt(c);return{real:Math.log(e.r),imaginary:e.theta}},Pe=(c,e)=>{if(e.imaginary)return Ni(ue(e,nn(c)));{let t=Bt(c);return en({r:Math.pow(t.r,e.real),theta:t.theta*e.real})}};var Fr=(c,e=0)=>c&&c.type===7?c:{type:7,value:{real:e,imaginary:0}},ft=c=>c.imaginary?{type:7,value:c}:{type:3,value:c.real},qe=(c,e)=>{if(c.type===6)return[0,0,c];if(e.type===6)return[0,0,e];let t=[0,0];switch(c.type){case 3:t[0]=c.value;break;case 4:t[0]=c.value?1:0;break;case 0:break;case 7:t[3]=c;break;default:return[0,0,I()]}switch(e.type){case 3:t[1]=e.value;break;case 4:t[1]=e.value?1:0;break;case 0:break;case 7:t[4]=e;break;default:return[0,0,I()]}return(t[3]||t[4])&&(t[3]=Fr(t[3],t[0]),t[4]=Fr(t[4],t[1])),t},on=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?ft({real:s.value.real+n.value.real,imaginary:s.value.imaginary+n.value.imaginary}):{value:t+i,type:3})},Hi=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?ft({real:s.value.real-n.value.real,imaginary:s.value.imaginary-n.value.imaginary}):{value:t-i,type:3})},zr=(c,e)=>{let[t,i,r,s,n]=qe(c,e);if(r)return r;if(s&&n)return ft(Pe(s.value,n.value));let o=Math.pow(t,i);return isNaN(o)?I():{type:3,value:o}},an=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?ft(ue(s.value,n.value)):{value:t*i,type:3})},ln=(c,e)=>{let[t,i,r,s,n]=qe(c,e);return r||(s&&n?n.value.real===0&&n.value.imaginary===0?We():ft(Ir(s.value,n.value)):i===0?We():{value:t/i,type:3})},cn=(c,e)=>{let[t,i,r]=qe(c,e);return r||(i===0?We():{value:t%i,type:3})},dn=(c,e)=>c.type===6?c:e.type===6?e:{type:2,value:`${c.type===0?"":c.value}${e.type===0?"":e.value}`},Gi=(c,e)=>{if(c.type===6)return c;if(e.type===6)return e;if(c.type===0&&(e.value===""||e.value===0||e.type===7&&e.value.real===0&&e.value.imaginary===0)||e.type===0&&(c.value===""||c.value===0||c.type===7&&c.value.real===0&&c.value.imaginary===0))return{type:4,value:!0};if(c.type===7||e.type===7){let t=!1;return c.type===e.type?t=c.value.real==e.value.real&&c.value.imaginary==e.value.imaginary:c.type===3?t=e.value.real==c.value&&!e.value.imaginary:e.type===3&&(t=c.value.real==e.value&&!c.value.imaginary),{type:4,value:t}}return{type:4,value:c.value==e.value}},Pr=(c,e)=>{let t=Gi(c,e);return t.type===6?t:{type:4,value:!t.value}},un=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:(c.value||0)>(e.value||0)},hn=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:c.value>=e.value},pn=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:c.value<e.value},fn=(c,e)=>c.type===6?c:e.type===6?e:c.type===7||e.type===7?I():{type:4,value:c.value<=e.value},Nr=c=>{switch(c){case"&":return dn;case"+":return on;case"-":return Hi;case"*":return an;case"/":return ln;case"^":return zr;case"**":return zr;case"%":return cn;case"=":return Gi;case"==":return Gi;case"!=":return Pr;case"<>":return Pr;case">":return un;case">=":return hn;case"<":return pn;case"<=":return fn}};var Or=c=>!Array.isArray(c)&&c.type===5&&!!c.value.type,Wt=c=>c.type===5&&c.key==="metadata",Jt=class{constructor(e,t){this.library=e;this.parser=t}context={address:{row:-1,column:-1},volatile:!1,call_index:0};call_index=0;named_range_map={};data_model;SetModel(e){this.data_model=e,this.named_range_map=e.named_ranges.Map(),this.context.model=e}Calculate(e,t,i=!1){return i||(this.context.address=t,this.context.volatile=!1,this.context.call_index=0,this.call_index=0),{value:this.CalculateExpression(e),volatile:this.context.volatile}}CellFunction2(e){if(!e.sheet_id)if(e.sheet)e.sheet_id=this.data_model.sheets.ID(e.sheet)||0;else return()=>Y();let t=this.data_model.sheets.Find(e.sheet_id)?.cells;if(!t)return console.warn("missing cells reference @ "+e.sheet_id),()=>Y();let i=t.GetCell(e);return i?()=>i.GetValue4():()=>({type:0,value:void 0})}CellFunction4(e,t){return e.sheet_id?this.data_model.sheets.Find(e.sheet_id)?.cells?.GetRange4(e,t,!0)||Y():Y()}GetMetadata(e,t){let i,r;switch(e.type){case"address":i=e;break;case"range":r=e;break;case"identifier":{let s=this.named_range_map[e.name.toUpperCase()];s&&(s.count===1?i=s.start:r=s)}break;case"call":{let s=this.CalculateExpression(e,!0);if(Or(s))if(s.value.type==="address")i=s.value;else if(s.value.type==="range")r=s.value;else return s;else return s}break;default:return this.CalculateExpression(e)}if(i){let s;if(i.sheet_id&&(s=this.data_model.sheets.Find(i.sheet_id)),!s)return console.error("missing sheet [ac8]"),Y();let n=s.CellData(i),o=n.calculated_type?n.calculated:n.value,a={type:"metadata",address:{...i},value:o,format:n.style?n.style.number_format:void 0,...t(n,i)};return{type:5,value:a,key:"metadata"}}else if(r){if(r.start.row===1/0||r.start.column===1/0)return Y();let s;if(r.start.sheet_id&&(s=this.data_model.sheets.Find(r.start.sheet_id)),!s)throw new Error("missing sheet [ac9]");let n=[];for(let o=r.start.column;o<=r.end.column;o++){let a=[];for(let l=r.start.row;l<=r.end.row;l++){let d=s.CellData({row:l,column:o});i={...r.start,row:l,column:o};let u=d.calculated_type?d.calculated:d.value,h={type:"metadata",address:i,value:u,format:d.style?d.style.number_format:void 0,...t(d,i)};a.push({type:5,value:h,key:"metadata"})}n.push(a)}return{type:8,value:n}}return this.CalculateExpression(e)}RewriteMacro(e,t){let i;switch(e.type){case"identifier":if(i=t[e.name.toUpperCase()],i)return JSON.parse(JSON.stringify(i));break;case"binary":e.left=this.RewriteMacro(e.left,t),e.right=this.RewriteMacro(e.right,t);break;case"unary":e.operand=this.RewriteMacro(e.operand,t);break;case"group":e.elements=e.elements.map(r=>this.RewriteMacro(r,t));break;case"call":e.args=e.args.map(r=>this.RewriteMacro(r,t));break}return e}CallMacro(e,t){if(!t.expression)return()=>Ee();let i=JSON.stringify(t.expression),r={},s=t.argument_names?.map(n=>n.toUpperCase())||[];return n=>{let o=JSON.parse(i);for(let a=0;a<s.length;a++)r[s[a]]=n.args[a]||{type:"missing",id:0};return this.CalculateExpression(this.RewriteMacro(o,r))}}CallExpression(e,t=!1){let i=this.library.Get(e.name);return i?r=>{let s=this.call_index++;this.context.volatile=this.context.volatile||!!i.volatile;let n=e.name.toLowerCase()==="if",o=-1,a,l=i.arguments||[],d=r.args.map((u,h)=>{if(a)return;let p=l[Math.min(h,l.length-1)]||{};if(h===o)return p.boxed?{type:0}:void 0;if(typeof u>"u")return n&&h===0&&(o=1),p.boxed?{type:0}:void 0;if(p.address)return p.boxed?{type:2,value:this.parser.Render(u).replace(/\$/g,"")}:this.parser.Render(u).replace(/\$/g,"");if(p.metadata)return this.GetMetadata(u,()=>({}));{let f=this.CalculateExpression(u);if(f.type===6){if(p.allow_error)return f;a=f;return}if(n&&h===0&&f.type!==8){let m=!1;if(f.type===2){let b=f.value.toLowerCase().trim();m=b!=="false"&&b!=="f"}else m=!!f.value;o=m?2:1}return p.boxed?f:f.type===8?f.value.map(m=>m.map(b=>b.value)):f.value}});if(a)return a;if(this.context.call_index=s,i.return_type===1){let u=i.fn.apply(null,d);if(t)return u;if(Or(u)){if(u.value.type==="address")return this.CellFunction2(u.value)();if(u.value.type==="range")return this.CellFunction4(u.value.start,u.value.end)}return u}return i.fn.apply(null,d)}:()=>zi()}ResolveDimensionedQuantity(){return e=>{let t=this.CalculateExpression(e.expression);return{type:9,value:{value:t.value,unit:e.unit.name}}}}UnaryExpression(e){switch(e.operator){case"+":return t=>this.CalculateExpression(t.operand);case"-":{let t=Hi,i={type:3,value:0};return r=>{let s=this.CalculateExpression(r.operand);return s.type===8?{type:8,value:s.value.map(n=>n.map(o=>t(i,o)))}:t(i,s)}}default:return()=>(console.warn("unexpected unary operator:",e.operator),Ee())}}RecycleArray(e,t,i){if(e[0].length<i){let r=e[0].length;for(let s of e)for(let n=r;n<i;n++)s[n]=s[n%r]}if(e.length<t){let r=e.length;for(let s=r;s<t;s++)e[s]=e[s%r].slice(0)}return e}ElementwiseBinaryExpression(e,t,i){let r=Math.max(t.value.length,i.value.length),s=Math.max(t.value[0].length,i.value[0].length),n=this.RecycleArray(t.value,r,s),o=this.RecycleArray(i.value,r,s),a=[];for(let l=0;l<r;l++){let d=[];for(let u=0;u<s;u++)d[u]=e(n[l][u],o[l][u]);a.push(d)}return{type:8,value:a}}BinaryExpression(e){let t=Nr(e.operator);return t?i=>{let r=this.CalculateExpression(i.left),s=this.CalculateExpression(i.right);return r.type===8?s.type===8?this.ElementwiseBinaryExpression(t,r,s):this.ElementwiseBinaryExpression(t,r,{type:8,value:[[s]]}):s.type===8?this.ElementwiseBinaryExpression(t,{type:8,value:[[r]]},s):t(r,s)}:()=>(console.info(`(unexpected binary operator: ${e.operator})`),Ee())}Identifier(e){let t=e.name;if(t[0]==="#")return()=>Y();let i=t.toUpperCase();switch(i){case"FALSE":case"F":return()=>({value:!1,type:4});case"TRUE":case"T":return()=>({value:!0,type:4});case"UNDEFINED":return()=>({value:void 0,type:0})}return()=>{let r=this.named_range_map[i];if(r)return r.count===1?this.CellFunction4(r.start,r.start):this.CellFunction4(r.start,r.end);let s=this.data_model.named_expressions.get(i);return s?this.CalculateExpression(s):zi()}}GroupExpression(e){return!e.elements||e.elements.length!==1?(console.warn("Can't handle group !== 1"),()=>Ee()):t=>this.CalculateExpression(t.elements[0])}CalculateExpression(e,t=!1){if(e.user_data)return e.user_data(e);switch(e.type){case"call":{let i=this.data_model.macro_functions.get(e.name.toUpperCase());return i?(e.user_data=this.CallMacro(e,i))(e):(e.user_data=this.CallExpression(e,t))(e)}case"address":return(e.user_data=this.CellFunction2(e))();case"range":return(e.user_data=i=>this.CellFunction4(i.start,i.end))(e);case"binary":return(e.user_data=this.BinaryExpression(e))(e);case"unary":return(e.user_data=this.UnaryExpression(e))(e);case"identifier":return(e.user_data=this.Identifier(e))();case"missing":return(e.user_data=()=>({value:void 0,type:0}))();case"dimensioned":return(e.user_data=this.ResolveDimensionedQuantity())(e);case"literal":{let i={value:e.value,type:re(e.value)};return(e.user_data=()=>i)()}case"group":return(e.user_data=this.GroupExpression(e))(e);case"complex":{let i={value:{real:e.real,imaginary:e.imaginary},type:7};return(e.user_data=()=>i)()}case"array":return(e.user_data=()=>({type:8,value:e.values.map(i=>(Array.isArray(i)?i:[i]).map(r=>({type:re(r),value:r})))}))();default:return console.warn("Unhandled parse expr:",e),$t()}}};var sh=1e3*60*60*24;var qt=c=>{let e=[],t=c.length,i=c[0].length;for(let r=0;r<i;r++){e[r]=[];for(let s=0;s<t;s++)e[r][s]=c[s][r]}return e};var De=c=>{let e=[];for(let t of c)if(t.type===8)for(let i of t.value)e=e.concat(De(i));else e.push(t);return e},O=c=>Array.isArray(c)?c.reduce((e,t)=>typeof t>"u"?e:Array.isArray(t)?e.concat(O(t)):t instanceof Float32Array||t instanceof Float64Array?e.concat(Array.from(t)):e.concat([t]),[]):[c];var G=c=>(e,...t)=>Array.isArray(e)?(console.info("AAA 71823"),{type:8,value:e.map(i=>i.map(r=>c(r,...t)))}):typeof e=="object"&&!!e&&e.type===8?{type:8,value:e.value.map(i=>i.map(r=>c(r,...t)))}:c(e,...t),Ne=c=>(e,t,...i)=>{let r=!1,s=!1;return!!e&&typeof e=="object"&&e.type===8?(e=e.value,r=!0):r=Array.isArray(e),!!t&&typeof t=="object"&&t.type===8?(t=t.value,s=!0):s=Array.isArray(t),r?s?{type:8,value:e.map((n,o)=>n.map((a,l)=>c(a,t[o][l],...i)))}:{type:8,value:e.map(n=>n.map(o=>c(o,t,...i)))}:s?{type:8,value:t.map(n=>n.map(o=>c(e,o,...i)))}:c(e,t,...i)};var Xt=class{functions={};Register(...e){for(let t of e)for(let i of Object.keys(t)){if(/[^a-zA-Z0-9._]/.test(i))throw new Error("invalid function name (invalid character)");if(i.length>255)throw new Error("invalid function name (too long, > 255)");if(/^[^a-zA-Z]/.test(i))throw new Error("invalid function name (start with an ascii letter)");let r=i.toLowerCase();if(this.functions[r])throw new Error(`function name (${r}) is already in use`);let s=t[i];s.canonical_name=i,this.functions[r]=s}}Get(e){let t=e.toLowerCase();return this.functions[t]}List(){let e={};for(let t of Object.keys(this.functions))e[t]=this.functions[t];return e}Alias(e,t){let i=this.Get(t);if(!i)throw new Error(`referenced function ${t} does not exist`);this.Register({[e]:{...i}})}};var Ke=class{static UnpackValues(e){if(Array.isArray(e)){let t=e[0];return Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array?e.reduce((i,r)=>i.concat(this.UnpackValues(r)),[]):e.map(i=>isNaN(i)?void 0:i)}else{if(e instanceof Float32Array||e instanceof Float64Array)return Array.prototype.slice.call(e);if(e&&typeof e=="object"){let i=Object.keys(e).length;if(typeof e[0]<"u"&&typeof e[(i-1).toString()]<"u"){let r=[];for(let s=0;s<i;s++)r[s]=e[s.toString()];return r}}}return[]}static SparklineCommon(e,t){let i=[],r=t.text?.text||this.default_color,s=[r,r];return Array.isArray(e.calculated)&&(i=this.UnpackValues(e.calculated[0]),typeof e.calculated[1]=="string"&&(s[0]=e.calculated[1]),typeof e.calculated[2]=="string"&&(s[1]=e.calculated[2])),{values:i,colors:s}}static RenderLine(e,t,i,r,s){let{values:n,colors:o}=this.SparklineCommon(r,s),a=.05,l=.1,d=1;Array.isArray(r.calculated)&&typeof r.calculated[2]=="number"&&(d=r.calculated[2]);let u=0,h=0,p=-1;for(let f=0;f<n.length;f++){let m=n[f];typeof m=="number"&&(p>=0?(u=Math.min(u,m),h=Math.max(h,m)):(p=f,u=h=m))}if(u!==h){let f=e*(1-2*a)/(n.length-1),m=h-u,b=t*(1-2*l),_=t*l;i.strokeStyle=o[0],i.lineWidth=d,i.lineCap="round",i.lineJoin="round",i.beginPath();let y=0;for(let x=p;x<n.length;x++){let v=n[x];if(typeof v=="number"){let w=e*a+f*x,C=t-(v-u)*b/m-_;y===0?(i.moveTo(w,C),y=1):i.lineTo(w,C)}else y=0}i.stroke()}}static RenderColumn(e,t,i,r,s){let{values:n,colors:o}=this.SparklineCommon(r,s),a=3,l=2.5,d=0,u=0,h=!1;for(let p of n)typeof p=="number"&&(h?(d=Math.min(d,p),u=Math.max(u,p)):(h=!0,d=u=p));if(n.length){let p=(e-2*a-2)/(n.length-0),f=t-2*l,m=l;if(d!==u)if(d<0&&u>0){let b=u-d,_=m+u/b*f;for(let y=0;y<n.length;y++){let x=n[y];if(typeof x=="number"){let v=a+y*p,w=Math.abs(x)/b*f;if(x>=0){i.fillStyle=o[0];let C=_-w;i.fillRect(v+2,C,p-2,w)}else{i.fillStyle=o[1];let C=_;i.fillRect(v+2,C,p-2,w)}}}}else if(u>0){i.fillStyle=o[0];let b=u-d;for(let _=0;_<n.length;_++){let y=n[_];if(typeof y=="number"){let x=a+_*p,v=Math.max(1,(y-d)/b*f),w=t-m-v;i.fillRect(x+2,w,p-2,v)}}}else{i.fillStyle=o[1];let b=u-d;for(let _=0;_<n.length;_++){let y=n[_];if(typeof y=="number"){let x=a+_*p,v=Math.max(1,Math.abs(u-y)/b*f),w=m;i.fillRect(x+2,w,p-2,v)}}}}}};E(Ke,"default_color","#888");var Gr=c=>{let{x:e,y:t,width:i,height:r,cell:s}=c,n={},o=3,a=Math.round(16*(c.scale||1));if(s&&i&&r&&e&&t){let l={x:o,y:r-o-a};if(s.style){switch(s.style.vertical_align){case A.VerticalAlign.Top:l.y=o;break;case A.VerticalAlign.Middle:l.y=Math.round((r-a)/2);break}switch(s.style.horizontal_align){case A.HorizontalAlign.Right:l.x=Math.round(i-o-a);break;case A.HorizontalAlign.Center:l.x=Math.round((i-a)/2);break}}e>=l.x&&e<=l.x+a&&t>=l.y&&t<=l.y+a&&(n.value=`=Checkbox(${s.calculated?"FALSE":"TRUE"})`,n.block_selection=!0)}return n},Hr=c=>{let{context:e,width:t,height:i,cell:r}=c,s=c.scale||1;e.lineJoin="round",e.lineCap="round";let n=3*s,o=16*s,a=n,l=i-n-o;if(r.style){switch(r.style.vertical_align){case A.VerticalAlign.Top:l=n;break;case A.VerticalAlign.Middle:l=(i-o)/2;break}switch(r.style.horizontal_align){case A.HorizontalAlign.Right:a=t-n-o;break;case A.HorizontalAlign.Center:a=(t-o)/2;break}}a=Math.floor(a)+.5,l=Math.floor(l)+.5;let d=Math.floor(a+o)+.5,u=Math.floor(l+o)+.5;if(r&&r.calculated){e.lineWidth=.5,e.fillStyle=e.strokeStyle,e.beginPath(),e.moveTo(a,l),e.lineTo(a+16*s,l),e.lineTo(a+16*s,l+16*s),e.lineTo(a,l+16*s),e.closePath(),e.moveTo(a+15*s,l+4*s);for(let h of[[13.59,2.58],[6,10.17],[2.41,6.59],[1,8],[6,13]])e.lineTo(a+h[0]*s,l+h[1]*s);e.closePath(),e.fill()}else e.lineWidth=1,e.lineJoin="round",e.beginPath(),e.moveTo(a,l),e.lineTo(d,l),e.lineTo(d,u),e.lineTo(a,u),e.closePath(),e.stroke();return{handled:!0}};var $r=c=>{let e=.254829592,t=-.284496736,i=1.421413741,r=-1.453152027,s=1.061405429,n=.3275911;c=Math.abs(c);let o=1/(1+n*c);return 1-((((s*o+r)*o+i)*o+t)*o+e)*o*Math.exp(-1*c*c)},bn=Math.sqrt(2*Math.PI),Br=c=>{if(c===.5)return 0;let e=c<1&&c>.5?1-c:c,t=Math.sqrt(Math.log(1/Math.pow(e,2))),i=t-(2.515517+.802853*t+.010328*Math.pow(t,2))/(1+1.432788*t+.189269*Math.pow(t,2)+.001308*Math.pow(t,3));return c>.5?i:-i},mt={Int:{fn:c=>({type:3,value:Math.floor(c)})},Rand:{volatile:!0,fn:()=>({type:3,value:Math.random()})},RandBetween:{arguments:[{name:"min"},{name:"max"}],volatile:!0,fn:(c=0,e=1)=>{if(c>e){let t=c;c=e,e=t}return{type:3,value:Math.floor(Math.random()*(e+1-c)+c)}}},Sum:{description:"Adds arguments and ranges",arguments:[{boxed:!0,name:"values or ranges"}],fn:(...c)=>{let e={real:0,imaginary:0},t=De(c);for(let i of t)switch(i.type){case 3:e.real+=i.value;break;case 4:e.real+=i.value?1:0;break;case 7:e.real+=i.value.real,e.imaginary+=i.value.imaginary;break;case 6:return i}return be(e)}},Now:{description:"Returns current time",volatile:!0,fn:()=>({type:3,value:je(new Date().getTime())})},Date:{description:"Constructs a Lotus date from parts",arguments:[{name:"year"},{name:"month"},{name:"day"}],fn:(c,e,t)=>{let i=new Date;return i.setMilliseconds(0),i.setSeconds(0),i.setMinutes(0),i.setHours(0),c<0||c>1e4?K():(c<1899&&(c+=1900),i.setFullYear(c),e<1||e>12?K():(i.setMonth(e-1),t<1||t>31?K():(i.setDate(t),{type:3,value:je(i.getTime())})))}},Today:{description:"Returns current day",volatile:!0,fn:()=>{let c=new Date;return c.setMilliseconds(0),c.setSeconds(0),c.setMinutes(0),c.setHours(12),{type:3,value:je(c.getTime())}}},IfError:{description:"Returns the original value, or the alternate value if the original value contains an error",arguments:[{name:"original value",allow_error:!0,boxed:!0},{name:"alternate value"}],fn:(c,e=0)=>c&&c.type===6?{value:e,type:re(e)}:c},IsError:{description:"Checks if another cell contains an error",arguments:[{name:"reference",allow_error:!0,boxed:!0}],fn:(...c)=>{let e=De(c);for(let t of e)if(t.type===6)return{type:4,value:!0};return{type:4,value:!1}}},Cell:{description:"Returns data about a cell",arguments:[{name:"type",description:"Type of data to return"},{name:"reference",description:"Cell reference",metadata:!0}],fn:(c,e)=>{if(!Wt(e))return Y();if(c)switch(c.toString().toLowerCase()){case"format":return e.value.format?{type:2,value:e.value.format}:Y();case"address":return{type:2,value:e.value.address.label.replace(/\$/g,"")}}return{type:6,value:Mr.error}}},Year:{description:"Returns year from date",arguments:[{name:"date"}],fn:c=>q(new Date(Ve(c)).getUTCFullYear())},Month:{description:"Returns month from date",arguments:[{name:"date"}],fn:c=>q(new Date(Ve(c)).getUTCMonth()+1)},Day:{description:"Returns day of month from date",arguments:[{name:"date"}],fn:c=>q(new Date(Ve(c)).getUTCDate())},Radians:{description:"Converts degrees to radians",arguments:[{name:"Degrees",description:"Angle in degrees"}],fn:G(c=>q(c*Math.PI/180))},Degrees:{description:"Converts radians to degrees",arguments:[{name:"Radians",description:"Angle in radians"}],fn:G(c=>q(c/Math.PI*180))},CountA:{description:"Counts cells that are not empty",fn:(...c)=>q(O(c).reduce((e,t)=>typeof t>"u"?e:e+1,0))},Count:{description:"Counts cells that contain numbers",fn:(...c)=>q(O(c).reduce((e,t)=>typeof t=="number"?e+1:e,0))},Or:{fn:(...c)=>{let e=!1;c=O(c);for(let t of c)e=e||!!t;return q(e)}},And:{fn:(...c)=>{let e=!0;c=O(c);for(let t of c)e=e&&!!t;return q(e)}},Not:{fn:(...c)=>c.length===0?K():c.length===1?q(!c[0]):q(!0)},If:{arguments:[{name:"test value",boxed:!0},{name:"value if true",boxed:!0,allow_error:!0},{name:"value if false",boxed:!0,allow_error:!0}],fn:(c,e={type:4,value:!0},t={type:4,value:!1})=>{let i=e.type===8,r=t.type===8;return c.type===8?{type:8,value:c.value.map((n,o)=>n.map((a,l)=>(a.type===2?a.value.toLowerCase()!=="false"&&a.value.toLowerCase()!=="f":!!a.value)?i?e.value[o][l]:e:r?t.value[o][l]:t))}:(c.type===2?c.value.toLowerCase()!=="false"&&c.value.toLowerCase()!=="f":!!c.value)?e:t}},Fact:{description:"Returns the factorial of a number",arguments:[{name:"number"}],fn:G(c=>{c=Math.floor(c);let e=1;for(;c>1;)e*=c,c--;return{type:3,value:e}})},Power:{description:"Returns base raised to the given power",arguments:[{name:"base",boxed:!0},{name:"exponent",boxed:!0}],fn:Ne((c,e)=>{if(c.type===7||e.type===7){let t=c.type===7?c.value:{real:c.value||0,imaginary:0},i=e.type===7?e.value:{real:e.value||0,imaginary:0},r=Pe(t,i);return be(r)}else{let t=Math.pow(c.value,e.value);return isNaN(t)?I():{type:3,value:t}}})},Mod:{fn:Ne((c,e)=>e?q(c%e):We())},Sort:{arguments:[{name:"values"}],fn:(...c)=>(c=O(c),c.every(e=>typeof e=="number")?c.sort((e,t)=>e-t):c.sort(),{type:8,value:[c.map(e=>q(e))]})},Transpose:{description:"Returns transpose of input matrix",arguments:[{name:"matrix",boxed:!0}],fn:c=>c.type===8?{type:8,value:qt(c.value)}:c},Max:{fn:(...c)=>({type:3,value:Math.max.apply(0,O(c).filter(e=>typeof e=="number"))})},Min:{fn:(...c)=>({type:3,value:Math.min.apply(0,O(c).filter(e=>typeof e=="number"))})},SumProduct:{description:"Returns the sum of pairwise products of two or more ranges",fn:(...c)=>{let e=c.map(r=>O(r)),t=Math.max.apply(0,e.map(r=>r.length)),i=0;for(let r=0;r<t;r++)i+=e.reduce((s,n)=>s*(n[r]||0),1);return{type:3,value:i}}},VLookup:{fn:(c,e,t,i=!0)=>{if(t=Math.max(0,t-1),i){let r=Math.abs(c-e[0][0]),s=e[t][0];for(let n=1;n<e[0].length;n++){let o=Math.abs(e[0][n]-c);o<r&&(r=o,s=e[t][n])}return q(s)}else{for(let r=1;r<e[0].length;r++)if(e[0][r]==c)return e[t][r];return Re()}}},Product:{arguments:[{boxed:!0}],fn:(...c)=>{let e={real:1,imaginary:0};c=De(c);for(let t of c)t.type===7?e=ue(e,t.value):t.type===3&&(e.real*=t.value,e.imaginary*=t.value);return be(e)}},Log:{fn:Ne((c,e=10)=>({type:3,value:Math.log(c)/Math.log(e)}))},Log10:{fn:G(c=>({type:3,value:Math.log(c)/Math.log(10)}))},Ln:{fn:G(c=>({type:3,value:Math.log(c)}))},Round:{fn:Ne((c,e=0)=>{let t=Math.pow(10,e);return{type:3,value:Math.round(t*c)/t}})},RoundDown:{fn:Ne((c,e=0)=>{let t=Math.pow(10,e),i=c>=0;return{type:3,value:i?Math.floor(t*c)/t:Math.ceil(t*c)/t}})},Reverse:{arguments:[{boxed:!0}],fn:c=>c.type===8?(c.value.length===1?c.value[0].reverse():c.value.reverse(),c):{type:2,value:c.value.toString().split("").reverse().join("")}},Exp:{arguments:[{boxed:!0}],fn:G(c=>{if(c.type===7){let e=Ni(c.value);return be(e)}return{type:3,value:Math.exp(c.value||0)}})},Abs:{arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:3,value:Math.sqrt(c.value.real*c.value.real+c.value.imaginary*c.value.imaginary)}:{type:3,value:Math.abs(c.value||0)})},Simplify:{arguments:[{name:"value"},{name:"significant digits"}],fn:Ne((c,e=2)=>{if(e=e||2,c===0)return{type:3,value:c};let t=c<0?-1:1;c*=t;let i=Math.pow(10,Math.floor(Math.log10(c))+1-e);return{type:3,value:Math.round(c/i)*i*t}})},Erf:{fn:c=>({type:3,value:$r(c)})},NormsInv:{description:"Inverse of the normal cumulative distribution",arguments:[{name:"probability"}],fn:c=>({type:3,value:Br(c)})},"Norm.Inv":{description:"Inverse of the normal cumulative distribution",arguments:[{name:"probability"},{name:"mean",default:0},{name:"standard deviation",default:1}],xlfn:!0,fn:(c,e=0,t=1)=>({type:3,value:Br(c)*t+e})},"Norm.Dist":{description:"Cumulative normal distribution",arguments:[{name:"value"},{name:"mean",default:0},{name:"standard deviation",default:1},{name:"cumulative",default:!0}],xlfn:!0,fn:(c,e=0,t=1,i=!0)=>{let r=0;if(i){let s=c<e?-1:1;r=.5*(1+s*$r(Math.abs(c-e)/(t*Math.sqrt(2))))}else r=Math.exp(-1/2*Math.pow((c-e)/t,2))/(t*bn);return{type:3,value:r}}},Sqrt:{description:"Returns the square root of the argument",arguments:[{boxed:!0}],fn:G(c=>{if(c.type===7){let e=Pe(c.value,{real:.5,imaginary:0});return be(e)}else{if(c.type===0||!c.value)return{type:3,value:0};{let e=Math.sqrt(c.value);return isNaN(e)?I():{type:3,value:e}}}})},HexToDec:{arguments:[{description:"hexadecimal string"}],fn:c=>({type:3,value:parseInt(c,16)})},DecToHex:{arguments:[{description:"number"}],fn:c=>({type:2,value:c.toString(16)})},Checkbox:{arguments:[{name:"checked"}],click:Gr,render:Hr,fn:c=>({value:!!c,type:4})},"Sparkline.Column":{arguments:[{name:"data"},{name:"color"},{name:"negative color"}],render:c=>(Ke.RenderColumn(c.width,c.height,c.context,c.cell,c.style),{handled:!0}),fn:(...c)=>({type:5,value:c,key:"sparkline-data"})},"Sparkline.Line":{arguments:[{name:"data"},{name:"color"},{name:"line width"}],render:c=>(Ke.RenderLine(c.width,c.height,c.context,c.cell,c.style),{handled:!0}),fn:(...c)=>({type:5,value:c,key:"sparkline-data"})}},jr={};for(let c of Object.keys(mt))jr[c.toLowerCase()]=c;var yn=["pow"],Jr={};for(let c of yn)Jr[c.toLowerCase()]=c;for(let c of Object.getOwnPropertyNames(Math)){let e=c.toLowerCase();if(jr[e]||Jr[e])continue;let t=Object.getOwnPropertyDescriptor(Math,c);if(!t)continue;let i=t.value,r=typeof i;switch(r){case"number":mt[c]={fn:()=>({type:3,value:i}),category:["Math Functions"]};break;case"function":mt[c]={fn:(...s)=>q(i(...s)),category:["Math Functions"]};break;default:console.info("unexpected type:",r,c);break}}Math.log10||(Math.log10=c=>Math.log(c)/Math.log(10));var _t=(c,e,t=0,i=0,r=0)=>r?-(t*(c/(1-Math.pow(1+c,-e))))/(1+c)-i*(1/((1+c)*((Math.pow(1+c,e)-1)/c))):-(t*c*Math.pow(1+c,e)+i*c)/(Math.pow(1+c,e)-1),qr=(c,e,t,i=0,r=0)=>r?(1+c)*-t/c*(Math.pow(1+c,e)-1)-i*Math.pow(1+c,e):-t/c*(Math.pow(1+c,e)-1)-i*Math.pow(1+c,e),$i=(c,e,t,i=0,r=0,s=0)=>{if(e<1)return NaN;if(e===1&&s)return 0;let n=_t(c,t,i,r,s),o=qr(c,e-1,n,i,s)*c;return s?o/(1+c):o},Wr=(c,e,t,i=0,r=0,s=0)=>_t(c,t,i,r,s)-$i(c,e,t,i,r,s),Xr={NPV:{description:"Returns the present value of a series of future cashflows",arguments:[{name:"Rate"},{name:"Cashflow"}],fn:(c=0,...e)=>{let t=0,i=O(e);for(let r=0;r<i.length;r++){let s=i[r];typeof s=="number"&&(t+=Math.pow(1+c,-(r+1))*s)}return{type:3,value:t}}},IRR:{description:"Calculates the internal rate of return of a series of cashflows",arguments:[{name:"Cashflows"},{name:"Guess",default:.1}],fn:(c,e=.1)=>{let t=O(c).map(s=>typeof s=="number"?s:0),i=.1,r=[{found:!1,value:0},{found:!1,value:0}];for(let s=0;s<50;s++){let n=0;for(let o=0;o<t.length;o++)n+=Math.pow(1+e,-(o+1))*t[o];if(Math.abs(n)<=.00125)return{type:3,value:e};if(n>0){if(r[0].value=r[0].found?Math.max(r[0].value,e):e,r[0].found=!0,!r[1].found){e+=i;continue}}else if(r[1].value=r[1].found?Math.min(r[1].value,e):e,r[1].found=!0,!r[0].found){e-=i;continue}e=r[0].value+(r[1].value-r[0].value)/2}return{type:6,value:"NUM"}}},CUMPRINC:{description:"Returns cumulative principal paid on a loan between two periods",arguments:[{name:"Rate"},{name:"Periods"},{name:"Present Value"},{name:"Start Period"},{name:"End Period"},{name:"Type",default:0}],fn:(c,e,t,i,r,s=0)=>{let n=0;for(let o=i;o<=r;o++)n+=Wr(c,o,e,t,0,s);return{type:3,value:n}}},CUMIPMT:{description:"Returns cumulative interest paid on a loan between two periods",arguments:[{name:"Rate"},{name:"Periods"},{name:"Present Value"},{name:"Start Period"},{name:"End Period"},{name:"Type",default:0}],fn:(c,e,t,i,r,s=0)=>{let n=0;for(let o=i;o<=r;o++)n+=$i(c,o,e,t,0,s);return{type:3,value:n}}},IPMT:{description:"Returns the interest portion of a payment",arguments:[{name:"Rate"},{name:"Period"},{name:"Periods"},{name:"Present Value",default:0},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0,s=0)=>({type:3,value:$i(c,e,t,i,r,s)})},PPMT:{description:"Returns the principal portion of a payment",arguments:[{name:"Rate"},{name:"Period"},{name:"Periods"},{name:"Present Value",default:0},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0,s=0)=>({type:3,value:Wr(c,e,t,i,r,s)})},Rate:{description:"Returns the interest rate of a loan",arguments:[{name:"Periods"},{name:"Payment"},{name:"Present Value",default:0},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t=0,i=0,r=0)=>{let s=.25,n=[-1,1],o=32,a=1e-6;for(let l=0;l<o;l++){let d=_t(s,c,t,i,r);if(Math.abs(d-e)<=a)return{type:3,value:s};let u=_t(n[1],c,t,i,r);e>=d&&e<=u||e>=u&&e<=d?n[0]=s:n[1]=s,s=n[0]+(n[1]-n[0])/2}return{type:3,value:s}}},FV:{description:"Returns the future value of an investment",arguments:[{name:"Rate"},{name:"Periods"},{name:"Payment"},{name:"Present Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0)=>({type:3,value:qr(c,e,t,i,r)})},PV:{description:"Returns the present value of an investment",arguments:[{name:"Rate"},{name:"Periods"},{name:"Payment"},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0)=>r?(t+=i*(1/((1+c)*((Math.pow(1+c,e)-1)/c))),{type:3,value:-(t+t/c*(1-Math.pow(1+c,-(e-1))))}):{type:3,value:-(i+t/c*(Math.pow(1+c,e)-1))/Math.pow(1+c,e)}},NPER:{description:"Returns the number of periods of an investment",arguments:[{name:"Rate"},{name:"Payment"},{name:"Present Value"},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t=0,i=0,r=0)=>r?{type:3,value:1+(-Math.log(1+c*(1-t/-e))+Math.log(1+i*c/(-e*(1+c))))/Math.log(1+c)}:{type:3,value:(Math.log(Math.pow(1-t*c/-e,-1))+Math.log(1+i*c/-e))/Math.log(1+c)}},PMT:{description:"Returns the periodic payment of a loan",arguments:[{name:"Rate"},{name:"Periods"},{name:"Present Value"},{name:"Future Value",default:0},{name:"Type",default:0}],fn:(c,e,t,i=0,r=0)=>({type:3,value:_t(c,e,t,i,r)})}};var gn=c=>{let e=[],t=c.length,i="[\\^$.|?*+()";for(let r=0;r<t;r++){let s=c[r];switch(s){case"*":e.push(".","*");break;case"?":e.push(".");break;case"~":s=c[++r]||"";default:for(let n=0;n<i.length;n++)if(s===i[n]){e.push("\\");break}e.push(s);break}}return e.join("")},Kr={Char:{arguments:[{name:"number"}],fn:c=>({type:2,value:String.fromCodePoint(c||32)}),category:["text"]},Code:{arguments:[{name:"string"}],fn:c=>({type:3,value:c.codePointAt(0)||0}),category:["text"]},Value:{arguments:[{name:"text"}],fn:c=>{let e=ye.TryParse(c);return e.type===3?{type:3,value:e.value}:K()},category:["text"]},Text:{arguments:[{name:"value"},{name:"number format"}],fn:(c,e="0.00####")=>({type:2,value:L.Get(e).Format(c||0)}),category:["text"]},Left:{arguments:[{name:"string"},{name:"count"}],fn:(c,e=1)=>({type:2,value:c.substr(0,e)}),category:["text"]},Right:{arguments:[{name:"string"},{name:"count"}],fn:(c,e=1)=>({type:2,value:c.slice(-e)}),category:["text"]},Mid:{arguments:[{name:"string"},{name:"left"},{name:"count"}],fn:(c,e=0,t=1)=>({type:2,value:c.substr(Math.max(0,e-1),t)}),category:["text"]},Search:{description:"Find a string (needle) in another string (haystack). Case-insensitive.",arguments:[{name:"Needle"},{name:"Haystack"},{name:"Start",default:1}],fn:(c,e,t=1)=>{if(t>=1){if(!c)return{type:3,value:t};let i=gn(c),r=new RegExp(i,"i").exec(e.substr(t-1));if(r)return{type:3,value:r.index+t}}return I()}},Find:{description:"Find a string (needle) in another string (haystack). Case-sensitive.",arguments:[{name:"Needle"},{name:"Haystack"},{name:"Start",default:1}],fn:(c,e,t=1)=>{if(t>=1){if(!c)return{type:3,value:t};let i=new RegExp(c).exec(e.substr(t-1));if(i)return{type:3,value:i.index+t}}return I()}},Concat:{description:"Pastes strings together",fn:(...c)=>{let t=O(c).map(i=>{let r=i?.toString()||"";return typeof i=="number"&&T.decimal_separator===","?r.replace(/\./,","):r}).join("");return{type:2,value:t}}}},Bi={Concatenate:"Concat"};var Yr={IsBlank:{description:"Returns true if the reference is blank",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:!c?.value||typeof c.value.value>"u"}))},IsNumber:{description:"Returns true if the reference is a number",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&typeof c.value.value=="number"}))},IsLogical:{description:"Returns true if the reference is a logical TRUE or FALSE",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&typeof c.value.value=="boolean"}))},IsText:{description:"Returns true if the reference is text",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&typeof c.value.value=="string"}))}};var Kt=(c,e=!1)=>{let t=c.length,i=0,r=0;for(let s=0;s<t;s++)i+=c[s];i/=t;for(let s=0;s<t;s++){let n=c[s]-i;r+=n*n}return e?r/(t-1):r/t},Zr={StDev:{description:"Returns the standard deviation of a set of values, corresponding to a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Math.sqrt(Kt(O(c),!1))})},"StDev.S":{description:"Returns the standard deviation of a set of values, corresponding to a sample of a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Math.sqrt(Kt(O(c),!0))})},Var:{description:"Returns the variance of a set of values, corresponding to a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Kt(O(c),!1)})},"Var.S":{description:"Returns the variance of a set of values, corresponding to a sample of a population",arguments:[{name:"data"}],fn:(...c)=>({type:3,value:Kt(O(c),!0)})},Covar:{description:"Returns the covariance between two ranges of values",arguments:[{name:"A"},{name:"B"}],fn:(c,e)=>{if(!Array.isArray(c)||!Array.isArray(e))return I();if(!Array.isArray(c[0])||!Array.isArray(e[0]))return I();if(c.length!==e.length)return K();let t=0,i=0,r={x:0,y:0},s={x:[],y:[]};for(let n=0;n<c.length;n++){if(!c[n]||!e[n])continue;if(c[n].length!==e[n].length)return K();let o=c[n].length;i+=o;for(let a=0;a<o;a++)r.x+=c[n][a],r.y+=e[n][a],s.x.push(c[n][a]),s.y.push(e[n][a])}if(i===0)return Re();r.x/=i,r.y/=i;for(let n=0;n<i;n++)t+=(s.x[n]-r.x)*(s.y[n]-r.y);return{type:3,value:t/i}}},Correl:{description:"Returns the correlation between two ranges of values",arguments:[{name:"A"},{name:"B"}],fn:(c,e)=>{if(!Array.isArray(c)||!Array.isArray(e))return I();if(!Array.isArray(c[0])||!Array.isArray(e[0]))return I();let t=0,i=0,r=0,s=0,n=0,o=0,a=0;for(let l=0;l<c.length;l++){if(!c[l]||!e[l])continue;let d=c[l].length;for(let u=0;u<d;u++){let h=Number(c[l][u]),p=Number(e[l][u]);isNaN(h)||isNaN(p)||(i+=h*p,r+=h,s+=p,n+=h*h,o+=p*p,a++)}}return t=a*i-r*s,t&&(t/=Math.sqrt((a*n-r*r)*(a*o-s*s))),{type:3,value:t}}},GeoMean:{description:"Returns the geometric mean of all numeric arguments",arguments:[{boxed:!0}],fn:(...c)=>{c=De(c);let e=0,t={real:1,imaginary:0},i=!1,r=!1;for(let s of c)s.type===7?(i=!0,t=ue(t,s.value),e++):s.type===3&&(s.value<0&&(r=!0),e++,t.real*=s.value,t.imaginary*=s.value);if(i){let s=Pe(t,{real:1/e,imaginary:0});return s.imaginary?{type:7,value:s}:{type:3,value:s.real}}else return r?I():{type:3,value:Math.pow(t.real,1/e)}}},Average:{description:"Returns the arithmetic mean of all numeric arguments",arguments:[{boxed:!0}],fn:(...c)=>{c=De(c);let e={real:0,imaginary:0},t=0;for(let i of c){if(i.type===6)return i;i.type===3&&(e.real+=i.value,t++),i.type===7&&(e.real+=i.value.real,e.imaginary+=i.value.imaginary,t++)}return e.real/=t,e.imaginary/=t,e.imaginary?{type:7,value:e}:{type:3,value:e.real}}},Percentile:{description:"Returns the kth percentile value from the range of data",arguments:[{name:"range"},{name:"percentile"}],fn:(c,e)=>{let t=O(c).filter(a=>typeof a=="number");t.sort((a,l)=>a-l);let i=t.length,r=Math.pow(10,8),s=Math.round((1+(i-1)*e)*r)/r,n=Math.floor(s),o=Math.ceil(s);return{type:3,value:(t[n-1]+t[o-1])/2}}},Median:{description:"Returns the median value of the range of data",arguments:[{name:"range"}],fn:(...c)=>{let e=O(c).filter(n=>typeof n=="number");e.sort((n,o)=>n-o);let t=e.length,i=1+(t-1)*.5,r=Math.floor(i),s=Math.ceil(i);return{type:3,value:(e[r-1]+e[s-1])/2}}}},ji={Mean:"Average","StDev.P":"StDev","Var.P":"Var"};var Qr={IsComplex:{description:"Returns true if the reference is a complex number",arguments:[{name:"Reference",metadata:!0}],fn:G(c=>({type:4,value:c?.value&&ge(c.value.value)}))},Real:{description:"Returns the real part of a complex number",arguments:[{boxed:!0}],fn:G(c=>c.type===3?{...c}:c.type===7?{type:3,value:c.value.real||0}:c.type===0||c.type===2&&c.value===""?{type:3,value:0}:I())},Imaginary:{description:"Returns the imaginary part of a complex number (as real)",arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:3,value:c.value.imaginary||0}:c.type===3||c.type===0||c.type===2&&c.value===""?{type:3,value:0}:I())},Conjugate:{description:"Returns the conjugate of a complex number",arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:7,value:{real:c.value.real,imaginary:-c.value.imaginary}}:c.type===3||c.type===0||!c.value?{type:3,value:c.value||0}:I())},Arg:{description:"Returns the principal argument of a complex number (in radians)",arguments:[{boxed:!0}],fn:G(c=>c.type===7?{type:3,value:Math.atan2(c.value.imaginary,c.value.real)}:c.type===3||c.type===0||c.type===2&&c.value===""?{type:3,value:Math.atan2(0,c.value||0)}:I())},Rectangular:{description:"Converts a complex number in polar form to rectangular form",arguments:[{name:"r"},{name:"\u03B8 in radians"}],fn:(c=0,e=0)=>({type:7,value:{real:c*Math.cos(e),imaginary:c*Math.sin(e)}})},Complex:{description:"Ensures that the given value will be treated as a complex number",arguments:[{boxed:!0}],fn:G(c=>c.type===7?c:c.type===3||c.type===0||!c.value?{type:7,value:{imaginary:0,real:c.value||0}}:I())},ComplexLog:{description:"Returns the principal value Log(z) of a complex number z",arguments:[{boxed:!0}],fn:G(c=>{if(c.type===3){if(!c.value)return I();c={type:7,value:{real:c.value,imaginary:0}}}else if(c.type===0||c.type===2&&c.value==="")return I();if(c.type===7){let e=Bt(c.value),t={real:Math.log(e.r),imaginary:e.theta};return t.imaginary?{type:7,value:t}:{type:3,value:t.real}}return I()})}};var Yt=c=>{let e=[];c.type===8?e=c.value:e=[[c.value]];let t=e.length,i=t?e[0].length:0,r=[];if(!t||!i)return{m:t,n:i,array:r};for(let s=0;s<t;s++){let n=[];for(let o=0;o<i;o++){let a=e[s][o];if(a.type===7)n.push({...a.value});else if(a.type===3)n.push({real:a.value,imaginary:0});else if(a.type===0||a.value==="")n.push({real:0,imaginary:0});else return{m:t,n:i,error:!0,array:[]}}r.push(n)}return{m:t,n:i,array:r}},es={MDeterm:{description:"Returns the determinant of a matrix",arguments:[{name:"matrix",boxed:!0}],fn:c=>{let e=Yt(c);if(!e.array||!e.m||!e.n||e.m!==e.n||e.error)return I();let t=jt(e);return t?be(t):I()}},MInverse:{description:"Returns the inverse matrix",arguments:[{name:"matrix",boxed:!0}],fn:c=>{let e=Yt(c);if(!e.array||!e.m||!e.n||e.m!==e.n||e.error)return I();let t=jt(e);if(t&&t.real===0&&t?.imaginary===0)return I();let i=Vr(e);return i?{type:8,value:i.map(r=>r.map(s=>be(s)))}:I()}},MMult:{description:"Returns the dot product of A and B",arguments:[{name:"A",boxed:!0},{name:"B",boxed:!0}],fn:(c,e)=>{let t=Yt(c),i=Yt(e);if(!t.array||t.error||!i.array||i.error)return I();if(t.m!==i.n)return I();let r=Lr(i,t);return{type:8,value:r.map(s=>s.map(n=>be(n)))}}}};var Ji=class extends Me{state_id=0;type=Ji.type;color=2;state_representation="";UpdateState(){let e=JSON.stringify(Array.from(this.edges_in).map(t=>t.result));e!==this.state_representation&&(this.state_representation=e,this.state_id++)}Calculate(e){if(!!this.dirty){for(let t of this.edges_in)if(t.dirty)return;this.UpdateState(),this.dirty=!1}}AddDependent(e){throw new Error("leaf vertex cannot have dependents")}},Ye=Ji;E(Ye,"type","leaf-vertex");var Zt=class extends Ht{constructor(t){super();this.model=t;this.UpdateLocale(),this.library.Register(mt,Kr,Zr,Xr,Yr,Qr,es);for(let i of Object.keys(ji))this.library.Alias(i,ji[i]);for(let i of Object.keys(Bi))this.library.Alias(i,Bi[i]);this.library.Register({CountIf:{arguments:[{name:"range"},{name:"criteria"}],fn:(i,r)=>{let s=O(i);typeof r!="string"?r="="+(r||0).toString():(r=r.trim(),/^[=<>]/.test(r)||(r="="+r));let n=this.parser.Parse("{}"+r),o=n.expression;if(n.error||!o)return Ee();if(o.type!=="binary")return Ee();if(o.left.type!=="array")return Ee();o.left.values=[s];let a=this.CalculateExpression(o);if(a.type===8){let l=0;for(let d of a.value)for(let u of d)u.value&&l++;return{type:3,value:l}}return a}},Offset:{arguments:[{name:"reference",description:"Base reference",metadata:!0},{name:"rows",description:"number of rows to offset"},{name:"columns",description:"number of columns to offset"}],return_type:1,volatile:!0,fn:((i,r=0,s=0,n=1,o=1)=>{if(!i)return K();if(!Wt(i))return Y();let a=this.DynamicDependencies(i.value.address,this.expression_calculator.context.address,!0,r,s,o,n);if(!a)return Y();if(a.dirty){let l=this.GetVertex(this.expression_calculator.context.address,!0);return l.short_circuit=!0,{type:0,value:void 0}}if(a.area){let l={type:"address",...a.area.start,label:"",position:0,id:0},d={type:"address",...a.area.end,label:"",position:0,id:0},u=a.area.count===1?l:{type:"range",start:l,end:d,label:"",position:0,id:0};return{type:5,value:u}}return I()}).bind(this)},Indirect:{arguments:[{name:"reference",description:"Cell reference (string)"}],return_type:1,volatile:!0,fn:(i=>{if(!i||typeof i!="string")return K();let r=this.parser.Parse(i);if(r.error||!r.expression||r.expression.type!=="address"&&r.expression.type!=="range")return Y();let s=this.DynamicDependencies(r.expression,this.expression_calculator.context.address);if(!s)return Y();if(s.dirty){let n=this.GetVertex(this.expression_calculator.context.address,!0);return n.short_circuit=!0,{type:0,value:void 0}}return{type:5,value:r.expression}}).bind(this)},Match:{arguments:[{name:"value",boxed:!0},{name:"range",boxed:!0},{name:"type"}],fn:(i,r,s=0)=>{if(s)return console.warn("inexact match not supported",{value:i,range:r,type:s}),Re();if(r.type===8){if(r.value.length===1){let n=r.value[0];for(let o=0;o<n.length;o++)if(i.type==n[o].type&&i.value===n[o].value)return{type:3,value:o+1}}else for(let n=0;n<r.value.length;n++){let o=r.value[n];if(o.length!==1)return Re();if(i.type==o[0].type&&i.value===o[0].value)return{type:3,value:n+1}}return Re()}else return i.type===r.type&&i.value===r.value?{type:3,value:1}:Re();return K()}},Index:{arguments:[{name:"range",boxed:!0},{name:"row"},{name:"column"}],volatile:!1,fn:(i,r,s)=>{if(i&&i.type!==8&&(i={type:8,value:[[i]]}),r&&s){let n=i.value[s-1];if(n){let o=n[r-1];if(o)return o}}else if(r){let n=[];for(let o of i.value){if(!o[r-1])return K();n.push([o[r-1]])}return{type:8,value:n}}else if(s){let n=i.value[s-1];if(n)return{type:8,value:[n]}}return K()}},Rows:{arguments:[{name:"reference",description:"Array or reference"}],volatile:!1,fn:i=>{if(!i)return K();if(Array.isArray(i)){let r=i[0];return Array.isArray(r)?{type:3,value:r.length}:I()}return{type:3,value:1}}},Columns:{arguments:[{name:"reference",description:"Array or reference"}],volatile:!1,fn:i=>i?Array.isArray(i)?{type:3,value:i.length}:{type:3,value:1}:K()},IsFormula:{description:"Returns true if the reference is a formula",arguments:[{name:"Reference",metadata:!0}],fn:G(i=>{let r=this.model.sheets.Find(i?.value?.address?.sheet_id||0);if(r){let s=r.cells.GetCell(i.value.address,!1);return{type:4,value:s?.type===1}}return{type:4,value:!1}})}})}parser=new $e;library=new Xt;registered_libraries={};expression_calculator=new Jt(this.library,this.parser);full_rebuild_required=!1;ExportCalculatedValues(){let t={};for(let i of this.model.sheets.list){let r=i.cells.toJSON({calculated_value:!0}).data;t[i.id]=r.filter(s=>s.calculated!==void 0)}return t}ApplyCalculatedValues(t){for(let i of this.model.sheets.list){let r=t[i.id];if(!r)console.info("mismatch",i.id);else for(let s of r)i.cells.data[s.row][s.column].SetCalculatedValue(s.calculated)}}SpreadCallback(t,i){if(!t.address||!t.address.sheet_id)throw new Error("spread callback called without sheet id");let r=this.model.sheets.Find(t.address.sheet_id)?.cells;if(!r)throw new Error("spread callback called without cells");if(!t||!t.reference)return;let s=t.reference.area;if(s){let n=s.rows,o=s.columns;if(i.type===8){let a=qt(i.value);for(let l=0;l<n;l++)if(a[l]){let d=0;for(;d<o&&d<a[l].length;d++)r.data[l+s.start.row][d+s.start.column].SetCalculatedValue(a[l][d].value,a[l][d].type);for(;d<o;d++)r.data[l+s.start.row][d+s.start.column].SetCalculatedValue(void 0,0)}else for(let d=0;d<o;d++)r.data[l+s.start.row][d+s.start.column].SetCalculatedValue(void 0,0)}else for(let a=0;a<n;a++)for(let l=0;l<o;l++)r.data[a+s.start.row][l+s.start.column].SetCalculatedValue(i.value,i.type)}}CalculationCallback(t){if(!t.address)throw new Error("vertex missing address");return t.expression_error?{value:$t()}:this.expression_calculator.Calculate(t.expression,t.address)}DynamicDependencies(t,i,r=!1,s=0,n=0,o=1,a=1){let l=this.ResolveExpressionAddress(t,i);if(!l)return;let d=!1,u;if(t.type==="address"||t.type==="range"){let p=t.type==="range"?t.start:t;p.sheet_id?u=this.model.sheets.Find(p.sheet_id):p.sheet&&(u=this.model.sheets.Find(p.sheet))}if(!u&&i?.sheet_id&&(u=this.model.sheets.Find(i.sheet_id)),!u)throw new Error("missing sheet in dynamic dependencies [b21]");l=u.RealArea(l);let h=l.start.sheet_id;r&&(l=new g({column:l.start.column+n,row:l.start.row+s,sheet_id:l.start.sheet_id},{column:l.start.column+n+o-1,row:l.start.row+s+a-1,sheet_id:l.end.sheet_id}));for(let p=l.start.row;p<=l.end.row;p++)for(let f=l.start.column;f<=l.end.column;f++){let m=this.GetVertex({row:p,column:f,sheet_id:h},!1);m&&m.dirty&&(this.AddEdge({row:p,column:f,sheet_id:h},this.expression_calculator.context.address),d=!0)}return{dirty:d,area:l}}UpdateLocale(){T.decimal_separator===","?(this.parser.decimal_mark=",",this.parser.argument_separator=";"):(this.parser.decimal_mark=".",this.parser.argument_separator=",")}SupportedFunctions(){let t=this.library.List(),i=Object.keys(t).map(r=>{let s=t[r].canonical_name;return s||(s=r.replace(/_/g,".")),{name:s,description:t[r].description,arguments:(t[r].arguments||[]).map(n=>({name:n.name||""}))}});for(let r of this.model.macro_functions.values())i.push({name:r.name,description:r.description,arguments:(r.argument_names||[]).map(s=>({name:s}))});return i}RegisterLibrary(t,i){return this.registered_libraries[t]?!1:(this.RegisterFunction(i),this.registered_libraries[t]=!0,!0)}RegisterFunction(t){for(let i of Object.keys(t)){let r=t[i],s=r.fn;r.fn=(...n)=>s.apply({address:{...this.expression_calculator.context.address}},n),this.library.Register({[i]:r})}}AttachModel(){this.expression_calculator.SetModel(this.model)}Calculate(t){if(this.AttachModel(),t&&!t.start.sheet_id)throw new Error("CalculateInternal called with subset w/out sheet ID");this.full_rebuild_required&&(t=void 0,this.UpdateAnnotations(),this.full_rebuild_required=!1),this.RebuildGraph(t);try{this.Recalculate()}catch(i){console.error(i),console.info("calculation error trapped")}}Reset(){this.FlushTree(),this.AttachModel(),this.full_rebuild_required=!0}DecoratedFunctionList(){let t={},i=this.library.List();for(let r of Object.keys(i)){let s=i[r];s.xlfn?t[r]="_xlfn":s.extension&&(t[r]="_xll")}return t}ResolveArea(t,i){let r=this.ResolveAddress(t,i);return P(r)?new g(r):new g(r.start,r.end)}ResolveAddress(t,i){if(typeof t=="string"){let r=this.parser.Parse(t);if(r.expression&&r.expression.type==="address")return this.ResolveSheetID(r.expression,void 0,i),{row:r.expression.row,column:r.expression.column,sheet_id:r.expression.sheet_id};if(r.expression&&r.expression.type==="range")return this.ResolveSheetID(r.expression,void 0,i),{start:{row:r.expression.start.row,column:r.expression.start.column,sheet_id:r.expression.start.sheet_id},end:{row:r.expression.end.row,column:r.expression.end.column}};if(r.expression&&r.expression.type==="identifier"){let s=this.model.named_ranges.Get(r.expression.name);if(s)return s}return{row:0,column:0}}return t}Evaluate(t,i){let r=this.parser.Parse(t);if(r&&r.expression){this.parser.Walk(r.expression,n=>((n.type==="address"||n.type==="range")&&this.ResolveSheetID(n,void 0,i),!0));let s=this.CalculateExpression(r.expression);return s.type===8?s.value.map(n=>n.map(o=>o.value)):s.value}throw r.error?new Error(r.error):new Error("invalid expression")}CalculateExpression(t,i={row:-1,column:-1},r=!1){return this.expression_calculator.Calculate(t,i,r).value}RebuildClean(t=!1){this.full_rebuild_required=!1,this.AttachModel(),this.RebuildGraph(),this.UpdateAnnotations(),this.InitializeGraph(),t&&this.volatile_list.length&&this.Recalculate()}FlattenCellList(t){let i={},r=[];for(let s of t){let n={column:s.column,row:s.row,sheet_id:s.sheet_id},o=g.CellAddressToLabel(n,!0);i[o]||(i[o]=o,r.push(n))}return r}RemoveAnnotation(t){let i=t.temp.vertex;!i||(i.Reset(),this.RemoveLeafVertex(i))}UpdateAnnotations(t,i){if(!t){for(let r of this.model.sheets.list)this.UpdateAnnotations(r.annotations,r);return}if(!i)throw new Error("invalid call to UpdateAnnotations with list but no sheet");typeof t<"u"&&!Array.isArray(t)&&(t=[t]);for(let r of t)if(r.formula){r.temp.vertex||(r.temp.vertex=new Ye);let s=r.temp.vertex;this.AddLeafVertex(s),this.UpdateLeafVertex(s,r.formula,i)}}ResolveSheetID(t,i,r){let s=t.type==="address"?t:t.start;if(s.sheet_id)return!0;if(s.sheet){let n=this.model.sheets.Find(s.sheet);if(n)return s.sheet_id=n.id,!0}else{if(i?.sheet_id)return s.sheet_id=i.sheet_id,!0;if(r?.id)return s.sheet_id=r.id,!0}return!1}ResolveExpressionAddress(t,i){switch(t.type){case"address":if(this.ResolveSheetID(t,i))return new g(t);break;case"range":if(this.ResolveSheetID(t,i))return new g(t.start,t.end);break;case"identifier":{let r=this.model.named_ranges.Get(t.name.toUpperCase());if(r)return new g(r.start,r.end)}break}}NamedRangeToAddressUnit(t){let i=t.name.toUpperCase(),r=this.model.named_ranges.Get(i);if(r)return r.count===1?this.ConstructAddressUnit(r.start,i,t.id,t.position):{type:"range",start:this.ConstructAddressUnit(r.start,i,t.id,t.position),end:this.ConstructAddressUnit(r.end,i,t.id,t.position),label:i,id:t.id,position:t.position}}ConstructAddressUnit(t,i,r,s){return{type:"address",row:t.row,column:t.column,sheet_id:t.sheet_id,label:i,id:r,position:s}}RebuildDependencies(t,i,r,s={addresses:{},ranges:{}}){if(!r){let n=this.model.sheets.Find(i);n&&(r=n.name)}switch(t.type){case"literal":case"missing":case"operator":break;case"identifier":{let n=t.name.toUpperCase();if(this.model.named_expressions.has(n)){let o=this.model.named_expressions.get(n);o&&this.RebuildDependencies(o,i,r,s)}else{let o=this.NamedRangeToAddressUnit(t);o&&(o.type==="address"?s.addresses[o.label]=o:s.ranges[o.label]=o)}}break;case"address":if(!t.sheet_id)if(t.sheet){let n=this.model.sheets.Find(t.sheet);n&&(t.sheet_id=n.id)}else t.sheet_id=i,t.sheet=r;t.sheet_id?s.addresses[t.sheet_id+"!"+t.label]=t:console.warn("invalid address in range [9d]");break;case"range":if(!t.start.sheet_id)if(t.start.sheet){let n=this.model.sheets.Find(t.start.sheet);n&&(t.start.sheet_id=n.id)}else t.start.sheet_id=i,t.start.sheet=r;t.start.sheet_id?s.ranges[t.start.sheet_id+"!"+t.start.label+":"+t.end.label]=t:console.warn("invalid sheet in range",t);break;case"unary":this.RebuildDependencies(t.operand,i,r,s);break;case"binary":this.RebuildDependencies(t.left,i,r,s),this.RebuildDependencies(t.right,i,r,s);break;case"group":t.elements.forEach(n=>this.RebuildDependencies(n,i,r,s));break;case"call":{let n=t.args.slice(0),o=this.library.Get(t.name);o&&o.arguments&&o.arguments.forEach((a,l)=>{a&&a.address&&(this.RebuildDependencies(n[l],i,r,void 0),n[l]={type:"missing",id:-1})}),n.forEach(a=>this.RebuildDependencies(a,i,r,s))}break}return s}UpdateLeafVertex(t,i,r){t.Reset();let s=this.parser.Parse(i);if(s.expression){let n=this.RebuildDependencies(s.expression,r.id,r.name);for(let o of Object.keys(n.ranges)){let a=n.ranges[o];new g(a.start,a.end).Iterate(d=>{this.AddLeafVertexEdge(d,t)})}for(let o of Object.keys(n.addresses)){let a=n.addresses[o];this.AddLeafVertexEdge(a,t)}}t.expression=s.expression||{type:"missing",id:-1},t.expression_error=!s.valid}RebuildGraphCell(t,i){if(t.area&&t.area.start.column===i.column&&t.area.start.row===i.row){let{start:r,end:s}=t.area,n=r.sheet_id||i.sheet_id;r.sheet_id||(r.sheet_id=n);for(let o=r.column;o<=s.column;o++)for(let a=r.row;a<=s.row;a++)this.ResetInbound({column:o,row:a,sheet_id:n},!0,!1);this.SetDirty(i);for(let o=r.column;o<=s.column;o++)for(let a=r.row;a<=s.row;a++)a===r.row&&o===r.column||this.AddEdge(r,{...r,row:a,column:o})}if(t.type===1){this.ResetInbound(i,!0);let r=this.parser.Parse(t.value);if(r.expression){if(r.expression.type==="call"){let o=this.library.Get(r.expression.name);o&&(o.render||o.click)&&(t.render_function=o.render,t.click_function=o.click)}let n=this.RebuildDependencies(r.expression,i.sheet_id,"");for(let o of Object.keys(n.ranges)){let a=n.ranges[o],l=new g(a.start,a.end);l.entire_row||l.entire_column?this.AddArrayEdge(l,i):l.Iterate(d=>this.AddEdge(d,i))}for(let o of Object.keys(n.addresses)){let a=n.addresses[o];this.AddEdge(a,i)}}let s=this.GetVertex(i,!0);s&&(s.expression=r.expression||{type:"missing",id:-1},s.expression_error=!r.valid)}else t.value!==t.calculated?this.ResetInbound(i,!0,!1):t.type===0&&this.ResetInbound(i,!0,!1,!0)}RebuildGraph(t){if(t){if(!t.start.sheet_id)throw new Error("subset missing sheet id");let i=this.model.sheets.Find(t.start.sheet_id)?.cells;if(i)for(let r=t.start.row;r<=t.end.row;r++){let s=i.data[r];if(s)for(let n=t.start.column;n<=t.end.column;n++){let o=s[n];o&&this.RebuildGraphCell(o,{row:r,column:n,sheet_id:t.start.sheet_id})}}}else for(let i of this.model.sheets.list||[]){let r=i.cells.data.length;for(let s=0;s<r;s++){let n=i.cells.data[s];if(n){let o=n.length;for(let a=0;a<o;a++){let l=n[a];l&&this.RebuildGraphCell(l,{row:s,column:a,sheet_id:i.id})}}}}}IsNativeOrTypedArray(t){return Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array}CheckVolatile(t){if(!t.expression||t.expression_error)return!1;let i=!1;return this.parser.Walk(t.expression,r=>{if(r.type==="call"){let s=this.library.Get(r.name);s&&s.volatile&&(i=!0)}return!i}),i}};var Wi=class{constructor(e){this.parent_node=e;let t="treb-leaf-gradient-"+Wi.unique_id;if(!document.querySelector("#"+t)){let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("aria-hidden","true"),r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.overflow="hidden";let s=document.createElementNS("http://www.w3.org/2000/svg","linearGradient");s.setAttribute("id",t),s.setAttribute("gradientUnits","userSpaceOnUse"),s.setAttribute("x1","0.6729"),s.setAttribute("y1","32"),s.setAttribute("x2","63.3271"),s.setAttribute("y2","32");let n=document.createElementNS("http://www.w3.org/2000/svg","stop");n.setAttribute("offset","0"),n.style.stopColor="#D4D400",s.appendChild(n),n=document.createElementNS("http://www.w3.org/2000/svg","stop"),n.setAttribute("offset","1"),n.style.stopColor="#AD4500",s.appendChild(n),r.appendChild(s),document.body.appendChild(r)}this.model=Et`<div id='mask' class='treb-embed-mask'><div id='dialog' class='treb-embed-dialog'><div id='left'><a href='https://treb.app' target='_blank'><svg alt='TREB logo (a leaf)' width=48 height=48 viewBox='0 0 64 64'>${""}<path fill="URL(#${t})" d="M37.913,14.323c-2.042,0-7.067,2.558-8.72,3.481c-0.959-1.012-1.065-2.522-1.243-4.475c-0.959,0.994-0.337,4.014,0,5.115c-4.19,3.125-7.707,6.357-11.295,10.016c-1.225-1.936-2.06-3.517-2.344-7.033c-1.243,2.664,0.355,6.163,1.278,8.098c-3.96,4.991-7.885,10.354-11.064,15.486C-10.001,14.323,34.344-3.916,63.327,8.641C45.372,20.593,40.736,58.313,9.197,48.28c-2.22,3.196-3.712,7.37-5.541,11.081c-1.527,0.107-2.593-0.674-2.983-1.277c3.072-7.441,7.033-13.995,11.082-20.459c4.387,0.125,8.737,0.195,12.36-0.426c-3.144-0.834-6.908-0.319-10.655-1.278c2.291-4.387,5.63-7.726,8.95-11.082c3.605,0.32,7.264,1.314,11.082,0.426c-3.32-0.586-6.535-0.799-9.377-1.705C27.223,20.131,33.438,16.401,37.913,14.323z"/></svg></a></div><div id='middle'><div id='title' class='treb-embed-dialog-title'></div><div id='message' class='treb-embed-dialog-message'></div><div id='about' class='treb-embed-dialog-body'>TREB version ${"21.6.5"}${""}<div class='smaller'><a target=_blank href='https://treb.app'>http://treb.app</a></div></div></div><button type='button' title='Close dialog' id='close' class='close-box'><svg viewBox='0 0 16 16'><path d='M11.854 4.146a.5.5 0 0 1 0 .708l-7 7a.5.5 0 0 1-.708-.708l7-7a.5.5 0 0 1 .708 0z'/><path d='M4.146 4.146a.5.5 0 0 0 0 .708l7 7a.5.5 0 0 0 .708-.708l-7-7a.5.5 0 0 0-.708 0z'/></svg></button></div></div>`,this.model.close.addEventListener("click",r=>{r.stopPropagation(),r.preventDefault(),this.HideDialog()}),e.appendChild(this.model.mask)}model;visible_=!1;timeout;pending_dialog_resoltion=[];options_={type:"initial"};set options(e){if(e.type==="about"&&(e.close_box=!0,e.icon=!0),this.options_.icon!==e.icon&&(this.model.left.style.display=e.icon?"block":"none"),this.options_.close_box!==e.close_box&&(this.model.close.style.display=e.close_box?"block":"none"),this.options_.message!==e.message&&(this.model.message.textContent=e.message||"",this.model.message.style.display=e.message?"block":"none"),this.options_.title!==e.title&&(this.model.title.textContent=e.title||"",this.model.title.style.display=e.title?"block":"none"),this.options_.type!==e.type){let t=this.model.dialog.className.replace(/dialog-type-\S+/g,"").trim();e.type&&(t+=` dialog-type-${e.type}`),this.model.dialog.className=t,e.type==="about"?this.model.about.style.display="block":this.model.about.style.display="none"}this.options_=e}event_handler=e=>{(e.key==="Escape"||e.key==="Esc")&&(e.stopPropagation(),e.preventDefault(),this.visible=!1)};get visible(){return this.visible_}set visible(e){if(e!==this.visible_)if(this.visible_=e,e)this.parent_node.classList.add("masked"),this.model.mask.classList.add("visible"),window.addEventListener("keydown",this.event_handler);else{this.parent_node.classList.remove("masked"),this.model.mask.classList.remove("visible"),window.removeEventListener("keydown",this.event_handler);let t=this.pending_dialog_resoltion.slice(0);this.pending_dialog_resoltion=[],Promise.resolve().then(()=>{for(let i of t)i()})}}Div(e,t){let i=document.createElement("div");return e&&i.setAttribute("class",e),t&&t.appendChild(i),i}Update(e,t=!0){t&&(e={...this.options_,...e}),this.options=e}HideDialog(){this.visible=!1}ShowDialog(e){return new Promise(t=>{this.pending_dialog_resoltion.push(t),this.options=e,this.visible=!0,this.timeout&&(clearTimeout(this.timeout),this.timeout=0),e.timeout&&(this.timeout=setTimeout(()=>this.HideDialog(),e.timeout))})}},bt=Wi;E(bt,"unique_id",Math.random().toString(36).substring(2,15));var Qt=class{constructor(e){this.container=e;this.node=document.createElement("div"),this.node.classList.add("treb-spinner"),this.node.innerHTML="<div><div></div><div></div><div></div><div></div></div>",e.appendChild(this.node)}node;visible=!1;Show(){this.node.classList.add("visible")}Hide(){this.node.classList.remove("visible")}};var ei={formula_bar:!0,in_cell_editor:!0,undo:!0,scrollbars:!0,headers:!0,export:!0,popout:!1,tab_bar:"auto",resizable:!0,hyperlinks:"_blank",max_file_size:94208,dnd:!1,add_tab:!1,expand_formula_button:!1,delete_tab:!1,expand:!1,markdown:!1,spinner:!1};var ti=class extends Q{constructor(t,i,r){super();this.container=t;this.options=i;this.theme=r;this.outer_container=t.parentElement;let s=T.decimal_separator;for(let h of[0,128,192,212,256])this.colors.push(`rgb(${h}, ${h}, ${h})`);for(let h of["red","orange","yellow","green","blue","indigo","violet"])this.colors.push(h);this.model=Et`<div id='root' class='treb-toolbar'><div class='group narrow'><button id='text-align' data-command='align-left' title='Align left'><div class='treb-toolbar-icon treb-icon-text-align-left'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button id='align-left-drop' data-command='align-left' title='Align left', data-replace='text-align'><div class='treb-toolbar-icon treb-icon-text-align-left'/></button></li><li><button id='align-center-drop' data-command='align-center' title='Align center', data-replace='text-align'><div class='treb-toolbar-icon treb-icon-text-align-center'/></button></li><li><button id='align-right-drop' data-command='align-right' title='Align right', data-replace='text-align'><div class='treb-toolbar-icon treb-icon-text-align-right'/></button></li></ul></div></div><div class='group narrow'><button id='vertical-align' data-command='align-top' title='Align top'><div class='treb-toolbar-icon treb-icon-text-align-top'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button id='align-top-drop' data-command='align-top' title='Align top', data-replace='vertical-align'><div class='treb-toolbar-icon treb-icon-text-align-top'/></button></li><li><button id='align-middle-drop' data-command='align-middle' title='Align middle', data-replace='vertical-align'><div class='treb-toolbar-icon treb-icon-text-align-middle'/></button></li><li><button id='align-bottom-drop' data-command='align-bottom' title='Align bottom', data-replace='vertical-align'><div class='treb-toolbar-icon treb-icon-text-align-bottom'/></button></li></ul></div></div>${i.file_menu?"<div class='group wide'><button title='File options' class='drop-button'><div class='treb-toolbar-icon treb-icon-file-menu'/></button><div class='drop-menu' tabindex='-1'><ul><li><button class='text' data-command='reset'>New Document</button></li><hr/><li><button class='text' data-command='import-desktop'>Open File</button></li><li><button class='text' data-command='save-json'>Save JSON</button></li><hr/><li><button class='text' data-command='export-xlsx'>Export XLSX</button></li></ul></div></div>":""}<div class='group wide'><button id='align-left' title='Align left' data-command='align-left'><div class='treb-toolbar-icon treb-icon-text-align-left'/></button><button id='align-center' title='Align center' data-command='align-center'><div class='treb-toolbar-icon treb-icon-text-align-center'/></button><button id='align-right' title='Align right' data-command='align-right'><div class='treb-toolbar-icon treb-icon-text-align-right'/></button></div><div class='group wide'><button id='align-top' data-command='align-top' title='Align top'><div class='treb-toolbar-icon treb-icon-text-align-top'/></button><button id='align-middle' data-command='align-middle' title='Align middle'><div class='treb-toolbar-icon treb-icon-text-align-middle'/></button><button id='align-bottom' data-command='align-bottom' title='Align bottom'><div class='treb-toolbar-icon treb-icon-text-align-bottom'/></button></div><div class='group'><button id='wrap' data-command='wrap' title='Wrap text'><div class='treb-toolbar-icon treb-icon-wrap-text'/></button><button id='merge' data-command='merge' title='Merge cells'><div class='active-icon treb-toolbar-icon treb-icon-unmerge-cells'></div><div class='inactive-icon treb-toolbar-icon treb-icon-merge-cells'></div></button><button id='lock' data-command='lock'><div class='treb-toolbar-icon treb-icon-lock'/></button><button id='comment' class='drop-button' title='Comment'><div class='treb-toolbar-icon treb-icon-comment'/></button><div class='drop-menu' tabindex='-1'><div class='comment-editor'><div class='label' id='comment-label'></div><textarea id='comment-text' class='comment-textarea'></textarea><div class='comment-buttons'><button data-command='clear-comment'>Clear</button><button id='update-comment' data-command='update-comment'>Save</button></div></div></div></div><div class='group'><button class='color-button' data-command='background-color' title='Background color'><div class='treb-toolbar-icon treb-icon-fill-color'></div><div id='background-color-bar' class='color-bar' ></div></button><button class='drop'></button><div class='drop-menu color-chooser' data-target='background' tabindex='-1'></div></div><div class='group'><button class='color-button' data-command='foreground-color' title='Text color'><div class='treb-toolbar-icon treb-icon-text-color'></div><div id='foreground-color-bar' class='color-bar' ></div></button><button class='drop'></button><div class='drop-menu color-chooser' data-target='foreground' tabindex='-1'></div></div>${i.font_scale?`<div class='group wide'><div class='container font-size'><input value='' id='font-size-input' title='Font scale'></div><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button class='text' data-command='font-scale' data-scale='0.80'>0${s}80</button></li><li><button class='text' data-command='font-scale' data-scale='0.90'>0${s}90</button></li><li><button class='text' data-command='font-scale' data-scale='1.00'>1${s}00</button></li><li><button class='text' data-command='font-scale' data-scale='1.10'>1${s}10</button></li><li><button class='text' data-command='font-scale' data-scale='1.20'>1${s}20</button></li><li><button class='text' data-command='font-scale' data-scale='1.50'>1${s}50</button></li><li><button class='text' data-command='font-scale' data-scale='2.00'>2${s}00</button></li></ul></div></div>`:""}<div class='group'><button id='update-border' data-command='border-bottom' title='Bottom border'><div class='treb-toolbar-icon treb-icon-border-bottom'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button id='border-top' data-command='border-top' title='Top border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-top'/></button></li><li><button id='border-left' data-command='border-left' title='Left border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-left'/></button></li><li><button id='border-right' data-command='border-right' title='Right border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-right'/></button></li><li><button id='border-bottom' data-command='border-bottom' title='Bottom border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-bottom'/></button></li><li><button id='border-double-bottom' data-command='border-double-bottom' title='Double bottom border' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-double-bottom'/></button></li><li><button id='border-all' data-command='border-all' title='All borders' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-all'/></button></li><li><button id='border-outside' data-command='border-outside' title='Outside borders' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-outer'/></button></li><li><button id='border-none' data-command='border-none' title='Remove borders' data-replace='update-border'><div class='treb-toolbar-icon treb-icon-border-none'/></button></li><hr/><li><button id='border-color' class='color-button drop-button' data-position='horizontal' title='Border color'><div class='treb-toolbar-icon treb-icon-palette'></div><div id='border-color-bar' class='color-bar'></div></button><div class='drop-menu color-chooser' data-target='border' tabindex='-1'></div></li></ul></div></div><div class='group'><button id='layout' class='drop-button' title='Rows/columns'><div class='treb-toolbar-icon treb-icon-layout'/></button><div class='drop-menu' tabindex='-1'><ul><li><button class='text' data-command='insert-row'>Insert row</button></li><li><button class='text' data-command='insert-column'>Insert column</button></li><li><button class='text' data-command='delete-row'>Delete row</button></li><li><button class='text' data-command='delete-column'>Delete column</button></li></ul>${i.add_tab?"<ul><hr/><li><button class='text' data-command='insert-sheet'>Insert sheet</button></li><li><button class='text' data-command='delete-sheet'>Delete sheet</button></li></ul>":""}</div></div><div class='group'><button id='freeze' data-command='freeze'><div class='treb-toolbar-icon treb-icon-freeze'/></button></div><div class='group'><div class='container'><input value='General' id='number-format-input' title='Number format'></div><button class='drop'></button><div class='drop-menu scroll' tabindex='-1' data-number-formats></div></div><div class='split-button'><button data-command='decrease-decimal' title='Decrease precision'><div>0${s}0</div></button><button data-command='increase-decimal' title='Increase precision'><div>0${s}00</div></button></div><div class='group'><button id='insert-annotation' data-command='column-chart' title='Insert column chart'><div class='treb-toolbar-icon treb-icon-column-chart'/></button><button class='drop'></button><div class='drop-menu' tabindex='-1'><ul><li><button title='Insert column chart' id='column-chart' data-command='column-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-column-chart'/></button></li><li><button title='Insert donut chart' id='donut-chart' data-command='donut-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-donut-chart'/></button></li><li><button title='Insert bar chart' id='bar-chart' data-command='bar-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-bar-chart'/></button></li><li><button title='Insert line chart' id='line-chart' data-command='line-chart' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-line-chart'/></button></li><hr/><li><button id='insert-image' data-command='insert-image' title='Insert image' data-replace='insert-annotation'><div class='treb-toolbar-icon treb-icon-image'/></button></li></ul></div></div>${i.toolbar_recalculate_button?"<div class='group end-group'><button data-command='recalculate' title='Recalculate'><div class='treb-toolbar-icon treb-icon-recalculate'></div></button></div>":""}<div class='staging'><div id='color-chooser' class='color-chooser-main'><div class='color-header'>Theme colors</div><div id='theme-color-list' class='color-list'></div><div class='color-header other-colors'>Other colors</div><div id='color-list' class='color-list'></div><div class='new-color'><input id='color-input' placeholder='New Color'><button id='color-button'><div class='treb-toolbar-icon treb-icon-check'></div></button></div></div></div></div>`,this.model["background-color-bar"].style.color="yellow",this.model["foreground-color-bar"].style.color="blue",this.model["border-color-bar"].style.color="#333";let n=this.model["color-button"],o=this.model["color-input"];this.UpdateTheme(r),n.addEventListener("click",()=>{this.CommitColor({text:o.value||""})}),o.addEventListener("keydown",h=>{h.key==="Enter"&&this.CommitColor({text:o.value||""})}),o.addEventListener("input",()=>{n.style.backgroundColor="";let h=o.value||"";n.style.backgroundColor=h;let p=ee.MeasureColor(h),f=et.RGBToHSL(p[0],p[1],p[2]);n.style.color=f.l>.5?"":"#fff"}),this.model["comment-text"].addEventListener("keydown",h=>{if(h.key==="Enter"&&h.ctrlKey){h.stopPropagation(),h.preventDefault(),this.model["update-comment"].click();return}});let a="",l=this.model["font-size-input"];l&&(l.addEventListener("focus",()=>a=l.value||""),l.addEventListener("keydown",h=>{switch(h.key){case"Enter":if(l.value){let p=l.value;T.decimal_separator!=="."&&(p=p.replace(new RegExp(T.decimal_separator,"g"),".")),this.Publish({type:"font-size",style:A.ParseFontSize(p)})}else this.Publish({type:"font-size",style:{font_size:void 0}});break;case"Escape":u.value=d,this.Publish({type:"cancel"});break;default:return}h.stopPropagation(),h.preventDefault()}));let d="",u=this.model["number-format-input"];u.addEventListener("focus",()=>d=u.value||""),u.addEventListener("keydown",h=>{switch(h.key){case"Enter":this.Publish({type:"format",format:u.value||""});break;case"Escape":u.value=d,this.Publish({type:"cancel"});break;default:return}h.stopPropagation(),h.preventDefault()}),this.model.root.addEventListener("click",h=>{this.HandleClick(h)}),/narrow/i.test((i.toolbar||"").toString())&&this.model.root.classList.add("narrow"),t.appendChild(this.model.root)}model;number_formats=[];date_formats=[];colors=[];color_target;state;background_color={text:"yellow"};foreground_color={text:"blue"};border_color=void 0;outer_container;menu_map={};menu_index=1;HandleClick(t){let i=this.model["color-button"],r=this.model["color-input"],s=t.target,n=s?.dataset?.command;if(n){let o={};if(/^border-/.test(n))o.border=n,o.color=this.border_color,n="border";else switch(n){case"font-scale":o.scale=s?.dataset?.scale||1;break;case"clear-comment":case"update-comment":this.state?.selection&&!this.state.selection.empty&&(o.address={...this.state.selection.target}),o.comment=this.model["comment-text"].value||"";break;case"background-color":o.target="background",o.color=this.background_color;break;case"foreground-color":o.target="foreground",o.color=this.foreground_color;break;case"border-color":o.target="border",o.color=this.border_color;break}this.Publish({type:"button",command:n,data:o});return}if(s?.classList?.contains("drop")||s?.classList?.contains("drop-button")){let o=s.parentElement;for(;o&&!o.classList.contains("group");){if(o===this.model.root)return;o=o.parentElement}if(o||s.dataset.position==="horizontal"){let a,l;if(s.dataset.menu_target)l=this.menu_map[s.dataset.menu_target];else{l=s.nextSibling;let d=(this.menu_index++).toString();this.menu_map[d]=l,s.dataset.menu_target=d,l.style.position="absolute",l.classList.add("treb-toolbar-drop-menu"),s.dataset.position!=="horizontal"&&this.outer_container?.appendChild(l)}if(l?.classList?.contains("drop-menu"))if(s===this.model.comment&&(this.model["comment-label"].textContent=this.state?.selection?.target?g.CellAddressToLabel(this.state?.selection.target):"",this.model["comment-text"].value=this.state?.comment||"",a=this.model["comment-text"]),l.dataset.numberFormats!==void 0&&this.RenderNumberFormats(l),l.classList.contains("color-chooser")&&(this.color_target=l.dataset?.target||"",this.RenderColors(this.model["color-list"]),r.value="",i.style.backgroundColor="",i.style.color="",l.appendChild(this.model["color-chooser"])),s.dataset?.position==="horizontal")this.Focus(l,s.offsetWidth+12,s.offsetTop-8,a);else{let d=(s.classList.contains("drop-button")?s:o)?.getBoundingClientRect()||{x:0},u=this.outer_container?.getBoundingClientRect()||{x:0,right:0},h=d.x-u.x,p=l.offsetWidth;p>0&&h+p>u.right&&(h=Math.max(0,u.right-p-10)),this.Focus(l,h,s.offsetHeight+4,a)}}return}}ResolveColor(t,i){return D(this.theme,t||i)||""}CommitColor(t){switch(this.color_target){case"background":this.model["background-color-bar"].style.color=this.ResolveColor(t,{theme:0}),this.background_color=t?{...t}:void 0;break;case"border":this.model["border-color-bar"].style.color=this.ResolveColor(t,{theme:1}),this.border_color=t?{...t}:void 0;break;case"foreground":t||(t={theme:1}),this.model["foreground-color-bar"].style.color=this.ResolveColor(t,{theme:1}),this.foreground_color=t?{...t}:void 0;break}this.Publish({type:"button",command:"color",data:{color:t?{...t}:void 0,target:this.color_target||""}})}Focus(t,i,r,s){t.style.left=i+"px",t.style.top=r+"px",t.classList.add("enabled"),requestAnimationFrame(()=>t.classList.add("visible"));let n=d=>{d.key==="Escape"&&(d.stopPropagation(),d.preventDefault(),this.Publish({type:"cancel"}))};window.addEventListener("keydown",n);let o=d=>{let u=d.target;if(u.dataset?.replace){let h=this.model[u.dataset.replace];h.innerHTML=u.innerHTML,h.setAttribute("title",u.getAttribute("title")||""),h.dataset.command=u.dataset.command||void 0}if(u.dataset?.command==="number-format"){let h=u.textContent||"General";this.model["number-format-input"].value=u.textContent||"",this.Publish({type:"format",format:h})}else if(u.dataset?.command||u.classList?.contains("drop-button")){this.HandleClick(d);return}else if(u.classList?.contains("color-swatch"))if(typeof u?.dataset?.theme<"u"){let h=Number(u?.dataset?.theme);isNaN(h)&&(h=0);let p={theme:h||0};if(u?.dataset?.tint){let f=Number(u.dataset.tint);f&&!isNaN(f)&&(p.tint=f)}this.CommitColor(p)}else{let h=u?.dataset?.color||"";this.CommitColor(h?{text:h}:void 0)}d.stopPropagation()};t.addEventListener("click",o);let a=()=>{t.classList.contains("visible")||(t.style.left="",t.style.top=""),t.removeEventListener("transitionend",a)},l=d=>{let u=d.relatedTarget;u&&t.contains(u)||(t.classList.remove("visible"),t.removeEventListener("focusout",l),t.removeEventListener("click",o),window.removeEventListener("keydown",n),t.addEventListener("transitionend",a))};t.addEventListener("focusout",l),requestAnimationFrame(()=>(s||t).focus())}UpdateState(t){this.state=t;let i={"align-center":t.style&&t.style?.horizontal_align===A.HorizontalAlign.Center,"align-left":t.style&&t.style?.horizontal_align===A.HorizontalAlign.Left,"align-right":t.style&&t.style?.horizontal_align===A.HorizontalAlign.Right,"align-top":t.style&&t.style?.vertical_align===A.VerticalAlign.Top,"align-middle":t.style&&t.style?.vertical_align===A.VerticalAlign.Middle,"align-bottom":t.style&&t.style?.vertical_align===A.VerticalAlign.Bottom,wrap:t.style&&!!t.style.wrap,comment:!!t.comment},r=this.model.freeze;t.frozen?(r.classList.add("active"),r.setAttribute("title","Unfreeze panes")):(r.classList.remove("active"),r.setAttribute("title","Freeze panes")),t.style?.locked?(this.model.lock.classList.add("active"),this.model.lock.setAttribute("title","Unlock cells")):(this.model.lock.classList.remove("active"),this.model.lock.setAttribute("title","Lock cells"));let s=this.model.merge;t.merge?(s.classList.add("active"),s.dataset.command="unmerge",s.setAttribute("title","Unmerge cells")):(s.classList.remove("active"),s.dataset.command="merge",s.setAttribute("title","Merge cells"));let n=this.model["font-size-input"];if(n){let a=A.RelativeFontSize(t.style||{},this.theme.grid_cell||{}).toFixed(2);a=a.replace(/\./g,T.decimal_separator),n.value=a}let o=t.style?.number_format||"";this.model["number-format-input"].value=L.SymbolicName(o)||o,Object.keys(i).forEach(a=>{i[a]?this.model[a]?.classList.add("active"):this.model[a]?.classList.remove("active")})}UpdateTheme(t){let i=this.model["theme-color-list"],r=[],s=["Background","Text","Background","Text","Accent","Accent","Accent","Accent","Accent","Accent"],n=0;if(t.theme_colors)if(this.options.tint_theme_colors)for(let a of[.5,.25,0,-.25,-.5]){for(r.push("<div class='color-list-row'>"),n=0;n<10;n++){let l=t.theme_colors[n]||"#000";if(a){let u=Math.round(Math.abs(a)*100),h=a>0?"lighter":"darker";l+=` (${u}% ${h})`}let d=this.ResolveColor({theme:n,tint:a},{});r.push(`<button data-color='${d}' class='color-swatch' data-tint=${a} data-theme=${n} title='${s[n]}: ${l}' ></button>`)}r.push("</div>")}else{for(r.push("<div class='color-list-row'>"),n=0;n<10;n++){let a=t.theme_colors[n]||"#000";r.push(`<button data-color='${a}' class='color-swatch' data-theme=${n} title='${s[n]}: ${a}' ></button>`)}r.push("</div>")}i.innerHTML=r.join("");let o=i.querySelectorAll("button[data-color]");for(let a=0;a<o.length;a++)o[a].style.backgroundColor=o[a].dataset.color||""}RenderColors(t){let i=["<div class='color-list-row'>","<button class='color-swatch default-color' data-color='' title='Default color'></button>"],r=0;for(;r<9&&r<this.colors.length;r++){let n=this.colors[r];i.push(`<button class='color-swatch' data-color='${n}' title='${n}' ></button>`)}for(i.push("</div>");r<this.colors.length;){i.push("<div class='color-list-row'>");let n=r+10;for(;r<this.colors.length&&r<n;r++){let o=this.colors[r];i.push(`<button class='color-swatch' data-color='${o}' title='${o}' ></button>`)}i.push("</div>")}t.innerHTML=i.join("");let s=t.querySelectorAll("button.color-swatch");for(let n=0;n<s.length;n++){let o=s[n];o.style.background=o.dataset.color||""}}RenderNumberFormats(t){t.innerHTML=`<ul>${this.number_formats.map(i=>Rt`<li><button data-command='number-format' class='text'>${i}</button></li>`).join(`
|
|
11
11
|
`)}</ul><hr/><ul>${this.date_formats.map(i=>Rt`<li><button data-command='number-format' class='text'>${i}</button></li>`).join(`
|
|
12
|
-
`)}</ul>`}UpdateDocumentStyles(t,i,r){let s=["General","Number","Integer","Percent","Fraction","Accounting","Currency","Scientific"],n=["Timestamp","Long Date","Short Date"];for(let a of t){if(L.SymbolicName(L.Translate(a)))continue;L.Get(a).date_format?n.push(a):s.push(a)}this.number_formats=s,this.date_formats=n;let o=this.colors.map(a=>ee.MeasureColor(a));for(let a of i){let l=ee.MeasureColor(a);o.some(d=>d[0]===l[0]&&d[1]===l[1]&&d[2]===l[2])||(this.colors.push(a),o.push(l))}}};var ke=class{constructor(e=0,t=0,i=100,r=100){this.left=e;this.top=t;this.right=i;this.bottom=r}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get center(){return{x:this.left+this.width/2,y:this.top+this.height/2}}};var yt="http://www.w3.org/2000/svg",M=(c,e={},t)=>{let i=document.createElementNS(yt,c);for(let r of Object.keys(e))if(e[r]!==void 0){let s=e[r];i.setAttribute(r,Array.isArray(s)?s.join(" "):s.toString())}return t&&(i.textContent=t),i},ii=class{parent;svg_node;text_measurement_node;container_group;group;axis_group;label_group;size={width:0,height:0};bounds=new ke;constructor(){this.container_group=M("g"),this.group=M("g"),this.axis_group=M("g",{class:"axis-group"}),this.label_group=M("g",{class:"label-group"}),this.container_group.appendChild(this.axis_group),this.container_group.appendChild(this.group),this.container_group.appendChild(this.label_group)}Initialize(e){this.parent=e,this.svg_node=M("svg",{class:"treb-chart"}),this.svg_node.style.overflow="hidden",this.svg_node.style.position="relative",this.svg_node.style.width="100%",this.svg_node.style.height="100%",this.svg_node.appendChild(this.container_group),this.parent.appendChild(this.svg_node),this.Resize()}Legend(e){let t=M("g");this.group.appendChild(t);let i=M("text");t.appendChild(i),t.setAttribute("class","legend");let r=[[]],s=10,n=e.area.width,o=0,a=0,l=e.area.width,d=e.style===1?14:26,u=e.labels.map((b,_)=>{i.textContent=b.label;let y=i.getBoundingClientRect(),x={width:y.width,height:y.height},v=x.width+d+s;return a=Math.max(a,x.height),e.layout===1?r[_]=[_]:v>n?r[o].length===0?(r[o].push(_),o++,r[o]=[],n=l):(o++,r[o]=[_],n=l-v):(r[o].push(_),n-=v),x});t.removeChild(i);let h=a,p=e.layout||0;p===0&&r.every(b=>b.length<=1)&&(p=0);for(let b=0;b<r.length;b++){let _=r[b].reduce((v,w)=>v+u[w].width+d,(r[b].length-1)*s),y=0,x=p===0?Math.round((l-_)/2):Math.round(s/2);for(let v=0;v<r[b].length;v++){let w=r[b][v],C=u[w],S=e.labels[w],U=h-1,J=!1;typeof navigator<"u"&&(J=/trident/i.test(navigator?.userAgent||""));let oe=typeof S.index=="number"?S.index:w+1;t.appendChild(M("text",{"dominant-baseline":"middle",x:x+d,y:h,dy:J?".3em":void 0},S.label)),e.style===1?t.appendChild(M("rect",{class:`series-${oe}`,x,y:U-4,width:8,height:8})):t.appendChild(M("rect",{class:`series-${oe}`,x,y:U-1,width:d-3,height:2})),y=Math.max(y,C.height),x+=C.width+d+s}h=Math.round(h+y*1.1)}let f=t.getBoundingClientRect(),m={width:f.width,height:f.height+a};switch(e.position){case 1:t.setAttribute("transform",`translate(${e.area.left}, ${e.area.bottom-m.height})`);break;case 2:t.setAttribute("transform",`translate(${e.area.left}, ${e.area.top})`);break;case 3:t.setAttribute("transform",`translate(${e.area.right-m.width}, ${e.area.top})`);break;case 0:default:t.setAttribute("transform",`translate(${e.area.left}, ${e.area.top})`)}e.position===0?e.area.top+=m.height||0:e.position===3?e.area.right-=(m.width||0)+8:e.position===2?e.area.left+=(m.width||0)+8:e.area.bottom-=m.height||0}Clear(e){this.group.textContent="",this.axis_group.textContent="",this.label_group.textContent="",e="treb-chart"+(e?" "+e:""),this.svg_node.setAttribute("class",e)}Resize(){let e=this.parent.getBoundingClientRect();this.svg_node.setAttribute("width",e.width.toString()),this.svg_node.setAttribute("height",e.height.toString()),this.size={width:e.width,height:e.height}}Prerender(){let e=this.svg_node.getBoundingClientRect();this.bounds.top=e.top,this.bounds.left=e.left,this.bounds.right=e.right,this.bounds.bottom=e.bottom}RenderTitle(e,t,i,r){let s=M("text",{class:"chart-title",x:Math.round(t.width/2)},e);s.style.textAnchor="middle",this.group.appendChild(s);let n=s.getBoundingClientRect();switch(r){case"bottom":s.setAttribute("y",Math.round(t.bottom-n.height).toString()),t.bottom-=n.height+i;break;default:s.setAttribute("y",Math.round(t.top+i+n.height).toString()),t.top+=n.height+i;break}}MeasureText(e,t,i=!1){this.text_measurement_node||(this.text_measurement_node=M("text",{x:"-100px",y:"-100px"}),this.svg_node.appendChild(this.text_measurement_node)),typeof t<"u"?(typeof t=="string"&&(t=[t]),this.text_measurement_node.setAttribute("class",t.join(" "))):this.text_measurement_node.setAttribute("class",""),this.text_measurement_node.textContent=e;let r=this.text_measurement_node.getBoundingClientRect(),s={width:r.width,height:r.height,y_offset:r.height-(this.bounds.top-r.top-100)};return i&&(s.width=Math.ceil(s.width),s.height=Math.ceil(s.height),s.y_offset=Math.ceil(s.y_offset)),s}RenderTicks(e,t,i,r,s){let n=[],o=e.width/r;for(let a=0;a<r;a++){let l=Math.round(e.left+o/2+o*a)-.5;n.push(`M${l} ${t} L${l} ${i}`)}this.group.appendChild(M("path",{d:n,class:s}))}RenderXAxisBar(e,t,i,r,s){let n=i.length;if(!n)return;let o=4,a=t?e.width/n:e.width/(n-1),l=t?a/2:0,d=1,u=!0;for(;u;){u=!1;let h=0;for(let p=0;p<n;p+=d){let f=Math.round(e.left+l+a*p),m=f-r[p].width/2;if(h&&m<=h){d++,u=!0;break}h=f+r[p].width/2+o}}for(let h=0;h<n;h+=d){let p=Math.round(e.left+l+a*h);this.RenderText(this.axis_group,i[h],"center",{x:p,y:e.bottom},s)}}RenderXAxisTicks(e,t,i){let r=t?e.width/i:e.width/(i-1),s=t?r/2:0,n=[];for(let o=0;o<i;o++){let a=Math.round(e.left+s+r*o)+.5;n.push(`M${a},${e.bottom+.5} v${6}`)}this.axis_group.appendChild(M("path",{d:n.join(" "),class:"x-axis-tick axis-tick"}))}RenderXAxis(e,t,i,r,s){let n=i.length;if(!n)return;let o=4,a=t?e.width/n:e.width/(n-1),l=t?a/2:0,d=1,u=!0,h=(i.length-1)%2===0,p=(i.length-1)%3===0;for(;u;){u=!1;let f=0;for(let m=0;m<n;m+=d){let b=Math.round(e.left+l+a*m),_=b-r[m].width/2;if(f&&_<=f){d++,u=!0;break}f=b+r[m].width/2+o}}d===3&&!p&&h&&d++;for(let f=0;f<n;f+=d){let m=Math.round(e.left+l+a*f);this.RenderText(this.axis_group,i[f],"center",{x:m,y:e.bottom},s)}}RenderYAxisBar(e,t,i,r){i=i.slice(0),i.reverse();let s=i.length;if(!s)return;let n=e.height/s,o=1,a=!0;for(;a;){a=!1;let l=0;for(let d=0;d<s;d+=o){let u=i[d],h=Math.round(e.bottom-n*(d+.5)+u.metrics.height/4);if(l&&h>=l){o++,a=!0;break}l=h-u.metrics.height}}for(let l=0;l<s;l+=o){let d=i[l],u=Math.round(e.bottom-n*(l+.5)+d.metrics.height/4);this.RenderText(this.axis_group,d.label,"right",{x:t,y:u},r)}}RenderYAxis(e,t,i,r){let s=i.length;if(!s)return;let n=e.height/(s-1),o=1,a=!0;for(;a;){a=!1;let l=0;for(let d=0;d<s;d+=o){let u=i[d],h=Math.round(e.bottom-n*d+u.metrics.height/4);if(l&&h>=l){o++,a=!0;break}l=h-u.metrics.height}}for(let l=0;l<s;l+=o){let d=i[l],u=Math.round(e.bottom-n*l+d.metrics.height/4);this.RenderText(this.axis_group,d.label,"right",{x:t,y:u},r)}}LineProperties(e,t){let i=t.x-e.x,r=t.y-e.y;return{length:Math.sqrt(i*i+r*r),angle:Math.atan2(r,i)}}RenderSmoothLine(e,t,i=!1,r,s){let n=M("g"),o=[],a=[],l=t.length,d=l-1,u=e.width/l/2,h=[],p=t.map((b,_)=>{if(!(typeof b>"u"))return{x:Math.round(e.left+e.width/d*_),y:e.bottom-b}}),f=[],m=()=>{if(f.length<2)return;let b="",_=f[0],y=f[f.length-1];if(f.length===2)b=`${f[0].x},${f[0].y} L${f[1].x},${f[1].y}`;else if(f.length>2){let x=this.CatmullRomChain(f);b=""+x.map(v=>`${v.x},${v.y}`).join(" L")}b&&(o.push("M"+b),i&&(a.push(`M ${_.x},${e.bottom} L ${_.x},${_.y}`),a.push("L"+b),a.push(`L ${y.x},${e.bottom}`)))};for(let b of p)b?f.push(b):(m(),f=[]);if(f.length&&m(),i&&n.appendChild(M("path",{class:"fill",d:a})),n.appendChild(M("path",{class:"line",d:o})),typeof s<"u"&&(typeof s=="string"&&(s=[s]),n.setAttribute("class",s.join(" "))),this.group.appendChild(n),r&&h.length){let b=document.createElementNS(yt,"g");for(let _ of h){let y=M("circle",{cx:_.x,cy:_.y,r:u});y.addEventListener("mouseenter",x=>{this.parent.setAttribute("title",r[_.i]||"")}),y.addEventListener("mouseleave",x=>{this.parent.setAttribute("title","")}),b.appendChild(y)}b.setAttribute("class","mouse-layer"),this.group.appendChild(b)}}RenderLine(e,t,i=!1,r,s){let n=document.createElementNS(yt,"g"),o=[],a=[],l=t.length,d=l-1,u=e.width/l/2,h=[],p=0,f=!0,m;for(;p<l;p++){let b=t[p];if(typeof b>"u"){f=!0,i&&typeof m<"u"&&a.push(`L${m} ${e.bottom}Z`),m=void 0;continue}let _=Math.round(+e.left+e.width/d*p);f?(i&&a.push(`M${_} ${e.bottom} L${_} ${e.bottom-b}`),o.push(`M${_} ${e.bottom-b}`)):(o.push(`L${_} ${e.bottom-b}`),a.push(`L${_} ${e.bottom-b}`)),h.push({x:_,y:e.bottom-b,i:p}),m=_,f=!1}if(i&&typeof m<"u"&&a.push(`L${m} ${e.bottom}Z`),i&&n.appendChild(M("path",{class:"fill",d:a})),n.appendChild(M("path",{class:"line",d:o})),typeof s<"u"&&(typeof s=="string"&&(s=[s]),n.setAttribute("class",s.join(" "))),this.group.appendChild(n),r&&h.length){let b=document.createElementNS(yt,"g");for(let _ of h){let y=M("circle",{cx:_.x,cy:_.y,r:u});y.addEventListener("mouseenter",x=>{this.parent.setAttribute("title",r[_.i]||"")}),y.addEventListener("mouseleave",x=>{this.parent.setAttribute("title","")}),b.appendChild(y)}b.setAttribute("class","mouse-layer"),this.group.appendChild(b)}}RenderBarGrid(e,t,i){let r=[],s=e.width/t;for(let n=0;n<=t;n++){let o=Math.round(e.left+s*n)-.5;r.push(`M${o} ${e.top} L${o} ${e.bottom}`)}this.group.appendChild(M("path",{d:r,class:i}))}RenderGrid(e,t,i=0,r){let s=[],n=e.height/t;for(let o=0;o<=t;o++){let a=Math.round(e.top+n*o)-.5;s.push(`M${e.left} ${a} L${e.right} ${a}`)}n=e.width/(i-1);for(let o=0;o<i;o++){let a=Math.round(e.left+n*o)-.5;s.push(`M${a} ${e.top} L${a} ${e.bottom}`)}this.group.appendChild(M("path",{d:s,class:r}))}MultiplyPoint(e,t){return{x:e.x*t,y:e.y*t}}AddPoints(e,t){return{x:e.x+t.x,y:e.y+t.y}}CatmullRomSpline(e,t){let i=.5;i=i/2;let r=(u,h,p)=>{let{x:f,y:m}=h,{x:b,y:_}=p;return((b-f)**2+(_-m)**2)**i+u},s=0,n=r(s,e[0],e[1]),o=r(n,e[1],e[2]),a=r(o,e[2],e[3]),l=(o-n)/t,d=[];for(let u=0;u<t;u++){let h=n+l*u,p=this.AddPoints(this.MultiplyPoint(e[0],(n-h)/(n-s)),this.MultiplyPoint(e[1],(h-s)/(n-s))),f=this.AddPoints(this.MultiplyPoint(e[1],(o-h)/(o-n)),this.MultiplyPoint(e[2],(h-n)/(o-n))),m=this.AddPoints(this.MultiplyPoint(e[2],(a-h)/(a-o)),this.MultiplyPoint(e[3],(h-o)/(a-o))),b=this.AddPoints(this.MultiplyPoint(p,(o-h)/(o-s)),this.MultiplyPoint(f,(h-s)/(o-s))),_=this.AddPoints(this.MultiplyPoint(f,(a-h)/(a-n)),this.MultiplyPoint(m,(h-n)/(a-n))),y=this.AddPoints(this.MultiplyPoint(b,(o-h)/(o-n)),this.MultiplyPoint(_,(h-n)/(o-n)));d.push(y)}return d}CatmullRomChain(e,t=30){let i=e.slice(0),r=[],s=i.length;if(s){let n=i[s-1].x-i[s-2].x,o=i[s-1].y-i[s-2].y;i.push({x:i[s-1].x+n,y:i[s-1].y+o}),i.push({x:i[s-1].x+n,y:i[s-1].y+o}),n=i[1].x-i[0].x,o=i[1].y-i[0].y,i.unshift({x:i[0].x-n,y:i[0].y-o});for(let a=0;a<i.length-4;a++){let l=i.slice(a,a+4),d=this.CatmullRomSpline(l,t);r.push(...d)}}return r}RenderDataLabels(e,t,i,r,s,n,o){let a=Math.max(t.length,i.length),l=r.max-r.min||1,d=s.max-s.min||1;for(let u=0;u<a;u++){let h=t[u],p=i[u];if(h!==void 0&&p!==void 0){let f={x:e.left+(h-r.min)/l*e.width,y:e.bottom-(p-s.min)/d*e.height},m=n[u];if(m){this.label_group.appendChild(M("circle",{class:"label-target",cx:f.x,cy:f.y,r:10}));let b=M("g",{class:"data-label",transform:`translate(${f.x+10},${f.y})`});this.label_group.appendChild(b);let _=M("circle",{cx:-10,y:0,r:5,class:`marker-highlight series-${o}`});b.appendChild(_);let y=M("text",{x:4,y:0},m);b.appendChild(y);let x=y.getBoundingClientRect(),v=x.height,w=x.width+8;w+15+f.x>=e.right&&(b.setAttribute("transform",`translate(${f.x-w-15},${f.y})`),_.setAttribute("cx",(w+15).toString()));let C=M("path",{d:`M0,5 h${w} v-${v} h-${w} Z`});b.insertBefore(C,y)}}}}RenderScatterSeries(e,t,i,r,s,n=!0,o=!1,a=!1,l=!1,d=!1,u){let h=Math.max(t.length,i.length),p=r.max-r.min||1,f=s.max-s.min||1,m=[],b=[],_=[],y=M("g",{class:u});this.group.appendChild(y);for(let x=0;x<h;x++){let v=t[x],w=i[x];typeof v>"u"||typeof w>"u"?m.push(void 0):m.push({x:e.left+(v-r.min)/p*e.width,y:e.bottom-(w-s.min)/f*e.height})}if(n){let x=[],v=d?()=>x.length===2?`${x[0].x},${x[0].y} L${x[1].x},${x[1].y}`:x.length>2?this.CatmullRomChain(x).map(C=>`${C.x},${C.y}`).join(" L"):"":()=>x.map(w=>`${w.x},${w.y}`).join(" L");for(let w of m)if(w)x.push(w);else{if(x.length>=2){let C=v();b.push("M"+C),_.push(`M${x[0].x},${e.bottom}L`+C+`L${x[x.length-1].x},${e.bottom}Z`)}x=[]}if(x.length>=2){let w=v();b.push("M"+w),_.push(`M${x[0].x},${e.bottom}L`+w+`L${x[x.length-1].x},${e.bottom}Z`)}}if(a&&y.appendChild(M("path",{d:_,class:"fill"})),n&&y.appendChild(M("path",{d:b,class:"line"})),o)for(let x of m)x&&y.appendChild(M("circle",{cx:x.x,cy:x.y,r:1,class:"point"}));if(l)for(let x of m)x&&y.appendChild(M("circle",{cx:x.x,cy:x.y,r:3,class:"marker"}))}RenderPoints(e,t,i,r){let s=[];for(let n=0;n<t.length;n++){let o=t[n]*e.width+e.left,a=e.bottom-i[n]*e.height;s.push(`M${o-1},${a-1} L${o+1},${a+1}`),s.push(`M${o-1},${a+1} L${o+1},${a-1}`)}this.group.appendChild(M("path",{d:s,class:r}))}RenderPoint(e,t,i){this.group.appendChild(M("circle",{cx:e,cy:t,r:1,class:i}))}RenderCalloutLines(e){let t=M("g",{class:"callouts"});this.label_group.appendChild(t);for(let i of e)t.appendChild(M("path",{d:`M${i.x1},${i.y1} L${i.x2},${i.y2}`,class:"callout "+(i.classes||"").trim()}))}RenderRectangle(e,t,i,r,s,n){let o="";if(t)if(t[0]&&t[0]===t[1]&&t[0]>=e.height){let l=t[0],d=t[0]-e.height,u=Math.sqrt(l*l-d*d);o=`M${e.left+e.width/2-u},${e.bottom} a${l},${l} 0 0 1 ${u*2},0 z`}else if(t[1]&&t[1]===t[2]&&t[1]>=e.width){let l=t[1],d=t[1]-e.width,u=Math.sqrt(l*l-d*d);o=`M${e.left},${e.top+e.height/2-u} a${l},${l} 0 0 1 0,${u*2} z`}else o=`M${e.left},${e.top+t[0]} a${t[0]},${t[0]} 0 0 1 ${t[0]},${-t[0]} h${e.width-t[0]-t[1]} a${t[1]},${t[1]} 0 0 1 ${t[1]},${t[1]} v${e.height-t[1]-t[2]} a${t[2]},${t[2]} 0 0 1 ${-t[2]},${t[2]} h${-e.width+t[2]+t[3]} a${t[3]},${t[3]} 0 0 1 ${-t[3]},${-t[3]} v${-e.height+t[3]+t[0]} `;else o=`M${e.left},${e.top} h${e.width} v${e.height} h${-e.width} v${-e.height} `;let a=M("path",{d:o,class:i});if(r&&(a.addEventListener("mouseenter",l=>{this.parent.setAttribute("title",r)}),a.addEventListener("mouseleave",l=>{this.parent.setAttribute("title","")})),this.group.appendChild(a),s){this.label_group.appendChild(M("path",{class:"label-target",d:o}));let l=n||{x:Math.round(e.left+e.width/2),y:Math.round(e.top-10)},d=M("g",{class:"data-label",transform:`translate(${l.x},${l.y})`});this.label_group.appendChild(d);let u=M("text",{x:0,y:0},s);d.appendChild(u);let h=u.getBoundingClientRect(),p=h.height,f=h.width+8;l.y-h.height<4&&(l.y-=l.y-h.height-4,d.setAttribute("transform",`translate(${l.x},${l.y})`)),u.setAttribute("x",Math.floor(-h.width/2).toString());let m=Math.ceil(p*.125),b=M("rect",{rx:3,x:-f/2,y:Math.round(-p+m*2/3),width:f,height:p+m});d.insertBefore(b,u)}}RenderText(e,t,i,r,s){let n=M("text",{x:r.x,y:r.y,class:s},t);switch(i){case"right":n.style.textAnchor="end";break;case"center":n.style.textAnchor="middle";break;default:n.style.textAnchor="start";break}(e||this.group).appendChild(n)}RenderDonut(e,t,i,r,s,n,o){let a=-Math.PI/2,l=0;n&&(i*=.8,r*=.7);let d=(u,h,p)=>[Math.cos(p)*h+u.x,Math.sin(p)*h+u.y];for(let u of e){let h=u.title||"",p=u.percent,f=u.index,m=[],b=0,_=d.bind(0,t,i),y=d.bind(0,t,r);if(p>.5){b=a+p/2*Math.PI*2,l=a+p*Math.PI*2;let w=b-a,C=l-b;m.push(`M${_(a)}`,`A${i},${i},${w},0,1,${_(b)}`,`A${i},${i},${C},0,1,${_(l)}`,`L${y(l)}`,`A${r},${r},${C},0,0,${y(b)}`,`A${r},${r},${w},0,0,${y(a)}`,"Z")}else{l=a+p*Math.PI*2,b=(l-a)/2+a;let w=l-a;m.push(`M${_(a)}`,`A${i},${i},${w},0,1,${_(l)}`,`L${y(l)}`,`A${r},${r},${w},0,0,${y(a)}`,"Z")}let x=M("path",{d:m,class:typeof f>"u"?void 0:`series-${f}`});typeof f<"u"&&x.setAttribute("data-index",f.toString());let v=M("g",{class:o});if(v.appendChild(x),this.group.appendChild(v),p>=.05&&h){let w=i-r;m=[];let C=d(t,r+(i-r)/2+w,b);m.push(`M${d(t,r+(i-r)/2,b)}`),m.push(`L${C}`),v.appendChild(M("path",{d:m,class:"callout"}));let S=[],U=M("text",{class:"callout-label"});v.appendChild(U);let J=b+Math.PI/2,oe=h;U.textContent=oe;let R=U.getBoundingClientRect(),k={width:R.width,height:R.height},[W,ae]=C;W+=k.height/2*Math.cos(b),ae+=k.height/4+k.height/2*Math.sin(b);let Z=!1;J>Math.PI?W-k.width<=s.left&&(Z=!0):W+k.width>s.right&&(Z=!0);let he=/[\s-]/;if(Z&&he.test(oe)){let $=-1,F=1,ie=[];for(let le=0;le<oe.length;le++)if(he.test(oe[le])){let _e=Math.abs(.5-le/oe.length);_e<F&&(F=_e,$=le)}$>0&&(S.push(oe.substr(0,$+1).trim()),S.push(oe.substr($+1).trim()))}if(S.length){let $=0,F=0,ie=S.map(le=>{U.textContent=le,R=U.getBoundingClientRect();let _e={width:R.width,height:R.height};return F=Math.max(F,_e.width),{text:le,metrics:_e}});U.textContent="";for(let le of ie){let _e=document.createElementNS(yt,"tspan");_e.textContent=le.text;let ss=J>Math.PI?W-(F-le.metrics.width)/2:W+(F-le.metrics.width)/2;_e.setAttribute("x",ss.toString()),_e.setAttribute("dy",$.toString()),U.appendChild(_e),$=le.metrics.height}}let pe=J>Math.PI?"end":"start";U.setAttribute("text-anchor",pe),U.setAttribute("x",W.toString()),U.setAttribute("y",ae.toString()),typeof f<"u"&&U.setAttribute("data-index",f.toString())}a=l}}};var N=class{static Scale(e,t,i=6.5){return pr(e,t,i)}static Range(e){let t,i;for(let s of e)typeof s>"u"||((typeof t>"u"||t>s)&&(t=s),(typeof i>"u"||i<s)&&(i=s));let r=typeof t>"u"||typeof i>"u"?0:i-t;return{min:t,max:i,range:r}}static ApplyScale(e,t,i){return t*(e-i.min)/(i.max-i.min)}static Flatten(e){let t=[];if(Array.isArray(e))for(let i of e)Array.isArray(i)?t=t.concat(this.Flatten(i)):t.push(i);else typeof e<"u"&&t.push(e);return t}};ts();var qi="#,##0.00",Ze=class{constructor(e=new ii){this.renderer=e}chart_data={type:"null"};margin={top:.025,left:.05,bottom:.025,right:.075};Initialize(e){this.renderer.Initialize(e)}Exec(e,t){let i=t?.value||[];switch(e.toLowerCase()){case"column.chart":this.CreateColumnChart(i,"column");break;case"bar.chart":this.CreateColumnChart(i,"bar");break;case"line.chart":this.CreateLineChart(i,"line");break;case"area.chart":this.CreateLineChart(i,"area");break;case"donut.chart":case"pie.chart":this.CreateDonut(i,e.toLowerCase()==="pie.chart");break;case"scatter.plot":this.CreateScatterChart(i,"plot");break;case"scatter.line":this.CreateScatterChart(i,"line");break;default:this.Clear();break}}Clear(){this.chart_data={type:"null"}}CreateColumnChart(e,t){let i=this.TransformSeriesData(e[0]),r=this.CommonData(i),s;if(e[1]){s=(e[1].type===8?N.Flatten(e[1].value):N.Flatten(e[1])).map(d=>d?d.type===5&&d.value.type==="metadata"?typeof d.value.value=="number"?L.Get(d.value.format||qi).Format(d.value.value):d.value.value:typeof d.value=="number"?L.Get(d.format||qi).Format(d.value):d.value:"");let l=i.reduce((d,u)=>Math.max(d,u.y.data.length),0);for(l<s.length&&(s=s.slice(0,l));l>s.length;)s.push("")}let n=e[2]?.toString()||void 0,o=e[3]?.toString()||void 0;if(this.chart_data={type:t,legend:r.legend,legend_style:1,series2:i,scale:r.y.scale,title:n,y_labels:t==="bar"?s:r.y.labels,x_labels:t==="bar"?r.y.labels:s},o){this.chart_data.round=/round/i.test(o),this.chart_data.data_labels=/labels/i.test(o);let a=o.match(/labels="(.*?)"/);a&&i?this.ApplyLabels(i,a[1],s):(a=o.match(/labels=([^\s\r\n,]+)(?:\W|$)/),a&&i&&this.ApplyLabels(i,a[1],s)),a=o.match(/class=([\w_-]+)(?:\W|$)/),a&&(this.chart_data.class_name=a[1])}}ReadSeries(e){let t={x:{data:[]},y:{data:[]}};if(e[3]&&typeof e[3]=="number"&&(t.index=e[3]),e[4]&&(t.subtype=e[4].toString()),e[0]){let i=N.Flatten(e[0]);typeof i[0]=="object"?t.label=i[0]?.value?.toString()||"":t.label=i[0].toString()}if(!!e[2]&&typeof e[2]=="object"&&e[2].type===8){let i=N.Flatten(e[2].value);if(t.y.data=i.map(r=>typeof r.value.value=="number"?r.value.value:void 0),i[0].value?.format){t.y.format=i[0].value?.format;let r=L.Get(t.y.format);t.y.labels=t.y.data.map(s=>s===void 0?void 0:r.Format(s))}}if(!!e[1]&&typeof e[1]=="object"&&e[1].type===8){let i=N.Flatten(e[1].value);t.x.data=i.map(r=>typeof r.value.value=="number"?r.value.value:void 0),i[0].value.format&&(t.x.format=i[0].value.format)}for(let i of[t.x,t.y])if(i.data.length){let r=i.data.filter(s=>s||s===0);i.range={min:Math.min.apply(0,r),max:Math.max.apply(0,r)}}return t}ArrayToSeries(e){let t={x:{data:[]},y:{data:[]}},i=N.Flatten(e.value);if(t.y.data=i.map((s,n)=>typeof s.value=="number"?s.value:typeof s.value.value?.real=="number"?(t.x.data[n]=s.value.value.real,s.value.value.imaginary):typeof s.value.value=="number"?s.value.value:void 0),i[0].value.format){t.y.format=i[0].value.format||"";let s=L.Get(t.y.format||"");t.y.labels=t.y.data.map(n=>n===void 0?void 0:s.Format(n))}let r=t.y.data.filter(s=>s||s===0);if(t.y.range={min:Math.min.apply(0,r),max:Math.max.apply(0,r)},t.x.data.length){let s=t.x.data.filter(n=>typeof n=="number");if(t.x.range={min:Math.min.apply(0,s),max:Math.max.apply(0,s)},i[0].value.format){t.x.format=i[0].value.format||"";let n=L.Get(t.x.format||"");t.x.labels=t.x.data.map(o=>o===void 0?void 0:n.Format(o))}}return t}TransformSeriesData(e,t){if(!e)return[];let i=[];if(e.type===5){if(e.key==="group"){if(Array.isArray(e.value)){for(let n of e.value)if(!!n&&typeof n=="object")if(n.key==="series"){let o=this.ReadSeries(n.value);i.push(o)}else n.type===8&&i.push(this.ArrayToSeries(n))}}else if(e.key==="series"){let n=this.ReadSeries(e.value);i.push(n)}}else e.type===8&&i.push(this.ArrayToSeries(e));let r,s=0;if(t?.type===8){let n=N.Flatten(t.value),o="0.00###";n[0]&&n[0].type===5&&(o=n[0].value.format);let a=n.map(d=>{if(d.type===3)return d.value;if(d.type===5)return d.value.value}),l=a.filter(d=>typeof d=="number");r={data:a,format:o,range:{min:Math.min.apply(0,l),max:Math.max.apply(0,l)}}}for(let n of i)s=Math.max(s,n.y.data.length),n.x.data.length&&(r||(r=n.x));if(!r){r={data:[],range:{min:0,max:Math.max(0,s-1)}};for(let n=0;n<s;n++)r.data.push(n)}for(let n of i)n.x.data.length||(n.x=r);return i}CommonData(e,t,i){let r="",s="";for(let _ of e)_.y.format&&!s&&(s=_.y.format),_.x.format&&!r&&(r=_.x.format);let n;e.some(_=>_.label&&_.label.length>0)&&(n=e.map((_,y)=>({label:_.label||`Series ${y+1}`,index:typeof _.index=="number"?_.index:y+1})));let o=e.filter(_=>_.x.range),a=Math.min.apply(0,o.map(_=>_.x.range?.min||0)),l=Math.max.apply(0,o.map(_=>_.x.range?.max||0)),d=e.filter(_=>_.y.range),u=Math.min.apply(0,o.map(_=>_.y.range?.min||0)),h=Math.max.apply(0,o.map(_=>_.y.range?.max||0));typeof t<"u"&&(u=Math.min(u,t)),typeof i<"u"&&(h=Math.max(h,i));let p=N.Scale(a,l,7),f=N.Scale(u,h,7),m,b;if(r){m=[];let _=L.Get(r);for(let y=0;y<=p.count;y++)m.push(_.Format(p.min+y*p.step))}if(s){b=[];let _=L.Get(s);for(let y=0;y<=f.count;y++)b.push(_.Format(f.min+y*f.step))}return{x:{format:r,scale:p,labels:m},y:{format:s,scale:f,labels:b},legend:n}}CreateScatterChart(e,t="plot"){let i=this.TransformSeriesData(e[0]),r=this.CommonData(i),s=e[1]?.toString()||void 0,n=e[2]?.toString()||void 0;if(this.chart_data={legend:r.legend,style:t,type:"scatter2",series:i,title:s,x_scale:r.x.scale,x_labels:r.x.labels,y_scale:r.y.scale,y_labels:r.y.labels,lines:t==="line",points:t==="plot"},n){this.chart_data.markers=/marker/i.test(n),this.chart_data.smooth=/smooth/i.test(n),this.chart_data.data_labels=/labels/i.test(n);let o=n.match(/labels="(.*?)"/);o&&this.chart_data.series?this.ApplyLabels(this.chart_data.series,o[1]):(o=n.match(/labels=([^\s\r\n,]+)(?:\W|$)/),o&&this.chart_data.series&&this.ApplyLabels(this.chart_data.series,o[1])),o=n.match(/class=([\w_-]+)(?:\W|$)/),o&&(this.chart_data.class_name=o[1])}}ApplyLabels(e,t,i){for(let r of e){let s={x:L.Get(r.x.format||""),y:L.Get(r.y.format||"")};r.y.labels=[];for(let n=0;n<r.y.data.length;n++){let o=i?i[n]:typeof r.x.data[n]=="number"?s.x.Format(r.x.data[n]):"",a=typeof r.y.data[n]=="number"?s.y.Format(r.y.data[n]):"";r.y.labels[n]=t.replace(/\bx\b/g,o).replace(/\by\b/g,a)}}}CreateLineChart(e,t){let i=this.TransformSeriesData(e[0],e[1]),r=this.CommonData(i,0,0),s=e[2]?.toString()||void 0,n=e[3]?.toString()||void 0;if(this.chart_data={legend:r.legend,type:"scatter2",series:i,title:s,x_scale:r.x.scale,x_labels:r.x.labels,y_scale:r.y.scale,y_labels:r.y.labels,lines:!0,filled:t==="area"},n){this.chart_data.smooth=/smooth/i.test(n);let o=n.match(/class=([\w_-]+)(?:\W|$)/);o&&(this.chart_data.class_name=o[1])}}CreateDonut(e,t=!1){let i=e[0]?.type===8?e[0].value:e[0],r=N.Flatten(i),s=r.map(_=>typeof _.value.value=="number"?_.value.value:void 0),n=e[1]?.type===8?e[1].value:e[1],o=N.Flatten(n).map(_=>{if(_&&typeof _=="object"){let y=_.value?.value;return typeof y=="number"&&_.value?.format?L.Get(_.value?.format).Format(y):y?y.toString():""}else return _?_.toString():""});s=s.map(_=>_<0?(console.warn("pie/donut chart does not support negative values (omitted)"),0):_);let a=e[2]||"",l=0,d=s.map((_,y)=>(typeof _<"u"&&(l+=_),{value:_,label:o[y]||"",index:y+1,percent:0}));if(l)for(let _ of d)_.percent=(_.value||0)/l;let u=r.length&&r[0].value?.format?r[0].value.format:"",h=L.Get(u||qi),p=L.Get("percent");typeof e[4]>"u"&&e[1]&&(e[4]="label");let f=e[4]||"";if(f)for(let _ of d){let y=h.Format(_.value||0),x=p.Format(_.percent);_.title=f.replace(/value%/ig,p.Format(_.value||0)).replace(/value/ig,y).replace(/percent/ig,x).replace(/label/ig,_.label||"").trim()}let m=(e[3]||"").toString().trim(),b=m.toUpperCase();if(b==="ASC"||b==="ASCENDING"||b==="INC")d.sort((_,y)=>(_.value||0)-(y.value||0));else if(b==="DESC"||b==="DESCENDING"||b==="DEC")d.sort((_,y)=>(y.value||0)-(_.value||0));else{let _=m.match(/sort=([\w]+)(?:\W|$)/i);_&&(b=_[1],/^(asc|inc)/i.test(b)?d.sort((y,x)=>(y.value||0)-(x.value||0)):/^(desc|dec)/i.test(b)&&d.sort((y,x)=>(x.value||0)-(y.value||0)))}if(this.chart_data={type:t?"pie":"donut",slices:d,title:a},m){let _=m.match(/class=([_-\w]+)(?:\W|$)/);_&&(this.chart_data.class_name=_[1])}}Resize(){this.renderer.Resize()}Update(){this.renderer.Resize(),this.renderer.Prerender(),this.renderer.Clear(this.chart_data.class_name);let e=new ke(0,0,this.renderer.size.width,this.renderer.size.height),t={top:Math.round(e.height)*this.margin.top,bottom:Math.round(e.height)*this.margin.bottom,left:Math.round(e.width)*this.margin.left,right:Math.round(e.width)*this.margin.right},i=this.chart_data.title;if(i&&this.renderer.RenderTitle(i,e,t.top,this.chart_data.title_layout||"top"),e.top+=t.top,e.left+=t.left,e.bottom-=t.bottom,e.right-=t.right,this.chart_data.legend&&this.chart_data.legend.length){let r=0;this.chart_data.title&&(!this.chart_data.title_layout||this.chart_data.title_layout==="top")&&(r=1);let s=this.chart_data.legend_position||r;this.renderer.Legend({labels:this.chart_data.legend,position:s,style:this.chart_data.legend_style,layout:s===0||s===1?0:1,area:e})}if(this.chart_data.type==="histogram"||this.chart_data.type==="line"||this.chart_data.type==="area"||this.chart_data.type==="column"||this.chart_data.type==="histogram2"||this.chart_data.type==="bar"||this.chart_data.type==="scatter2"){let r=[],s=0;if(this.chart_data.x_labels&&this.chart_data.x_labels.length&&(r=this.chart_data.x_labels.map(n=>{let o=this.renderer.MeasureText(n,["axis-label","x-axis-label"],!0);return s=Math.max(s,o.height),o})),this.chart_data.y_labels&&this.chart_data.y_labels.length){let n=[],o=0,a=0,l=this.chart_data.type==="scatter2"?this.chart_data.y_scale:this.chart_data.scale,d=this.chart_data.type==="bar"?this.chart_data.y_labels.length:l.count+1;for(let u=0;u<d;u++){let h=this.renderer.MeasureText(this.chart_data.y_labels[u],["axis-label","y-axis-label"]);n.push({label:this.chart_data.y_labels[u],metrics:h}),o=Math.max(o,h.width),a=Math.max(a,h.height)}e.bottom=Math.round(e.bottom-a/2),e.top=Math.round(e.top+a/2),r.length&&(e.bottom-=s+t.bottom),this.chart_data.type==="bar"?this.renderer.RenderYAxisBar(e,e.left+o,n,["axis-label","y-axis-label"]):this.renderer.RenderYAxis(e,e.left+o,n,["axis-label","y-axis-label"]),e.left+=o+t.left}if(r.length&&this.chart_data.x_labels&&this.chart_data.x_labels.length){let n=this.chart_data.type==="histogram2",o=this.chart_data.type!=="line"&&this.chart_data.type!=="area"&&this.chart_data.type!=="bar"&&this.chart_data.type!=="scatter2"&&this.chart_data.type!=="histogram2";n&&this.renderer.RenderXAxisTicks(e,o,this.chart_data.x_labels.length),this.chart_data.y_labels&&(e.bottom+=s+t.bottom),this.renderer.RenderXAxis(e,o,this.chart_data.x_labels,r,["axis-label","x-axis-label"]),e.bottom-=s+t.bottom}}switch(this.chart_data.type){case"scatter":this.renderer.RenderPoints(e,this.chart_data.x,this.chart_data.y,"mc mc-correlation series-1");break;case"scatter2":if(this.renderer.RenderGrid(e,this.chart_data.y_scale.count,this.chart_data.x_scale.count+1,"chart-grid"),this.chart_data.series){for(let r=0;r<this.chart_data.series.length;r++){let s=this.chart_data.series[r],n=!!this.chart_data.lines,o=!!this.chart_data.points;s.subtype==="plot"?(o=!0,n=!1):s.subtype==="line"&&(o=!1,n=!0);let a=typeof s.index=="number"?s.index:r+1;this.renderer.RenderScatterSeries(e,s.x.data,s.y.data,this.chart_data.x_scale,this.chart_data.y_scale,n,o,!!this.chart_data.filled,!!this.chart_data.markers,!!this.chart_data.smooth,`scatter-plot series-${a}`)}if(this.chart_data.data_labels)for(let r=0;r<this.chart_data.series.length;r++){let s=this.chart_data.series[r];s.y.labels&&this.renderer.RenderDataLabels(e,s.x.data,s.y.data,this.chart_data.x_scale,this.chart_data.y_scale,s.y.labels,r+1)}}break;case"pie":case"donut":{let r=Math.min(e.height,e.width)/2*.9,s=this.chart_data.type==="pie"?0:r*.8;this.renderer.RenderDonut(this.chart_data.slices,e.center,r,s,e,!0,"donut")}break;case"line":case"area":{let r=this.chart_data.scale;if(this.chart_data.series){let s=this.chart_data.x_scale?this.chart_data.x_scale.max:Math.max.apply(0,this.chart_data.series.map(a=>a.length)),n=this.chart_data.smooth?this.renderer.RenderSmoothLine:this.renderer.RenderLine;this.renderer.RenderGrid(e,this.chart_data.scale.count,this.chart_data.x_scale?this.chart_data.x_scale.count+1:s,"chart-grid");let o=0;for(let a of this.chart_data.series){let l=a.map(u=>{if(!(typeof u>"u"))return N.ApplyScale(u,e.height,r)});if(l.length<s)for(let u=l.length;u<s;u++)l.push(void 0);let d=[this.chart_data.type==="area"?"chart-area":"chart-line",`series-${o+1}`];n.call(this.renderer,e,l,this.chart_data.type==="area",this.chart_data.titles,d),o++}}}break;case"bar":{let r;if(this.renderer.RenderBarGrid(e,this.chart_data.scale.count,"chart-grid"),this.chart_data.series2){let s=0,n=this.chart_data.series2.length;for(let h of this.chart_data.series2)s=Math.max(s,h.y.data.length);let o=e.height/s,a=.7;typeof this.chart_data.space=="number"&&(a=Math.max(0,Math.min(1,1-this.chart_data.space)));let l=o*(1-a)/2,d=(o-l*2)/n,u=0;if(this.chart_data.scale.min<0&&(u=N.ApplyScale(0,e.width,this.chart_data.scale)),this.chart_data.round){let h=Math.floor(d/2);r=[0,h,h,0]}for(let h=0;h<n;h++){let p=this.chart_data.series2[h],f=typeof p.index=="number"?p.index:h+1;for(let m=0;m<p.y.data.length;m++){let b=p.y.data[m];if(typeof b=="number"){let _=Math.round(e.top+m*o+l)+h*d,y=0,x=0,v=!1;u?b>0?(x=N.ApplyScale(b+this.chart_data.scale.min,e.width,this.chart_data.scale),y=e.left+u):(x=N.ApplyScale(this.chart_data.scale.min-b,e.width,this.chart_data.scale),y=e.left+u-x,v=!0):(x=N.ApplyScale(b,e.width,this.chart_data.scale),y=e.left);let w=void 0;x&&this.renderer.RenderRectangle(new ke(y,_,y+x,_+d),r,["chart-column",`series-${f}`],w||void 0)}}}}}break;case"column":case"histogram2":if(this.renderer.RenderGrid(e,this.chart_data.scale.count,0,"chart-grid"),this.chart_data.series2){let r=0,s=this.chart_data.series2.length;for(let h of this.chart_data.series2)r=Math.max(r,h.y.data.length);let n=e.width/r,o=.7;typeof this.chart_data.space=="number"&&(o=Math.max(0,Math.min(1,1-this.chart_data.space)));let a=n*(1-o)/2,l=(n-a*2)/s,d=0;if(this.chart_data.scale.min<0&&(d=N.ApplyScale(0,e.height,this.chart_data.scale)),this.chart_data.callouts&&this.chart_data.x_scale){let h=this.chart_data.x_scale,p=this.chart_data.callouts.map((f,m)=>{let b=Math.round(e.left+N.ApplyScale(f.value,e.width,h))+.5;return{x1:b,y1:e.bottom-e.height,x2:b,y2:e.bottom,classes:`callout-${m+1}`}});this.renderer.RenderCalloutLines(p)}let u;if(this.chart_data.round){let h=Math.floor(l/2);u=[h,h,0,0]}for(let h=0;h<s;h++){let p=this.chart_data.series2[h],f=typeof p.index=="number"?p.index:h+1;for(let m=0;m<p.y.data.length;m++){let b=p.y.data[m];if(typeof b=="number"){let _=e.left+m*n+a+h*l,y=0,x=0,v=!1;d?b>0?(y=N.ApplyScale(b+this.chart_data.scale.min,e.height,this.chart_data.scale),x=e.bottom-y-d):(y=N.ApplyScale(this.chart_data.scale.min-b,e.height,this.chart_data.scale),x=e.bottom-d,v=!0):(y=N.ApplyScale(b,e.height,this.chart_data.scale),x=e.bottom-y);let w=void 0;if(y){let C=this.chart_data.data_labels&&!!p.y.labels?p.y.labels[m]:"",S={x:Math.round(_+l/2),y:Math.round(x-10)};this.renderer.RenderRectangle(new ke(_,x,_+l,x+y),u,["chart-column",`series-${f}`],w||void 0,C,S)}}}}}break;case"histogram":{this.renderer.RenderGrid(e,this.chart_data.scale.count,0,"chart-grid");let r=e.width/this.chart_data.count,s=this.chart_data.column_width,n=r*(1-s)/2;for(let o=0;o<this.chart_data.count;o++){let a=Math.round(e.left+o*r+n),l=r-n*2,d=N.ApplyScale(this.chart_data.bins[o],e.height,this.chart_data.scale),u=e.bottom-d,h=this.chart_data.titles?this.chart_data.titles[o]:void 0;this.renderer.RenderRectangle(new ke(a,u,a+l,u+d),void 0,"chart-column series-1",h||void 0)}}break}}IsCellData(e){return typeof e=="object"&&typeof e.address=="object"&&typeof e.address.row=="number"&&typeof e.address.column=="number"}};E(Ze,"functions_registered",!1);var Le=(...c)=>({type:5,value:c,key:"arguments"}),Xi={Group:{arguments:[{name:"Array...",metadata:!0}],fn:(...c)=>({type:5,value:c,key:"group"})},Series:{arguments:[{name:"Label"},{name:"X",metadata:!0},{name:"Y",metadata:!0},{name:"index"},{name:"subtype"}],fn:(...c)=>({type:5,value:c,key:"series"})},"Bar.Chart":{arguments:[{name:"Data",metadata:!0},{name:"Categories",metadata:!0},{name:"ChartTitle"}],fn:Le},"Line.Chart":{arguments:[{name:"y",metadata:!0},{name:"x",metadata:!0},{name:"ChartTitle"}],fn:Le},"Area.Chart":{arguments:[{name:"y",metadata:!0},{name:"x",metadata:!0},{name:"ChartTitle"}],fn:Le},"Pie.Chart":{arguments:[{name:"Values",metadata:!0},{name:"Labels"},{name:"Title"},{name:"Sort"},{name:"Label"}],fn:Le},"Donut.Chart":{arguments:[{name:"Values",metadata:!0},{name:"Labels",metadata:!0},{name:"Title"},{name:"Sort"},{name:"Label"}],fn:Le},"Scatter.Line":{arguments:[{name:"Data",metadata:!0},{name:"ChartTitle"}],fn:Le},"Scatter.Plot":{arguments:[{name:"Data",metadata:!0},{name:"ChartTitle"}],fn:Le},"Column.Chart":{arguments:[{name:"Data",metadata:!0},{name:"Categories",metadata:!0},{name:"Chart Title"}],fn:Le}};var Zi=hs(is());var Oe=class{loaded=!1;toolbar_ctl;get Localization(){return T}language_model;events=new Q;calculation=0;file_version=0;last_save_version=0;calculator;grid;model;options;dialog;spinner;file_chooser;file_chooser_operation=0;toolbar;selection_state;get parser(){return this.calculator.parser}view;key_listener;node;views=[];focus_target=this;export_worker;undo_pointer=0;undo_stack=[];last_selection;get modified(){return this.undo_stack.length!==1}get document_name(){return this.grid.model.document_name}set document_name(e){this.grid.model.document_name=e,this.DocumentChange()}get user_data(){return this.grid.model.user_data}set user_data(e){this.grid.model.user_data=e,this.DocumentChange()}get scale(){return this.grid.scale}set scale(e){this.grid.scale=e}get headless(){return this.grid.headless}set headless(e){this.grid.headless!==e&&(this.grid.headless=e,e||(this.grid.Update(!0),this.RebuildAllAnnotations()))}get state(){return this.file_version}get dirty(){return this.file_version!==this.last_save_version}constructor(e){this.options={...ei,...e},typeof this.options.imaginary_value=="string"&&(X.imaginary_character=this.options.imaginary_value);let t=this.options.network_document,i,r;this.options.storage_key&&!this.options.toll_initial_load&&!e.model&&(i=localStorage.getItem(this.options.storage_key)||void 0,i&&(r="local-storage"),!i&&this.options.alternate_document&&(t=this.options.alternate_document),window.addEventListener("beforeunload",()=>{this.options.storage_key&&this.SaveLocalStorage(this.options.storage_key)}));let s;typeof this.options.container=="string"?s=document.getElementById(this.options.container):this.options.container&&(s=this.options.container);let n={insert_function_button:!1,in_cell_editor:!0,repaint_on_cell_change:!1,scrollbars:this.options.scrollbars,markdown:!!this.options.markdown,formula_bar:this.options.formula_bar,expand_formula_button:this.options.expand_formula_button,tab_bar:this.options.tab_bar,add_tab:this.options.add_tab,delete_tab:this.options.delete_tab,expand:this.options.expand};if(this.options.scale&&(n.initial_scale=this.options.scale),this.options.stats&&(n.stats=this.options.stats,n.tab_bar=!0),this.options.scale_control&&(n.scale_control=!0,n.tab_bar=!0,this.options.persist_scale)){this.options.persist_scale===!0?n.persist_scale_key="spreadsheet-scale":n.persist_scale_key="spreadsheet-scale-"+this.options.persist_scale;let o=localStorage.getItem(n.persist_scale_key);if(o)try{let a=JSON.parse(o);n.initial_scale=a.scale||1}catch{console.warn("parsing persisted scale failed")}}if(e.model?(this.model=e.model.model,this.calculator=e.model.calculator):(this.model=new ht,this.model.sheets.Add(j.Blank(this.model.theme_style_properties)),this.calculator=this.CreateCalculator(this.model)),this.grid=new dt(n,this.parser,this.model),this.options.headless&&(this.grid.headless=!0),s){this.view=document.createElement("div"),this.view.classList.add("treb-view"),this.node=document.createElement("div"),this.view.appendChild(this.node),s.appendChild(this.view),this.node.addEventListener("focusin",()=>{this.focus_target=this}),this.key_listener=this.HandleKeyDown.bind(this),s.addEventListener("keydown",this.key_listener);let o=!!(i||this.options.network_document);this.grid.Initialize(this.node,o),this.options.dnd&&(this.node.addEventListener("dragenter",a=>this.HandleDrag(a)),this.node.addEventListener("dragover",a=>this.HandleDrag(a)),this.node.addEventListener("drop",a=>this.HandleDrop(a))),this.grid.grid_events.Subscribe(a=>{switch(a.type){case"error":this.dialog?.ShowDialog({type:"error",...this.TranslateGridError(a.code),timeout:3e3,close_box:!0});break;case"selection":this.UpdateSelection(a.selection),this.UpdateSelectionStyle(a.selection);break;case"sheet-change":this.OnSheetChange(a),this.UpdateSelectionStyle();break;case"data":{let l=this.last_selection;(this.calculation===0?this.Recalculate(a):Promise.resolve()).then(()=>{this.DocumentChange(l)})}break;case"style":this.DocumentChange(),this.UpdateDocumentStyles(!1),this.UpdateSelectionStyle();break;case"scale":this.RebuildAllAnnotations();break;case"annotation":if(a.annotation){let l=a.annotation.view[this.grid.view_index]||{};switch(this.DocumentChange(),a.event){case"create":this.InflateAnnotation(a.annotation),this.calculator.UpdateAnnotations(a.annotation,this.grid.active_sheet),this.grid.AnnotationUpdated(a.annotation);break;case"delete":this.calculator.RemoveAnnotation(a.annotation);break;case"update":l.update_callback?(l.update_callback(),this.grid.AnnotationUpdated(a.annotation)):console.info("annotation update event without update callback"),this.calculator.UpdateAnnotations(a.annotation,this.grid.active_sheet);break;case"resize":l.resize_callback&&(l.resize_callback(),this.grid.AnnotationUpdated(a.annotation));break}}else console.info("annotation event without annotation");break;case"structure":{let l=this.last_selection;a.rebuild_required?(this.calculator.Reset(),(this.calculation===0?this.Recalculate(a):Promise.resolve()).then(()=>{this.DocumentChange(l)})):this.DocumentChange(l)}this.UpdateSelectionStyle();break;case"cell-event":this.HandleCellEvent(a);break}}),this.options.prompt_save&&window.addEventListener("beforeunload",a=>{this.last_save_version!==this.file_version&&(a.preventDefault(),a.returnValue="")})}else console.info("not initializing grid; don't call UI functions"),this.grid.headless=!0;if(i?this.LoadDocument(JSON.parse(i),{recalculate:!!this.options.recalculate,source:r}):t||this.calculator.RebuildClean(!0),this.FlushUndo(),this.grid.ShowHeaders(this.options.headers),this.options.scroll&&!this.options.network_document){let o=this.options.scroll;requestAnimationFrame(()=>{this.ScrollTo(o)})}this.UpdateAC(),this.options.global_name&&(self[this.options.global_name]=this),s&&this.options.spinner&&(this.spinner=new Qt(s)),t&&!e.model&&this.LoadNetworkDocument(t,this.options),s&&(this.dialog=new bt(s))}static BuildPath(){let e=typeof document>"u"?[]:document.querySelectorAll("script"),t="treb-bundle",i=new RegExp(t);for(let r=0;r<e.length;r++){let n=e[r].src;if(n&&i.test(n)){n&&/\?.*?engine/i.test(n)&&(this.enable_engine=!0),n&&/\?.*?format/i.test(n)&&(this.enable_formatter=!0),this.treb_embedded_script_path=n,this.treb_base_path=n.replace(new RegExp(t+".*$"),"");return}}i=new RegExp(`import.*?from.*?['"](.*?${t}.*?)['"]`);for(let r=0;r<e.length;r++){let s=e[r];if(!s.src){let o=(s.textContent||"").match(i);if(o){let a=o[1];this.treb_embedded_script_path=a,this.treb_base_path=a.replace(new RegExp(t+".*$"),"");return}}}}UpdateAC(){let e=this.calculator.SupportedFunctions();if(this.language_model){let t={};for(let i of this.language_model.functions||[])t[i.base.toUpperCase()]=i;e=e.map(i=>t[i.name.toUpperCase()]||i)}this.grid.SetAutocompleteFunctions(e)}CreateCalculator(e){return new Zt(e)}TranslateGridError(e){switch(e){case 0:return{message:"No error"};case 2:return{message:"You can't change part of an array"};case 3:return{message:"Invalid value (data validation)"};default:return{message:`Unknown error (${e})`}}}CreateView(){return new Oe({...this.options,global_name:void 0,model:this})}Unsplit(){let e=this.views.pop();if(e){let t=e.view;t.grid.grid_events.CancelAll(),t.events.CancelAll(),t.view?.parentElement&&(t.key_listener&&t.view.parentElement.removeEventListener("keydown",t.key_listener),t.view.parentElement.removeChild(t.view)),this.node?.focus()}}Split(){let e=this.CreateView();e.grid.EnsureActiveSheet(!0),e.node?.addEventListener("focusin",()=>{this.focus_target=e}),e.grid.grid_events.Subscribe(i=>{i.type==="structure"&&(this.grid.EnsureActiveSheet(),this.grid.UpdateLayout(),this.grid.tab_bar?.Update())}),e.Subscribe(i=>{switch(i.type){case"selection":break;default:e.UpdateAnnotations(),this.grid.Update(!0)}}),this.grid.grid_events.Subscribe(i=>{i.type==="structure"&&(e.grid.EnsureActiveSheet(),e.grid.UpdateLayout(),e.grid.tab_bar?.Update())});let t=this.Subscribe(i=>{switch(i.type){case"selection":break;case"load":e.grid.EnsureActiveSheet(!0),e.UpdateAnnotations(),e.grid.Update(!0);break;default:e.UpdateAnnotations(),e.grid.Update(!0)}});this.views.push({view:e,subscription:t})}HandleToolbarEvent(e){let t={},i=r=>{let s=this.grid.GetSelection();if(s&&!s.empty){let n=s.area.spreadsheet_label;this.InsertAnnotation(`=${r}(${n},,"${n}")`)}};if(e.type==="format")t.number_format=e.format||"General";else if(e.type==="font-size"){let r=this.grid.GetSelection(),s=this.grid.active_sheet.RealArea(r.area);this.grid.ApplyStyle(void 0,e.style,!0);let n=[];for(let o=s.start.row;o<=s.end.row;o++)n.push(o);this.grid.SetRowHeight(n,void 0,!1)}else if(e.type==="button")switch(e.command){case"font-scale":{let r=this.grid.GetSelection(),s=this.grid.active_sheet.RealArea(r.area),n=Number(e.data?.scale||1);if(n&&!isNaN(n)){this.grid.ApplyStyle(void 0,{font_size:{unit:"em",value:n}},!0);let o=[];for(let a=s.start.row;a<=s.end.row;a++)o.push(a);this.selection_state?.merge||this.grid.SetRowHeight(o,void 0,!1)}}break;case"update-comment":this.SetNote(void 0,e.data?.comment||"");break;case"clear-comment":this.SetNote(void 0,"");break;case"border":{let r=1,s=(e.data?.border||"").replace(/^border-/,"");s==="double-bottom"&&(s="bottom",r=2),s&&this.grid.ApplyBorders2(void 0,s,e.data?.color||void 0,r)}break;case"color":case"background-color":case"foreground-color":case"border-color":switch(e.data?.target){case"border":t.border_top_fill=t.border_bottom_fill=t.border_left_fill=t.border_right_fill=e.data?.color||{};break;case"foreground":t.text=e.data?.color||{theme:1};break;case"background":t.fill=e.data?.color||{};break}break;case"insert-row":this.InsertRows();break;case"insert-column":this.InsertColumns();break;case"delete-row":this.DeleteRows();break;case"delete-column":this.DeleteColumns();break;case"insert-sheet":this.grid.InsertSheet();break;case"delete-sheet":this.grid.DeleteSheet();break;case"freeze":{let r=this.grid.GetFreeze();r.rows||r.columns?this.Freeze(0,0):this.FreezeSelection()}break;case"insert-image":this.InsertImage();break;case"donut-chart":i("Donut.Chart");break;case"column-chart":i("Column.Chart");break;case"bar-chart":i("Bar.Chart");break;case"line-chart":i("Line.Chart");break;case"increase-decimal":case"decrease-decimal":if(this.selection_state?.style){let r=L.Get(this.selection_state.style.number_format||"General");if(r.date_format)break;let s=new X(r.pattern);if(r.magic_decimal){let n=0,o=this.GetRange();Array.isArray(o)||(o=[[o]]);e:for(let a=0;a<o.length;a++)for(let l=0;l<o[a].length;l++){let d=o[a][l];if(typeof d<"u"&&ge(d)){let u=L.Get(this.selection_state.style.number_format||"General",!0),h=u.BaseFormat(d.real),p=u.BaseFormat(d.imaginary);h.parts&&typeof h.parts[1]=="string"&&(n=h.parts[1].length),p.parts&&typeof p.parts[1]=="string"&&(n=Math.max(n,p.parts[1].length));break e}else if(typeof d=="number"){let u=r.BaseFormat(d);u.parts&&typeof u.parts[1]=="string"&&(n=u.parts[1].length);break e}}e.command==="increase-decimal"?s.SetDecimal(n+1):s.SetDecimal(Math.max(0,n-1))}else e.command==="increase-decimal"?s.IncreaseDecimal():s.DecreaseDecimal();t.number_format=s.toString()}break;case"merge":this.grid.MergeCells();break;case"unmerge":this.grid.UnmergeCells();break;case"lock":t={locked:this.selection_state?.style?!this.selection_state.style.locked:!0};break;case"wrap":t={wrap:this.selection_state?.style?!this.selection_state?.style.wrap:!0};break;case"align-left":t={horizontal_align:A.HorizontalAlign.Left};break;case"align-center":t={horizontal_align:A.HorizontalAlign.Center};break;case"align-right":t={horizontal_align:A.HorizontalAlign.Right};break;case"align-top":t={vertical_align:A.VerticalAlign.Top};break;case"align-middle":t={vertical_align:A.VerticalAlign.Middle};break;case"align-bottom":t={vertical_align:A.VerticalAlign.Bottom};break;case"reset":this.Reset();break;case"import-desktop":this.LoadLocalFile();break;case"save-json":this.SaveLocalFile();break;case"save-csv":this.SaveLocalFile("csv");break;case"export-xlsx":this.Export();break;case"recalculate":this.Recalculate();break;default:console.info("unhandled",e.command);break}Object.keys(t).length&&this.grid.ApplyStyle(void 0,t,!0),this.Focus()}CreateToolbar(e){return this.toolbar=new ti(e,this.options,this.grid.theme),this.toolbar.Subscribe(t=>this.focus_target.HandleToolbarEvent(t)),this.UpdateDocumentStyles(!1),this.UpdateSelectionStyle(void 0),this.toolbar}CreateChart(){return this.calculator.RegisterLibrary("treb-charts",Xi)&&this.UpdateAC(),new Ze}SetLanguage(e){if(this.language_model=e,!e)this.grid.SetLanguageMap();else{let t={};for(let i of e.functions||[])t[i.base]=i.name;this.grid.SetLanguageMap(t)}this.UpdateAC()}async Batch(e,t=!1){let i=this.last_selection,r=this.grid.Batch(e,t),s=!1,n=!1;for(let o of r)o.type==="data"?s=!0:o.type==="structure"&&o.rebuild_required&&(n=!0);n&&this.calculator.Reset(),(s||n)&&(await this.Recalculate(),this.DocumentChange(i))}Freeze(e=0,t=0){this.grid.Freeze(e,t,!0)}FreezeSelection(){let e=this.grid.GetSelection();if(e.empty)this.grid.Freeze(0,0);else{let t=e.area;t.entire_sheet||(t.entire_row?this.grid.Freeze(t.end.row+1,0):t.entire_column?this.grid.Freeze(0,t.end.column+1):this.grid.Freeze(t.end.row+1,t.end.column+1))}}GetFreeze(){return this.grid.GetFreeze()}UpdateTheme(){this.grid.UpdateTheme(void 0),this.toolbar&&this.toolbar.UpdateTheme(this.grid.theme)}GetSheetID(e){if(typeof e=="number"){let t=this.grid.model.sheets.list[e];if(t)return t.id}else{let t=this.model.sheets.Find(e);if(t)return t.id}}AddSheet(e){this.grid.AddSheet(e),this.calculator.Reset()}InsertAnnotation(e,t="treb-chart",i){let r;i&&(r=z.IsRectangle(i)?i:this.calculator.ResolveArea(i,this.grid.active_sheet));let{x:s,y:n}=this.grid.GetScrollOffset(),o=this.grid.scale||1;this.grid.CreateAnnotation({type:t,formula:e},void 0,void 0,r||{top:n/o+30,left:s/o+30,width:300,height:300})}InsertImage(){this.SelectFile2(".png, .jpg, .jpeg, .gif, .svg",2)}RenameSheet(e,t){let i;typeof e=="number"?i=this.grid.model.sheets.list[e]:typeof e=="string"?i=this.model.sheets.Find(e):i=this.grid.active_sheet,i&&this.grid.RenameSheet(i,t)}DeleteSheet(e){if(typeof e=="string"){let t=this.model.sheets.Find(e);t&&this.grid.DeleteSheetID(t.id)}else this.grid.DeleteSheet(e);this.calculator.Reset()}HideSheet(e=0,t=!0){this.grid.ShowSheet(e,!t)}ShowSheet(e=0,t=!0){this.grid.ShowSheet(e,t)}ActivateSheet(e){this.grid.ActivateSheet(e)}SetColumnWidth(e,t){this.grid.SetColumnWidth(e,t)}SetRowHeight(e,t){this.grid.SetRowHeight(e,t)}InsertRows(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_column?0:r.start.row}this.grid.InsertRows(e,t)}InsertColumns(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_row?0:r.start.column}this.grid.InsertColumns(e,t)}DeleteRows(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_column?0:r.start.row,t=r.rows}this.grid.InsertRows(e,-t)}DeleteColumns(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_row?0:r.start.column,t=r.columns}this.grid.InsertColumns(e,-t)}MergeCells(e){this.grid.MergeCells(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0)}UnmergeCells(e){this.grid.UnmergeCells(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0)}async ExportBlob(){if(!this.export_worker){let e="treb-export-worker";this.export_worker=await this.LoadWorker(e)}return new Promise((e,t)=>{if(this.export_worker){this.export_worker.onmessage=r=>{e(r.data?r.data.blob:void 0)},this.export_worker.onerror=r=>{console.error("export worker error"),console.info(r),t(r)};let i=this.grid.Serialize({rendered_values:!0,expand_arrays:!0,export_colors:!0,decorated_cells:!0});i.decimal_mark=T.decimal_separator,this.export_worker.postMessage({command:"export",sheet:i,decorated:this.calculator.DecoratedFunctionList()})}else t("worker failed")})}Revert(){if(this.options.alternate_document){this.LoadNetworkDocument(this.options.alternate_document),this.options.storage_key&&(this.SaveLocalStorage("reverted_backup"),localStorage.removeItem(this.options.storage_key));return}console.warn("to revert, there must be an alternate_document set in options"),this.dialog?.ShowDialog({title:"Can't revert",close_box:!0,timeout:3e3,type:"error"})}Export(){this.ExportBlob().then(e=>{let t="export";this.grid.model.document_name&&(t=this.grid.model.document_name.toLowerCase().replace(/\s+/g,"-")),e&&(Zi.saveAs(e,t+".xlsx",{autoBom:!1}),this.last_save_version=this.file_version)}).catch(e=>{throw/invalid uri/i.test(e.message)&&this.dialog?.ShowDialog({title:"Error exporting file",close_box:!0,message:"The worker cannot run from the filesystem, please use a web server.",timeout:3e3,type:"error"}),e})}GetSelectionReference(){return this.grid.GetSelection()}Focus(){this.grid.Focus()}Resize(){this.grid.UpdateLayout(),this.Publish({type:"resize"})}Reset(){this.grid.Reset(),this.ResetInternal(),this.calculator.AttachModel(),this.UpdateAC(),this.Publish({type:"reset"})}LoadFromLocalStorage(e){this.options.storage_key=e;let t=localStorage.getItem(e);if(t)try{let i=JSON.parse(t);return this.LoadDocument(i,{source:"local-storage"}),!0}catch(i){console.error(i)}return!1}async LoadNetworkDocument(e,t){let i=t?t.scroll:void 0,r=t?!!t.recalculate:!1,s=t?t.sheet:void 0,n=/csv(?:$|\?|&)/i.test(e),o=/tsv(?:$|\?|&)/i.test(e);try{this.spinner?.Show();let a=await fetch(e);if(this.spinner?.Hide(),!a.ok)throw new Error("network error");let l=await a.text();if(typeof l=="string")if(n)this.LoadCSV(l,"network-file");else{if(o)throw new Error("tsv not supported (TODO)");{l.substr(0,11)==="&&&START&&&"?l=l.substr(11):l.substr(0,8)==="for(;;);"&&(l=l.substr(8));let d=JSON.parse(l);this.LoadDocument(d,{scroll:i,recalculate:r,override_sheet:s,source:"network-file"})}}}catch(a){console.info("error loading network document",e),console.error(a),this.dialog?.ShowDialog({title:"Error loading file",close_box:!0,message:"The network document returned an error",type:"error",timeout:3e3}),this.Reset()}}async LoadLocalFile(){this.SelectFile2(".treb, .csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/json",1)}ExportDelimited(e={}){if(e={delimiter:",",...e},!e.delimiter||e.delimiter!==","&&e.delimiter!==" ")throw new Error("invalid delimiter");let t=this.grid.active_sheet;switch(typeof e.sheet){case"undefined":break;case"string":t=this.model.sheets.Find(e.sheet);break;case"number":t=this.grid.model.sheets.list[e.sheet];break;default:t=void 0;break}if(!t)throw new Error("invalid sheet identifier");let i=t.cells.toJSON({nested:!1,expand_arrays:!0,calculated_value:!0}),r=[];for(let o=0;o<i.columns;o++)r.push("");let s=[];for(let o=0;o<i.rows;o++)s.push(r.slice(0));let n=new RegExp(`[
|
|
12
|
+
`)}</ul>`}UpdateDocumentStyles(t,i,r){let s=["General","Number","Integer","Percent","Fraction","Accounting","Currency","Scientific"],n=["Timestamp","Long Date","Short Date"];for(let a of t){if(L.SymbolicName(L.Translate(a)))continue;L.Get(a).date_format?n.push(a):s.push(a)}this.number_formats=s,this.date_formats=n;let o=this.colors.map(a=>ee.MeasureColor(a));for(let a of i){let l=ee.MeasureColor(a);o.some(d=>d[0]===l[0]&&d[1]===l[1]&&d[2]===l[2])||(this.colors.push(a),o.push(l))}}};var ke=class{constructor(e=0,t=0,i=100,r=100){this.left=e;this.top=t;this.right=i;this.bottom=r}get width(){return this.right-this.left}get height(){return this.bottom-this.top}get center(){return{x:this.left+this.width/2,y:this.top+this.height/2}}};var yt="http://www.w3.org/2000/svg",M=(c,e={},t)=>{let i=document.createElementNS(yt,c);for(let r of Object.keys(e))if(e[r]!==void 0){let s=e[r];i.setAttribute(r,Array.isArray(s)?s.join(" "):s.toString())}return t&&(i.textContent=t),i},ii=class{parent;svg_node;text_measurement_node;container_group;group;axis_group;label_group;size={width:0,height:0};bounds=new ke;constructor(){this.container_group=M("g"),this.group=M("g"),this.axis_group=M("g",{class:"axis-group"}),this.label_group=M("g",{class:"label-group"}),this.container_group.appendChild(this.axis_group),this.container_group.appendChild(this.group),this.container_group.appendChild(this.label_group)}Initialize(e){this.parent=e,this.svg_node=M("svg",{class:"treb-chart"}),this.svg_node.style.overflow="hidden",this.svg_node.style.position="relative",this.svg_node.style.width="100%",this.svg_node.style.height="100%",this.svg_node.appendChild(this.container_group),this.parent.appendChild(this.svg_node),this.Resize()}Legend(e){let t=M("g");this.group.appendChild(t);let i=M("text");t.appendChild(i),t.setAttribute("class","legend");let r=[[]],s=10,n=e.area.width,o=0,a=0,l=e.area.width,d=e.style===1?14:26,u=e.labels.map((b,_)=>{i.textContent=b.label;let y=i.getBoundingClientRect(),x={width:y.width,height:y.height},v=x.width+d+s;return a=Math.max(a,x.height),e.layout===1?r[_]=[_]:v>n?r[o].length===0?(r[o].push(_),o++,r[o]=[],n=l):(o++,r[o]=[_],n=l-v):(r[o].push(_),n-=v),x});t.removeChild(i);let h=a,p=e.layout||0;p===0&&r.every(b=>b.length<=1)&&(p=0);for(let b=0;b<r.length;b++){let _=r[b].reduce((v,w)=>v+u[w].width+d,(r[b].length-1)*s),y=0,x=p===0?Math.round((l-_)/2):Math.round(s/2);for(let v=0;v<r[b].length;v++){let w=r[b][v],C=u[w],S=e.labels[w],U=h-1,J=!1;typeof navigator<"u"&&(J=/trident/i.test(navigator?.userAgent||""));let oe=typeof S.index=="number"?S.index:w+1;t.appendChild(M("text",{"dominant-baseline":"middle",x:x+d,y:h,dy:J?".3em":void 0},S.label)),e.style===1?t.appendChild(M("rect",{class:`series-${oe}`,x,y:U-4,width:8,height:8})):t.appendChild(M("rect",{class:`series-${oe}`,x,y:U-1,width:d-3,height:2})),y=Math.max(y,C.height),x+=C.width+d+s}h=Math.round(h+y*1.1)}let f=t.getBoundingClientRect(),m={width:f.width,height:f.height+a};switch(e.position){case 1:t.setAttribute("transform",`translate(${e.area.left}, ${e.area.bottom-m.height})`);break;case 2:t.setAttribute("transform",`translate(${e.area.left}, ${e.area.top})`);break;case 3:t.setAttribute("transform",`translate(${e.area.right-m.width}, ${e.area.top})`);break;case 0:default:t.setAttribute("transform",`translate(${e.area.left}, ${e.area.top})`)}e.position===0?e.area.top+=m.height||0:e.position===3?e.area.right-=(m.width||0)+8:e.position===2?e.area.left+=(m.width||0)+8:e.area.bottom-=m.height||0}Clear(e){this.group.textContent="",this.axis_group.textContent="",this.label_group.textContent="",e="treb-chart"+(e?" "+e:""),this.svg_node.setAttribute("class",e)}Resize(){let e=this.parent.getBoundingClientRect();this.svg_node.setAttribute("width",e.width.toString()),this.svg_node.setAttribute("height",e.height.toString()),this.size={width:e.width,height:e.height}}Prerender(){let e=this.svg_node.getBoundingClientRect();this.bounds.top=e.top,this.bounds.left=e.left,this.bounds.right=e.right,this.bounds.bottom=e.bottom}RenderTitle(e,t,i,r){let s=M("text",{class:"chart-title",x:Math.round(t.width/2)},e);s.style.textAnchor="middle",this.group.appendChild(s);let n=s.getBoundingClientRect();switch(r){case"bottom":s.setAttribute("y",Math.round(t.bottom-n.height).toString()),t.bottom-=n.height+i;break;default:s.setAttribute("y",Math.round(t.top+i+n.height).toString()),t.top+=n.height+i;break}}MeasureText(e,t,i=!1){this.text_measurement_node||(this.text_measurement_node=M("text",{x:"-100px",y:"-100px"}),this.svg_node.appendChild(this.text_measurement_node)),typeof t<"u"?(typeof t=="string"&&(t=[t]),this.text_measurement_node.setAttribute("class",t.join(" "))):this.text_measurement_node.setAttribute("class",""),this.text_measurement_node.textContent=e;let r=this.text_measurement_node.getBoundingClientRect(),s={width:r.width,height:r.height,y_offset:r.height-(this.bounds.top-r.top-100)};return i&&(s.width=Math.ceil(s.width),s.height=Math.ceil(s.height),s.y_offset=Math.ceil(s.y_offset)),s}RenderTicks(e,t,i,r,s){let n=[],o=e.width/r;for(let a=0;a<r;a++){let l=Math.round(e.left+o/2+o*a)-.5;n.push(`M${l} ${t} L${l} ${i}`)}this.group.appendChild(M("path",{d:n,class:s}))}RenderXAxisBar(e,t,i,r,s){let n=i.length;if(!n)return;let o=4,a=t?e.width/n:e.width/(n-1),l=t?a/2:0,d=1,u=!0;for(;u;){u=!1;let h=0;for(let p=0;p<n;p+=d){let f=Math.round(e.left+l+a*p),m=f-r[p].width/2;if(h&&m<=h){d++,u=!0;break}h=f+r[p].width/2+o}}for(let h=0;h<n;h+=d){let p=Math.round(e.left+l+a*h);this.RenderText(this.axis_group,i[h],"center",{x:p,y:e.bottom},s)}}RenderXAxisTicks(e,t,i){let r=t?e.width/i:e.width/(i-1),s=t?r/2:0,n=[];for(let o=0;o<i;o++){let a=Math.round(e.left+s+r*o)+.5;n.push(`M${a},${e.bottom+.5} v${6}`)}this.axis_group.appendChild(M("path",{d:n.join(" "),class:"x-axis-tick axis-tick"}))}RenderXAxis(e,t,i,r,s){let n=i.length;if(!n)return;let o=4,a=t?e.width/n:e.width/(n-1),l=t?a/2:0,d=1,u=!0,h=(i.length-1)%2===0,p=(i.length-1)%3===0;for(;u;){u=!1;let f=0;for(let m=0;m<n;m+=d){let b=Math.round(e.left+l+a*m),_=b-r[m].width/2;if(f&&_<=f){d++,u=!0;break}f=b+r[m].width/2+o}}d===3&&!p&&h&&d++;for(let f=0;f<n;f+=d){let m=Math.round(e.left+l+a*f);this.RenderText(this.axis_group,i[f],"center",{x:m,y:e.bottom},s)}}RenderYAxisBar(e,t,i,r){i=i.slice(0),i.reverse();let s=i.length;if(!s)return;let n=e.height/s,o=1,a=!0;for(;a;){a=!1;let l=0;for(let d=0;d<s;d+=o){let u=i[d],h=Math.round(e.bottom-n*(d+.5)+u.metrics.height/4);if(l&&h>=l){o++,a=!0;break}l=h-u.metrics.height}}for(let l=0;l<s;l+=o){let d=i[l],u=Math.round(e.bottom-n*(l+.5)+d.metrics.height/4);this.RenderText(this.axis_group,d.label,"right",{x:t,y:u},r)}}RenderYAxis(e,t,i,r){let s=i.length;if(!s)return;let n=e.height/(s-1),o=1,a=!0;for(;a;){a=!1;let l=0;for(let d=0;d<s;d+=o){let u=i[d],h=Math.round(e.bottom-n*d+u.metrics.height/4);if(l&&h>=l){o++,a=!0;break}l=h-u.metrics.height}}for(let l=0;l<s;l+=o){let d=i[l],u=Math.round(e.bottom-n*l+d.metrics.height/4);this.RenderText(this.axis_group,d.label,"right",{x:t,y:u},r)}}LineProperties(e,t){let i=t.x-e.x,r=t.y-e.y;return{length:Math.sqrt(i*i+r*r),angle:Math.atan2(r,i)}}RenderSmoothLine(e,t,i=!1,r,s){let n=M("g"),o=[],a=[],l=t.length,d=l-1,u=e.width/l/2,h=[],p=t.map((b,_)=>{if(!(typeof b>"u"))return{x:Math.round(e.left+e.width/d*_),y:e.bottom-b}}),f=[],m=()=>{if(f.length<2)return;let b="",_=f[0],y=f[f.length-1];if(f.length===2)b=`${f[0].x},${f[0].y} L${f[1].x},${f[1].y}`;else if(f.length>2){let x=this.CatmullRomChain(f);b=""+x.map(v=>`${v.x},${v.y}`).join(" L")}b&&(o.push("M"+b),i&&(a.push(`M ${_.x},${e.bottom} L ${_.x},${_.y}`),a.push("L"+b),a.push(`L ${y.x},${e.bottom}`)))};for(let b of p)b?f.push(b):(m(),f=[]);if(f.length&&m(),i&&n.appendChild(M("path",{class:"fill",d:a})),n.appendChild(M("path",{class:"line",d:o})),typeof s<"u"&&(typeof s=="string"&&(s=[s]),n.setAttribute("class",s.join(" "))),this.group.appendChild(n),r&&h.length){let b=document.createElementNS(yt,"g");for(let _ of h){let y=M("circle",{cx:_.x,cy:_.y,r:u});y.addEventListener("mouseenter",x=>{this.parent.setAttribute("title",r[_.i]||"")}),y.addEventListener("mouseleave",x=>{this.parent.setAttribute("title","")}),b.appendChild(y)}b.setAttribute("class","mouse-layer"),this.group.appendChild(b)}}RenderLine(e,t,i=!1,r,s){let n=document.createElementNS(yt,"g"),o=[],a=[],l=t.length,d=l-1,u=e.width/l/2,h=[],p=0,f=!0,m;for(;p<l;p++){let b=t[p];if(typeof b>"u"){f=!0,i&&typeof m<"u"&&a.push(`L${m} ${e.bottom}Z`),m=void 0;continue}let _=Math.round(+e.left+e.width/d*p);f?(i&&a.push(`M${_} ${e.bottom} L${_} ${e.bottom-b}`),o.push(`M${_} ${e.bottom-b}`)):(o.push(`L${_} ${e.bottom-b}`),a.push(`L${_} ${e.bottom-b}`)),h.push({x:_,y:e.bottom-b,i:p}),m=_,f=!1}if(i&&typeof m<"u"&&a.push(`L${m} ${e.bottom}Z`),i&&n.appendChild(M("path",{class:"fill",d:a})),n.appendChild(M("path",{class:"line",d:o})),typeof s<"u"&&(typeof s=="string"&&(s=[s]),n.setAttribute("class",s.join(" "))),this.group.appendChild(n),r&&h.length){let b=document.createElementNS(yt,"g");for(let _ of h){let y=M("circle",{cx:_.x,cy:_.y,r:u});y.addEventListener("mouseenter",x=>{this.parent.setAttribute("title",r[_.i]||"")}),y.addEventListener("mouseleave",x=>{this.parent.setAttribute("title","")}),b.appendChild(y)}b.setAttribute("class","mouse-layer"),this.group.appendChild(b)}}RenderBarGrid(e,t,i){let r=[],s=e.width/t;for(let n=0;n<=t;n++){let o=Math.round(e.left+s*n)-.5;r.push(`M${o} ${e.top} L${o} ${e.bottom}`)}this.group.appendChild(M("path",{d:r,class:i}))}RenderGrid(e,t,i=0,r){let s=[],n=e.height/t;for(let o=0;o<=t;o++){let a=Math.round(e.top+n*o)-.5;s.push(`M${e.left} ${a} L${e.right} ${a}`)}n=e.width/(i-1);for(let o=0;o<i;o++){let a=Math.round(e.left+n*o)-.5;s.push(`M${a} ${e.top} L${a} ${e.bottom}`)}this.group.appendChild(M("path",{d:s,class:r}))}MultiplyPoint(e,t){return{x:e.x*t,y:e.y*t}}AddPoints(e,t){return{x:e.x+t.x,y:e.y+t.y}}CatmullRomSpline(e,t){let i=.5;i=i/2;let r=(u,h,p)=>{let{x:f,y:m}=h,{x:b,y:_}=p;return((b-f)**2+(_-m)**2)**i+u},s=0,n=r(s,e[0],e[1]),o=r(n,e[1],e[2]),a=r(o,e[2],e[3]),l=(o-n)/t,d=[];for(let u=0;u<t;u++){let h=n+l*u,p=this.AddPoints(this.MultiplyPoint(e[0],(n-h)/(n-s)),this.MultiplyPoint(e[1],(h-s)/(n-s))),f=this.AddPoints(this.MultiplyPoint(e[1],(o-h)/(o-n)),this.MultiplyPoint(e[2],(h-n)/(o-n))),m=this.AddPoints(this.MultiplyPoint(e[2],(a-h)/(a-o)),this.MultiplyPoint(e[3],(h-o)/(a-o))),b=this.AddPoints(this.MultiplyPoint(p,(o-h)/(o-s)),this.MultiplyPoint(f,(h-s)/(o-s))),_=this.AddPoints(this.MultiplyPoint(f,(a-h)/(a-n)),this.MultiplyPoint(m,(h-n)/(a-n))),y=this.AddPoints(this.MultiplyPoint(b,(o-h)/(o-n)),this.MultiplyPoint(_,(h-n)/(o-n)));d.push(y)}return d}CatmullRomChain(e,t=30){let i=e.slice(0),r=[],s=i.length;if(s){let n=i[s-1].x-i[s-2].x,o=i[s-1].y-i[s-2].y;i.push({x:i[s-1].x+n,y:i[s-1].y+o}),i.push({x:i[s-1].x+n,y:i[s-1].y+o}),n=i[1].x-i[0].x,o=i[1].y-i[0].y,i.unshift({x:i[0].x-n,y:i[0].y-o});for(let a=0;a<i.length-4;a++){let l=i.slice(a,a+4),d=this.CatmullRomSpline(l,t);r.push(...d)}}return r}RenderDataLabels(e,t,i,r,s,n,o){let a=Math.max(t.length,i.length),l=r.max-r.min||1,d=s.max-s.min||1;for(let u=0;u<a;u++){let h=t[u],p=i[u];if(h!==void 0&&p!==void 0){let f={x:e.left+(h-r.min)/l*e.width,y:e.bottom-(p-s.min)/d*e.height},m=n[u];if(m){this.label_group.appendChild(M("circle",{class:"label-target",cx:f.x,cy:f.y,r:10}));let b=M("g",{class:"data-label",transform:`translate(${f.x+10},${f.y})`});this.label_group.appendChild(b);let _=M("circle",{cx:-10,y:0,r:5,class:`marker-highlight series-${o}`});b.appendChild(_);let y=M("text",{x:4,y:0},m);b.appendChild(y);let x=y.getBoundingClientRect(),v=x.height,w=x.width+8;w+15+f.x>=e.right&&(b.setAttribute("transform",`translate(${f.x-w-15},${f.y})`),_.setAttribute("cx",(w+15).toString()));let C=M("path",{d:`M0,5 h${w} v-${v} h-${w} Z`});b.insertBefore(C,y)}}}}RenderScatterSeries(e,t,i,r,s,n=!0,o=!1,a=!1,l=!1,d=!1,u){let h=Math.max(t.length,i.length),p=r.max-r.min||1,f=s.max-s.min||1,m=[],b=[],_=[],y=M("g",{class:u});this.group.appendChild(y);for(let x=0;x<h;x++){let v=t[x],w=i[x];typeof v>"u"||typeof w>"u"?m.push(void 0):m.push({x:e.left+(v-r.min)/p*e.width,y:e.bottom-(w-s.min)/f*e.height})}if(n){let x=[],v=d?()=>x.length===2?`${x[0].x},${x[0].y} L${x[1].x},${x[1].y}`:x.length>2?this.CatmullRomChain(x).map(C=>`${C.x},${C.y}`).join(" L"):"":()=>x.map(w=>`${w.x},${w.y}`).join(" L");for(let w of m)if(w)x.push(w);else{if(x.length>=2){let C=v();b.push("M"+C),_.push(`M${x[0].x},${e.bottom}L`+C+`L${x[x.length-1].x},${e.bottom}Z`)}x=[]}if(x.length>=2){let w=v();b.push("M"+w),_.push(`M${x[0].x},${e.bottom}L`+w+`L${x[x.length-1].x},${e.bottom}Z`)}}if(a&&y.appendChild(M("path",{d:_,class:"fill"})),n&&y.appendChild(M("path",{d:b,class:"line"})),o)for(let x of m)x&&y.appendChild(M("circle",{cx:x.x,cy:x.y,r:1,class:"point"}));if(l)for(let x of m)x&&y.appendChild(M("circle",{cx:x.x,cy:x.y,r:3,class:"marker"}))}RenderPoints(e,t,i,r){let s=[];for(let n=0;n<t.length;n++){let o=t[n]*e.width+e.left,a=e.bottom-i[n]*e.height;s.push(`M${o-1},${a-1} L${o+1},${a+1}`),s.push(`M${o-1},${a+1} L${o+1},${a-1}`)}this.group.appendChild(M("path",{d:s,class:r}))}RenderPoint(e,t,i){this.group.appendChild(M("circle",{cx:e,cy:t,r:1,class:i}))}RenderCalloutLines(e){let t=M("g",{class:"callouts"});this.label_group.appendChild(t);for(let i of e)t.appendChild(M("path",{d:`M${i.x1},${i.y1} L${i.x2},${i.y2}`,class:"callout "+(i.classes||"").trim()}))}RenderRectangle(e,t,i,r,s,n){let o="";if(t)if(t[0]&&t[0]===t[1]&&t[0]>=e.height){let l=t[0],d=t[0]-e.height,u=Math.sqrt(l*l-d*d);o=`M${e.left+e.width/2-u},${e.bottom} a${l},${l} 0 0 1 ${u*2},0 z`}else if(t[1]&&t[1]===t[2]&&t[1]>=e.width){let l=t[1],d=t[1]-e.width,u=Math.sqrt(l*l-d*d);o=`M${e.left},${e.top+e.height/2-u} a${l},${l} 0 0 1 0,${u*2} z`}else o=`M${e.left},${e.top+t[0]} a${t[0]},${t[0]} 0 0 1 ${t[0]},${-t[0]} h${e.width-t[0]-t[1]} a${t[1]},${t[1]} 0 0 1 ${t[1]},${t[1]} v${e.height-t[1]-t[2]} a${t[2]},${t[2]} 0 0 1 ${-t[2]},${t[2]} h${-e.width+t[2]+t[3]} a${t[3]},${t[3]} 0 0 1 ${-t[3]},${-t[3]} v${-e.height+t[3]+t[0]} `;else o=`M${e.left},${e.top} h${e.width} v${e.height} h${-e.width} v${-e.height} `;let a=M("path",{d:o,class:i});if(r&&(a.addEventListener("mouseenter",l=>{this.parent.setAttribute("title",r)}),a.addEventListener("mouseleave",l=>{this.parent.setAttribute("title","")})),this.group.appendChild(a),s){this.label_group.appendChild(M("path",{class:"label-target",d:o}));let l=n||{x:Math.round(e.left+e.width/2),y:Math.round(e.top-10)},d=M("g",{class:"data-label",transform:`translate(${l.x},${l.y})`});this.label_group.appendChild(d);let u=M("text",{x:0,y:0},s);d.appendChild(u);let h=u.getBoundingClientRect(),p=h.height,f=h.width+8;l.y-h.height<4&&(l.y-=l.y-h.height-4,d.setAttribute("transform",`translate(${l.x},${l.y})`)),u.setAttribute("x",Math.floor(-h.width/2).toString());let m=Math.ceil(p*.125),b=M("rect",{rx:3,x:-f/2,y:Math.round(-p+m*2/3),width:f,height:p+m});d.insertBefore(b,u)}}RenderText(e,t,i,r,s){let n=M("text",{x:r.x,y:r.y,class:s},t);switch(i){case"right":n.style.textAnchor="end";break;case"center":n.style.textAnchor="middle";break;default:n.style.textAnchor="start";break}(e||this.group).appendChild(n)}RenderDonut(e,t,i,r,s,n,o){let a=-Math.PI/2,l=0;n&&(i*=.8,r*=.7);let d=(u,h,p)=>[Math.cos(p)*h+u.x,Math.sin(p)*h+u.y];for(let u of e){let h=u.title||"",p=u.percent,f=u.index,m=[],b=0,_=d.bind(0,t,i),y=d.bind(0,t,r);if(p>.5){b=a+p/2*Math.PI*2,l=a+p*Math.PI*2;let w=b-a,C=l-b;m.push(`M${_(a)}`,`A${i},${i},${w},0,1,${_(b)}`,`A${i},${i},${C},0,1,${_(l)}`,`L${y(l)}`,`A${r},${r},${C},0,0,${y(b)}`,`A${r},${r},${w},0,0,${y(a)}`,"Z")}else{l=a+p*Math.PI*2,b=(l-a)/2+a;let w=l-a;m.push(`M${_(a)}`,`A${i},${i},${w},0,1,${_(l)}`,`L${y(l)}`,`A${r},${r},${w},0,0,${y(a)}`,"Z")}let x=M("path",{d:m,class:typeof f>"u"?void 0:`series-${f}`});typeof f<"u"&&x.setAttribute("data-index",f.toString());let v=M("g",{class:o});if(v.appendChild(x),this.group.appendChild(v),p>=.05&&h){let w=i-r;m=[];let C=d(t,r+(i-r)/2+w,b);m.push(`M${d(t,r+(i-r)/2,b)}`),m.push(`L${C}`),v.appendChild(M("path",{d:m,class:"callout"}));let S=[],U=M("text",{class:"callout-label"});v.appendChild(U);let J=b+Math.PI/2,oe=h;U.textContent=oe;let R=U.getBoundingClientRect(),k={width:R.width,height:R.height},[W,ae]=C;W+=k.height/2*Math.cos(b),ae+=k.height/4+k.height/2*Math.sin(b);let Z=!1;J>Math.PI?W-k.width<=s.left&&(Z=!0):W+k.width>s.right&&(Z=!0);let he=/[\s-]/;if(Z&&he.test(oe)){let $=-1,F=1,ie=[];for(let le=0;le<oe.length;le++)if(he.test(oe[le])){let _e=Math.abs(.5-le/oe.length);_e<F&&(F=_e,$=le)}$>0&&(S.push(oe.substr(0,$+1).trim()),S.push(oe.substr($+1).trim()))}if(S.length){let $=0,F=0,ie=S.map(le=>{U.textContent=le,R=U.getBoundingClientRect();let _e={width:R.width,height:R.height};return F=Math.max(F,_e.width),{text:le,metrics:_e}});U.textContent="";for(let le of ie){let _e=document.createElementNS(yt,"tspan");_e.textContent=le.text;let ss=J>Math.PI?W-(F-le.metrics.width)/2:W+(F-le.metrics.width)/2;_e.setAttribute("x",ss.toString()),_e.setAttribute("dy",$.toString()),U.appendChild(_e),$=le.metrics.height}}let pe=J>Math.PI?"end":"start";U.setAttribute("text-anchor",pe),U.setAttribute("x",W.toString()),U.setAttribute("y",ae.toString()),typeof f<"u"&&U.setAttribute("data-index",f.toString())}a=l}}};var N=class{static Scale(e,t,i=6.5){return pr(e,t,i)}static Range(e){let t,i;for(let s of e)typeof s>"u"||((typeof t>"u"||t>s)&&(t=s),(typeof i>"u"||i<s)&&(i=s));let r=typeof t>"u"||typeof i>"u"?0:i-t;return{min:t,max:i,range:r}}static ApplyScale(e,t,i){return t*(e-i.min)/(i.max-i.min)}static Flatten(e){let t=[];if(Array.isArray(e))for(let i of e)Array.isArray(i)?t=t.concat(this.Flatten(i)):t.push(i);else typeof e<"u"&&t.push(e);return t}};ts();var qi="#,##0.00",Ze=class{constructor(e=new ii){this.renderer=e}chart_data={type:"null"};margin={top:.025,left:.05,bottom:.025,right:.075};Initialize(e){this.renderer.Initialize(e)}Exec(e,t){let i=t?.value||[];switch(e.toLowerCase()){case"column.chart":this.CreateColumnChart(i,"column");break;case"bar.chart":this.CreateColumnChart(i,"bar");break;case"line.chart":this.CreateLineChart(i,"line");break;case"area.chart":this.CreateLineChart(i,"area");break;case"donut.chart":case"pie.chart":this.CreateDonut(i,e.toLowerCase()==="pie.chart");break;case"scatter.plot":this.CreateScatterChart(i,"plot");break;case"scatter.line":this.CreateScatterChart(i,"line");break;default:this.Clear();break}}Clear(){this.chart_data={type:"null"}}CreateColumnChart(e,t){let i=this.TransformSeriesData(e[0]),r=this.CommonData(i),s;if(e[1]){s=(e[1].type===8?N.Flatten(e[1].value):N.Flatten(e[1])).map(d=>d?d.type===5&&d.value.type==="metadata"?typeof d.value.value=="number"?L.Get(d.value.format||qi).Format(d.value.value):d.value.value:typeof d.value=="number"?L.Get(d.format||qi).Format(d.value):d.value:"");let l=i.reduce((d,u)=>Math.max(d,u.y.data.length),0);for(l<s.length&&(s=s.slice(0,l));l>s.length;)s.push("")}let n=e[2]?.toString()||void 0,o=e[3]?.toString()||void 0;if(this.chart_data={type:t,legend:r.legend,legend_style:1,series2:i,scale:r.y.scale,title:n,y_labels:t==="bar"?s:r.y.labels,x_labels:t==="bar"?r.y.labels:s},o){this.chart_data.round=/round/i.test(o),this.chart_data.data_labels=/labels/i.test(o);let a=o.match(/labels="(.*?)"/);a&&i?this.ApplyLabels(i,a[1],s):(a=o.match(/labels=([^\s\r\n,]+)(?:\W|$)/),a&&i&&this.ApplyLabels(i,a[1],s)),a=o.match(/class=([\w_-]+)(?:\W|$)/),a&&(this.chart_data.class_name=a[1])}}ReadSeries(e){let t={x:{data:[]},y:{data:[]}};if(e[3]&&typeof e[3]=="number"&&(t.index=e[3]),e[4]&&(t.subtype=e[4].toString()),e[0]){let i=N.Flatten(e[0]);typeof i[0]=="object"?t.label=i[0]?.value?.toString()||"":t.label=i[0].toString()}if(!!e[2]&&typeof e[2]=="object"&&e[2].type===8){let i=N.Flatten(e[2].value);if(t.y.data=i.map(r=>typeof r.value.value=="number"?r.value.value:void 0),i[0].value?.format){t.y.format=i[0].value?.format;let r=L.Get(t.y.format);t.y.labels=t.y.data.map(s=>s===void 0?void 0:r.Format(s))}}if(!!e[1]&&typeof e[1]=="object"&&e[1].type===8){let i=N.Flatten(e[1].value);t.x.data=i.map(r=>typeof r.value.value=="number"?r.value.value:void 0),i[0].value.format&&(t.x.format=i[0].value.format)}for(let i of[t.x,t.y])if(i.data.length){let r=i.data.filter(s=>s||s===0);i.range={min:Math.min.apply(0,r),max:Math.max.apply(0,r)}}return t}ArrayToSeries(e){let t={x:{data:[]},y:{data:[]}},i=N.Flatten(e.value);if(t.y.data=i.map((s,n)=>typeof s.value=="number"?s.value:typeof s.value.value?.real=="number"?(t.x.data[n]=s.value.value.real,s.value.value.imaginary):typeof s.value.value=="number"?s.value.value:void 0),i[0].value.format){t.y.format=i[0].value.format||"";let s=L.Get(t.y.format||"");t.y.labels=t.y.data.map(n=>n===void 0?void 0:s.Format(n))}let r=t.y.data.filter(s=>s||s===0);if(t.y.range={min:Math.min.apply(0,r),max:Math.max.apply(0,r)},t.x.data.length){let s=t.x.data.filter(n=>typeof n=="number");if(t.x.range={min:Math.min.apply(0,s),max:Math.max.apply(0,s)},i[0].value.format){t.x.format=i[0].value.format||"";let n=L.Get(t.x.format||"");t.x.labels=t.x.data.map(o=>o===void 0?void 0:n.Format(o))}}return t}TransformSeriesData(e,t){if(!e)return[];let i=[];if(e.type===5){if(e.key==="group"){if(Array.isArray(e.value)){for(let n of e.value)if(!!n&&typeof n=="object")if(n.key==="series"){let o=this.ReadSeries(n.value);i.push(o)}else n.type===8&&i.push(this.ArrayToSeries(n))}}else if(e.key==="series"){let n=this.ReadSeries(e.value);i.push(n)}}else e.type===8&&i.push(this.ArrayToSeries(e));let r,s=0;if(t?.type===8){let n=N.Flatten(t.value),o="0.00###";n[0]&&n[0].type===5&&(o=n[0].value.format);let a=n.map(d=>{if(d.type===3)return d.value;if(d.type===5)return d.value.value}),l=a.filter(d=>typeof d=="number");r={data:a,format:o,range:{min:Math.min.apply(0,l),max:Math.max.apply(0,l)}}}for(let n of i)s=Math.max(s,n.y.data.length),n.x.data.length&&(r||(r=n.x));if(!r){r={data:[],range:{min:0,max:Math.max(0,s-1)}};for(let n=0;n<s;n++)r.data.push(n)}for(let n of i)n.x.data.length||(n.x=r);return i}CommonData(e,t,i){let r="",s="";for(let _ of e)_.y.format&&!s&&(s=_.y.format),_.x.format&&!r&&(r=_.x.format);let n;e.some(_=>_.label&&_.label.length>0)&&(n=e.map((_,y)=>({label:_.label||`Series ${y+1}`,index:typeof _.index=="number"?_.index:y+1})));let o=e.filter(_=>_.x.range),a=Math.min.apply(0,o.map(_=>_.x.range?.min||0)),l=Math.max.apply(0,o.map(_=>_.x.range?.max||0)),d=e.filter(_=>_.y.range),u=Math.min.apply(0,o.map(_=>_.y.range?.min||0)),h=Math.max.apply(0,o.map(_=>_.y.range?.max||0));typeof t<"u"&&(u=Math.min(u,t)),typeof i<"u"&&(h=Math.max(h,i));let p=N.Scale(a,l,7),f=N.Scale(u,h,7),m,b;if(r){m=[];let _=L.Get(r);for(let y=0;y<=p.count;y++)m.push(_.Format(p.min+y*p.step))}if(s){b=[];let _=L.Get(s);for(let y=0;y<=f.count;y++)b.push(_.Format(f.min+y*f.step))}return{x:{format:r,scale:p,labels:m},y:{format:s,scale:f,labels:b},legend:n}}CreateScatterChart(e,t="plot"){let i=this.TransformSeriesData(e[0]),r=this.CommonData(i),s=e[1]?.toString()||void 0,n=e[2]?.toString()||void 0;if(this.chart_data={legend:r.legend,style:t,type:"scatter2",series:i,title:s,x_scale:r.x.scale,x_labels:r.x.labels,y_scale:r.y.scale,y_labels:r.y.labels,lines:t==="line",points:t==="plot"},n){this.chart_data.markers=/marker/i.test(n),this.chart_data.smooth=/smooth/i.test(n),this.chart_data.data_labels=/labels/i.test(n);let o=n.match(/labels="(.*?)"/);o&&this.chart_data.series?this.ApplyLabels(this.chart_data.series,o[1]):(o=n.match(/labels=([^\s\r\n,]+)(?:\W|$)/),o&&this.chart_data.series&&this.ApplyLabels(this.chart_data.series,o[1])),o=n.match(/class=([\w_-]+)(?:\W|$)/),o&&(this.chart_data.class_name=o[1])}}ApplyLabels(e,t,i){for(let r of e){let s={x:L.Get(r.x.format||""),y:L.Get(r.y.format||"")};r.y.labels=[];for(let n=0;n<r.y.data.length;n++){let o=i?i[n]:typeof r.x.data[n]=="number"?s.x.Format(r.x.data[n]):"",a=typeof r.y.data[n]=="number"?s.y.Format(r.y.data[n]):"";r.y.labels[n]=t.replace(/\bx\b/g,o).replace(/\by\b/g,a)}}}CreateLineChart(e,t){let i=this.TransformSeriesData(e[0],e[1]),r=this.CommonData(i,0,0),s=e[2]?.toString()||void 0,n=e[3]?.toString()||void 0;if(this.chart_data={legend:r.legend,type:"scatter2",series:i,title:s,x_scale:r.x.scale,x_labels:r.x.labels,y_scale:r.y.scale,y_labels:r.y.labels,lines:!0,filled:t==="area"},n){this.chart_data.smooth=/smooth/i.test(n);let o=n.match(/class=([\w_-]+)(?:\W|$)/);o&&(this.chart_data.class_name=o[1])}}CreateDonut(e,t=!1){let i=e[0]?.type===8?e[0].value:e[0],r=N.Flatten(i),s=r.map(_=>typeof _.value.value=="number"?_.value.value:void 0),n=e[1]?.type===8?e[1].value:e[1],o=N.Flatten(n).map(_=>{if(_&&typeof _=="object"){let y=_.value?.value;return typeof y=="number"&&_.value?.format?L.Get(_.value?.format).Format(y):y?y.toString():""}else return _?_.toString():""});s=s.map(_=>_<0?(console.warn("pie/donut chart does not support negative values (omitted)"),0):_);let a=e[2]||"",l=0,d=s.map((_,y)=>(typeof _<"u"&&(l+=_),{value:_,label:o[y]||"",index:y+1,percent:0}));if(l)for(let _ of d)_.percent=(_.value||0)/l;let u=r.length&&r[0].value?.format?r[0].value.format:"",h=L.Get(u||qi),p=L.Get("percent");typeof e[4]>"u"&&e[1]&&(e[4]="label");let f=e[4]||"";if(f)for(let _ of d){let y=h.Format(_.value||0),x=p.Format(_.percent);_.title=f.replace(/value%/ig,p.Format(_.value||0)).replace(/value/ig,y).replace(/percent/ig,x).replace(/label/ig,_.label||"").trim()}let m=(e[3]||"").toString().trim(),b=m.toUpperCase();if(b==="ASC"||b==="ASCENDING"||b==="INC")d.sort((_,y)=>(_.value||0)-(y.value||0));else if(b==="DESC"||b==="DESCENDING"||b==="DEC")d.sort((_,y)=>(y.value||0)-(_.value||0));else{let _=m.match(/sort=([\w]+)(?:\W|$)/i);_&&(b=_[1],/^(asc|inc)/i.test(b)?d.sort((y,x)=>(y.value||0)-(x.value||0)):/^(desc|dec)/i.test(b)&&d.sort((y,x)=>(x.value||0)-(y.value||0)))}if(this.chart_data={type:t?"pie":"donut",slices:d,title:a},m){let _=m.match(/class=([_-\w]+)(?:\W|$)/);_&&(this.chart_data.class_name=_[1])}}Resize(){this.renderer.Resize()}Update(){this.renderer.Resize(),this.renderer.Prerender(),this.renderer.Clear(this.chart_data.class_name);let e=new ke(0,0,this.renderer.size.width,this.renderer.size.height),t={top:Math.round(e.height)*this.margin.top,bottom:Math.round(e.height)*this.margin.bottom,left:Math.round(e.width)*this.margin.left,right:Math.round(e.width)*this.margin.right},i=this.chart_data.title;if(i&&this.renderer.RenderTitle(i,e,t.top,this.chart_data.title_layout||"top"),e.top+=t.top,e.left+=t.left,e.bottom-=t.bottom,e.right-=t.right,this.chart_data.legend&&this.chart_data.legend.length){let r=0;this.chart_data.title&&(!this.chart_data.title_layout||this.chart_data.title_layout==="top")&&(r=1);let s=this.chart_data.legend_position||r;this.renderer.Legend({labels:this.chart_data.legend,position:s,style:this.chart_data.legend_style,layout:s===0||s===1?0:1,area:e})}if(this.chart_data.type==="histogram"||this.chart_data.type==="line"||this.chart_data.type==="area"||this.chart_data.type==="column"||this.chart_data.type==="histogram2"||this.chart_data.type==="bar"||this.chart_data.type==="scatter2"){let r=[],s=0;if(this.chart_data.x_labels&&this.chart_data.x_labels.length&&(r=this.chart_data.x_labels.map(n=>{let o=this.renderer.MeasureText(n,["axis-label","x-axis-label"],!0);return s=Math.max(s,o.height),o})),this.chart_data.y_labels&&this.chart_data.y_labels.length){let n=[],o=0,a=0,l=this.chart_data.type==="scatter2"?this.chart_data.y_scale:this.chart_data.scale,d=this.chart_data.type==="bar"?this.chart_data.y_labels.length:l.count+1;for(let u=0;u<d;u++){let h=this.renderer.MeasureText(this.chart_data.y_labels[u],["axis-label","y-axis-label"]);n.push({label:this.chart_data.y_labels[u],metrics:h}),o=Math.max(o,h.width),a=Math.max(a,h.height)}e.bottom=Math.round(e.bottom-a/2),e.top=Math.round(e.top+a/2),r.length&&(e.bottom-=s+t.bottom),this.chart_data.type==="bar"?this.renderer.RenderYAxisBar(e,e.left+o,n,["axis-label","y-axis-label"]):this.renderer.RenderYAxis(e,e.left+o,n,["axis-label","y-axis-label"]),e.left+=o+t.left}if(r.length&&this.chart_data.x_labels&&this.chart_data.x_labels.length){let n=this.chart_data.type==="histogram2",o=this.chart_data.type!=="line"&&this.chart_data.type!=="area"&&this.chart_data.type!=="bar"&&this.chart_data.type!=="scatter2"&&this.chart_data.type!=="histogram2";n&&this.renderer.RenderXAxisTicks(e,o,this.chart_data.x_labels.length),this.chart_data.y_labels&&(e.bottom+=s+t.bottom),this.renderer.RenderXAxis(e,o,this.chart_data.x_labels,r,["axis-label","x-axis-label"]),e.bottom-=s+t.bottom}}switch(this.chart_data.type){case"scatter":this.renderer.RenderPoints(e,this.chart_data.x,this.chart_data.y,"mc mc-correlation series-1");break;case"scatter2":if(this.renderer.RenderGrid(e,this.chart_data.y_scale.count,this.chart_data.x_scale.count+1,"chart-grid"),this.chart_data.series){for(let r=0;r<this.chart_data.series.length;r++){let s=this.chart_data.series[r],n=!!this.chart_data.lines,o=!!this.chart_data.points;s.subtype==="plot"?(o=!0,n=!1):s.subtype==="line"&&(o=!1,n=!0);let a=typeof s.index=="number"?s.index:r+1;this.renderer.RenderScatterSeries(e,s.x.data,s.y.data,this.chart_data.x_scale,this.chart_data.y_scale,n,o,!!this.chart_data.filled,!!this.chart_data.markers,!!this.chart_data.smooth,`scatter-plot series-${a}`)}if(this.chart_data.data_labels)for(let r=0;r<this.chart_data.series.length;r++){let s=this.chart_data.series[r];s.y.labels&&this.renderer.RenderDataLabels(e,s.x.data,s.y.data,this.chart_data.x_scale,this.chart_data.y_scale,s.y.labels,r+1)}}break;case"pie":case"donut":{let r=Math.min(e.height,e.width)/2*.9,s=this.chart_data.type==="pie"?0:r*.8;this.renderer.RenderDonut(this.chart_data.slices,e.center,r,s,e,!0,"donut")}break;case"line":case"area":{let r=this.chart_data.scale;if(this.chart_data.series){let s=this.chart_data.x_scale?this.chart_data.x_scale.max:Math.max.apply(0,this.chart_data.series.map(a=>a.length)),n=this.chart_data.smooth?this.renderer.RenderSmoothLine:this.renderer.RenderLine;this.renderer.RenderGrid(e,this.chart_data.scale.count,this.chart_data.x_scale?this.chart_data.x_scale.count+1:s,"chart-grid");let o=0;for(let a of this.chart_data.series){let l=a.map(u=>{if(!(typeof u>"u"))return N.ApplyScale(u,e.height,r)});if(l.length<s)for(let u=l.length;u<s;u++)l.push(void 0);let d=[this.chart_data.type==="area"?"chart-area":"chart-line",`series-${o+1}`];n.call(this.renderer,e,l,this.chart_data.type==="area",this.chart_data.titles,d),o++}}}break;case"bar":{let r;if(this.renderer.RenderBarGrid(e,this.chart_data.scale.count,"chart-grid"),this.chart_data.series2){let s=0,n=this.chart_data.series2.length;for(let h of this.chart_data.series2)s=Math.max(s,h.y.data.length);let o=e.height/s,a=.7;typeof this.chart_data.space=="number"&&(a=Math.max(0,Math.min(1,1-this.chart_data.space)));let l=o*(1-a)/2,d=(o-l*2)/n,u=0;if(this.chart_data.scale.min<0&&(u=N.ApplyScale(0,e.width,this.chart_data.scale)),this.chart_data.round){let h=Math.floor(d/2);r=[0,h,h,0]}for(let h=0;h<n;h++){let p=this.chart_data.series2[h],f=typeof p.index=="number"?p.index:h+1;for(let m=0;m<p.y.data.length;m++){let b=p.y.data[m];if(typeof b=="number"){let _=Math.round(e.top+m*o+l)+h*d,y=0,x=0,v=!1;u?b>0?(x=N.ApplyScale(b+this.chart_data.scale.min,e.width,this.chart_data.scale),y=e.left+u):(x=N.ApplyScale(this.chart_data.scale.min-b,e.width,this.chart_data.scale),y=e.left+u-x,v=!0):(x=N.ApplyScale(b,e.width,this.chart_data.scale),y=e.left);let w=void 0;x&&this.renderer.RenderRectangle(new ke(y,_,y+x,_+d),r,["chart-column",`series-${f}`],w||void 0)}}}}}break;case"column":case"histogram2":if(this.renderer.RenderGrid(e,this.chart_data.scale.count,0,"chart-grid"),this.chart_data.series2){let r=0,s=this.chart_data.series2.length;for(let h of this.chart_data.series2)r=Math.max(r,h.y.data.length);let n=e.width/r,o=.7;typeof this.chart_data.space=="number"&&(o=Math.max(0,Math.min(1,1-this.chart_data.space)));let a=n*(1-o)/2,l=(n-a*2)/s,d=0;if(this.chart_data.scale.min<0&&(d=N.ApplyScale(0,e.height,this.chart_data.scale)),this.chart_data.callouts&&this.chart_data.x_scale){let h=this.chart_data.x_scale,p=this.chart_data.callouts.map((f,m)=>{let b=Math.round(e.left+N.ApplyScale(f.value,e.width,h))+.5;return{x1:b,y1:e.bottom-e.height,x2:b,y2:e.bottom,classes:`callout-${m+1}`}});this.renderer.RenderCalloutLines(p)}let u;if(this.chart_data.round){let h=Math.floor(l/2);u=[h,h,0,0]}for(let h=0;h<s;h++){let p=this.chart_data.series2[h],f=typeof p.index=="number"?p.index:h+1;for(let m=0;m<p.y.data.length;m++){let b=p.y.data[m];if(typeof b=="number"){let _=e.left+m*n+a+h*l,y=0,x=0,v=!1;d?b>0?(y=N.ApplyScale(b+this.chart_data.scale.min,e.height,this.chart_data.scale),x=e.bottom-y-d):(y=N.ApplyScale(this.chart_data.scale.min-b,e.height,this.chart_data.scale),x=e.bottom-d,v=!0):(y=N.ApplyScale(b,e.height,this.chart_data.scale),x=e.bottom-y);let w=void 0;if(y){let C=this.chart_data.data_labels&&!!p.y.labels?p.y.labels[m]:"",S={x:Math.round(_+l/2),y:Math.round(x-10)};this.renderer.RenderRectangle(new ke(_,x,_+l,x+y),u,["chart-column",`series-${f}`],w||void 0,C,S)}}}}}break;case"histogram":{this.renderer.RenderGrid(e,this.chart_data.scale.count,0,"chart-grid");let r=e.width/this.chart_data.count,s=this.chart_data.column_width,n=r*(1-s)/2;for(let o=0;o<this.chart_data.count;o++){let a=Math.round(e.left+o*r+n),l=r-n*2,d=N.ApplyScale(this.chart_data.bins[o],e.height,this.chart_data.scale),u=e.bottom-d,h=this.chart_data.titles?this.chart_data.titles[o]:void 0;this.renderer.RenderRectangle(new ke(a,u,a+l,u+d),void 0,"chart-column series-1",h||void 0)}}break}}IsCellData(e){return typeof e=="object"&&typeof e.address=="object"&&typeof e.address.row=="number"&&typeof e.address.column=="number"}};E(Ze,"functions_registered",!1);var Le=(...c)=>({type:5,value:c,key:"arguments"}),Xi={Group:{arguments:[{name:"Array...",metadata:!0}],fn:(...c)=>({type:5,value:c,key:"group"})},Series:{arguments:[{name:"Label"},{name:"X",metadata:!0},{name:"Y",metadata:!0},{name:"index"},{name:"subtype"}],fn:(...c)=>({type:5,value:c,key:"series"})},"Bar.Chart":{arguments:[{name:"Data",metadata:!0},{name:"Categories",metadata:!0},{name:"ChartTitle"}],fn:Le},"Line.Chart":{arguments:[{name:"y",metadata:!0},{name:"x",metadata:!0},{name:"ChartTitle"}],fn:Le},"Area.Chart":{arguments:[{name:"y",metadata:!0},{name:"x",metadata:!0},{name:"ChartTitle"}],fn:Le},"Pie.Chart":{arguments:[{name:"Values",metadata:!0},{name:"Labels"},{name:"Title"},{name:"Sort"},{name:"Label"}],fn:Le},"Donut.Chart":{arguments:[{name:"Values",metadata:!0},{name:"Labels",metadata:!0},{name:"Title"},{name:"Sort"},{name:"Label"}],fn:Le},"Scatter.Line":{arguments:[{name:"Data",metadata:!0},{name:"ChartTitle"}],fn:Le},"Scatter.Plot":{arguments:[{name:"Data",metadata:!0},{name:"ChartTitle"}],fn:Le},"Column.Chart":{arguments:[{name:"Data",metadata:!0},{name:"Categories",metadata:!0},{name:"Chart Title"}],fn:Le}};var Zi=hs(is());var Oe=class{loaded=!1;toolbar_ctl;get Localization(){return T}language_model;events=new Q;calculation=0;file_version=0;last_save_version=0;calculator;grid;model;options;dialog;spinner;file_chooser;file_chooser_operation=0;toolbar;selection_state;get parser(){return this.calculator.parser}view;key_listener;node;views=[];focus_target=this;parent_view;export_worker;undo_pointer=0;undo_stack=[];last_selection;get modified(){return this.undo_stack.length!==1}get document_name(){return this.grid.model.document_name}set document_name(e){this.grid.model.document_name=e,this.DocumentChange()}get user_data(){return this.grid.model.user_data}set user_data(e){this.grid.model.user_data=e,this.DocumentChange()}get scale(){return this.grid.scale}set scale(e){this.grid.scale=e}get headless(){return this.grid.headless}set headless(e){this.grid.headless!==e&&(this.grid.headless=e,e||(this.grid.Update(!0),this.RebuildAllAnnotations()))}get state(){return this.file_version}get dirty(){return this.file_version!==this.last_save_version}constructor(e){this.options={...ei,...e},typeof this.options.imaginary_value=="string"&&(X.imaginary_character=this.options.imaginary_value);let t=this.options.network_document,i,r;this.options.storage_key&&!this.options.toll_initial_load&&!e.model&&(i=localStorage.getItem(this.options.storage_key)||void 0,i&&(r="local-storage"),!i&&this.options.alternate_document&&(t=this.options.alternate_document),window.addEventListener("beforeunload",()=>{this.options.storage_key&&this.SaveLocalStorage(this.options.storage_key)}));let s;typeof this.options.container=="string"?s=document.getElementById(this.options.container):this.options.container&&(s=this.options.container);let n={insert_function_button:!1,in_cell_editor:!0,repaint_on_cell_change:!1,scrollbars:this.options.scrollbars,markdown:!!this.options.markdown,formula_bar:this.options.formula_bar,expand_formula_button:this.options.expand_formula_button,tab_bar:this.options.tab_bar,add_tab:this.options.add_tab,delete_tab:this.options.delete_tab,expand:this.options.expand};if(this.options.scale&&(n.initial_scale=this.options.scale),this.options.stats&&(n.stats=this.options.stats,n.tab_bar=!0),this.options.scale_control&&(n.scale_control=!0,n.tab_bar=!0,this.options.persist_scale)){this.options.persist_scale===!0?n.persist_scale_key="spreadsheet-scale":n.persist_scale_key="spreadsheet-scale-"+this.options.persist_scale;let o=localStorage.getItem(n.persist_scale_key);if(o)try{let a=JSON.parse(o);n.initial_scale=a.scale||1}catch{console.warn("parsing persisted scale failed")}}if(e.model?(this.model=e.model.model,this.calculator=e.model.calculator):(this.model=new ht,this.model.sheets.Add(j.Blank(this.model.theme_style_properties)),this.calculator=this.CreateCalculator(this.model)),this.grid=new dt(n,this.parser,this.model),this.options.headless&&(this.grid.headless=!0),s){this.view=document.createElement("div"),this.view.classList.add("treb-view"),this.node=document.createElement("div"),this.view.appendChild(this.node),s.appendChild(this.view),this.node.addEventListener("focusin",()=>{this.focus_target=this}),this.key_listener=this.HandleKeyDown.bind(this),s.addEventListener("keydown",this.key_listener);let o=!!(i||this.options.network_document);this.grid.Initialize(this.node,o),this.options.dnd&&(this.node.addEventListener("dragenter",a=>this.HandleDrag(a)),this.node.addEventListener("dragover",a=>this.HandleDrag(a)),this.node.addEventListener("drop",a=>this.HandleDrop(a))),this.grid.grid_events.Subscribe(a=>{switch(a.type){case"error":this.dialog?.ShowDialog({type:"error",...this.TranslateGridError(a.code),timeout:3e3,close_box:!0});break;case"selection":this.UpdateSelection(a.selection),this.UpdateSelectionStyle(a.selection);break;case"sheet-change":this.OnSheetChange(a),this.UpdateSelectionStyle();break;case"data":{let l=this.last_selection;(this.calculation===0?this.Recalculate(a):Promise.resolve()).then(()=>{this.DocumentChange(l)})}break;case"style":this.DocumentChange(),this.UpdateDocumentStyles(!1),this.UpdateSelectionStyle();break;case"scale":this.RebuildAllAnnotations();break;case"annotation":if(a.annotation){let l=a.annotation.view[this.grid.view_index]||{};switch(this.DocumentChange(),a.event){case"create":this.InflateAnnotation(a.annotation),this.calculator.UpdateAnnotations(a.annotation,this.grid.active_sheet),this.grid.AnnotationUpdated(a.annotation);break;case"delete":this.calculator.RemoveAnnotation(a.annotation);break;case"update":l.update_callback?(l.update_callback(),this.grid.AnnotationUpdated(a.annotation)):console.info("annotation update event without update callback"),this.calculator.UpdateAnnotations(a.annotation,this.grid.active_sheet);break;case"resize":l.resize_callback&&(l.resize_callback(),this.grid.AnnotationUpdated(a.annotation));break}}else console.info("annotation event without annotation");break;case"structure":{let l=this.last_selection;a.rebuild_required?(this.calculator.Reset(),(this.calculation===0?this.Recalculate(a):Promise.resolve()).then(()=>{this.DocumentChange(l)})):this.DocumentChange(l)}this.UpdateSelectionStyle();break;case"cell-event":this.HandleCellEvent(a);break}}),this.options.prompt_save&&window.addEventListener("beforeunload",a=>{this.last_save_version!==this.file_version&&(a.preventDefault(),a.returnValue="")})}else console.info("not initializing grid; don't call UI functions"),this.grid.headless=!0;if(i?this.LoadDocument(JSON.parse(i),{recalculate:!!this.options.recalculate,source:r}):t||this.calculator.RebuildClean(!0),this.FlushUndo(),this.grid.ShowHeaders(this.options.headers),this.options.scroll&&!this.options.network_document){let o=this.options.scroll;requestAnimationFrame(()=>{this.ScrollTo(o)})}this.UpdateAC(),this.options.global_name&&(self[this.options.global_name]=this),s&&this.options.spinner&&(this.spinner=new Qt(s)),t&&!e.model&&this.LoadNetworkDocument(t,this.options),s&&(this.dialog=new bt(s))}static BuildPath(){let e=typeof document>"u"?[]:document.querySelectorAll("script"),t="treb-bundle",i=new RegExp(t);for(let r=0;r<e.length;r++){let n=e[r].src;if(n&&i.test(n)){n&&/\?.*?engine/i.test(n)&&(this.enable_engine=!0),n&&/\?.*?format/i.test(n)&&(this.enable_formatter=!0),this.treb_embedded_script_path=n,this.treb_base_path=n.replace(new RegExp(t+".*$"),"");return}}i=new RegExp(`import.*?from.*?['"](.*?${t}.*?)['"]`);for(let r=0;r<e.length;r++){let s=e[r];if(!s.src){let o=(s.textContent||"").match(i);if(o){let a=o[1];this.treb_embedded_script_path=a,this.treb_base_path=a.replace(new RegExp(t+".*$"),"");return}}}}UpdateAC(){let e=this.calculator.SupportedFunctions();if(this.language_model){let t={};for(let i of this.language_model.functions||[])t[i.base.toUpperCase()]=i;e=e.map(i=>t[i.name.toUpperCase()]||i)}this.grid.SetAutocompleteFunctions(e)}CreateCalculator(e){return new Zt(e)}TranslateGridError(e){switch(e){case 0:return{message:"No error"};case 2:return{message:"You can't change part of an array"};case 3:return{message:"Invalid value (data validation)"};default:return{message:`Unknown error (${e})`}}}CreateView(){let e=new Oe({...this.options,global_name:void 0,model:this});return e.parent_view=this,e}Unsplit(){let e=this.views.pop();if(e){let t=e.view;t.grid.grid_events.CancelAll(),t.events.CancelAll(),t.view?.parentElement&&(t.key_listener&&t.view.parentElement.removeEventListener("keydown",t.key_listener),t.view.parentElement.removeChild(t.view)),this.node?.focus()}}Split(){let e=this.CreateView();e.grid.EnsureActiveSheet(!0),e.node?.addEventListener("focusin",()=>{this.focus_target=e}),e.grid.grid_events.Subscribe(i=>{i.type==="structure"&&(this.grid.EnsureActiveSheet(),this.grid.UpdateLayout(),this.grid.tab_bar?.Update())}),e.Subscribe(i=>{switch(i.type){case"selection":break;default:e.UpdateAnnotations(),this.grid.Update(!0)}}),this.grid.grid_events.Subscribe(i=>{i.type==="structure"&&(e.grid.EnsureActiveSheet(),e.grid.UpdateLayout(),e.grid.tab_bar?.Update())});let t=this.Subscribe(i=>{switch(i.type){case"selection":break;case"load":case"reset":e.grid.EnsureActiveSheet(!0),e.UpdateAnnotations(),e.grid.Update(!0);break;default:e.UpdateAnnotations(),e.grid.Update(!0)}});this.views.push({view:e,subscription:t})}HandleToolbarEvent(e){let t={},i=r=>{let s=this.grid.GetSelection();if(s&&!s.empty){let n=s.area.spreadsheet_label;this.InsertAnnotation(`=${r}(${n},,"${n}")`)}};if(e.type==="format")t.number_format=e.format||"General";else if(e.type==="font-size"){let r=this.grid.GetSelection(),s=this.grid.active_sheet.RealArea(r.area);this.grid.ApplyStyle(void 0,e.style,!0);let n=[];for(let o=s.start.row;o<=s.end.row;o++)n.push(o);this.grid.SetRowHeight(n,void 0,!1)}else if(e.type==="button")switch(e.command){case"font-scale":{let r=this.grid.GetSelection(),s=this.grid.active_sheet.RealArea(r.area),n=Number(e.data?.scale||1);if(n&&!isNaN(n)){this.grid.ApplyStyle(void 0,{font_size:{unit:"em",value:n}},!0);let o=[];for(let a=s.start.row;a<=s.end.row;a++)o.push(a);this.selection_state?.merge||this.grid.SetRowHeight(o,void 0,!1)}}break;case"update-comment":this.SetNote(void 0,e.data?.comment||"");break;case"clear-comment":this.SetNote(void 0,"");break;case"border":{let r=1,s=(e.data?.border||"").replace(/^border-/,"");s==="double-bottom"&&(s="bottom",r=2),s&&this.grid.ApplyBorders2(void 0,s,e.data?.color||void 0,r)}break;case"color":case"background-color":case"foreground-color":case"border-color":switch(e.data?.target){case"border":t.border_top_fill=t.border_bottom_fill=t.border_left_fill=t.border_right_fill=e.data?.color||{};break;case"foreground":t.text=e.data?.color||{theme:1};break;case"background":t.fill=e.data?.color||{};break}break;case"insert-row":this.InsertRows();break;case"insert-column":this.InsertColumns();break;case"delete-row":this.DeleteRows();break;case"delete-column":this.DeleteColumns();break;case"insert-sheet":this.grid.InsertSheet();break;case"delete-sheet":this.grid.DeleteSheet();break;case"freeze":{let r=this.grid.GetFreeze();r.rows||r.columns?this.Freeze(0,0):this.FreezeSelection()}break;case"insert-image":this.InsertImage();break;case"donut-chart":i("Donut.Chart");break;case"column-chart":i("Column.Chart");break;case"bar-chart":i("Bar.Chart");break;case"line-chart":i("Line.Chart");break;case"increase-decimal":case"decrease-decimal":if(this.selection_state?.style){let r=L.Get(this.selection_state.style.number_format||"General");if(r.date_format)break;let s=new X(r.pattern);if(r.magic_decimal){let n=0,o=this.GetRange();Array.isArray(o)||(o=[[o]]);e:for(let a=0;a<o.length;a++)for(let l=0;l<o[a].length;l++){let d=o[a][l];if(typeof d<"u"&&ge(d)){let u=L.Get(this.selection_state.style.number_format||"General",!0),h=u.BaseFormat(d.real),p=u.BaseFormat(d.imaginary);h.parts&&typeof h.parts[1]=="string"&&(n=h.parts[1].length),p.parts&&typeof p.parts[1]=="string"&&(n=Math.max(n,p.parts[1].length));break e}else if(typeof d=="number"){let u=r.BaseFormat(d);u.parts&&typeof u.parts[1]=="string"&&(n=u.parts[1].length);break e}}e.command==="increase-decimal"?s.SetDecimal(n+1):s.SetDecimal(Math.max(0,n-1))}else e.command==="increase-decimal"?s.IncreaseDecimal():s.DecreaseDecimal();t.number_format=s.toString()}break;case"merge":this.grid.MergeCells();break;case"unmerge":this.grid.UnmergeCells();break;case"lock":t={locked:this.selection_state?.style?!this.selection_state.style.locked:!0};break;case"wrap":t={wrap:this.selection_state?.style?!this.selection_state?.style.wrap:!0};break;case"align-left":t={horizontal_align:A.HorizontalAlign.Left};break;case"align-center":t={horizontal_align:A.HorizontalAlign.Center};break;case"align-right":t={horizontal_align:A.HorizontalAlign.Right};break;case"align-top":t={vertical_align:A.VerticalAlign.Top};break;case"align-middle":t={vertical_align:A.VerticalAlign.Middle};break;case"align-bottom":t={vertical_align:A.VerticalAlign.Bottom};break;case"reset":this.Reset();break;case"import-desktop":this.LoadLocalFile();break;case"save-json":this.SaveLocalFile();break;case"save-csv":this.SaveLocalFile("csv");break;case"export-xlsx":this.Export();break;case"recalculate":this.Recalculate();break;default:console.info("unhandled",e.command);break}Object.keys(t).length&&this.grid.ApplyStyle(void 0,t,!0),this.Focus()}CreateToolbar(e){return this.toolbar=new ti(e,this.options,this.grid.theme),this.toolbar.Subscribe(t=>this.focus_target.HandleToolbarEvent(t)),this.UpdateDocumentStyles(!1),this.UpdateSelectionStyle(void 0),this.toolbar}CreateChart(){return this.calculator.RegisterLibrary("treb-charts",Xi)&&this.UpdateAC(),new Ze}SetLanguage(e){if(this.language_model=e,!e)this.grid.SetLanguageMap();else{let t={};for(let i of e.functions||[])t[i.base]=i.name;this.grid.SetLanguageMap(t)}this.UpdateAC()}async Batch(e,t=!1){let i=this.last_selection,r=this.grid.Batch(e,t),s=!1,n=!1;for(let o of r)o.type==="data"?s=!0:o.type==="structure"&&o.rebuild_required&&(n=!0);n&&this.calculator.Reset(),(s||n)&&(await this.Recalculate(),this.DocumentChange(i))}Freeze(e=0,t=0){this.grid.Freeze(e,t,!0)}FreezeSelection(){let e=this.grid.GetSelection();if(e.empty)this.grid.Freeze(0,0);else{let t=e.area;t.entire_sheet||(t.entire_row?this.grid.Freeze(t.end.row+1,0):t.entire_column?this.grid.Freeze(0,t.end.column+1):this.grid.Freeze(t.end.row+1,t.end.column+1))}}GetFreeze(){return this.grid.GetFreeze()}UpdateTheme(){this.grid.UpdateTheme(void 0),this.toolbar&&this.toolbar.UpdateTheme(this.grid.theme)}GetSheetID(e){if(typeof e=="number"){let t=this.grid.model.sheets.list[e];if(t)return t.id}else{let t=this.model.sheets.Find(e);if(t)return t.id}}AddSheet(e){this.grid.AddSheet(e),this.calculator.Reset()}InsertAnnotation(e,t="treb-chart",i){let r;i&&(r=z.IsRectangle(i)?i:this.calculator.ResolveArea(i,this.grid.active_sheet));let{x:s,y:n}=this.grid.GetScrollOffset(),o=this.grid.scale||1;this.grid.CreateAnnotation({type:t,formula:e},void 0,void 0,r||{top:n/o+30,left:s/o+30,width:300,height:300})}InsertImage(){this.SelectFile2(".png, .jpg, .jpeg, .gif, .svg",2)}RenameSheet(e,t){let i;typeof e=="number"?i=this.grid.model.sheets.list[e]:typeof e=="string"?i=this.model.sheets.Find(e):i=this.grid.active_sheet,i&&this.grid.RenameSheet(i,t)}DeleteSheet(e){if(typeof e=="string"){let t=this.model.sheets.Find(e);t&&this.grid.DeleteSheetID(t.id)}else this.grid.DeleteSheet(e);this.calculator.Reset()}HideSheet(e=0,t=!0){this.grid.ShowSheet(e,!t)}ShowSheet(e=0,t=!0){this.grid.ShowSheet(e,t)}ActivateSheet(e){this.grid.ActivateSheet(e)}SetColumnWidth(e,t){this.grid.SetColumnWidth(e,t)}SetRowHeight(e,t){this.grid.SetRowHeight(e,t)}InsertRows(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_column?0:r.start.row}this.grid.InsertRows(e,t)}InsertColumns(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_row?0:r.start.column}this.grid.InsertColumns(e,t)}DeleteRows(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_column?0:r.start.row,t=r.rows}this.grid.InsertRows(e,-t)}DeleteColumns(e,t=1){if(typeof e>"u"){let i=this.grid.GetSelection();if(i.empty)return;let r=i.area;e=r.entire_row?0:r.start.column,t=r.columns}this.grid.InsertColumns(e,-t)}MergeCells(e){this.grid.MergeCells(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0)}UnmergeCells(e){this.grid.UnmergeCells(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0)}async ExportBlob(){if(!this.export_worker){let e="treb-export-worker";this.export_worker=await this.LoadWorker(e)}return new Promise((e,t)=>{if(this.export_worker){this.export_worker.onmessage=r=>{e(r.data?r.data.blob:void 0)},this.export_worker.onerror=r=>{console.error("export worker error"),console.info(r),t(r)};let i=this.grid.Serialize({rendered_values:!0,expand_arrays:!0,export_colors:!0,decorated_cells:!0});i.decimal_mark=T.decimal_separator,this.export_worker.postMessage({command:"export",sheet:i,decorated:this.calculator.DecoratedFunctionList()})}else t("worker failed")})}Revert(){if(this.options.alternate_document){this.LoadNetworkDocument(this.options.alternate_document),this.options.storage_key&&(this.SaveLocalStorage("reverted_backup"),localStorage.removeItem(this.options.storage_key));return}console.warn("to revert, there must be an alternate_document set in options"),this.dialog?.ShowDialog({title:"Can't revert",close_box:!0,timeout:3e3,type:"error"})}Export(){this.ExportBlob().then(e=>{let t="export";this.grid.model.document_name&&(t=this.grid.model.document_name.toLowerCase().replace(/\s+/g,"-")),e&&(Zi.saveAs(e,t+".xlsx",{autoBom:!1}),this.last_save_version=this.file_version)}).catch(e=>{throw/invalid uri/i.test(e.message)&&this.dialog?.ShowDialog({title:"Error exporting file",close_box:!0,message:"The worker cannot run from the filesystem, please use a web server.",timeout:3e3,type:"error"}),e})}GetSelectionReference(){return this.grid.GetSelection()}Focus(){this.grid.Focus()}Resize(){this.grid.UpdateLayout(),this.Publish({type:"resize"})}Reset(){if(this.parent_view)return this.parent_view.Reset();this.grid.Reset(),this.ResetInternal(),this.calculator.AttachModel(),this.UpdateAC(),this.Publish({type:"reset"})}LoadFromLocalStorage(e){this.options.storage_key=e;let t=localStorage.getItem(e);if(t)try{let i=JSON.parse(t);return this.LoadDocument(i,{source:"local-storage"}),!0}catch(i){console.error(i)}return!1}async LoadNetworkDocument(e,t){let i=t?t.scroll:void 0,r=t?!!t.recalculate:!1,s=t?t.sheet:void 0,n=/csv(?:$|\?|&)/i.test(e),o=/tsv(?:$|\?|&)/i.test(e);try{this.spinner?.Show();let a=await fetch(e);if(this.spinner?.Hide(),!a.ok)throw new Error("network error");let l=await a.text();if(typeof l=="string")if(n)this.LoadCSV(l,"network-file");else{if(o)throw new Error("tsv not supported (TODO)");{l.substr(0,11)==="&&&START&&&"?l=l.substr(11):l.substr(0,8)==="for(;;);"&&(l=l.substr(8));let d=JSON.parse(l);this.LoadDocument(d,{scroll:i,recalculate:r,override_sheet:s,source:"network-file"})}}}catch(a){console.info("error loading network document",e),console.error(a),this.dialog?.ShowDialog({title:"Error loading file",close_box:!0,message:"The network document returned an error",type:"error",timeout:3e3}),this.Reset()}}async LoadLocalFile(){this.SelectFile2(".treb, .csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/json",1)}ExportDelimited(e={}){if(e={delimiter:",",...e},!e.delimiter||e.delimiter!==","&&e.delimiter!==" ")throw new Error("invalid delimiter");let t=this.grid.active_sheet;switch(typeof e.sheet){case"undefined":break;case"string":t=this.model.sheets.Find(e.sheet);break;case"number":t=this.grid.model.sheets.list[e.sheet];break;default:t=void 0;break}if(!t)throw new Error("invalid sheet identifier");let i=t.cells.toJSON({nested:!1,expand_arrays:!0,calculated_value:!0}),r=[];for(let o=0;o<i.columns;o++)r.push("");let s=[];for(let o=0;o<i.rows;o++)s.push(r.slice(0));let n=new RegExp(`[
|
|
13
13
|
\r"${e.delimiter}]`);if(Qe(i.data))for(let o of i.data){let a="";!e.formulas&&typeof o.calculated<"u"?a=ge(o.calculated)?Ge(o.calculated):o.calculated.toString():typeof o.value=="string"&&o.value[0]==="'"?a=o.value.substr(1):typeof o.value<"u"&&(a=ge(o.value)?Ge(o.value):o.value.toString()),n.test(a)&&(a=a.replace(/"/g,'""'),a='"'+a+'"'),s[o.row][o.column]=a}return s.map(o=>o.join(e.delimiter)).join(`\r
|
|
14
|
-
`)}SaveLocalFile(e="treb.json",t={}){let i=this.grid.model.document_name||"document",r,s,n=e.split(/\./).filter(a=>a.trim().length),o=n.length?n[n.length-1].toLowerCase():"treb";if(n.length<=1||e==="treb.json")if(e==="treb.json"&&(o=e),(o==="csv"||o==="tsv")&&this.grid.model.sheets.length>1){let a=this.grid.active_sheet.name;e=(i+"-"+a).toLowerCase().replace(/\W+/g,"-")+"."+o}else e=i.toLowerCase().replace(/\W+/g,"-")+"."+o;switch(o){case"csv":s=this.ExportDelimited({delimiter:","});break;case"tsv":s=this.ExportDelimited({delimiter:" "});break;case"treb":case"json":case"treb.json":r=this.SerializeDocument({...t}),s=JSON.stringify(r,void 0,t.pretty?2:void 0),this.last_save_version=this.file_version;break;default:throw new Error("invalid file type")}if(s&&e){let a=new Blob([s],{type:"text/plain;charset=utf-8"});Zi.saveAs(a,e,{autoBom:!1})}}LoadCSV(e,t){this.grid.FromCSV(e),this.ResetInternal(),this.grid.Update(!0),this.Publish({type:"load",source:t}),this.UpdateDocumentStyles()}ScrollOffset(e){return this.grid.ScrollOffset(e)}LoadDocument(e,t={}){if(t={flush:!0,recalculate:!1,...t},t.override_selection&&e.sheet_data){let i=Array.isArray(e.sheet_data)?e.sheet_data:[e.sheet_data];for(let r of i)if(r.id===t.override_selection.target.sheet_id){r.selection=t.override_selection;break}}if(this.ImportDocumentData(e,t.override_sheet),this.calculator.Reset(),e.rendered_values&&!t.recalculate?(this.grid.Update(),this.calculator.RebuildClean(!0)):this.Recalculate(),this.InflateAnnotations(),t.flush&&this.FlushUndo(),this.Publish({type:"load",source:t.source}),this.UpdateDocumentStyles(),this.loaded=!0,t.scroll){let i=t.scroll;se().then(()=>this.ScrollTo(i))}}SetNote(e,t){if(typeof e=="string"){let i=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(i)?i:i.start}this.grid.SetNote(e,t)}SetValidation(e,t,i){if(typeof e=="string"){let r=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(r)?r:r.start}if(typeof t>"u"||Array.isArray(t))this.grid.SetValidation(e,t,i);else{let r=this.calculator.ResolveArea(t,this.grid.active_sheet);this.grid.SetValidation(e,r,i)}}RemoveFunction(e){let t=e.toUpperCase();this.model.macro_functions.delete(t),this.UpdateAC()}DefineFunction(e,t="",i="0"){if(!e.length||/^[^A-Za-z]/.test(e)||/[^\w_.]/.test(e))throw new Error("invalid function name");typeof t=="string"&&(t=t?t.split(this.parser.argument_separator).map(r=>r.trim()):[]);for(let r of t)if(!r.length||/^[^A-Za-z]/.test(r)||/[^\w_.]/.test(r))throw new Error("invalid argument name");this.RemoveFunction(e),this.grid.model.macro_functions.set(e.toUpperCase(),{name:e,function_def:i,argument_names:t,expression:this.parser.Parse(i).expression}),this.UpdateAC()}SerializeDocument(e={}){let t=this.grid.Serialize({shrink:!0,...e}),i={app:"treb",version:"21.6.2",revision:this.file_version,name:this.grid.model.document_name,user_data:this.grid.model.user_data,decimal_mark:T.decimal_separator,...t};return e.rendered_values&&(i.rendered_values=!0),i}async Recalculate(e){let t;e&&e.type==="data"&&e.area&&(t=e.area),this.calculator.Calculate(t),this.grid.Update(!0),this.UpdateAnnotations(),this.Publish({type:"data"})}SaveLocalStorage(e=this.options.storage_key){if(!e){console.warn("not saving, no key");return}let t=JSON.stringify(this.SerializeDocument({rendered_values:!0,expand_arrays:!0}));localStorage.setItem(e,t)}Undo(){if(this.undo_pointer<=1){console.warn("nothing to undo");return}let e=this.undo_stack[--this.undo_pointer-1],t=e.selection?JSON.parse(e.selection):void 0;this.LoadDocument(JSON.parse(e.data),{flush:!1,override_selection:t,source:"undo"})}About(){this.dialog?.ShowDialog({type:"about"})}ScrollTo(e,t={}){if(typeof e=="string"){let i=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(i)?i:i.start}t={x:!0,y:!0,smooth:!1,...t},this.grid.ScrollTo(e,t.x,t.y,t.smooth)}Resolve(e){let t=this.calculator.ResolveAddress(e,this.grid.active_sheet);return P(t)?t.sheet_id?t:void 0:t.start.sheet_id?t:void 0}Evaluate(e){return this.calculator.Evaluate(e)}GetSelection(e=!0){let t=this.grid.GetSelection();if(t.empty)return"";let i="";if(t.area.count>1?i=g.CellAddressToLabel(t.area.start)+":"+g.CellAddressToLabel(t.area.end):i=g.CellAddressToLabel(t.area.start),!e)return i;let r=t.area.start.sheet_id||this.grid.active_sheet.id,s=this.ResolveSheetName(r,!0);return s?s+"!"+i:i}ParseNumber(e){return ye.TryParse(e).value}FormatNumber(e,t="General"){return L.Get(t).Format(e)}ApplyBorders(e,t,i=1){this.grid.ApplyBorders(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0,t,void 0,i)}ApplyStyle(e,t={},i=!0){this.grid.ApplyStyle(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0,t,i)}ClearName(e){this.grid.SetName(e)}DefineName(e,t){if(typeof t>"u"||t===null)throw new Error("invalid value (null or undefined)");if(typeof t=="object"&&(P(t)||ir(t))){this.grid.SetName(e,this.calculator.ResolveArea(t,this.grid.active_sheet));return}if(typeof t=="string"){let i=this.parser.Parse(t);if(!i.expression)throw new Error("invalid expression");switch(i.expression.type){case"address":case"range":this.grid.SetName(e,this.calculator.ResolveArea(i.expression,this.grid.active_sheet));return}this.grid.SetName(e,void 0,t)}else this.grid.SetName(e,void 0,t.toString())}SetLink(e,t=""){if(typeof e=="string"){let i=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(i)?i:i.start}if(!e){let i=this.GetSelectionReference();if(i.empty)return;e=i.target}this.grid.SetLink(e,t)}Select(e){this.grid.SelectRange(this.calculator.ResolveArea(e,this.grid.active_sheet))}GetRange(e,t={}){if(!e){let i=this.GetSelectionReference();i.empty||(e=i.area)}if(!!e)return t.type||(t.formatted&&(t.type="formatted"),t.formula&&(t.type="formula")),this.grid.GetRange(this.calculator.ResolveAddress(e,this.grid.active_sheet),t.type)}GetStyle(e,t=!1){if(!e){let i=this.GetSelectionReference();i.empty||(e=i.area)}if(!!e)return this.grid.GetRangeStyle(this.calculator.ResolveAddress(e,this.grid.active_sheet),t)}SetRange(e,t=void 0,i={}){if(!e){let r=this.GetSelectionReference();r.empty||(e=r.area)}if(e){let r=this.calculator.ResolveArea(e,this.grid.active_sheet);if(i.spill&&Array.isArray(t)){let s=t.length,n=Math.max(0,...t.map(a=>a.length)),o={row:r.start.row+s+1,column:r.start.column+n+1};r.ConsumeAddress(o)}return this.grid.SetRange(r,t,i.recycle,i.transpose,i.array,!0)}}Subscribe(e){return this.events.Subscribe(e)}Cancel(e){this.events.Cancel(e)}Publish(e){this.events.Publish(e)}async ImportXLSX(e,t){if(!this.export_worker){let i="treb-export-worker";this.export_worker=await this.LoadWorker(i)}return new Promise((i,r)=>{this.export_worker?(this.dialog?.ShowDialog({message:"Importing XLSX..."}),this.export_worker.onmessage=s=>{if(s.data){if(s.data.status==="error")return r(s.data.error||"unknown error");this.grid.FromImportData(s.data.results),this.ResetInternal(),this.grid.Update(),this.UpdateAC(),this.calculator.AttachModel(),this.Publish({type:"load",source:t}),this.UpdateDocumentStyles(),this.InflateAnnotations()}else return r("unknown error (missing data)");this.dialog?.HideDialog(),i()},this.export_worker.onerror=s=>{console.error("import worker error"),console.info(s),r(s)},this.export_worker.postMessage({command:"import",data:e})):r("worker failed")})}ResetInternal(){this.calculator.Reset(),this.FlushUndo(),this.file_version=this.last_save_version=0}HandleCellEvent(e){if(e.data?.type==="hyperlink"){let i="hyperlink invalid target",r=e.data.data||"";if(typeof r=="string"){if(/^https{0,1}:\/\//i.test(r)){if(!this.options.hyperlinks){console.warn("hyperlinks are disabled");return}let s=document.createElement("a");s.setAttribute("target",this.options.hyperlinks),s.setAttribute("href",r),s.setAttribute("noreferrer","true"),s.setAttribute("nofollow","true"),s.click();return}else{let s=this.parser.Parse(r);if(s.expression){if(s.expression.type==="address"){(s.expression.sheet||s.expression.sheet_id)&&this.ActivateSheet(s.expression.sheet||s.expression.sheet_id),this.Select(r);return}else if(s.expression.type==="range"){(s.expression.start.sheet||s.expression.start.sheet_id)&&this.ActivateSheet(s.expression.start.sheet||s.expression.start.sheet_id),this.Select(r);return}}}console.warn(i,2);return}}}OnSheetChange(e){for(let t of e.activate.annotations)this.InflateAnnotation(t),this.calculator.UpdateAnnotations(t,e.activate);this.UpdateAnnotations()}HandleDrag(e){if(e.dataTransfer&&e.dataTransfer.types){if(e.dataTransfer.types.some&&e.dataTransfer.types.some(t=>t==="Files"))e.preventDefault();else for(let t=0;t<e.dataTransfer.types.length;t++)if(e.dataTransfer.types[t]==="files"){e.preventDefault();return}}}HandleDrop(e){if(e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){e.preventDefault();let t=e.dataTransfer.files[0];/^image/.test(t.type)?this.InsertImageInternal(t):this.LoadFileInternal(t,"drag-and-drop").catch(()=>{})}}SelectFile2(e,t){if(!this.file_chooser){this.file_chooser=document.createElement("input"),this.file_chooser.type="file";let i=this.file_chooser;i.addEventListener("change",()=>{if(i.files&&i.files[0]){let r=i.files[0];switch(i.value="",this.file_chooser_operation){case 2:this.InsertImageInternal(r);break;case 1:this.LoadFileInternal(r,"local-file",!0);break;default:console.warn("file chooser: no operation");break}}})}if(!this.file_chooser)throw new Error("could not create file chooser");this.file_chooser_operation=t,this.file_chooser.accept=e||"",this.file_chooser.click()}async InsertImageInternal(e){if(this.options.max_file_size&&e.size>this.options.max_file_size){this.dialog?.ShowDialog({type:"error",message:"This file exceeds the allowed image size. Please try a smaller image.",title:"Error adding image",timeout:3e3,close_box:!0});return}let t=e;await new Promise((i,r)=>{let s=new FileReader;s.onload=async()=>{try{if(s.result){let n;if(typeof s.result=="string")n=s.result;else{n="";let l=new Uint8Array(s.result);for(let d=0;d<l.byteLength;d++)n+=String.fromCharCode(l[d])}let o=document.createElement("img");o.src=n,await Promise.resolve();let a=this.grid.CreateAnnotation({type:"image",formula:""},void 0,void 0,{top:30,left:30,width:o.width||300,height:o.height||300});a.data.src=n,a.data.original_size={width:o.width||300,height:o.height||300}}i()}catch(n){r(n)}},s.onabort=()=>{r("Aborted")},s.onerror=()=>{r("File error")},setTimeout(()=>{s.readAsDataURL(t)},100)})}LoadFileInternal(e,t,i=!0){if(!e)return Promise.resolve();let r=new FileReader;return new Promise((s,n)=>{let o=a=>{r.onload=null,r.onabort=null,r.onerror=null,a?(i&&(this.dialog?.ShowDialog({title:"Error reading file",close_box:!0,message:"Please make sure your file is a valid XLSX, CSV or TREB file.",type:"error",timeout:3e3}),console.error(a)),n(a)):s()};r.onload=()=>{try{if(r.result)if(/\.csv$/i.test(e.name))this.LoadCSV(r.result,t);else if(/\.xls[xm]$/i.test(e.name)){let a;if(typeof r.result=="string")a=r.result;else{a="";let l=new Uint8Array(r.result);for(let d=0;d<l.byteLength;d++)a+=String.fromCharCode(l[d])}this.ImportXLSX(a,t).then(()=>o()).catch(l=>o(l));return}else{let a=JSON.parse(r.result);this.LoadDocument(a,{source:t})}o()}catch(a){o(a?.toString())}},r.onabort=()=>{o("Aborted")},r.onerror=()=>{o("File error")},setTimeout(()=>{/\.xlsx$/i.test(e.name)?r.readAsBinaryString?r.readAsBinaryString(e):r.readAsArrayBuffer(e):r.readAsText(e)},100)})}UpdateAnnotations(){for(let e of this.grid.active_sheet.annotations){if(e.temp.vertex){let i=e.temp.vertex;if(i.state_id!==e.temp.state){e.temp.state=i.state_id;for(let r of e.view)r.dirty=!0}}let t=e.view[this.grid.view_index]||{};t.dirty&&(t.update_callback&&t.update_callback(),this.grid.AnnotationUpdated(e))}}RebuildAllAnnotations(){for(let e of this.grid.active_sheet.annotations){this.InflateAnnotation(e);let t=e.view[this.grid.view_index]||{};t.resize_callback&&t.resize_callback(),t.update_callback&&t.update_callback()}}InflateAnnotations(){for(let e of this.grid.active_sheet.annotations)this.InflateAnnotation(e)}InflateAnnotation(e){if(this.grid.headless)return;let t=e.view[this.grid.view_index]||{};if(t.inflated){e.dirty&&(t.resize_callback&&t.resize_callback(),e.dirty=!1);return}if(t.inflated=!0,e.dirty&&(e.dirty=!1),t.content_node&&e.data){if(e.type==="treb-chart"){let i=this.CreateChart();i.Initialize(t.content_node);let r=()=>{if(e.formula){let s=this.parser.Parse(e.formula);if(s&&s.expression&&s.expression.type==="call"){this.parser.Walk(s.expression,a=>((a.type==="address"||a.type==="range")&&this.calculator.ResolveSheetID(a,void 0,this.grid.active_sheet),!0));let n=s.expression.name.toLowerCase(),o=this.calculator.CalculateExpression(s.expression);i.Exec(n,o)}}i.Update()};t.resize_callback=()=>{this.grid.headless||(i.Resize(),i.Update())},t.update_callback=()=>{this.grid.headless||r()},t.node?.parentElement&&(this.grid.headless||r())}else if(e.type==="image"){let i=document.createElement("img");typeof e.data.src=="string"&&/^data:image/i.test(e.data.src)&&i.setAttribute("src",e.data.src),i.style.width="100%",i.style.height="100%",t.content_node.appendChild(i)}}}DocumentChange(e){se().then(()=>{this.file_version++,this.file_version>=65536&&(this.file_version=1);let t=JSON.stringify(this.SerializeDocument({optimize:"size",rendered_values:!0,expand_arrays:!0}));this.options.storage_key&&localStorage.setItem(this.options.storage_key,t),this.options.undo&&this.PushUndo(t,e,!1),this.Publish({type:"document-change"})})}PushUndo(e,t,i=!0){let r=t||this.last_selection;this.undo_stack[this.undo_pointer-1]&&(this.undo_stack[this.undo_pointer-1].selection=r),i&&(this.file_version++,this.file_version>=65536&&(this.file_version=1)),e||(e=JSON.stringify(this.SerializeDocument({optimize:"size",rendered_values:!0,expand_arrays:!0}))),this.undo_stack[this.undo_pointer++]={data:e,selection:void 0};let s=this.undo_stack.length;if(s>16){let n=s-16;this.undo_stack=this.undo_stack.slice(n),this.undo_pointer-=n}}FlushUndo(e=!0){this.undo_stack=[],this.undo_pointer=0,this.last_save_version=this.file_version,e&&this.PushUndo(void 0,void 0,!1)}UpdateSelection(e){this.last_selection=JSON.stringify(e),this.Publish({type:"selection"})}UpdateSelectionStyle(e){let t=this.grid.GetFreeze(),i={frozen:!!t.rows||!!t.columns};if(e||(e=this.grid.GetSelection()),e&&!e.empty){i.selection=e,i.merge=!1;let r=this.grid.active_sheet.CellData(e.target);i.merge=!!r.merge_area,i.merge&&r.merge_area&&(r.merge_area.start.row!==e.target.row||r.merge_area.start.column!==e.target.column)&&(r=this.grid.active_sheet.CellData(r.merge_area.start)),i.comment=r.note,i.style=r.style?{...r.style}:void 0}this.selection_state=i,this.toolbar?.UpdateState(i)}UpdateDocumentStyles(e=!0){if(!this.toolbar)return;let t={},i={};for(let r of this.grid.model.sheets.list)r.NumberFormatsAndColors(i,t);this.toolbar.UpdateDocumentStyles(Object.keys(t),Object.keys(i),e)}ConvertLocale(e){let t=new $e;t.flags={...this.parser.flags};let i,r;e.decimal_mark==="."?(t.decimal_mark=".",t.argument_separator=",",i=",",r=";"):(t.decimal_mark=",",t.argument_separator=";",i=".",r=",");let s=n=>{let o=t.Parse(n);if(!!o.expression)return"="+t.Render(o.expression,void 0,"",i,r)};if(e.macro_functions)for(let n of e.macro_functions){let o=s(n.function_def);o&&(n.function_def=o)}if(e.sheet_data){let n=Array.isArray(e.sheet_data)?e.sheet_data:[e.sheet_data];for(let o of n){if(o.annotations){for(let a of o.annotations)if(a.formula){let l=s(a.formula);l&&(a.formula=l)}}if(o.data?.length)for(let a of o.data){let l=oi(a)?[a]:a.cells;for(let d of l)if(d.value&&typeof d.value=="string"&&d.value[0]==="="){let u=s(d.value.slice(1));u&&(d.value=u)}}}}}CompareVersions(e="",t=""){let i=e.split(".").map(o=>Number(o)||0).concat([0,0,0]),r=t.split(".").map(o=>Number(o)||0).concat([0,0,0]),s=[0,1,2],n={match:0};for(let o=0;o<3;o++)if(i[o]!==r[o]){n.match=i[o]>r[o]?1:-1,n.level=s[o];break}return n}ImportDocumentData(e,t){this.file_version=e.revision||0;let i=[],r=this.CompareVersions(e.version,"21.6.2");r.match>0&&(r.level===0||r.level===1)&&console.warn(`The file you are opening was created with a newer version of TREB (${e.version} vs 21.6.2).
|
|
15
|
-
You may encounter compatibility errors.`),e.sheet_data&&(Array.isArray(e.sheet_data)?i=e.sheet_data:i.push(e.sheet_data)),e.decimal_mark&&e.decimal_mark!==T.decimal_separator&&this.ConvertLocale(e),this.grid.UpdateSheets(i,void 0,t||e.active_sheet);let s=this.grid.model;s.document_name=e.name,s.user_data=e.user_data,s.named_ranges.Reset();let n=e.named_ranges;if(!n&&i[0]&&i[0].named_ranges&&(n=i[0].named_ranges),n&&s.named_ranges.Deserialize(n),s.named_expressions.clear(),e.named_expressions)for(let o of e.named_expressions){let a=this.parser.Parse(o.expression);a.valid&&a.expression&&(this.parser.Walk(a.expression,l=>{if(l.type==="address"||l.type==="range"){if(l.type==="range"&&(l=l.start),!l.sheet_id&&l.sheet){let d=this.model.sheets.Find(l.sheet);d&&(l.sheet_id=d.id)}return l.sheet_id||(l.sheet_id=this.grid.active_sheet.id),!1}return!0}),s.named_expressions.set(o.name.toUpperCase(),a.expression))}if(s.macro_functions.clear(),e.macro_functions)for(let o of e.macro_functions)s.macro_functions.set(o.name.toUpperCase(),{...o,expression:this.parser.Parse(o.function_def||"").expression});this.UpdateAC()}async LoadWorker(e){if(Oe.export_worker_text)try{return new Worker(URL.createObjectURL(new Blob([Oe.export_worker_text],{type:"application/javascript"})))}catch(r){console.info("embedded worker failed"),console.error(r)}if(!Oe.treb_base_path)throw console.warn("worker path is not set. it you are loading TREB in an ESM module, please either include the script in a document <script/> tag, or call the method TREB.SetScriptPath() to set the load path for workers (this should be the path to TREB script files)."),new Error("worker path not set");/\.js$/.test(e)||(e+="-21.6.2.js");let t,i=Oe.treb_base_path;if(i&&(/\/$/.test(i)||(i+="/"),e=i+e),/^(http:|https:|\/\/)/.test(e)){let r=await fetch(e);if(!r.ok)throw new Error("Error loading worker script");let s=await r.text();t=new Worker(URL.createObjectURL(new Blob([s],{type:"application/javascript"})))}else{if(/^file:/.test(e))throw new Error("invalid URI");t=new Worker(e)}return t}HandleKeyDown(e){e.ctrlKey&&(e.code==="KeyZ"||e.key==="z")&&(e.stopPropagation(),e.preventDefault(),this.Undo())}ResolveSheetName(e,t=!1){let i=this.model.sheets.Find(e);if(i)return t&&st.test(i.name)?`'${i.name}'`:i.name}},ne=Oe;E(ne,"treb_base_path",""),E(ne,"export_worker_text",""),E(ne,"treb_embedded_script_path",""),E(ne,"enable_engine",!1),E(ne,"enable_formatter",!1);var Qi="sidebar-open",ri="toolbar-open";var er=class{constructor(e,t){this.base_type=e;let i=typeof t.container=="string"?document.querySelector(t.container):t.container;if(!i)throw new Error("missing container");i.classList.add("treb-container"),this.options={...ei,...t},window.getComputedStyle(i).position==="static"&&(i.style.position="relative");let s=i.getBoundingClientRect();!this.options.headless&&(!s.width||!s.height)&&i.classList.add("default-spreadsheet-size"),this.inner_container=document.createElement("div"),this.inner_container.classList.add("treb-views"),this.options.collapsed||i.classList.add("sidebar-open"),(this.options.toolbar==="show"||this.options.toolbar==="show-narrow")&&i.classList.add(ri),i.appendChild(this.inner_container),this.sheet=new e({...this.options,container:this.inner_container,resizable:!1}),this.sidebar=document.createElement("div"),this.sidebar.classList.add("embedded-spreadsheet-sidebar"),this.AddSidebarButton({icon:"treb-icon-reset",title:"Recalculate",click:()=>this.sheet.Recalculate()}),this.options.toolbar&&(this.toolbar_container=document.createElement("div"),this.toolbar_container.classList.add("toolbar-container"),this.toolbar_button=this.AddSidebarButton({icon:"treb-icon-toolbar",title:"Show Toolbar",click:()=>this.ToggleToolbar()}),i.appendChild(this.toolbar_container),this.sheet.toolbar_ctl={Show:a=>this.ShowToolbar(a)}),this.options.export&&this.AddSidebarButton({icon:"treb-icon-export",title:"Download as XLSX",click:()=>this.sheet.Export()}),this.options.revert&&this.AddSidebarButton({icon:"treb-icon-revert",title:"Revert to original version",click:()=>this.sheet.Revert()}),this.options.popout&&this.AddSidebarButton({icon:"treb-icon-popout",title:"Open in New Tab",click:()=>this.Popout()}),this.AddSidebarButton({icon:"treb-icon-about",title:"What's This?",click:()=>this.sheet.About()});let n=document.createElement("div");n.classList.add("sidebar-spacer"),this.sidebar.appendChild(n),this.AddSidebarButton({icon:"treb-icon-chevron-right",classes:"smaller",title:"Hide Sidebar",click:()=>this.HideSidebar()}),i.appendChild(this.sidebar);let o=this.AddSidebarButton({icon:"treb-icon-chevron-left",classes:["smaller","show-sidebar-button"],title:"Show Sidebar",click:()=>this.ShowSidebar()},void 0);if(i.appendChild(o),this.options.resizable){let a=i.querySelector(".treb-grid"),l=i.querySelector(".treb-layout-master");a&&Be.Create({container:i,node:a,resize_callback:()=>this.sheet.Resize(),layout_reference:l||void 0})}(this.options.toolbar==="show"||this.options.toolbar==="show-narrow")&&this.ShowToolbar(!0),t.container._spreadsheet=this.sheet}inner_container;sidebar;toolbar_container;toolbar_button;sheet;options;toolbar;static Create(e,t){return new er(e,t)}Popout(){let e=window.open("","_blank");if(!e)return;e.document.head.innerHTML=`<title>${this.sheet.document_name?`TREB: ${this.sheet.document_name}`:"TREB: Untitled Document"}</title><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='IE=edge'><meta name='viewport' content='width=device-width,initial-scale=1'><link rel='icon' type='image/svg+xml' href='https://treb.app/leaf.svg'>`;let t="treb-bundle";/\.js$/.test(t)||(t+=".js");let i=ne.treb_base_path;i&&(/\/$/.test(i)||(i+="/"),t=i+t);let r=e.document.createElement("script");r.src=t,r.setAttribute("type","text/javascript"),e.document.body.appendChild(r);let s=JSON.stringify(this.sheet.SerializeDocument({rendered_values:!0})),n=e.document.createElement("style");n.setAttribute("type","text/css"),n.textContent="*{box-sizing:border-box;padding:0;margin:0;}body,html{height:100%;width:100%;position:relative;}.treb{top:0;left:0;right:0;bottom:0;position:absolute;background:#fff;}",e.document.head.appendChild(n);let o=e.document.createElement("div");o.setAttribute("class","treb treb-fullscreen-padding"),e.document.body.appendChild(o);let a=window.screen.availWidth>=1200,l=e.document.createElement("script"),d={...this.options,container:void 0,network_document:void 0,storage_key:void 0,resizable:!1,export:!0,scroll:void 0,toolbar:a?"show":!0,file_menu:!0,prompt_save:!0,expand_formula_button:a,popout:!1,add_tab:!0,tab_bar:"auto",headless:!1,dnd:!0,collapsed:!a},u=(h,p)=>{let f=0,m=()=>{h.container=document.querySelector(".treb"),h.container&&window.TREB?(window.sheet=window.TREB.CreateSpreadsheet(h),window.sheet.LoadDocument(p)):++f<32&&setTimeout(()=>m(),100)};m()};l.textContent=`(${u.toString()})(${JSON.stringify(d)},${s})`,e.document.body.appendChild(l),e.document.close()}AddSidebarButton(e={},t=this.sidebar){let i=document.createElement("button");if(i.setAttribute("type","button"),i.classList.add("sidebar-button"),e.classes){let r=typeof e.classes=="string"?[e.classes]:e.classes;for(let s of r)i.classList.add(s)}if(e.title&&i.setAttribute("title",e.title),e.text&&(i.textContent=e.text),e.click){let r=e.click;i.addEventListener("click",()=>r())}if(e.icon&&i.classList.add("treb-icon",e.icon),t)if(typeof e.position=="number"){let s=t.children[e.position];s?t.insertBefore(i,s):t.appendChild(i)}else t.appendChild(i);return i}ToggleSidebar(){this.sidebar.parentElement.classList.toggle(Qi)}ShowSidebar(e=!0){let t=this.sidebar.parentElement;e?t.classList.add(Qi):t.classList.remove(Qi)}HideSidebar(){this.ShowSidebar(!1)}ToggleToolbar(){let e=this.toolbar_container?.parentElement;this.ShowToolbar(!e.classList.contains(ri))}ShowToolbar(e=!0){let t=this.toolbar_container?.parentElement,i="Hide Toolbar";e?(this.toolbar_container&&!this.toolbar&&(this.toolbar=this.sheet.CreateToolbar(this.toolbar_container)),t.classList.add(ri)):(t.classList.remove(ri),i="Show Toolbar"),this.toolbar_button&&this.toolbar_button.setAttribute("title",i)}HideToolbar(){this.ShowToolbar(!1)}},gt=er;E(gt,"symbols_injected",!1);var rs='"use strict";/*! TREB v21.6.2. Copyright 2018-2022 trebco, llc. All rights reserved. LGPL: https://treb.app/license */\n(()=>{var ki=Object.create;var Bt=Object.defineProperty;var Ni=Object.getOwnPropertyDescriptor;var Fi=Object.getOwnPropertyNames;var Si=Object.getPrototypeOf,Ti=Object.prototype.hasOwnProperty;var Pi=(s,e,t)=>e in s?Bt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Ye=(s=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(s,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):s)(function(s){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error(\'Dynamic require of "\'+s+\'" is not supported\')});var ge=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Ri=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fi(e))!Ti.call(s,n)&&n!==t&&Bt(s,n,{get:()=>e[n],enumerable:!(r=Ni(e,n))||r.enumerable});return s};var Fe=(s,e,t)=>(t=s!=null?ki(Si(s)):{},Ri(e||!s||!s.__esModule?Bt(t,"default",{value:s,enumerable:!0}):t,s));var ie=(s,e,t)=>(Pi(s,typeof e!="symbol"?e+"":e,t),t);var st=ge((nt,He)=>{(function(s){var e=typeof nt=="object"&&nt,t=typeof He=="object"&&He&&He.exports==e&&He,r=typeof global=="object"&&global;(r.global===r||r.window===r)&&(s=r);var n=/[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g,i=/[\\x01-\\x7F]/g,a=/[\\x01-\\t\\x0B\\f\\x0E-\\x1F\\x7F\\x81\\x8D\\x8F\\x90\\x9D\\xA0-\\uFFFF]/g,o=/<\\u20D2|=\\u20E5|>\\u20D2|\\u205F\\u200A|\\u219D\\u0338|\\u2202\\u0338|\\u2220\\u20D2|\\u2229\\uFE00|\\u222A\\uFE00|\\u223C\\u20D2|\\u223D\\u0331|\\u223E\\u0333|\\u2242\\u0338|\\u224B\\u0338|\\u224D\\u20D2|\\u224E\\u0338|\\u224F\\u0338|\\u2250\\u0338|\\u2261\\u20E5|\\u2264\\u20D2|\\u2265\\u20D2|\\u2266\\u0338|\\u2267\\u0338|\\u2268\\uFE00|\\u2269\\uFE00|\\u226A\\u0338|\\u226A\\u20D2|\\u226B\\u0338|\\u226B\\u20D2|\\u227F\\u0338|\\u2282\\u20D2|\\u2283\\u20D2|\\u228A\\uFE00|\\u228B\\uFE00|\\u228F\\u0338|\\u2290\\u0338|\\u2293\\uFE00|\\u2294\\uFE00|\\u22B4\\u20D2|\\u22B5\\u20D2|\\u22D8\\u0338|\\u22D9\\u0338|\\u22DA\\uFE00|\\u22DB\\uFE00|\\u22F5\\u0338|\\u22F9\\u0338|\\u2933\\u0338|\\u29CF\\u0338|\\u29D0\\u0338|\\u2A6D\\u0338|\\u2A70\\u0338|\\u2A7D\\u0338|\\u2A7E\\u0338|\\u2AA1\\u0338|\\u2AA2\\u0338|\\u2AAC\\uFE00|\\u2AAD\\uFE00|\\u2AAF\\u0338|\\u2AB0\\u0338|\\u2AC5\\u0338|\\u2AC6\\u0338|\\u2ACB\\uFE00|\\u2ACC\\uFE00|\\u2AFD\\u20E5|[\\xA0-\\u0113\\u0116-\\u0122\\u0124-\\u012B\\u012E-\\u014D\\u0150-\\u017E\\u0192\\u01B5\\u01F5\\u0237\\u02C6\\u02C7\\u02D8-\\u02DD\\u0311\\u0391-\\u03A1\\u03A3-\\u03A9\\u03B1-\\u03C9\\u03D1\\u03D2\\u03D5\\u03D6\\u03DC\\u03DD\\u03F0\\u03F1\\u03F5\\u03F6\\u0401-\\u040C\\u040E-\\u044F\\u0451-\\u045C\\u045E\\u045F\\u2002-\\u2005\\u2007-\\u2010\\u2013-\\u2016\\u2018-\\u201A\\u201C-\\u201E\\u2020-\\u2022\\u2025\\u2026\\u2030-\\u2035\\u2039\\u203A\\u203E\\u2041\\u2043\\u2044\\u204F\\u2057\\u205F-\\u2063\\u20AC\\u20DB\\u20DC\\u2102\\u2105\\u210A-\\u2113\\u2115-\\u211E\\u2122\\u2124\\u2127-\\u2129\\u212C\\u212D\\u212F-\\u2131\\u2133-\\u2138\\u2145-\\u2148\\u2153-\\u215E\\u2190-\\u219B\\u219D-\\u21A7\\u21A9-\\u21AE\\u21B0-\\u21B3\\u21B5-\\u21B7\\u21BA-\\u21DB\\u21DD\\u21E4\\u21E5\\u21F5\\u21FD-\\u2205\\u2207-\\u2209\\u220B\\u220C\\u220F-\\u2214\\u2216-\\u2218\\u221A\\u221D-\\u2238\\u223A-\\u2257\\u2259\\u225A\\u225C\\u225F-\\u2262\\u2264-\\u228B\\u228D-\\u229B\\u229D-\\u22A5\\u22A7-\\u22B0\\u22B2-\\u22BB\\u22BD-\\u22DB\\u22DE-\\u22E3\\u22E6-\\u22F7\\u22F9-\\u22FE\\u2305\\u2306\\u2308-\\u2310\\u2312\\u2313\\u2315\\u2316\\u231C-\\u231F\\u2322\\u2323\\u232D\\u232E\\u2336\\u233D\\u233F\\u237C\\u23B0\\u23B1\\u23B4-\\u23B6\\u23DC-\\u23DF\\u23E2\\u23E7\\u2423\\u24C8\\u2500\\u2502\\u250C\\u2510\\u2514\\u2518\\u251C\\u2524\\u252C\\u2534\\u253C\\u2550-\\u256C\\u2580\\u2584\\u2588\\u2591-\\u2593\\u25A1\\u25AA\\u25AB\\u25AD\\u25AE\\u25B1\\u25B3-\\u25B5\\u25B8\\u25B9\\u25BD-\\u25BF\\u25C2\\u25C3\\u25CA\\u25CB\\u25EC\\u25EF\\u25F8-\\u25FC\\u2605\\u2606\\u260E\\u2640\\u2642\\u2660\\u2663\\u2665\\u2666\\u266A\\u266D-\\u266F\\u2713\\u2717\\u2720\\u2736\\u2758\\u2772\\u2773\\u27C8\\u27C9\\u27E6-\\u27ED\\u27F5-\\u27FA\\u27FC\\u27FF\\u2902-\\u2905\\u290C-\\u2913\\u2916\\u2919-\\u2920\\u2923-\\u292A\\u2933\\u2935-\\u2939\\u293C\\u293D\\u2945\\u2948-\\u294B\\u294E-\\u2976\\u2978\\u2979\\u297B-\\u297F\\u2985\\u2986\\u298B-\\u2996\\u299A\\u299C\\u299D\\u29A4-\\u29B7\\u29B9\\u29BB\\u29BC\\u29BE-\\u29C5\\u29C9\\u29CD-\\u29D0\\u29DC-\\u29DE\\u29E3-\\u29E5\\u29EB\\u29F4\\u29F6\\u2A00-\\u2A02\\u2A04\\u2A06\\u2A0C\\u2A0D\\u2A10-\\u2A17\\u2A22-\\u2A27\\u2A29\\u2A2A\\u2A2D-\\u2A31\\u2A33-\\u2A3C\\u2A3F\\u2A40\\u2A42-\\u2A4D\\u2A50\\u2A53-\\u2A58\\u2A5A-\\u2A5D\\u2A5F\\u2A66\\u2A6A\\u2A6D-\\u2A75\\u2A77-\\u2A9A\\u2A9D-\\u2AA2\\u2AA4-\\u2AB0\\u2AB3-\\u2AC8\\u2ACB\\u2ACC\\u2ACF-\\u2ADB\\u2AE4\\u2AE6-\\u2AE9\\u2AEB-\\u2AF3\\u2AFD\\uFB00-\\uFB04]|\\uD835[\\uDC9C\\uDC9E\\uDC9F\\uDCA2\\uDCA5\\uDCA6\\uDCA9-\\uDCAC\\uDCAE-\\uDCB9\\uDCBB\\uDCBD-\\uDCC3\\uDCC5-\\uDCCF\\uDD04\\uDD05\\uDD07-\\uDD0A\\uDD0D-\\uDD14\\uDD16-\\uDD1C\\uDD1E-\\uDD39\\uDD3B-\\uDD3E\\uDD40-\\uDD44\\uDD46\\uDD4A-\\uDD50\\uDD52-\\uDD6B]/g,u={"\\xAD":"shy","\\u200C":"zwnj","\\u200D":"zwj","\\u200E":"lrm","\\u2063":"ic","\\u2062":"it","\\u2061":"af","\\u200F":"rlm","\\u200B":"ZeroWidthSpace","\\u2060":"NoBreak","\\u0311":"DownBreve","\\u20DB":"tdot","\\u20DC":"DotDot"," ":"Tab","\\n":"NewLine","\\u2008":"puncsp","\\u205F":"MediumSpace","\\u2009":"thinsp","\\u200A":"hairsp","\\u2004":"emsp13","\\u2002":"ensp","\\u2005":"emsp14","\\u2003":"emsp","\\u2007":"numsp","\\xA0":"nbsp","\\u205F\\u200A":"ThickSpace","\\u203E":"oline",_:"lowbar","\\u2010":"dash","\\u2013":"ndash","\\u2014":"mdash","\\u2015":"horbar",",":"comma",";":"semi","\\u204F":"bsemi",":":"colon","\\u2A74":"Colone","!":"excl","\\xA1":"iexcl","?":"quest","\\xBF":"iquest",".":"period","\\u2025":"nldr","\\u2026":"mldr","\\xB7":"middot","\'":"apos","\\u2018":"lsquo","\\u2019":"rsquo","\\u201A":"sbquo","\\u2039":"lsaquo","\\u203A":"rsaquo",\'"\':"quot","\\u201C":"ldquo","\\u201D":"rdquo","\\u201E":"bdquo","\\xAB":"laquo","\\xBB":"raquo","(":"lpar",")":"rpar","[":"lsqb","]":"rsqb","{":"lcub","}":"rcub","\\u2308":"lceil","\\u2309":"rceil","\\u230A":"lfloor","\\u230B":"rfloor","\\u2985":"lopar","\\u2986":"ropar","\\u298B":"lbrke","\\u298C":"rbrke","\\u298D":"lbrkslu","\\u298E":"rbrksld","\\u298F":"lbrksld","\\u2990":"rbrkslu","\\u2991":"langd","\\u2992":"rangd","\\u2993":"lparlt","\\u2994":"rpargt","\\u2995":"gtlPar","\\u2996":"ltrPar","\\u27E6":"lobrk","\\u27E7":"robrk","\\u27E8":"lang","\\u27E9":"rang","\\u27EA":"Lang","\\u27EB":"Rang","\\u27EC":"loang","\\u27ED":"roang","\\u2772":"lbbrk","\\u2773":"rbbrk","\\u2016":"Vert","\\xA7":"sect","\\xB6":"para","@":"commat","*":"ast","/":"sol",undefined:null,"&":"amp","#":"num","%":"percnt","\\u2030":"permil","\\u2031":"pertenk","\\u2020":"dagger","\\u2021":"Dagger","\\u2022":"bull","\\u2043":"hybull","\\u2032":"prime","\\u2033":"Prime","\\u2034":"tprime","\\u2057":"qprime","\\u2035":"bprime","\\u2041":"caret","`":"grave","\\xB4":"acute","\\u02DC":"tilde","^":"Hat","\\xAF":"macr","\\u02D8":"breve","\\u02D9":"dot","\\xA8":"die","\\u02DA":"ring","\\u02DD":"dblac","\\xB8":"cedil","\\u02DB":"ogon","\\u02C6":"circ","\\u02C7":"caron","\\xB0":"deg","\\xA9":"copy","\\xAE":"reg","\\u2117":"copysr","\\u2118":"wp","\\u211E":"rx","\\u2127":"mho","\\u2129":"iiota","\\u2190":"larr","\\u219A":"nlarr","\\u2192":"rarr","\\u219B":"nrarr","\\u2191":"uarr","\\u2193":"darr","\\u2194":"harr","\\u21AE":"nharr","\\u2195":"varr","\\u2196":"nwarr","\\u2197":"nearr","\\u2198":"searr","\\u2199":"swarr","\\u219D":"rarrw","\\u219D\\u0338":"nrarrw","\\u219E":"Larr","\\u219F":"Uarr","\\u21A0":"Rarr","\\u21A1":"Darr","\\u21A2":"larrtl","\\u21A3":"rarrtl","\\u21A4":"mapstoleft","\\u21A5":"mapstoup","\\u21A6":"map","\\u21A7":"mapstodown","\\u21A9":"larrhk","\\u21AA":"rarrhk","\\u21AB":"larrlp","\\u21AC":"rarrlp","\\u21AD":"harrw","\\u21B0":"lsh","\\u21B1":"rsh","\\u21B2":"ldsh","\\u21B3":"rdsh","\\u21B5":"crarr","\\u21B6":"cularr","\\u21B7":"curarr","\\u21BA":"olarr","\\u21BB":"orarr","\\u21BC":"lharu","\\u21BD":"lhard","\\u21BE":"uharr","\\u21BF":"uharl","\\u21C0":"rharu","\\u21C1":"rhard","\\u21C2":"dharr","\\u21C3":"dharl","\\u21C4":"rlarr","\\u21C5":"udarr","\\u21C6":"lrarr","\\u21C7":"llarr","\\u21C8":"uuarr","\\u21C9":"rrarr","\\u21CA":"ddarr","\\u21CB":"lrhar","\\u21CC":"rlhar","\\u21D0":"lArr","\\u21CD":"nlArr","\\u21D1":"uArr","\\u21D2":"rArr","\\u21CF":"nrArr","\\u21D3":"dArr","\\u21D4":"iff","\\u21CE":"nhArr","\\u21D5":"vArr","\\u21D6":"nwArr","\\u21D7":"neArr","\\u21D8":"seArr","\\u21D9":"swArr","\\u21DA":"lAarr","\\u21DB":"rAarr","\\u21DD":"zigrarr","\\u21E4":"larrb","\\u21E5":"rarrb","\\u21F5":"duarr","\\u21FD":"loarr","\\u21FE":"roarr","\\u21FF":"hoarr","\\u2200":"forall","\\u2201":"comp","\\u2202":"part","\\u2202\\u0338":"npart","\\u2203":"exist","\\u2204":"nexist","\\u2205":"empty","\\u2207":"Del","\\u2208":"in","\\u2209":"notin","\\u220B":"ni","\\u220C":"notni","\\u03F6":"bepsi","\\u220F":"prod","\\u2210":"coprod","\\u2211":"sum","+":"plus","\\xB1":"pm","\\xF7":"div","\\xD7":"times","<":"lt","\\u226E":"nlt","<\\u20D2":"nvlt","=":"equals","\\u2260":"ne","=\\u20E5":"bne","\\u2A75":"Equal",">":"gt","\\u226F":"ngt",">\\u20D2":"nvgt","\\xAC":"not","|":"vert","\\xA6":"brvbar","\\u2212":"minus","\\u2213":"mp","\\u2214":"plusdo","\\u2044":"frasl","\\u2216":"setmn","\\u2217":"lowast","\\u2218":"compfn","\\u221A":"Sqrt","\\u221D":"prop","\\u221E":"infin","\\u221F":"angrt","\\u2220":"ang","\\u2220\\u20D2":"nang","\\u2221":"angmsd","\\u2222":"angsph","\\u2223":"mid","\\u2224":"nmid","\\u2225":"par","\\u2226":"npar","\\u2227":"and","\\u2228":"or","\\u2229":"cap","\\u2229\\uFE00":"caps","\\u222A":"cup","\\u222A\\uFE00":"cups","\\u222B":"int","\\u222C":"Int","\\u222D":"tint","\\u2A0C":"qint","\\u222E":"oint","\\u222F":"Conint","\\u2230":"Cconint","\\u2231":"cwint","\\u2232":"cwconint","\\u2233":"awconint","\\u2234":"there4","\\u2235":"becaus","\\u2236":"ratio","\\u2237":"Colon","\\u2238":"minusd","\\u223A":"mDDot","\\u223B":"homtht","\\u223C":"sim","\\u2241":"nsim","\\u223C\\u20D2":"nvsim","\\u223D":"bsim","\\u223D\\u0331":"race","\\u223E":"ac","\\u223E\\u0333":"acE","\\u223F":"acd","\\u2240":"wr","\\u2242":"esim","\\u2242\\u0338":"nesim","\\u2243":"sime","\\u2244":"nsime","\\u2245":"cong","\\u2247":"ncong","\\u2246":"simne","\\u2248":"ap","\\u2249":"nap","\\u224A":"ape","\\u224B":"apid","\\u224B\\u0338":"napid","\\u224C":"bcong","\\u224D":"CupCap","\\u226D":"NotCupCap","\\u224D\\u20D2":"nvap","\\u224E":"bump","\\u224E\\u0338":"nbump","\\u224F":"bumpe","\\u224F\\u0338":"nbumpe","\\u2250":"doteq","\\u2250\\u0338":"nedot","\\u2251":"eDot","\\u2252":"efDot","\\u2253":"erDot","\\u2254":"colone","\\u2255":"ecolon","\\u2256":"ecir","\\u2257":"cire","\\u2259":"wedgeq","\\u225A":"veeeq","\\u225C":"trie","\\u225F":"equest","\\u2261":"equiv","\\u2262":"nequiv","\\u2261\\u20E5":"bnequiv","\\u2264":"le","\\u2270":"nle","\\u2264\\u20D2":"nvle","\\u2265":"ge","\\u2271":"nge","\\u2265\\u20D2":"nvge","\\u2266":"lE","\\u2266\\u0338":"nlE","\\u2267":"gE","\\u2267\\u0338":"ngE","\\u2268\\uFE00":"lvnE","\\u2268":"lnE","\\u2269":"gnE","\\u2269\\uFE00":"gvnE","\\u226A":"ll","\\u226A\\u0338":"nLtv","\\u226A\\u20D2":"nLt","\\u226B":"gg","\\u226B\\u0338":"nGtv","\\u226B\\u20D2":"nGt","\\u226C":"twixt","\\u2272":"lsim","\\u2274":"nlsim","\\u2273":"gsim","\\u2275":"ngsim","\\u2276":"lg","\\u2278":"ntlg","\\u2277":"gl","\\u2279":"ntgl","\\u227A":"pr","\\u2280":"npr","\\u227B":"sc","\\u2281":"nsc","\\u227C":"prcue","\\u22E0":"nprcue","\\u227D":"sccue","\\u22E1":"nsccue","\\u227E":"prsim","\\u227F":"scsim","\\u227F\\u0338":"NotSucceedsTilde","\\u2282":"sub","\\u2284":"nsub","\\u2282\\u20D2":"vnsub","\\u2283":"sup","\\u2285":"nsup","\\u2283\\u20D2":"vnsup","\\u2286":"sube","\\u2288":"nsube","\\u2287":"supe","\\u2289":"nsupe","\\u228A\\uFE00":"vsubne","\\u228A":"subne","\\u228B\\uFE00":"vsupne","\\u228B":"supne","\\u228D":"cupdot","\\u228E":"uplus","\\u228F":"sqsub","\\u228F\\u0338":"NotSquareSubset","\\u2290":"sqsup","\\u2290\\u0338":"NotSquareSuperset","\\u2291":"sqsube","\\u22E2":"nsqsube","\\u2292":"sqsupe","\\u22E3":"nsqsupe","\\u2293":"sqcap","\\u2293\\uFE00":"sqcaps","\\u2294":"sqcup","\\u2294\\uFE00":"sqcups","\\u2295":"oplus","\\u2296":"ominus","\\u2297":"otimes","\\u2298":"osol","\\u2299":"odot","\\u229A":"ocir","\\u229B":"oast","\\u229D":"odash","\\u229E":"plusb","\\u229F":"minusb","\\u22A0":"timesb","\\u22A1":"sdotb","\\u22A2":"vdash","\\u22AC":"nvdash","\\u22A3":"dashv","\\u22A4":"top","\\u22A5":"bot","\\u22A7":"models","\\u22A8":"vDash","\\u22AD":"nvDash","\\u22A9":"Vdash","\\u22AE":"nVdash","\\u22AA":"Vvdash","\\u22AB":"VDash","\\u22AF":"nVDash","\\u22B0":"prurel","\\u22B2":"vltri","\\u22EA":"nltri","\\u22B3":"vrtri","\\u22EB":"nrtri","\\u22B4":"ltrie","\\u22EC":"nltrie","\\u22B4\\u20D2":"nvltrie","\\u22B5":"rtrie","\\u22ED":"nrtrie","\\u22B5\\u20D2":"nvrtrie","\\u22B6":"origof","\\u22B7":"imof","\\u22B8":"mumap","\\u22B9":"hercon","\\u22BA":"intcal","\\u22BB":"veebar","\\u22BD":"barvee","\\u22BE":"angrtvb","\\u22BF":"lrtri","\\u22C0":"Wedge","\\u22C1":"Vee","\\u22C2":"xcap","\\u22C3":"xcup","\\u22C4":"diam","\\u22C5":"sdot","\\u22C6":"Star","\\u22C7":"divonx","\\u22C8":"bowtie","\\u22C9":"ltimes","\\u22CA":"rtimes","\\u22CB":"lthree","\\u22CC":"rthree","\\u22CD":"bsime","\\u22CE":"cuvee","\\u22CF":"cuwed","\\u22D0":"Sub","\\u22D1":"Sup","\\u22D2":"Cap","\\u22D3":"Cup","\\u22D4":"fork","\\u22D5":"epar","\\u22D6":"ltdot","\\u22D7":"gtdot","\\u22D8":"Ll","\\u22D8\\u0338":"nLl","\\u22D9":"Gg","\\u22D9\\u0338":"nGg","\\u22DA\\uFE00":"lesg","\\u22DA":"leg","\\u22DB":"gel","\\u22DB\\uFE00":"gesl","\\u22DE":"cuepr","\\u22DF":"cuesc","\\u22E6":"lnsim","\\u22E7":"gnsim","\\u22E8":"prnsim","\\u22E9":"scnsim","\\u22EE":"vellip","\\u22EF":"ctdot","\\u22F0":"utdot","\\u22F1":"dtdot","\\u22F2":"disin","\\u22F3":"isinsv","\\u22F4":"isins","\\u22F5":"isindot","\\u22F5\\u0338":"notindot","\\u22F6":"notinvc","\\u22F7":"notinvb","\\u22F9":"isinE","\\u22F9\\u0338":"notinE","\\u22FA":"nisd","\\u22FB":"xnis","\\u22FC":"nis","\\u22FD":"notnivc","\\u22FE":"notnivb","\\u2305":"barwed","\\u2306":"Barwed","\\u230C":"drcrop","\\u230D":"dlcrop","\\u230E":"urcrop","\\u230F":"ulcrop","\\u2310":"bnot","\\u2312":"profline","\\u2313":"profsurf","\\u2315":"telrec","\\u2316":"target","\\u231C":"ulcorn","\\u231D":"urcorn","\\u231E":"dlcorn","\\u231F":"drcorn","\\u2322":"frown","\\u2323":"smile","\\u232D":"cylcty","\\u232E":"profalar","\\u2336":"topbot","\\u233D":"ovbar","\\u233F":"solbar","\\u237C":"angzarr","\\u23B0":"lmoust","\\u23B1":"rmoust","\\u23B4":"tbrk","\\u23B5":"bbrk","\\u23B6":"bbrktbrk","\\u23DC":"OverParenthesis","\\u23DD":"UnderParenthesis","\\u23DE":"OverBrace","\\u23DF":"UnderBrace","\\u23E2":"trpezium","\\u23E7":"elinters","\\u2423":"blank","\\u2500":"boxh","\\u2502":"boxv","\\u250C":"boxdr","\\u2510":"boxdl","\\u2514":"boxur","\\u2518":"boxul","\\u251C":"boxvr","\\u2524":"boxvl","\\u252C":"boxhd","\\u2534":"boxhu","\\u253C":"boxvh","\\u2550":"boxH","\\u2551":"boxV","\\u2552":"boxdR","\\u2553":"boxDr","\\u2554":"boxDR","\\u2555":"boxdL","\\u2556":"boxDl","\\u2557":"boxDL","\\u2558":"boxuR","\\u2559":"boxUr","\\u255A":"boxUR","\\u255B":"boxuL","\\u255C":"boxUl","\\u255D":"boxUL","\\u255E":"boxvR","\\u255F":"boxVr","\\u2560":"boxVR","\\u2561":"boxvL","\\u2562":"boxVl","\\u2563":"boxVL","\\u2564":"boxHd","\\u2565":"boxhD","\\u2566":"boxHD","\\u2567":"boxHu","\\u2568":"boxhU","\\u2569":"boxHU","\\u256A":"boxvH","\\u256B":"boxVh","\\u256C":"boxVH","\\u2580":"uhblk","\\u2584":"lhblk","\\u2588":"block","\\u2591":"blk14","\\u2592":"blk12","\\u2593":"blk34","\\u25A1":"squ","\\u25AA":"squf","\\u25AB":"EmptyVerySmallSquare","\\u25AD":"rect","\\u25AE":"marker","\\u25B1":"fltns","\\u25B3":"xutri","\\u25B4":"utrif","\\u25B5":"utri","\\u25B8":"rtrif","\\u25B9":"rtri","\\u25BD":"xdtri","\\u25BE":"dtrif","\\u25BF":"dtri","\\u25C2":"ltrif","\\u25C3":"ltri","\\u25CA":"loz","\\u25CB":"cir","\\u25EC":"tridot","\\u25EF":"xcirc","\\u25F8":"ultri","\\u25F9":"urtri","\\u25FA":"lltri","\\u25FB":"EmptySmallSquare","\\u25FC":"FilledSmallSquare","\\u2605":"starf","\\u2606":"star","\\u260E":"phone","\\u2640":"female","\\u2642":"male","\\u2660":"spades","\\u2663":"clubs","\\u2665":"hearts","\\u2666":"diams","\\u266A":"sung","\\u2713":"check","\\u2717":"cross","\\u2720":"malt","\\u2736":"sext","\\u2758":"VerticalSeparator","\\u27C8":"bsolhsub","\\u27C9":"suphsol","\\u27F5":"xlarr","\\u27F6":"xrarr","\\u27F7":"xharr","\\u27F8":"xlArr","\\u27F9":"xrArr","\\u27FA":"xhArr","\\u27FC":"xmap","\\u27FF":"dzigrarr","\\u2902":"nvlArr","\\u2903":"nvrArr","\\u2904":"nvHarr","\\u2905":"Map","\\u290C":"lbarr","\\u290D":"rbarr","\\u290E":"lBarr","\\u290F":"rBarr","\\u2910":"RBarr","\\u2911":"DDotrahd","\\u2912":"UpArrowBar","\\u2913":"DownArrowBar","\\u2916":"Rarrtl","\\u2919":"latail","\\u291A":"ratail","\\u291B":"lAtail","\\u291C":"rAtail","\\u291D":"larrfs","\\u291E":"rarrfs","\\u291F":"larrbfs","\\u2920":"rarrbfs","\\u2923":"nwarhk","\\u2924":"nearhk","\\u2925":"searhk","\\u2926":"swarhk","\\u2927":"nwnear","\\u2928":"toea","\\u2929":"tosa","\\u292A":"swnwar","\\u2933":"rarrc","\\u2933\\u0338":"nrarrc","\\u2935":"cudarrr","\\u2936":"ldca","\\u2937":"rdca","\\u2938":"cudarrl","\\u2939":"larrpl","\\u293C":"curarrm","\\u293D":"cularrp","\\u2945":"rarrpl","\\u2948":"harrcir","\\u2949":"Uarrocir","\\u294A":"lurdshar","\\u294B":"ldrushar","\\u294E":"LeftRightVector","\\u294F":"RightUpDownVector","\\u2950":"DownLeftRightVector","\\u2951":"LeftUpDownVector","\\u2952":"LeftVectorBar","\\u2953":"RightVectorBar","\\u2954":"RightUpVectorBar","\\u2955":"RightDownVectorBar","\\u2956":"DownLeftVectorBar","\\u2957":"DownRightVectorBar","\\u2958":"LeftUpVectorBar","\\u2959":"LeftDownVectorBar","\\u295A":"LeftTeeVector","\\u295B":"RightTeeVector","\\u295C":"RightUpTeeVector","\\u295D":"RightDownTeeVector","\\u295E":"DownLeftTeeVector","\\u295F":"DownRightTeeVector","\\u2960":"LeftUpTeeVector","\\u2961":"LeftDownTeeVector","\\u2962":"lHar","\\u2963":"uHar","\\u2964":"rHar","\\u2965":"dHar","\\u2966":"luruhar","\\u2967":"ldrdhar","\\u2968":"ruluhar","\\u2969":"rdldhar","\\u296A":"lharul","\\u296B":"llhard","\\u296C":"rharul","\\u296D":"lrhard","\\u296E":"udhar","\\u296F":"duhar","\\u2970":"RoundImplies","\\u2971":"erarr","\\u2972":"simrarr","\\u2973":"larrsim","\\u2974":"rarrsim","\\u2975":"rarrap","\\u2976":"ltlarr","\\u2978":"gtrarr","\\u2979":"subrarr","\\u297B":"suplarr","\\u297C":"lfisht","\\u297D":"rfisht","\\u297E":"ufisht","\\u297F":"dfisht","\\u299A":"vzigzag","\\u299C":"vangrt","\\u299D":"angrtvbd","\\u29A4":"ange","\\u29A5":"range","\\u29A6":"dwangle","\\u29A7":"uwangle","\\u29A8":"angmsdaa","\\u29A9":"angmsdab","\\u29AA":"angmsdac","\\u29AB":"angmsdad","\\u29AC":"angmsdae","\\u29AD":"angmsdaf","\\u29AE":"angmsdag","\\u29AF":"angmsdah","\\u29B0":"bemptyv","\\u29B1":"demptyv","\\u29B2":"cemptyv","\\u29B3":"raemptyv","\\u29B4":"laemptyv","\\u29B5":"ohbar","\\u29B6":"omid","\\u29B7":"opar","\\u29B9":"operp","\\u29BB":"olcross","\\u29BC":"odsold","\\u29BE":"olcir","\\u29BF":"ofcir","\\u29C0":"olt","\\u29C1":"ogt","\\u29C2":"cirscir","\\u29C3":"cirE","\\u29C4":"solb","\\u29C5":"bsolb","\\u29C9":"boxbox","\\u29CD":"trisb","\\u29CE":"rtriltri","\\u29CF":"LeftTriangleBar","\\u29CF\\u0338":"NotLeftTriangleBar","\\u29D0":"RightTriangleBar","\\u29D0\\u0338":"NotRightTriangleBar","\\u29DC":"iinfin","\\u29DD":"infintie","\\u29DE":"nvinfin","\\u29E3":"eparsl","\\u29E4":"smeparsl","\\u29E5":"eqvparsl","\\u29EB":"lozf","\\u29F4":"RuleDelayed","\\u29F6":"dsol","\\u2A00":"xodot","\\u2A01":"xoplus","\\u2A02":"xotime","\\u2A04":"xuplus","\\u2A06":"xsqcup","\\u2A0D":"fpartint","\\u2A10":"cirfnint","\\u2A11":"awint","\\u2A12":"rppolint","\\u2A13":"scpolint","\\u2A14":"npolint","\\u2A15":"pointint","\\u2A16":"quatint","\\u2A17":"intlarhk","\\u2A22":"pluscir","\\u2A23":"plusacir","\\u2A24":"simplus","\\u2A25":"plusdu","\\u2A26":"plussim","\\u2A27":"plustwo","\\u2A29":"mcomma","\\u2A2A":"minusdu","\\u2A2D":"loplus","\\u2A2E":"roplus","\\u2A2F":"Cross","\\u2A30":"timesd","\\u2A31":"timesbar","\\u2A33":"smashp","\\u2A34":"lotimes","\\u2A35":"rotimes","\\u2A36":"otimesas","\\u2A37":"Otimes","\\u2A38":"odiv","\\u2A39":"triplus","\\u2A3A":"triminus","\\u2A3B":"tritime","\\u2A3C":"iprod","\\u2A3F":"amalg","\\u2A40":"capdot","\\u2A42":"ncup","\\u2A43":"ncap","\\u2A44":"capand","\\u2A45":"cupor","\\u2A46":"cupcap","\\u2A47":"capcup","\\u2A48":"cupbrcap","\\u2A49":"capbrcup","\\u2A4A":"cupcup","\\u2A4B":"capcap","\\u2A4C":"ccups","\\u2A4D":"ccaps","\\u2A50":"ccupssm","\\u2A53":"And","\\u2A54":"Or","\\u2A55":"andand","\\u2A56":"oror","\\u2A57":"orslope","\\u2A58":"andslope","\\u2A5A":"andv","\\u2A5B":"orv","\\u2A5C":"andd","\\u2A5D":"ord","\\u2A5F":"wedbar","\\u2A66":"sdote","\\u2A6A":"simdot","\\u2A6D":"congdot","\\u2A6D\\u0338":"ncongdot","\\u2A6E":"easter","\\u2A6F":"apacir","\\u2A70":"apE","\\u2A70\\u0338":"napE","\\u2A71":"eplus","\\u2A72":"pluse","\\u2A73":"Esim","\\u2A77":"eDDot","\\u2A78":"equivDD","\\u2A79":"ltcir","\\u2A7A":"gtcir","\\u2A7B":"ltquest","\\u2A7C":"gtquest","\\u2A7D":"les","\\u2A7D\\u0338":"nles","\\u2A7E":"ges","\\u2A7E\\u0338":"nges","\\u2A7F":"lesdot","\\u2A80":"gesdot","\\u2A81":"lesdoto","\\u2A82":"gesdoto","\\u2A83":"lesdotor","\\u2A84":"gesdotol","\\u2A85":"lap","\\u2A86":"gap","\\u2A87":"lne","\\u2A88":"gne","\\u2A89":"lnap","\\u2A8A":"gnap","\\u2A8B":"lEg","\\u2A8C":"gEl","\\u2A8D":"lsime","\\u2A8E":"gsime","\\u2A8F":"lsimg","\\u2A90":"gsiml","\\u2A91":"lgE","\\u2A92":"glE","\\u2A93":"lesges","\\u2A94":"gesles","\\u2A95":"els","\\u2A96":"egs","\\u2A97":"elsdot","\\u2A98":"egsdot","\\u2A99":"el","\\u2A9A":"eg","\\u2A9D":"siml","\\u2A9E":"simg","\\u2A9F":"simlE","\\u2AA0":"simgE","\\u2AA1":"LessLess","\\u2AA1\\u0338":"NotNestedLessLess","\\u2AA2":"GreaterGreater","\\u2AA2\\u0338":"NotNestedGreaterGreater","\\u2AA4":"glj","\\u2AA5":"gla","\\u2AA6":"ltcc","\\u2AA7":"gtcc","\\u2AA8":"lescc","\\u2AA9":"gescc","\\u2AAA":"smt","\\u2AAB":"lat","\\u2AAC":"smte","\\u2AAC\\uFE00":"smtes","\\u2AAD":"late","\\u2AAD\\uFE00":"lates","\\u2AAE":"bumpE","\\u2AAF":"pre","\\u2AAF\\u0338":"npre","\\u2AB0":"sce","\\u2AB0\\u0338":"nsce","\\u2AB3":"prE","\\u2AB4":"scE","\\u2AB5":"prnE","\\u2AB6":"scnE","\\u2AB7":"prap","\\u2AB8":"scap","\\u2AB9":"prnap","\\u2ABA":"scnap","\\u2ABB":"Pr","\\u2ABC":"Sc","\\u2ABD":"subdot","\\u2ABE":"supdot","\\u2ABF":"subplus","\\u2AC0":"supplus","\\u2AC1":"submult","\\u2AC2":"supmult","\\u2AC3":"subedot","\\u2AC4":"supedot","\\u2AC5":"subE","\\u2AC5\\u0338":"nsubE","\\u2AC6":"supE","\\u2AC6\\u0338":"nsupE","\\u2AC7":"subsim","\\u2AC8":"supsim","\\u2ACB\\uFE00":"vsubnE","\\u2ACB":"subnE","\\u2ACC\\uFE00":"vsupnE","\\u2ACC":"supnE","\\u2ACF":"csub","\\u2AD0":"csup","\\u2AD1":"csube","\\u2AD2":"csupe","\\u2AD3":"subsup","\\u2AD4":"supsub","\\u2AD5":"subsub","\\u2AD6":"supsup","\\u2AD7":"suphsub","\\u2AD8":"supdsub","\\u2AD9":"forkv","\\u2ADA":"topfork","\\u2ADB":"mlcp","\\u2AE4":"Dashv","\\u2AE6":"Vdashl","\\u2AE7":"Barv","\\u2AE8":"vBar","\\u2AE9":"vBarv","\\u2AEB":"Vbar","\\u2AEC":"Not","\\u2AED":"bNot","\\u2AEE":"rnmid","\\u2AEF":"cirmid","\\u2AF0":"midcir","\\u2AF1":"topcir","\\u2AF2":"nhpar","\\u2AF3":"parsim","\\u2AFD":"parsl","\\u2AFD\\u20E5":"nparsl","\\u266D":"flat","\\u266E":"natur","\\u266F":"sharp","\\xA4":"curren","\\xA2":"cent",$:"dollar","\\xA3":"pound","\\xA5":"yen","\\u20AC":"euro","\\xB9":"sup1","\\xBD":"half","\\u2153":"frac13","\\xBC":"frac14","\\u2155":"frac15","\\u2159":"frac16","\\u215B":"frac18","\\xB2":"sup2","\\u2154":"frac23","\\u2156":"frac25","\\xB3":"sup3","\\xBE":"frac34","\\u2157":"frac35","\\u215C":"frac38","\\u2158":"frac45","\\u215A":"frac56","\\u215D":"frac58","\\u215E":"frac78","\\u{1D4B6}":"ascr","\\u{1D552}":"aopf","\\u{1D51E}":"afr","\\u{1D538}":"Aopf","\\u{1D504}":"Afr","\\u{1D49C}":"Ascr",\\u00AA:"ordf",\\u00E1:"aacute",\\u00C1:"Aacute",\\u00E0:"agrave",\\u00C0:"Agrave",\\u0103:"abreve",\\u0102:"Abreve",\\u00E2:"acirc",\\u00C2:"Acirc",\\u00E5:"aring",\\u00C5:"angst",\\u00E4:"auml",\\u00C4:"Auml",\\u00E3:"atilde",\\u00C3:"Atilde",\\u0105:"aogon",\\u0104:"Aogon",\\u0101:"amacr",\\u0100:"Amacr",\\u00E6:"aelig",\\u00C6:"AElig","\\u{1D4B7}":"bscr","\\u{1D553}":"bopf","\\u{1D51F}":"bfr","\\u{1D539}":"Bopf",\\u212C:"Bscr","\\u{1D505}":"Bfr","\\u{1D520}":"cfr","\\u{1D4B8}":"cscr","\\u{1D554}":"copf",\\u212D:"Cfr","\\u{1D49E}":"Cscr",\\u2102:"Copf",\\u0107:"cacute",\\u0106:"Cacute",\\u0109:"ccirc",\\u0108:"Ccirc",\\u010D:"ccaron",\\u010C:"Ccaron",\\u010B:"cdot",\\u010A:"Cdot",\\u00E7:"ccedil",\\u00C7:"Ccedil","\\u2105":"incare","\\u{1D521}":"dfr","\\u2146":"dd","\\u{1D555}":"dopf","\\u{1D4B9}":"dscr","\\u{1D49F}":"Dscr","\\u{1D507}":"Dfr","\\u2145":"DD","\\u{1D53B}":"Dopf",\\u010F:"dcaron",\\u010E:"Dcaron",\\u0111:"dstrok",\\u0110:"Dstrok",\\u00F0:"eth",\\u00D0:"ETH","\\u2147":"ee",\\u212F:"escr","\\u{1D522}":"efr","\\u{1D556}":"eopf",\\u2130:"Escr","\\u{1D508}":"Efr","\\u{1D53C}":"Eopf",\\u00E9:"eacute",\\u00C9:"Eacute",\\u00E8:"egrave",\\u00C8:"Egrave",\\u00EA:"ecirc",\\u00CA:"Ecirc",\\u011B:"ecaron",\\u011A:"Ecaron",\\u00EB:"euml",\\u00CB:"Euml",\\u0117:"edot",\\u0116:"Edot",\\u0119:"eogon",\\u0118:"Eogon",\\u0113:"emacr",\\u0112:"Emacr","\\u{1D523}":"ffr","\\u{1D557}":"fopf","\\u{1D4BB}":"fscr","\\u{1D509}":"Ffr","\\u{1D53D}":"Fopf",\\u2131:"Fscr",\\uFB00:"fflig",\\uFB03:"ffilig",\\uFB04:"ffllig",\\uFB01:"filig",fj:"fjlig",\\uFB02:"fllig",\\u0192:"fnof",\\u210A:"gscr","\\u{1D558}":"gopf","\\u{1D524}":"gfr","\\u{1D4A2}":"Gscr","\\u{1D53E}":"Gopf","\\u{1D50A}":"Gfr",\\u01F5:"gacute",\\u011F:"gbreve",\\u011E:"Gbreve",\\u011D:"gcirc",\\u011C:"Gcirc",\\u0121:"gdot",\\u0120:"Gdot",\\u0122:"Gcedil","\\u{1D525}":"hfr",\\u210E:"planckh","\\u{1D4BD}":"hscr","\\u{1D559}":"hopf",\\u210B:"Hscr",\\u210C:"Hfr",\\u210D:"Hopf",\\u0125:"hcirc",\\u0124:"Hcirc",\\u210F:"hbar",\\u0127:"hstrok",\\u0126:"Hstrok","\\u{1D55A}":"iopf","\\u{1D526}":"ifr","\\u{1D4BE}":"iscr","\\u2148":"ii","\\u{1D540}":"Iopf",\\u2110:"Iscr",\\u2111:"Im",\\u00ED:"iacute",\\u00CD:"Iacute",\\u00EC:"igrave",\\u00CC:"Igrave",\\u00EE:"icirc",\\u00CE:"Icirc",\\u00EF:"iuml",\\u00CF:"Iuml",\\u0129:"itilde",\\u0128:"Itilde",\\u0130:"Idot",\\u012F:"iogon",\\u012E:"Iogon",\\u012B:"imacr",\\u012A:"Imacr",\\u0133:"ijlig",\\u0132:"IJlig",\\u0131:"imath","\\u{1D4BF}":"jscr","\\u{1D55B}":"jopf","\\u{1D527}":"jfr","\\u{1D4A5}":"Jscr","\\u{1D50D}":"Jfr","\\u{1D541}":"Jopf",\\u0135:"jcirc",\\u0134:"Jcirc","\\u0237":"jmath","\\u{1D55C}":"kopf","\\u{1D4C0}":"kscr","\\u{1D528}":"kfr","\\u{1D4A6}":"Kscr","\\u{1D542}":"Kopf","\\u{1D50E}":"Kfr",\\u0137:"kcedil",\\u0136:"Kcedil","\\u{1D529}":"lfr","\\u{1D4C1}":"lscr",\\u2113:"ell","\\u{1D55D}":"lopf",\\u2112:"Lscr","\\u{1D50F}":"Lfr","\\u{1D543}":"Lopf",\\u013A:"lacute",\\u0139:"Lacute",\\u013E:"lcaron",\\u013D:"Lcaron",\\u013C:"lcedil",\\u013B:"Lcedil",\\u0142:"lstrok",\\u0141:"Lstrok",\\u0140:"lmidot",\\u013F:"Lmidot","\\u{1D52A}":"mfr","\\u{1D55E}":"mopf","\\u{1D4C2}":"mscr","\\u{1D510}":"Mfr","\\u{1D544}":"Mopf",\\u2133:"Mscr","\\u{1D52B}":"nfr","\\u{1D55F}":"nopf","\\u{1D4C3}":"nscr",\\u2115:"Nopf","\\u{1D4A9}":"Nscr","\\u{1D511}":"Nfr",\\u0144:"nacute",\\u0143:"Nacute",\\u0148:"ncaron",\\u0147:"Ncaron",\\u00F1:"ntilde",\\u00D1:"Ntilde",\\u0146:"ncedil",\\u0145:"Ncedil","\\u2116":"numero",\\u014B:"eng",\\u014A:"ENG","\\u{1D560}":"oopf","\\u{1D52C}":"ofr",\\u2134:"oscr","\\u{1D4AA}":"Oscr","\\u{1D512}":"Ofr","\\u{1D546}":"Oopf",\\u00BA:"ordm",\\u00F3:"oacute",\\u00D3:"Oacute",\\u00F2:"ograve",\\u00D2:"Ograve",\\u00F4:"ocirc",\\u00D4:"Ocirc",\\u00F6:"ouml",\\u00D6:"Ouml",\\u0151:"odblac",\\u0150:"Odblac",\\u00F5:"otilde",\\u00D5:"Otilde",\\u00F8:"oslash",\\u00D8:"Oslash",\\u014D:"omacr",\\u014C:"Omacr",\\u0153:"oelig",\\u0152:"OElig","\\u{1D52D}":"pfr","\\u{1D4C5}":"pscr","\\u{1D561}":"popf",\\u2119:"Popf","\\u{1D513}":"Pfr","\\u{1D4AB}":"Pscr","\\u{1D562}":"qopf","\\u{1D52E}":"qfr","\\u{1D4C6}":"qscr","\\u{1D4AC}":"Qscr","\\u{1D514}":"Qfr",\\u211A:"Qopf",\\u0138:"kgreen","\\u{1D52F}":"rfr","\\u{1D563}":"ropf","\\u{1D4C7}":"rscr",\\u211B:"Rscr",\\u211C:"Re",\\u211D:"Ropf",\\u0155:"racute",\\u0154:"Racute",\\u0159:"rcaron",\\u0158:"Rcaron",\\u0157:"rcedil",\\u0156:"Rcedil","\\u{1D564}":"sopf","\\u{1D4C8}":"sscr","\\u{1D530}":"sfr","\\u{1D54A}":"Sopf","\\u{1D516}":"Sfr","\\u{1D4AE}":"Sscr","\\u24C8":"oS",\\u015B:"sacute",\\u015A:"Sacute",\\u015D:"scirc",\\u015C:"Scirc",\\u0161:"scaron",\\u0160:"Scaron",\\u015F:"scedil",\\u015E:"Scedil",\\u00DF:"szlig","\\u{1D531}":"tfr","\\u{1D4C9}":"tscr","\\u{1D565}":"topf","\\u{1D4AF}":"Tscr","\\u{1D517}":"Tfr","\\u{1D54B}":"Topf",\\u0165:"tcaron",\\u0164:"Tcaron",\\u0163:"tcedil",\\u0162:"Tcedil","\\u2122":"trade",\\u0167:"tstrok",\\u0166:"Tstrok","\\u{1D4CA}":"uscr","\\u{1D566}":"uopf","\\u{1D532}":"ufr","\\u{1D54C}":"Uopf","\\u{1D518}":"Ufr","\\u{1D4B0}":"Uscr",\\u00FA:"uacute",\\u00DA:"Uacute",\\u00F9:"ugrave",\\u00D9:"Ugrave",\\u016D:"ubreve",\\u016C:"Ubreve",\\u00FB:"ucirc",\\u00DB:"Ucirc",\\u016F:"uring",\\u016E:"Uring",\\u00FC:"uuml",\\u00DC:"Uuml",\\u0171:"udblac",\\u0170:"Udblac",\\u0169:"utilde",\\u0168:"Utilde",\\u0173:"uogon",\\u0172:"Uogon",\\u016B:"umacr",\\u016A:"Umacr","\\u{1D533}":"vfr","\\u{1D567}":"vopf","\\u{1D4CB}":"vscr","\\u{1D519}":"Vfr","\\u{1D54D}":"Vopf","\\u{1D4B1}":"Vscr","\\u{1D568}":"wopf","\\u{1D4CC}":"wscr","\\u{1D534}":"wfr","\\u{1D4B2}":"Wscr","\\u{1D54E}":"Wopf","\\u{1D51A}":"Wfr",\\u0175:"wcirc",\\u0174:"Wcirc","\\u{1D535}":"xfr","\\u{1D4CD}":"xscr","\\u{1D569}":"xopf","\\u{1D54F}":"Xopf","\\u{1D51B}":"Xfr","\\u{1D4B3}":"Xscr","\\u{1D536}":"yfr","\\u{1D4CE}":"yscr","\\u{1D56A}":"yopf","\\u{1D4B4}":"Yscr","\\u{1D51C}":"Yfr","\\u{1D550}":"Yopf",\\u00FD:"yacute",\\u00DD:"Yacute",\\u0177:"ycirc",\\u0176:"Ycirc",\\u00FF:"yuml",\\u0178:"Yuml","\\u{1D4CF}":"zscr","\\u{1D537}":"zfr","\\u{1D56B}":"zopf",\\u2128:"Zfr",\\u2124:"Zopf","\\u{1D4B5}":"Zscr",\\u017A:"zacute",\\u0179:"Zacute",\\u017E:"zcaron",\\u017D:"Zcaron",\\u017C:"zdot",\\u017B:"Zdot",\\u01B5:"imped",\\u00FE:"thorn",\\u00DE:"THORN",\\u0149:"napos",\\u03B1:"alpha",\\u0391:"Alpha",\\u03B2:"beta",\\u0392:"Beta",\\u03B3:"gamma",\\u0393:"Gamma",\\u03B4:"delta",\\u0394:"Delta",\\u03B5:"epsi","\\u03F5":"epsiv",\\u0395:"Epsilon",\\u03DD:"gammad",\\u03DC:"Gammad",\\u03B6:"zeta",\\u0396:"Zeta",\\u03B7:"eta",\\u0397:"Eta",\\u03B8:"theta",\\u03D1:"thetav",\\u0398:"Theta",\\u03B9:"iota",\\u0399:"Iota",\\u03BA:"kappa",\\u03F0:"kappav",\\u039A:"Kappa",\\u03BB:"lambda",\\u039B:"Lambda",\\u03BC:"mu",\\u00B5:"micro",\\u039C:"Mu",\\u03BD:"nu",\\u039D:"Nu",\\u03BE:"xi",\\u039E:"Xi",\\u03BF:"omicron",\\u039F:"Omicron",\\u03C0:"pi",\\u03D6:"piv",\\u03A0:"Pi",\\u03C1:"rho",\\u03F1:"rhov",\\u03A1:"Rho",\\u03C3:"sigma",\\u03A3:"Sigma",\\u03C2:"sigmaf",\\u03C4:"tau",\\u03A4:"Tau",\\u03C5:"upsi",\\u03A5:"Upsilon",\\u03D2:"Upsi",\\u03C6:"phi",\\u03D5:"phiv",\\u03A6:"Phi",\\u03C7:"chi",\\u03A7:"Chi",\\u03C8:"psi",\\u03A8:"Psi",\\u03C9:"omega",\\u03A9:"ohm",\\u0430:"acy",\\u0410:"Acy",\\u0431:"bcy",\\u0411:"Bcy",\\u0432:"vcy",\\u0412:"Vcy",\\u0433:"gcy",\\u0413:"Gcy",\\u0453:"gjcy",\\u0403:"GJcy",\\u0434:"dcy",\\u0414:"Dcy",\\u0452:"djcy",\\u0402:"DJcy",\\u0435:"iecy",\\u0415:"IEcy",\\u0451:"iocy",\\u0401:"IOcy",\\u0454:"jukcy",\\u0404:"Jukcy",\\u0436:"zhcy",\\u0416:"ZHcy",\\u0437:"zcy",\\u0417:"Zcy",\\u0455:"dscy",\\u0405:"DScy",\\u0438:"icy",\\u0418:"Icy",\\u0456:"iukcy",\\u0406:"Iukcy",\\u0457:"yicy",\\u0407:"YIcy",\\u0439:"jcy",\\u0419:"Jcy",\\u0458:"jsercy",\\u0408:"Jsercy",\\u043A:"kcy",\\u041A:"Kcy",\\u045C:"kjcy",\\u040C:"KJcy",\\u043B:"lcy",\\u041B:"Lcy",\\u0459:"ljcy",\\u0409:"LJcy",\\u043C:"mcy",\\u041C:"Mcy",\\u043D:"ncy",\\u041D:"Ncy",\\u045A:"njcy",\\u040A:"NJcy",\\u043E:"ocy",\\u041E:"Ocy",\\u043F:"pcy",\\u041F:"Pcy",\\u0440:"rcy",\\u0420:"Rcy",\\u0441:"scy",\\u0421:"Scy",\\u0442:"tcy",\\u0422:"Tcy",\\u045B:"tshcy",\\u040B:"TSHcy",\\u0443:"ucy",\\u0423:"Ucy",\\u045E:"ubrcy",\\u040E:"Ubrcy",\\u0444:"fcy",\\u0424:"Fcy",\\u0445:"khcy",\\u0425:"KHcy",\\u0446:"tscy",\\u0426:"TScy",\\u0447:"chcy",\\u0427:"CHcy",\\u045F:"dzcy",\\u040F:"DZcy",\\u0448:"shcy",\\u0428:"SHcy",\\u0449:"shchcy",\\u0429:"SHCHcy",\\u044A:"hardcy",\\u042A:"HARDcy",\\u044B:"ycy",\\u042B:"Ycy",\\u044C:"softcy",\\u042C:"SOFTcy",\\u044D:"ecy",\\u042D:"Ecy",\\u044E:"yucy",\\u042E:"YUcy",\\u044F:"yacy",\\u042F:"YAcy",\\u2135:"aleph",\\u2136:"beth",\\u2137:"gimel",\\u2138:"daleth"},d=/["&\'<>`]/g,p={\'"\':""","&":"&","\'":"'","<":"<",">":">","`":"`"},l=/&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/,b=/[\\0-\\x08\\x0B\\x0E-\\x1F\\x7F-\\x9F\\uFDD0-\\uFDEF\\uFFFE\\uFFFF]|[\\uD83F\\uD87F\\uD8BF\\uD8FF\\uD93F\\uD97F\\uD9BF\\uD9FF\\uDA3F\\uDA7F\\uDABF\\uDAFF\\uDB3F\\uDB7F\\uDBBF\\uDBFF][\\uDFFE\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/,f=/&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g,m={aacute:"\\xE1",Aacute:"\\xC1",abreve:"\\u0103",Abreve:"\\u0102",ac:"\\u223E",acd:"\\u223F",acE:"\\u223E\\u0333",acirc:"\\xE2",Acirc:"\\xC2",acute:"\\xB4",acy:"\\u0430",Acy:"\\u0410",aelig:"\\xE6",AElig:"\\xC6",af:"\\u2061",afr:"\\u{1D51E}",Afr:"\\u{1D504}",agrave:"\\xE0",Agrave:"\\xC0",alefsym:"\\u2135",aleph:"\\u2135",alpha:"\\u03B1",Alpha:"\\u0391",amacr:"\\u0101",Amacr:"\\u0100",amalg:"\\u2A3F",amp:"&",AMP:"&",and:"\\u2227",And:"\\u2A53",andand:"\\u2A55",andd:"\\u2A5C",andslope:"\\u2A58",andv:"\\u2A5A",ang:"\\u2220",ange:"\\u29A4",angle:"\\u2220",angmsd:"\\u2221",angmsdaa:"\\u29A8",angmsdab:"\\u29A9",angmsdac:"\\u29AA",angmsdad:"\\u29AB",angmsdae:"\\u29AC",angmsdaf:"\\u29AD",angmsdag:"\\u29AE",angmsdah:"\\u29AF",angrt:"\\u221F",angrtvb:"\\u22BE",angrtvbd:"\\u299D",angsph:"\\u2222",angst:"\\xC5",angzarr:"\\u237C",aogon:"\\u0105",Aogon:"\\u0104",aopf:"\\u{1D552}",Aopf:"\\u{1D538}",ap:"\\u2248",apacir:"\\u2A6F",ape:"\\u224A",apE:"\\u2A70",apid:"\\u224B",apos:"\'",ApplyFunction:"\\u2061",approx:"\\u2248",approxeq:"\\u224A",aring:"\\xE5",Aring:"\\xC5",ascr:"\\u{1D4B6}",Ascr:"\\u{1D49C}",Assign:"\\u2254",ast:"*",asymp:"\\u2248",asympeq:"\\u224D",atilde:"\\xE3",Atilde:"\\xC3",auml:"\\xE4",Auml:"\\xC4",awconint:"\\u2233",awint:"\\u2A11",backcong:"\\u224C",backepsilon:"\\u03F6",backprime:"\\u2035",backsim:"\\u223D",backsimeq:"\\u22CD",Backslash:"\\u2216",Barv:"\\u2AE7",barvee:"\\u22BD",barwed:"\\u2305",Barwed:"\\u2306",barwedge:"\\u2305",bbrk:"\\u23B5",bbrktbrk:"\\u23B6",bcong:"\\u224C",bcy:"\\u0431",Bcy:"\\u0411",bdquo:"\\u201E",becaus:"\\u2235",because:"\\u2235",Because:"\\u2235",bemptyv:"\\u29B0",bepsi:"\\u03F6",bernou:"\\u212C",Bernoullis:"\\u212C",beta:"\\u03B2",Beta:"\\u0392",beth:"\\u2136",between:"\\u226C",bfr:"\\u{1D51F}",Bfr:"\\u{1D505}",bigcap:"\\u22C2",bigcirc:"\\u25EF",bigcup:"\\u22C3",bigodot:"\\u2A00",bigoplus:"\\u2A01",bigotimes:"\\u2A02",bigsqcup:"\\u2A06",bigstar:"\\u2605",bigtriangledown:"\\u25BD",bigtriangleup:"\\u25B3",biguplus:"\\u2A04",bigvee:"\\u22C1",bigwedge:"\\u22C0",bkarow:"\\u290D",blacklozenge:"\\u29EB",blacksquare:"\\u25AA",blacktriangle:"\\u25B4",blacktriangledown:"\\u25BE",blacktriangleleft:"\\u25C2",blacktriangleright:"\\u25B8",blank:"\\u2423",blk12:"\\u2592",blk14:"\\u2591",blk34:"\\u2593",block:"\\u2588",bne:"=\\u20E5",bnequiv:"\\u2261\\u20E5",bnot:"\\u2310",bNot:"\\u2AED",bopf:"\\u{1D553}",Bopf:"\\u{1D539}",bot:"\\u22A5",bottom:"\\u22A5",bowtie:"\\u22C8",boxbox:"\\u29C9",boxdl:"\\u2510",boxdL:"\\u2555",boxDl:"\\u2556",boxDL:"\\u2557",boxdr:"\\u250C",boxdR:"\\u2552",boxDr:"\\u2553",boxDR:"\\u2554",boxh:"\\u2500",boxH:"\\u2550",boxhd:"\\u252C",boxhD:"\\u2565",boxHd:"\\u2564",boxHD:"\\u2566",boxhu:"\\u2534",boxhU:"\\u2568",boxHu:"\\u2567",boxHU:"\\u2569",boxminus:"\\u229F",boxplus:"\\u229E",boxtimes:"\\u22A0",boxul:"\\u2518",boxuL:"\\u255B",boxUl:"\\u255C",boxUL:"\\u255D",boxur:"\\u2514",boxuR:"\\u2558",boxUr:"\\u2559",boxUR:"\\u255A",boxv:"\\u2502",boxV:"\\u2551",boxvh:"\\u253C",boxvH:"\\u256A",boxVh:"\\u256B",boxVH:"\\u256C",boxvl:"\\u2524",boxvL:"\\u2561",boxVl:"\\u2562",boxVL:"\\u2563",boxvr:"\\u251C",boxvR:"\\u255E",boxVr:"\\u255F",boxVR:"\\u2560",bprime:"\\u2035",breve:"\\u02D8",Breve:"\\u02D8",brvbar:"\\xA6",bscr:"\\u{1D4B7}",Bscr:"\\u212C",bsemi:"\\u204F",bsim:"\\u223D",bsime:"\\u22CD",bsol:"\\\\",bsolb:"\\u29C5",bsolhsub:"\\u27C8",bull:"\\u2022",bullet:"\\u2022",bump:"\\u224E",bumpe:"\\u224F",bumpE:"\\u2AAE",bumpeq:"\\u224F",Bumpeq:"\\u224E",cacute:"\\u0107",Cacute:"\\u0106",cap:"\\u2229",Cap:"\\u22D2",capand:"\\u2A44",capbrcup:"\\u2A49",capcap:"\\u2A4B",capcup:"\\u2A47",capdot:"\\u2A40",CapitalDifferentialD:"\\u2145",caps:"\\u2229\\uFE00",caret:"\\u2041",caron:"\\u02C7",Cayleys:"\\u212D",ccaps:"\\u2A4D",ccaron:"\\u010D",Ccaron:"\\u010C",ccedil:"\\xE7",Ccedil:"\\xC7",ccirc:"\\u0109",Ccirc:"\\u0108",Cconint:"\\u2230",ccups:"\\u2A4C",ccupssm:"\\u2A50",cdot:"\\u010B",Cdot:"\\u010A",cedil:"\\xB8",Cedilla:"\\xB8",cemptyv:"\\u29B2",cent:"\\xA2",centerdot:"\\xB7",CenterDot:"\\xB7",cfr:"\\u{1D520}",Cfr:"\\u212D",chcy:"\\u0447",CHcy:"\\u0427",check:"\\u2713",checkmark:"\\u2713",chi:"\\u03C7",Chi:"\\u03A7",cir:"\\u25CB",circ:"\\u02C6",circeq:"\\u2257",circlearrowleft:"\\u21BA",circlearrowright:"\\u21BB",circledast:"\\u229B",circledcirc:"\\u229A",circleddash:"\\u229D",CircleDot:"\\u2299",circledR:"\\xAE",circledS:"\\u24C8",CircleMinus:"\\u2296",CirclePlus:"\\u2295",CircleTimes:"\\u2297",cire:"\\u2257",cirE:"\\u29C3",cirfnint:"\\u2A10",cirmid:"\\u2AEF",cirscir:"\\u29C2",ClockwiseContourIntegral:"\\u2232",CloseCurlyDoubleQuote:"\\u201D",CloseCurlyQuote:"\\u2019",clubs:"\\u2663",clubsuit:"\\u2663",colon:":",Colon:"\\u2237",colone:"\\u2254",Colone:"\\u2A74",coloneq:"\\u2254",comma:",",commat:"@",comp:"\\u2201",compfn:"\\u2218",complement:"\\u2201",complexes:"\\u2102",cong:"\\u2245",congdot:"\\u2A6D",Congruent:"\\u2261",conint:"\\u222E",Conint:"\\u222F",ContourIntegral:"\\u222E",copf:"\\u{1D554}",Copf:"\\u2102",coprod:"\\u2210",Coproduct:"\\u2210",copy:"\\xA9",COPY:"\\xA9",copysr:"\\u2117",CounterClockwiseContourIntegral:"\\u2233",crarr:"\\u21B5",cross:"\\u2717",Cross:"\\u2A2F",cscr:"\\u{1D4B8}",Cscr:"\\u{1D49E}",csub:"\\u2ACF",csube:"\\u2AD1",csup:"\\u2AD0",csupe:"\\u2AD2",ctdot:"\\u22EF",cudarrl:"\\u2938",cudarrr:"\\u2935",cuepr:"\\u22DE",cuesc:"\\u22DF",cularr:"\\u21B6",cularrp:"\\u293D",cup:"\\u222A",Cup:"\\u22D3",cupbrcap:"\\u2A48",cupcap:"\\u2A46",CupCap:"\\u224D",cupcup:"\\u2A4A",cupdot:"\\u228D",cupor:"\\u2A45",cups:"\\u222A\\uFE00",curarr:"\\u21B7",curarrm:"\\u293C",curlyeqprec:"\\u22DE",curlyeqsucc:"\\u22DF",curlyvee:"\\u22CE",curlywedge:"\\u22CF",curren:"\\xA4",curvearrowleft:"\\u21B6",curvearrowright:"\\u21B7",cuvee:"\\u22CE",cuwed:"\\u22CF",cwconint:"\\u2232",cwint:"\\u2231",cylcty:"\\u232D",dagger:"\\u2020",Dagger:"\\u2021",daleth:"\\u2138",darr:"\\u2193",dArr:"\\u21D3",Darr:"\\u21A1",dash:"\\u2010",dashv:"\\u22A3",Dashv:"\\u2AE4",dbkarow:"\\u290F",dblac:"\\u02DD",dcaron:"\\u010F",Dcaron:"\\u010E",dcy:"\\u0434",Dcy:"\\u0414",dd:"\\u2146",DD:"\\u2145",ddagger:"\\u2021",ddarr:"\\u21CA",DDotrahd:"\\u2911",ddotseq:"\\u2A77",deg:"\\xB0",Del:"\\u2207",delta:"\\u03B4",Delta:"\\u0394",demptyv:"\\u29B1",dfisht:"\\u297F",dfr:"\\u{1D521}",Dfr:"\\u{1D507}",dHar:"\\u2965",dharl:"\\u21C3",dharr:"\\u21C2",DiacriticalAcute:"\\xB4",DiacriticalDot:"\\u02D9",DiacriticalDoubleAcute:"\\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\\u02DC",diam:"\\u22C4",diamond:"\\u22C4",Diamond:"\\u22C4",diamondsuit:"\\u2666",diams:"\\u2666",die:"\\xA8",DifferentialD:"\\u2146",digamma:"\\u03DD",disin:"\\u22F2",div:"\\xF7",divide:"\\xF7",divideontimes:"\\u22C7",divonx:"\\u22C7",djcy:"\\u0452",DJcy:"\\u0402",dlcorn:"\\u231E",dlcrop:"\\u230D",dollar:"$",dopf:"\\u{1D555}",Dopf:"\\u{1D53B}",dot:"\\u02D9",Dot:"\\xA8",DotDot:"\\u20DC",doteq:"\\u2250",doteqdot:"\\u2251",DotEqual:"\\u2250",dotminus:"\\u2238",dotplus:"\\u2214",dotsquare:"\\u22A1",doublebarwedge:"\\u2306",DoubleContourIntegral:"\\u222F",DoubleDot:"\\xA8",DoubleDownArrow:"\\u21D3",DoubleLeftArrow:"\\u21D0",DoubleLeftRightArrow:"\\u21D4",DoubleLeftTee:"\\u2AE4",DoubleLongLeftArrow:"\\u27F8",DoubleLongLeftRightArrow:"\\u27FA",DoubleLongRightArrow:"\\u27F9",DoubleRightArrow:"\\u21D2",DoubleRightTee:"\\u22A8",DoubleUpArrow:"\\u21D1",DoubleUpDownArrow:"\\u21D5",DoubleVerticalBar:"\\u2225",downarrow:"\\u2193",Downarrow:"\\u21D3",DownArrow:"\\u2193",DownArrowBar:"\\u2913",DownArrowUpArrow:"\\u21F5",DownBreve:"\\u0311",downdownarrows:"\\u21CA",downharpoonleft:"\\u21C3",downharpoonright:"\\u21C2",DownLeftRightVector:"\\u2950",DownLeftTeeVector:"\\u295E",DownLeftVector:"\\u21BD",DownLeftVectorBar:"\\u2956",DownRightTeeVector:"\\u295F",DownRightVector:"\\u21C1",DownRightVectorBar:"\\u2957",DownTee:"\\u22A4",DownTeeArrow:"\\u21A7",drbkarow:"\\u2910",drcorn:"\\u231F",drcrop:"\\u230C",dscr:"\\u{1D4B9}",Dscr:"\\u{1D49F}",dscy:"\\u0455",DScy:"\\u0405",dsol:"\\u29F6",dstrok:"\\u0111",Dstrok:"\\u0110",dtdot:"\\u22F1",dtri:"\\u25BF",dtrif:"\\u25BE",duarr:"\\u21F5",duhar:"\\u296F",dwangle:"\\u29A6",dzcy:"\\u045F",DZcy:"\\u040F",dzigrarr:"\\u27FF",eacute:"\\xE9",Eacute:"\\xC9",easter:"\\u2A6E",ecaron:"\\u011B",Ecaron:"\\u011A",ecir:"\\u2256",ecirc:"\\xEA",Ecirc:"\\xCA",ecolon:"\\u2255",ecy:"\\u044D",Ecy:"\\u042D",eDDot:"\\u2A77",edot:"\\u0117",eDot:"\\u2251",Edot:"\\u0116",ee:"\\u2147",efDot:"\\u2252",efr:"\\u{1D522}",Efr:"\\u{1D508}",eg:"\\u2A9A",egrave:"\\xE8",Egrave:"\\xC8",egs:"\\u2A96",egsdot:"\\u2A98",el:"\\u2A99",Element:"\\u2208",elinters:"\\u23E7",ell:"\\u2113",els:"\\u2A95",elsdot:"\\u2A97",emacr:"\\u0113",Emacr:"\\u0112",empty:"\\u2205",emptyset:"\\u2205",EmptySmallSquare:"\\u25FB",emptyv:"\\u2205",EmptyVerySmallSquare:"\\u25AB",emsp:"\\u2003",emsp13:"\\u2004",emsp14:"\\u2005",eng:"\\u014B",ENG:"\\u014A",ensp:"\\u2002",eogon:"\\u0119",Eogon:"\\u0118",eopf:"\\u{1D556}",Eopf:"\\u{1D53C}",epar:"\\u22D5",eparsl:"\\u29E3",eplus:"\\u2A71",epsi:"\\u03B5",epsilon:"\\u03B5",Epsilon:"\\u0395",epsiv:"\\u03F5",eqcirc:"\\u2256",eqcolon:"\\u2255",eqsim:"\\u2242",eqslantgtr:"\\u2A96",eqslantless:"\\u2A95",Equal:"\\u2A75",equals:"=",EqualTilde:"\\u2242",equest:"\\u225F",Equilibrium:"\\u21CC",equiv:"\\u2261",equivDD:"\\u2A78",eqvparsl:"\\u29E5",erarr:"\\u2971",erDot:"\\u2253",escr:"\\u212F",Escr:"\\u2130",esdot:"\\u2250",esim:"\\u2242",Esim:"\\u2A73",eta:"\\u03B7",Eta:"\\u0397",eth:"\\xF0",ETH:"\\xD0",euml:"\\xEB",Euml:"\\xCB",euro:"\\u20AC",excl:"!",exist:"\\u2203",Exists:"\\u2203",expectation:"\\u2130",exponentiale:"\\u2147",ExponentialE:"\\u2147",fallingdotseq:"\\u2252",fcy:"\\u0444",Fcy:"\\u0424",female:"\\u2640",ffilig:"\\uFB03",fflig:"\\uFB00",ffllig:"\\uFB04",ffr:"\\u{1D523}",Ffr:"\\u{1D509}",filig:"\\uFB01",FilledSmallSquare:"\\u25FC",FilledVerySmallSquare:"\\u25AA",fjlig:"fj",flat:"\\u266D",fllig:"\\uFB02",fltns:"\\u25B1",fnof:"\\u0192",fopf:"\\u{1D557}",Fopf:"\\u{1D53D}",forall:"\\u2200",ForAll:"\\u2200",fork:"\\u22D4",forkv:"\\u2AD9",Fouriertrf:"\\u2131",fpartint:"\\u2A0D",frac12:"\\xBD",frac13:"\\u2153",frac14:"\\xBC",frac15:"\\u2155",frac16:"\\u2159",frac18:"\\u215B",frac23:"\\u2154",frac25:"\\u2156",frac34:"\\xBE",frac35:"\\u2157",frac38:"\\u215C",frac45:"\\u2158",frac56:"\\u215A",frac58:"\\u215D",frac78:"\\u215E",frasl:"\\u2044",frown:"\\u2322",fscr:"\\u{1D4BB}",Fscr:"\\u2131",gacute:"\\u01F5",gamma:"\\u03B3",Gamma:"\\u0393",gammad:"\\u03DD",Gammad:"\\u03DC",gap:"\\u2A86",gbreve:"\\u011F",Gbreve:"\\u011E",Gcedil:"\\u0122",gcirc:"\\u011D",Gcirc:"\\u011C",gcy:"\\u0433",Gcy:"\\u0413",gdot:"\\u0121",Gdot:"\\u0120",ge:"\\u2265",gE:"\\u2267",gel:"\\u22DB",gEl:"\\u2A8C",geq:"\\u2265",geqq:"\\u2267",geqslant:"\\u2A7E",ges:"\\u2A7E",gescc:"\\u2AA9",gesdot:"\\u2A80",gesdoto:"\\u2A82",gesdotol:"\\u2A84",gesl:"\\u22DB\\uFE00",gesles:"\\u2A94",gfr:"\\u{1D524}",Gfr:"\\u{1D50A}",gg:"\\u226B",Gg:"\\u22D9",ggg:"\\u22D9",gimel:"\\u2137",gjcy:"\\u0453",GJcy:"\\u0403",gl:"\\u2277",gla:"\\u2AA5",glE:"\\u2A92",glj:"\\u2AA4",gnap:"\\u2A8A",gnapprox:"\\u2A8A",gne:"\\u2A88",gnE:"\\u2269",gneq:"\\u2A88",gneqq:"\\u2269",gnsim:"\\u22E7",gopf:"\\u{1D558}",Gopf:"\\u{1D53E}",grave:"`",GreaterEqual:"\\u2265",GreaterEqualLess:"\\u22DB",GreaterFullEqual:"\\u2267",GreaterGreater:"\\u2AA2",GreaterLess:"\\u2277",GreaterSlantEqual:"\\u2A7E",GreaterTilde:"\\u2273",gscr:"\\u210A",Gscr:"\\u{1D4A2}",gsim:"\\u2273",gsime:"\\u2A8E",gsiml:"\\u2A90",gt:">",Gt:"\\u226B",GT:">",gtcc:"\\u2AA7",gtcir:"\\u2A7A",gtdot:"\\u22D7",gtlPar:"\\u2995",gtquest:"\\u2A7C",gtrapprox:"\\u2A86",gtrarr:"\\u2978",gtrdot:"\\u22D7",gtreqless:"\\u22DB",gtreqqless:"\\u2A8C",gtrless:"\\u2277",gtrsim:"\\u2273",gvertneqq:"\\u2269\\uFE00",gvnE:"\\u2269\\uFE00",Hacek:"\\u02C7",hairsp:"\\u200A",half:"\\xBD",hamilt:"\\u210B",hardcy:"\\u044A",HARDcy:"\\u042A",harr:"\\u2194",hArr:"\\u21D4",harrcir:"\\u2948",harrw:"\\u21AD",Hat:"^",hbar:"\\u210F",hcirc:"\\u0125",Hcirc:"\\u0124",hearts:"\\u2665",heartsuit:"\\u2665",hellip:"\\u2026",hercon:"\\u22B9",hfr:"\\u{1D525}",Hfr:"\\u210C",HilbertSpace:"\\u210B",hksearow:"\\u2925",hkswarow:"\\u2926",hoarr:"\\u21FF",homtht:"\\u223B",hookleftarrow:"\\u21A9",hookrightarrow:"\\u21AA",hopf:"\\u{1D559}",Hopf:"\\u210D",horbar:"\\u2015",HorizontalLine:"\\u2500",hscr:"\\u{1D4BD}",Hscr:"\\u210B",hslash:"\\u210F",hstrok:"\\u0127",Hstrok:"\\u0126",HumpDownHump:"\\u224E",HumpEqual:"\\u224F",hybull:"\\u2043",hyphen:"\\u2010",iacute:"\\xED",Iacute:"\\xCD",ic:"\\u2063",icirc:"\\xEE",Icirc:"\\xCE",icy:"\\u0438",Icy:"\\u0418",Idot:"\\u0130",iecy:"\\u0435",IEcy:"\\u0415",iexcl:"\\xA1",iff:"\\u21D4",ifr:"\\u{1D526}",Ifr:"\\u2111",igrave:"\\xEC",Igrave:"\\xCC",ii:"\\u2148",iiiint:"\\u2A0C",iiint:"\\u222D",iinfin:"\\u29DC",iiota:"\\u2129",ijlig:"\\u0133",IJlig:"\\u0132",Im:"\\u2111",imacr:"\\u012B",Imacr:"\\u012A",image:"\\u2111",ImaginaryI:"\\u2148",imagline:"\\u2110",imagpart:"\\u2111",imath:"\\u0131",imof:"\\u22B7",imped:"\\u01B5",Implies:"\\u21D2",in:"\\u2208",incare:"\\u2105",infin:"\\u221E",infintie:"\\u29DD",inodot:"\\u0131",int:"\\u222B",Int:"\\u222C",intcal:"\\u22BA",integers:"\\u2124",Integral:"\\u222B",intercal:"\\u22BA",Intersection:"\\u22C2",intlarhk:"\\u2A17",intprod:"\\u2A3C",InvisibleComma:"\\u2063",InvisibleTimes:"\\u2062",iocy:"\\u0451",IOcy:"\\u0401",iogon:"\\u012F",Iogon:"\\u012E",iopf:"\\u{1D55A}",Iopf:"\\u{1D540}",iota:"\\u03B9",Iota:"\\u0399",iprod:"\\u2A3C",iquest:"\\xBF",iscr:"\\u{1D4BE}",Iscr:"\\u2110",isin:"\\u2208",isindot:"\\u22F5",isinE:"\\u22F9",isins:"\\u22F4",isinsv:"\\u22F3",isinv:"\\u2208",it:"\\u2062",itilde:"\\u0129",Itilde:"\\u0128",iukcy:"\\u0456",Iukcy:"\\u0406",iuml:"\\xEF",Iuml:"\\xCF",jcirc:"\\u0135",Jcirc:"\\u0134",jcy:"\\u0439",Jcy:"\\u0419",jfr:"\\u{1D527}",Jfr:"\\u{1D50D}",jmath:"\\u0237",jopf:"\\u{1D55B}",Jopf:"\\u{1D541}",jscr:"\\u{1D4BF}",Jscr:"\\u{1D4A5}",jsercy:"\\u0458",Jsercy:"\\u0408",jukcy:"\\u0454",Jukcy:"\\u0404",kappa:"\\u03BA",Kappa:"\\u039A",kappav:"\\u03F0",kcedil:"\\u0137",Kcedil:"\\u0136",kcy:"\\u043A",Kcy:"\\u041A",kfr:"\\u{1D528}",Kfr:"\\u{1D50E}",kgreen:"\\u0138",khcy:"\\u0445",KHcy:"\\u0425",kjcy:"\\u045C",KJcy:"\\u040C",kopf:"\\u{1D55C}",Kopf:"\\u{1D542}",kscr:"\\u{1D4C0}",Kscr:"\\u{1D4A6}",lAarr:"\\u21DA",lacute:"\\u013A",Lacute:"\\u0139",laemptyv:"\\u29B4",lagran:"\\u2112",lambda:"\\u03BB",Lambda:"\\u039B",lang:"\\u27E8",Lang:"\\u27EA",langd:"\\u2991",langle:"\\u27E8",lap:"\\u2A85",Laplacetrf:"\\u2112",laquo:"\\xAB",larr:"\\u2190",lArr:"\\u21D0",Larr:"\\u219E",larrb:"\\u21E4",larrbfs:"\\u291F",larrfs:"\\u291D",larrhk:"\\u21A9",larrlp:"\\u21AB",larrpl:"\\u2939",larrsim:"\\u2973",larrtl:"\\u21A2",lat:"\\u2AAB",latail:"\\u2919",lAtail:"\\u291B",late:"\\u2AAD",lates:"\\u2AAD\\uFE00",lbarr:"\\u290C",lBarr:"\\u290E",lbbrk:"\\u2772",lbrace:"{",lbrack:"[",lbrke:"\\u298B",lbrksld:"\\u298F",lbrkslu:"\\u298D",lcaron:"\\u013E",Lcaron:"\\u013D",lcedil:"\\u013C",Lcedil:"\\u013B",lceil:"\\u2308",lcub:"{",lcy:"\\u043B",Lcy:"\\u041B",ldca:"\\u2936",ldquo:"\\u201C",ldquor:"\\u201E",ldrdhar:"\\u2967",ldrushar:"\\u294B",ldsh:"\\u21B2",le:"\\u2264",lE:"\\u2266",LeftAngleBracket:"\\u27E8",leftarrow:"\\u2190",Leftarrow:"\\u21D0",LeftArrow:"\\u2190",LeftArrowBar:"\\u21E4",LeftArrowRightArrow:"\\u21C6",leftarrowtail:"\\u21A2",LeftCeiling:"\\u2308",LeftDoubleBracket:"\\u27E6",LeftDownTeeVector:"\\u2961",LeftDownVector:"\\u21C3",LeftDownVectorBar:"\\u2959",LeftFloor:"\\u230A",leftharpoondown:"\\u21BD",leftharpoonup:"\\u21BC",leftleftarrows:"\\u21C7",leftrightarrow:"\\u2194",Leftrightarrow:"\\u21D4",LeftRightArrow:"\\u2194",leftrightarrows:"\\u21C6",leftrightharpoons:"\\u21CB",leftrightsquigarrow:"\\u21AD",LeftRightVector:"\\u294E",LeftTee:"\\u22A3",LeftTeeArrow:"\\u21A4",LeftTeeVector:"\\u295A",leftthreetimes:"\\u22CB",LeftTriangle:"\\u22B2",LeftTriangleBar:"\\u29CF",LeftTriangleEqual:"\\u22B4",LeftUpDownVector:"\\u2951",LeftUpTeeVector:"\\u2960",LeftUpVector:"\\u21BF",LeftUpVectorBar:"\\u2958",LeftVector:"\\u21BC",LeftVectorBar:"\\u2952",leg:"\\u22DA",lEg:"\\u2A8B",leq:"\\u2264",leqq:"\\u2266",leqslant:"\\u2A7D",les:"\\u2A7D",lescc:"\\u2AA8",lesdot:"\\u2A7F",lesdoto:"\\u2A81",lesdotor:"\\u2A83",lesg:"\\u22DA\\uFE00",lesges:"\\u2A93",lessapprox:"\\u2A85",lessdot:"\\u22D6",lesseqgtr:"\\u22DA",lesseqqgtr:"\\u2A8B",LessEqualGreater:"\\u22DA",LessFullEqual:"\\u2266",LessGreater:"\\u2276",lessgtr:"\\u2276",LessLess:"\\u2AA1",lesssim:"\\u2272",LessSlantEqual:"\\u2A7D",LessTilde:"\\u2272",lfisht:"\\u297C",lfloor:"\\u230A",lfr:"\\u{1D529}",Lfr:"\\u{1D50F}",lg:"\\u2276",lgE:"\\u2A91",lHar:"\\u2962",lhard:"\\u21BD",lharu:"\\u21BC",lharul:"\\u296A",lhblk:"\\u2584",ljcy:"\\u0459",LJcy:"\\u0409",ll:"\\u226A",Ll:"\\u22D8",llarr:"\\u21C7",llcorner:"\\u231E",Lleftarrow:"\\u21DA",llhard:"\\u296B",lltri:"\\u25FA",lmidot:"\\u0140",Lmidot:"\\u013F",lmoust:"\\u23B0",lmoustache:"\\u23B0",lnap:"\\u2A89",lnapprox:"\\u2A89",lne:"\\u2A87",lnE:"\\u2268",lneq:"\\u2A87",lneqq:"\\u2268",lnsim:"\\u22E6",loang:"\\u27EC",loarr:"\\u21FD",lobrk:"\\u27E6",longleftarrow:"\\u27F5",Longleftarrow:"\\u27F8",LongLeftArrow:"\\u27F5",longleftrightarrow:"\\u27F7",Longleftrightarrow:"\\u27FA",LongLeftRightArrow:"\\u27F7",longmapsto:"\\u27FC",longrightarrow:"\\u27F6",Longrightarrow:"\\u27F9",LongRightArrow:"\\u27F6",looparrowleft:"\\u21AB",looparrowright:"\\u21AC",lopar:"\\u2985",lopf:"\\u{1D55D}",Lopf:"\\u{1D543}",loplus:"\\u2A2D",lotimes:"\\u2A34",lowast:"\\u2217",lowbar:"_",LowerLeftArrow:"\\u2199",LowerRightArrow:"\\u2198",loz:"\\u25CA",lozenge:"\\u25CA",lozf:"\\u29EB",lpar:"(",lparlt:"\\u2993",lrarr:"\\u21C6",lrcorner:"\\u231F",lrhar:"\\u21CB",lrhard:"\\u296D",lrm:"\\u200E",lrtri:"\\u22BF",lsaquo:"\\u2039",lscr:"\\u{1D4C1}",Lscr:"\\u2112",lsh:"\\u21B0",Lsh:"\\u21B0",lsim:"\\u2272",lsime:"\\u2A8D",lsimg:"\\u2A8F",lsqb:"[",lsquo:"\\u2018",lsquor:"\\u201A",lstrok:"\\u0142",Lstrok:"\\u0141",lt:"<",Lt:"\\u226A",LT:"<",ltcc:"\\u2AA6",ltcir:"\\u2A79",ltdot:"\\u22D6",lthree:"\\u22CB",ltimes:"\\u22C9",ltlarr:"\\u2976",ltquest:"\\u2A7B",ltri:"\\u25C3",ltrie:"\\u22B4",ltrif:"\\u25C2",ltrPar:"\\u2996",lurdshar:"\\u294A",luruhar:"\\u2966",lvertneqq:"\\u2268\\uFE00",lvnE:"\\u2268\\uFE00",macr:"\\xAF",male:"\\u2642",malt:"\\u2720",maltese:"\\u2720",map:"\\u21A6",Map:"\\u2905",mapsto:"\\u21A6",mapstodown:"\\u21A7",mapstoleft:"\\u21A4",mapstoup:"\\u21A5",marker:"\\u25AE",mcomma:"\\u2A29",mcy:"\\u043C",Mcy:"\\u041C",mdash:"\\u2014",mDDot:"\\u223A",measuredangle:"\\u2221",MediumSpace:"\\u205F",Mellintrf:"\\u2133",mfr:"\\u{1D52A}",Mfr:"\\u{1D510}",mho:"\\u2127",micro:"\\xB5",mid:"\\u2223",midast:"*",midcir:"\\u2AF0",middot:"\\xB7",minus:"\\u2212",minusb:"\\u229F",minusd:"\\u2238",minusdu:"\\u2A2A",MinusPlus:"\\u2213",mlcp:"\\u2ADB",mldr:"\\u2026",mnplus:"\\u2213",models:"\\u22A7",mopf:"\\u{1D55E}",Mopf:"\\u{1D544}",mp:"\\u2213",mscr:"\\u{1D4C2}",Mscr:"\\u2133",mstpos:"\\u223E",mu:"\\u03BC",Mu:"\\u039C",multimap:"\\u22B8",mumap:"\\u22B8",nabla:"\\u2207",nacute:"\\u0144",Nacute:"\\u0143",nang:"\\u2220\\u20D2",nap:"\\u2249",napE:"\\u2A70\\u0338",napid:"\\u224B\\u0338",napos:"\\u0149",napprox:"\\u2249",natur:"\\u266E",natural:"\\u266E",naturals:"\\u2115",nbsp:"\\xA0",nbump:"\\u224E\\u0338",nbumpe:"\\u224F\\u0338",ncap:"\\u2A43",ncaron:"\\u0148",Ncaron:"\\u0147",ncedil:"\\u0146",Ncedil:"\\u0145",ncong:"\\u2247",ncongdot:"\\u2A6D\\u0338",ncup:"\\u2A42",ncy:"\\u043D",Ncy:"\\u041D",ndash:"\\u2013",ne:"\\u2260",nearhk:"\\u2924",nearr:"\\u2197",neArr:"\\u21D7",nearrow:"\\u2197",nedot:"\\u2250\\u0338",NegativeMediumSpace:"\\u200B",NegativeThickSpace:"\\u200B",NegativeThinSpace:"\\u200B",NegativeVeryThinSpace:"\\u200B",nequiv:"\\u2262",nesear:"\\u2928",nesim:"\\u2242\\u0338",NestedGreaterGreater:"\\u226B",NestedLessLess:"\\u226A",NewLine:`\n`,nexist:"\\u2204",nexists:"\\u2204",nfr:"\\u{1D52B}",Nfr:"\\u{1D511}",nge:"\\u2271",ngE:"\\u2267\\u0338",ngeq:"\\u2271",ngeqq:"\\u2267\\u0338",ngeqslant:"\\u2A7E\\u0338",nges:"\\u2A7E\\u0338",nGg:"\\u22D9\\u0338",ngsim:"\\u2275",ngt:"\\u226F",nGt:"\\u226B\\u20D2",ngtr:"\\u226F",nGtv:"\\u226B\\u0338",nharr:"\\u21AE",nhArr:"\\u21CE",nhpar:"\\u2AF2",ni:"\\u220B",nis:"\\u22FC",nisd:"\\u22FA",niv:"\\u220B",njcy:"\\u045A",NJcy:"\\u040A",nlarr:"\\u219A",nlArr:"\\u21CD",nldr:"\\u2025",nle:"\\u2270",nlE:"\\u2266\\u0338",nleftarrow:"\\u219A",nLeftarrow:"\\u21CD",nleftrightarrow:"\\u21AE",nLeftrightarrow:"\\u21CE",nleq:"\\u2270",nleqq:"\\u2266\\u0338",nleqslant:"\\u2A7D\\u0338",nles:"\\u2A7D\\u0338",nless:"\\u226E",nLl:"\\u22D8\\u0338",nlsim:"\\u2274",nlt:"\\u226E",nLt:"\\u226A\\u20D2",nltri:"\\u22EA",nltrie:"\\u22EC",nLtv:"\\u226A\\u0338",nmid:"\\u2224",NoBreak:"\\u2060",NonBreakingSpace:"\\xA0",nopf:"\\u{1D55F}",Nopf:"\\u2115",not:"\\xAC",Not:"\\u2AEC",NotCongruent:"\\u2262",NotCupCap:"\\u226D",NotDoubleVerticalBar:"\\u2226",NotElement:"\\u2209",NotEqual:"\\u2260",NotEqualTilde:"\\u2242\\u0338",NotExists:"\\u2204",NotGreater:"\\u226F",NotGreaterEqual:"\\u2271",NotGreaterFullEqual:"\\u2267\\u0338",NotGreaterGreater:"\\u226B\\u0338",NotGreaterLess:"\\u2279",NotGreaterSlantEqual:"\\u2A7E\\u0338",NotGreaterTilde:"\\u2275",NotHumpDownHump:"\\u224E\\u0338",NotHumpEqual:"\\u224F\\u0338",notin:"\\u2209",notindot:"\\u22F5\\u0338",notinE:"\\u22F9\\u0338",notinva:"\\u2209",notinvb:"\\u22F7",notinvc:"\\u22F6",NotLeftTriangle:"\\u22EA",NotLeftTriangleBar:"\\u29CF\\u0338",NotLeftTriangleEqual:"\\u22EC",NotLess:"\\u226E",NotLessEqual:"\\u2270",NotLessGreater:"\\u2278",NotLessLess:"\\u226A\\u0338",NotLessSlantEqual:"\\u2A7D\\u0338",NotLessTilde:"\\u2274",NotNestedGreaterGreater:"\\u2AA2\\u0338",NotNestedLessLess:"\\u2AA1\\u0338",notni:"\\u220C",notniva:"\\u220C",notnivb:"\\u22FE",notnivc:"\\u22FD",NotPrecedes:"\\u2280",NotPrecedesEqual:"\\u2AAF\\u0338",NotPrecedesSlantEqual:"\\u22E0",NotReverseElement:"\\u220C",NotRightTriangle:"\\u22EB",NotRightTriangleBar:"\\u29D0\\u0338",NotRightTriangleEqual:"\\u22ED",NotSquareSubset:"\\u228F\\u0338",NotSquareSubsetEqual:"\\u22E2",NotSquareSuperset:"\\u2290\\u0338",NotSquareSupersetEqual:"\\u22E3",NotSubset:"\\u2282\\u20D2",NotSubsetEqual:"\\u2288",NotSucceeds:"\\u2281",NotSucceedsEqual:"\\u2AB0\\u0338",NotSucceedsSlantEqual:"\\u22E1",NotSucceedsTilde:"\\u227F\\u0338",NotSuperset:"\\u2283\\u20D2",NotSupersetEqual:"\\u2289",NotTilde:"\\u2241",NotTildeEqual:"\\u2244",NotTildeFullEqual:"\\u2247",NotTildeTilde:"\\u2249",NotVerticalBar:"\\u2224",npar:"\\u2226",nparallel:"\\u2226",nparsl:"\\u2AFD\\u20E5",npart:"\\u2202\\u0338",npolint:"\\u2A14",npr:"\\u2280",nprcue:"\\u22E0",npre:"\\u2AAF\\u0338",nprec:"\\u2280",npreceq:"\\u2AAF\\u0338",nrarr:"\\u219B",nrArr:"\\u21CF",nrarrc:"\\u2933\\u0338",nrarrw:"\\u219D\\u0338",nrightarrow:"\\u219B",nRightarrow:"\\u21CF",nrtri:"\\u22EB",nrtrie:"\\u22ED",nsc:"\\u2281",nsccue:"\\u22E1",nsce:"\\u2AB0\\u0338",nscr:"\\u{1D4C3}",Nscr:"\\u{1D4A9}",nshortmid:"\\u2224",nshortparallel:"\\u2226",nsim:"\\u2241",nsime:"\\u2244",nsimeq:"\\u2244",nsmid:"\\u2224",nspar:"\\u2226",nsqsube:"\\u22E2",nsqsupe:"\\u22E3",nsub:"\\u2284",nsube:"\\u2288",nsubE:"\\u2AC5\\u0338",nsubset:"\\u2282\\u20D2",nsubseteq:"\\u2288",nsubseteqq:"\\u2AC5\\u0338",nsucc:"\\u2281",nsucceq:"\\u2AB0\\u0338",nsup:"\\u2285",nsupe:"\\u2289",nsupE:"\\u2AC6\\u0338",nsupset:"\\u2283\\u20D2",nsupseteq:"\\u2289",nsupseteqq:"\\u2AC6\\u0338",ntgl:"\\u2279",ntilde:"\\xF1",Ntilde:"\\xD1",ntlg:"\\u2278",ntriangleleft:"\\u22EA",ntrianglelefteq:"\\u22EC",ntriangleright:"\\u22EB",ntrianglerighteq:"\\u22ED",nu:"\\u03BD",Nu:"\\u039D",num:"#",numero:"\\u2116",numsp:"\\u2007",nvap:"\\u224D\\u20D2",nvdash:"\\u22AC",nvDash:"\\u22AD",nVdash:"\\u22AE",nVDash:"\\u22AF",nvge:"\\u2265\\u20D2",nvgt:">\\u20D2",nvHarr:"\\u2904",nvinfin:"\\u29DE",nvlArr:"\\u2902",nvle:"\\u2264\\u20D2",nvlt:"<\\u20D2",nvltrie:"\\u22B4\\u20D2",nvrArr:"\\u2903",nvrtrie:"\\u22B5\\u20D2",nvsim:"\\u223C\\u20D2",nwarhk:"\\u2923",nwarr:"\\u2196",nwArr:"\\u21D6",nwarrow:"\\u2196",nwnear:"\\u2927",oacute:"\\xF3",Oacute:"\\xD3",oast:"\\u229B",ocir:"\\u229A",ocirc:"\\xF4",Ocirc:"\\xD4",ocy:"\\u043E",Ocy:"\\u041E",odash:"\\u229D",odblac:"\\u0151",Odblac:"\\u0150",odiv:"\\u2A38",odot:"\\u2299",odsold:"\\u29BC",oelig:"\\u0153",OElig:"\\u0152",ofcir:"\\u29BF",ofr:"\\u{1D52C}",Ofr:"\\u{1D512}",ogon:"\\u02DB",ograve:"\\xF2",Ograve:"\\xD2",ogt:"\\u29C1",ohbar:"\\u29B5",ohm:"\\u03A9",oint:"\\u222E",olarr:"\\u21BA",olcir:"\\u29BE",olcross:"\\u29BB",oline:"\\u203E",olt:"\\u29C0",omacr:"\\u014D",Omacr:"\\u014C",omega:"\\u03C9",Omega:"\\u03A9",omicron:"\\u03BF",Omicron:"\\u039F",omid:"\\u29B6",ominus:"\\u2296",oopf:"\\u{1D560}",Oopf:"\\u{1D546}",opar:"\\u29B7",OpenCurlyDoubleQuote:"\\u201C",OpenCurlyQuote:"\\u2018",operp:"\\u29B9",oplus:"\\u2295",or:"\\u2228",Or:"\\u2A54",orarr:"\\u21BB",ord:"\\u2A5D",order:"\\u2134",orderof:"\\u2134",ordf:"\\xAA",ordm:"\\xBA",origof:"\\u22B6",oror:"\\u2A56",orslope:"\\u2A57",orv:"\\u2A5B",oS:"\\u24C8",oscr:"\\u2134",Oscr:"\\u{1D4AA}",oslash:"\\xF8",Oslash:"\\xD8",osol:"\\u2298",otilde:"\\xF5",Otilde:"\\xD5",otimes:"\\u2297",Otimes:"\\u2A37",otimesas:"\\u2A36",ouml:"\\xF6",Ouml:"\\xD6",ovbar:"\\u233D",OverBar:"\\u203E",OverBrace:"\\u23DE",OverBracket:"\\u23B4",OverParenthesis:"\\u23DC",par:"\\u2225",para:"\\xB6",parallel:"\\u2225",parsim:"\\u2AF3",parsl:"\\u2AFD",part:"\\u2202",PartialD:"\\u2202",pcy:"\\u043F",Pcy:"\\u041F",percnt:"%",period:".",permil:"\\u2030",perp:"\\u22A5",pertenk:"\\u2031",pfr:"\\u{1D52D}",Pfr:"\\u{1D513}",phi:"\\u03C6",Phi:"\\u03A6",phiv:"\\u03D5",phmmat:"\\u2133",phone:"\\u260E",pi:"\\u03C0",Pi:"\\u03A0",pitchfork:"\\u22D4",piv:"\\u03D6",planck:"\\u210F",planckh:"\\u210E",plankv:"\\u210F",plus:"+",plusacir:"\\u2A23",plusb:"\\u229E",pluscir:"\\u2A22",plusdo:"\\u2214",plusdu:"\\u2A25",pluse:"\\u2A72",PlusMinus:"\\xB1",plusmn:"\\xB1",plussim:"\\u2A26",plustwo:"\\u2A27",pm:"\\xB1",Poincareplane:"\\u210C",pointint:"\\u2A15",popf:"\\u{1D561}",Popf:"\\u2119",pound:"\\xA3",pr:"\\u227A",Pr:"\\u2ABB",prap:"\\u2AB7",prcue:"\\u227C",pre:"\\u2AAF",prE:"\\u2AB3",prec:"\\u227A",precapprox:"\\u2AB7",preccurlyeq:"\\u227C",Precedes:"\\u227A",PrecedesEqual:"\\u2AAF",PrecedesSlantEqual:"\\u227C",PrecedesTilde:"\\u227E",preceq:"\\u2AAF",precnapprox:"\\u2AB9",precneqq:"\\u2AB5",precnsim:"\\u22E8",precsim:"\\u227E",prime:"\\u2032",Prime:"\\u2033",primes:"\\u2119",prnap:"\\u2AB9",prnE:"\\u2AB5",prnsim:"\\u22E8",prod:"\\u220F",Product:"\\u220F",profalar:"\\u232E",profline:"\\u2312",profsurf:"\\u2313",prop:"\\u221D",Proportion:"\\u2237",Proportional:"\\u221D",propto:"\\u221D",prsim:"\\u227E",prurel:"\\u22B0",pscr:"\\u{1D4C5}",Pscr:"\\u{1D4AB}",psi:"\\u03C8",Psi:"\\u03A8",puncsp:"\\u2008",qfr:"\\u{1D52E}",Qfr:"\\u{1D514}",qint:"\\u2A0C",qopf:"\\u{1D562}",Qopf:"\\u211A",qprime:"\\u2057",qscr:"\\u{1D4C6}",Qscr:"\\u{1D4AC}",quaternions:"\\u210D",quatint:"\\u2A16",quest:"?",questeq:"\\u225F",quot:\'"\',QUOT:\'"\',rAarr:"\\u21DB",race:"\\u223D\\u0331",racute:"\\u0155",Racute:"\\u0154",radic:"\\u221A",raemptyv:"\\u29B3",rang:"\\u27E9",Rang:"\\u27EB",rangd:"\\u2992",range:"\\u29A5",rangle:"\\u27E9",raquo:"\\xBB",rarr:"\\u2192",rArr:"\\u21D2",Rarr:"\\u21A0",rarrap:"\\u2975",rarrb:"\\u21E5",rarrbfs:"\\u2920",rarrc:"\\u2933",rarrfs:"\\u291E",rarrhk:"\\u21AA",rarrlp:"\\u21AC",rarrpl:"\\u2945",rarrsim:"\\u2974",rarrtl:"\\u21A3",Rarrtl:"\\u2916",rarrw:"\\u219D",ratail:"\\u291A",rAtail:"\\u291C",ratio:"\\u2236",rationals:"\\u211A",rbarr:"\\u290D",rBarr:"\\u290F",RBarr:"\\u2910",rbbrk:"\\u2773",rbrace:"}",rbrack:"]",rbrke:"\\u298C",rbrksld:"\\u298E",rbrkslu:"\\u2990",rcaron:"\\u0159",Rcaron:"\\u0158",rcedil:"\\u0157",Rcedil:"\\u0156",rceil:"\\u2309",rcub:"}",rcy:"\\u0440",Rcy:"\\u0420",rdca:"\\u2937",rdldhar:"\\u2969",rdquo:"\\u201D",rdquor:"\\u201D",rdsh:"\\u21B3",Re:"\\u211C",real:"\\u211C",realine:"\\u211B",realpart:"\\u211C",reals:"\\u211D",rect:"\\u25AD",reg:"\\xAE",REG:"\\xAE",ReverseElement:"\\u220B",ReverseEquilibrium:"\\u21CB",ReverseUpEquilibrium:"\\u296F",rfisht:"\\u297D",rfloor:"\\u230B",rfr:"\\u{1D52F}",Rfr:"\\u211C",rHar:"\\u2964",rhard:"\\u21C1",rharu:"\\u21C0",rharul:"\\u296C",rho:"\\u03C1",Rho:"\\u03A1",rhov:"\\u03F1",RightAngleBracket:"\\u27E9",rightarrow:"\\u2192",Rightarrow:"\\u21D2",RightArrow:"\\u2192",RightArrowBar:"\\u21E5",RightArrowLeftArrow:"\\u21C4",rightarrowtail:"\\u21A3",RightCeiling:"\\u2309",RightDoubleBracket:"\\u27E7",RightDownTeeVector:"\\u295D",RightDownVector:"\\u21C2",RightDownVectorBar:"\\u2955",RightFloor:"\\u230B",rightharpoondown:"\\u21C1",rightharpoonup:"\\u21C0",rightleftarrows:"\\u21C4",rightleftharpoons:"\\u21CC",rightrightarrows:"\\u21C9",rightsquigarrow:"\\u219D",RightTee:"\\u22A2",RightTeeArrow:"\\u21A6",RightTeeVector:"\\u295B",rightthreetimes:"\\u22CC",RightTriangle:"\\u22B3",RightTriangleBar:"\\u29D0",RightTriangleEqual:"\\u22B5",RightUpDownVector:"\\u294F",RightUpTeeVector:"\\u295C",RightUpVector:"\\u21BE",RightUpVectorBar:"\\u2954",RightVector:"\\u21C0",RightVectorBar:"\\u2953",ring:"\\u02DA",risingdotseq:"\\u2253",rlarr:"\\u21C4",rlhar:"\\u21CC",rlm:"\\u200F",rmoust:"\\u23B1",rmoustache:"\\u23B1",rnmid:"\\u2AEE",roang:"\\u27ED",roarr:"\\u21FE",robrk:"\\u27E7",ropar:"\\u2986",ropf:"\\u{1D563}",Ropf:"\\u211D",roplus:"\\u2A2E",rotimes:"\\u2A35",RoundImplies:"\\u2970",rpar:")",rpargt:"\\u2994",rppolint:"\\u2A12",rrarr:"\\u21C9",Rrightarrow:"\\u21DB",rsaquo:"\\u203A",rscr:"\\u{1D4C7}",Rscr:"\\u211B",rsh:"\\u21B1",Rsh:"\\u21B1",rsqb:"]",rsquo:"\\u2019",rsquor:"\\u2019",rthree:"\\u22CC",rtimes:"\\u22CA",rtri:"\\u25B9",rtrie:"\\u22B5",rtrif:"\\u25B8",rtriltri:"\\u29CE",RuleDelayed:"\\u29F4",ruluhar:"\\u2968",rx:"\\u211E",sacute:"\\u015B",Sacute:"\\u015A",sbquo:"\\u201A",sc:"\\u227B",Sc:"\\u2ABC",scap:"\\u2AB8",scaron:"\\u0161",Scaron:"\\u0160",sccue:"\\u227D",sce:"\\u2AB0",scE:"\\u2AB4",scedil:"\\u015F",Scedil:"\\u015E",scirc:"\\u015D",Scirc:"\\u015C",scnap:"\\u2ABA",scnE:"\\u2AB6",scnsim:"\\u22E9",scpolint:"\\u2A13",scsim:"\\u227F",scy:"\\u0441",Scy:"\\u0421",sdot:"\\u22C5",sdotb:"\\u22A1",sdote:"\\u2A66",searhk:"\\u2925",searr:"\\u2198",seArr:"\\u21D8",searrow:"\\u2198",sect:"\\xA7",semi:";",seswar:"\\u2929",setminus:"\\u2216",setmn:"\\u2216",sext:"\\u2736",sfr:"\\u{1D530}",Sfr:"\\u{1D516}",sfrown:"\\u2322",sharp:"\\u266F",shchcy:"\\u0449",SHCHcy:"\\u0429",shcy:"\\u0448",SHcy:"\\u0428",ShortDownArrow:"\\u2193",ShortLeftArrow:"\\u2190",shortmid:"\\u2223",shortparallel:"\\u2225",ShortRightArrow:"\\u2192",ShortUpArrow:"\\u2191",shy:"\\xAD",sigma:"\\u03C3",Sigma:"\\u03A3",sigmaf:"\\u03C2",sigmav:"\\u03C2",sim:"\\u223C",simdot:"\\u2A6A",sime:"\\u2243",simeq:"\\u2243",simg:"\\u2A9E",simgE:"\\u2AA0",siml:"\\u2A9D",simlE:"\\u2A9F",simne:"\\u2246",simplus:"\\u2A24",simrarr:"\\u2972",slarr:"\\u2190",SmallCircle:"\\u2218",smallsetminus:"\\u2216",smashp:"\\u2A33",smeparsl:"\\u29E4",smid:"\\u2223",smile:"\\u2323",smt:"\\u2AAA",smte:"\\u2AAC",smtes:"\\u2AAC\\uFE00",softcy:"\\u044C",SOFTcy:"\\u042C",sol:"/",solb:"\\u29C4",solbar:"\\u233F",sopf:"\\u{1D564}",Sopf:"\\u{1D54A}",spades:"\\u2660",spadesuit:"\\u2660",spar:"\\u2225",sqcap:"\\u2293",sqcaps:"\\u2293\\uFE00",sqcup:"\\u2294",sqcups:"\\u2294\\uFE00",Sqrt:"\\u221A",sqsub:"\\u228F",sqsube:"\\u2291",sqsubset:"\\u228F",sqsubseteq:"\\u2291",sqsup:"\\u2290",sqsupe:"\\u2292",sqsupset:"\\u2290",sqsupseteq:"\\u2292",squ:"\\u25A1",square:"\\u25A1",Square:"\\u25A1",SquareIntersection:"\\u2293",SquareSubset:"\\u228F",SquareSubsetEqual:"\\u2291",SquareSuperset:"\\u2290",SquareSupersetEqual:"\\u2292",SquareUnion:"\\u2294",squarf:"\\u25AA",squf:"\\u25AA",srarr:"\\u2192",sscr:"\\u{1D4C8}",Sscr:"\\u{1D4AE}",ssetmn:"\\u2216",ssmile:"\\u2323",sstarf:"\\u22C6",star:"\\u2606",Star:"\\u22C6",starf:"\\u2605",straightepsilon:"\\u03F5",straightphi:"\\u03D5",strns:"\\xAF",sub:"\\u2282",Sub:"\\u22D0",subdot:"\\u2ABD",sube:"\\u2286",subE:"\\u2AC5",subedot:"\\u2AC3",submult:"\\u2AC1",subne:"\\u228A",subnE:"\\u2ACB",subplus:"\\u2ABF",subrarr:"\\u2979",subset:"\\u2282",Subset:"\\u22D0",subseteq:"\\u2286",subseteqq:"\\u2AC5",SubsetEqual:"\\u2286",subsetneq:"\\u228A",subsetneqq:"\\u2ACB",subsim:"\\u2AC7",subsub:"\\u2AD5",subsup:"\\u2AD3",succ:"\\u227B",succapprox:"\\u2AB8",succcurlyeq:"\\u227D",Succeeds:"\\u227B",SucceedsEqual:"\\u2AB0",SucceedsSlantEqual:"\\u227D",SucceedsTilde:"\\u227F",succeq:"\\u2AB0",succnapprox:"\\u2ABA",succneqq:"\\u2AB6",succnsim:"\\u22E9",succsim:"\\u227F",SuchThat:"\\u220B",sum:"\\u2211",Sum:"\\u2211",sung:"\\u266A",sup:"\\u2283",Sup:"\\u22D1",sup1:"\\xB9",sup2:"\\xB2",sup3:"\\xB3",supdot:"\\u2ABE",supdsub:"\\u2AD8",supe:"\\u2287",supE:"\\u2AC6",supedot:"\\u2AC4",Superset:"\\u2283",SupersetEqual:"\\u2287",suphsol:"\\u27C9",suphsub:"\\u2AD7",suplarr:"\\u297B",supmult:"\\u2AC2",supne:"\\u228B",supnE:"\\u2ACC",supplus:"\\u2AC0",supset:"\\u2283",Supset:"\\u22D1",supseteq:"\\u2287",supseteqq:"\\u2AC6",supsetneq:"\\u228B",supsetneqq:"\\u2ACC",supsim:"\\u2AC8",supsub:"\\u2AD4",supsup:"\\u2AD6",swarhk:"\\u2926",swarr:"\\u2199",swArr:"\\u21D9",swarrow:"\\u2199",swnwar:"\\u292A",szlig:"\\xDF",Tab:" ",target:"\\u2316",tau:"\\u03C4",Tau:"\\u03A4",tbrk:"\\u23B4",tcaron:"\\u0165",Tcaron:"\\u0164",tcedil:"\\u0163",Tcedil:"\\u0162",tcy:"\\u0442",Tcy:"\\u0422",tdot:"\\u20DB",telrec:"\\u2315",tfr:"\\u{1D531}",Tfr:"\\u{1D517}",there4:"\\u2234",therefore:"\\u2234",Therefore:"\\u2234",theta:"\\u03B8",Theta:"\\u0398",thetasym:"\\u03D1",thetav:"\\u03D1",thickapprox:"\\u2248",thicksim:"\\u223C",ThickSpace:"\\u205F\\u200A",thinsp:"\\u2009",ThinSpace:"\\u2009",thkap:"\\u2248",thksim:"\\u223C",thorn:"\\xFE",THORN:"\\xDE",tilde:"\\u02DC",Tilde:"\\u223C",TildeEqual:"\\u2243",TildeFullEqual:"\\u2245",TildeTilde:"\\u2248",times:"\\xD7",timesb:"\\u22A0",timesbar:"\\u2A31",timesd:"\\u2A30",tint:"\\u222D",toea:"\\u2928",top:"\\u22A4",topbot:"\\u2336",topcir:"\\u2AF1",topf:"\\u{1D565}",Topf:"\\u{1D54B}",topfork:"\\u2ADA",tosa:"\\u2929",tprime:"\\u2034",trade:"\\u2122",TRADE:"\\u2122",triangle:"\\u25B5",triangledown:"\\u25BF",triangleleft:"\\u25C3",trianglelefteq:"\\u22B4",triangleq:"\\u225C",triangleright:"\\u25B9",trianglerighteq:"\\u22B5",tridot:"\\u25EC",trie:"\\u225C",triminus:"\\u2A3A",TripleDot:"\\u20DB",triplus:"\\u2A39",trisb:"\\u29CD",tritime:"\\u2A3B",trpezium:"\\u23E2",tscr:"\\u{1D4C9}",Tscr:"\\u{1D4AF}",tscy:"\\u0446",TScy:"\\u0426",tshcy:"\\u045B",TSHcy:"\\u040B",tstrok:"\\u0167",Tstrok:"\\u0166",twixt:"\\u226C",twoheadleftarrow:"\\u219E",twoheadrightarrow:"\\u21A0",uacute:"\\xFA",Uacute:"\\xDA",uarr:"\\u2191",uArr:"\\u21D1",Uarr:"\\u219F",Uarrocir:"\\u2949",ubrcy:"\\u045E",Ubrcy:"\\u040E",ubreve:"\\u016D",Ubreve:"\\u016C",ucirc:"\\xFB",Ucirc:"\\xDB",ucy:"\\u0443",Ucy:"\\u0423",udarr:"\\u21C5",udblac:"\\u0171",Udblac:"\\u0170",udhar:"\\u296E",ufisht:"\\u297E",ufr:"\\u{1D532}",Ufr:"\\u{1D518}",ugrave:"\\xF9",Ugrave:"\\xD9",uHar:"\\u2963",uharl:"\\u21BF",uharr:"\\u21BE",uhblk:"\\u2580",ulcorn:"\\u231C",ulcorner:"\\u231C",ulcrop:"\\u230F",ultri:"\\u25F8",umacr:"\\u016B",Umacr:"\\u016A",uml:"\\xA8",UnderBar:"_",UnderBrace:"\\u23DF",UnderBracket:"\\u23B5",UnderParenthesis:"\\u23DD",Union:"\\u22C3",UnionPlus:"\\u228E",uogon:"\\u0173",Uogon:"\\u0172",uopf:"\\u{1D566}",Uopf:"\\u{1D54C}",uparrow:"\\u2191",Uparrow:"\\u21D1",UpArrow:"\\u2191",UpArrowBar:"\\u2912",UpArrowDownArrow:"\\u21C5",updownarrow:"\\u2195",Updownarrow:"\\u21D5",UpDownArrow:"\\u2195",UpEquilibrium:"\\u296E",upharpoonleft:"\\u21BF",upharpoonright:"\\u21BE",uplus:"\\u228E",UpperLeftArrow:"\\u2196",UpperRightArrow:"\\u2197",upsi:"\\u03C5",Upsi:"\\u03D2",upsih:"\\u03D2",upsilon:"\\u03C5",Upsilon:"\\u03A5",UpTee:"\\u22A5",UpTeeArrow:"\\u21A5",upuparrows:"\\u21C8",urcorn:"\\u231D",urcorner:"\\u231D",urcrop:"\\u230E",uring:"\\u016F",Uring:"\\u016E",urtri:"\\u25F9",uscr:"\\u{1D4CA}",Uscr:"\\u{1D4B0}",utdot:"\\u22F0",utilde:"\\u0169",Utilde:"\\u0168",utri:"\\u25B5",utrif:"\\u25B4",uuarr:"\\u21C8",uuml:"\\xFC",Uuml:"\\xDC",uwangle:"\\u29A7",vangrt:"\\u299C",varepsilon:"\\u03F5",varkappa:"\\u03F0",varnothing:"\\u2205",varphi:"\\u03D5",varpi:"\\u03D6",varpropto:"\\u221D",varr:"\\u2195",vArr:"\\u21D5",varrho:"\\u03F1",varsigma:"\\u03C2",varsubsetneq:"\\u228A\\uFE00",varsubsetneqq:"\\u2ACB\\uFE00",varsupsetneq:"\\u228B\\uFE00",varsupsetneqq:"\\u2ACC\\uFE00",vartheta:"\\u03D1",vartriangleleft:"\\u22B2",vartriangleright:"\\u22B3",vBar:"\\u2AE8",Vbar:"\\u2AEB",vBarv:"\\u2AE9",vcy:"\\u0432",Vcy:"\\u0412",vdash:"\\u22A2",vDash:"\\u22A8",Vdash:"\\u22A9",VDash:"\\u22AB",Vdashl:"\\u2AE6",vee:"\\u2228",Vee:"\\u22C1",veebar:"\\u22BB",veeeq:"\\u225A",vellip:"\\u22EE",verbar:"|",Verbar:"\\u2016",vert:"|",Vert:"\\u2016",VerticalBar:"\\u2223",VerticalLine:"|",VerticalSeparator:"\\u2758",VerticalTilde:"\\u2240",VeryThinSpace:"\\u200A",vfr:"\\u{1D533}",Vfr:"\\u{1D519}",vltri:"\\u22B2",vnsub:"\\u2282\\u20D2",vnsup:"\\u2283\\u20D2",vopf:"\\u{1D567}",Vopf:"\\u{1D54D}",vprop:"\\u221D",vrtri:"\\u22B3",vscr:"\\u{1D4CB}",Vscr:"\\u{1D4B1}",vsubne:"\\u228A\\uFE00",vsubnE:"\\u2ACB\\uFE00",vsupne:"\\u228B\\uFE00",vsupnE:"\\u2ACC\\uFE00",Vvdash:"\\u22AA",vzigzag:"\\u299A",wcirc:"\\u0175",Wcirc:"\\u0174",wedbar:"\\u2A5F",wedge:"\\u2227",Wedge:"\\u22C0",wedgeq:"\\u2259",weierp:"\\u2118",wfr:"\\u{1D534}",Wfr:"\\u{1D51A}",wopf:"\\u{1D568}",Wopf:"\\u{1D54E}",wp:"\\u2118",wr:"\\u2240",wreath:"\\u2240",wscr:"\\u{1D4CC}",Wscr:"\\u{1D4B2}",xcap:"\\u22C2",xcirc:"\\u25EF",xcup:"\\u22C3",xdtri:"\\u25BD",xfr:"\\u{1D535}",Xfr:"\\u{1D51B}",xharr:"\\u27F7",xhArr:"\\u27FA",xi:"\\u03BE",Xi:"\\u039E",xlarr:"\\u27F5",xlArr:"\\u27F8",xmap:"\\u27FC",xnis:"\\u22FB",xodot:"\\u2A00",xopf:"\\u{1D569}",Xopf:"\\u{1D54F}",xoplus:"\\u2A01",xotime:"\\u2A02",xrarr:"\\u27F6",xrArr:"\\u27F9",xscr:"\\u{1D4CD}",Xscr:"\\u{1D4B3}",xsqcup:"\\u2A06",xuplus:"\\u2A04",xutri:"\\u25B3",xvee:"\\u22C1",xwedge:"\\u22C0",yacute:"\\xFD",Yacute:"\\xDD",yacy:"\\u044F",YAcy:"\\u042F",ycirc:"\\u0177",Ycirc:"\\u0176",ycy:"\\u044B",Ycy:"\\u042B",yen:"\\xA5",yfr:"\\u{1D536}",Yfr:"\\u{1D51C}",yicy:"\\u0457",YIcy:"\\u0407",yopf:"\\u{1D56A}",Yopf:"\\u{1D550}",yscr:"\\u{1D4CE}",Yscr:"\\u{1D4B4}",yucy:"\\u044E",YUcy:"\\u042E",yuml:"\\xFF",Yuml:"\\u0178",zacute:"\\u017A",Zacute:"\\u0179",zcaron:"\\u017E",Zcaron:"\\u017D",zcy:"\\u0437",Zcy:"\\u0417",zdot:"\\u017C",Zdot:"\\u017B",zeetrf:"\\u2128",ZeroWidthSpace:"\\u200B",zeta:"\\u03B6",Zeta:"\\u0396",zfr:"\\u{1D537}",Zfr:"\\u2128",zhcy:"\\u0436",ZHcy:"\\u0416",zigrarr:"\\u21DD",zopf:"\\u{1D56B}",Zopf:"\\u2124",zscr:"\\u{1D4CF}",Zscr:"\\u{1D4B5}",zwj:"\\u200D",zwnj:"\\u200C"},g={aacute:"\\xE1",Aacute:"\\xC1",acirc:"\\xE2",Acirc:"\\xC2",acute:"\\xB4",aelig:"\\xE6",AElig:"\\xC6",agrave:"\\xE0",Agrave:"\\xC0",amp:"&",AMP:"&",aring:"\\xE5",Aring:"\\xC5",atilde:"\\xE3",Atilde:"\\xC3",auml:"\\xE4",Auml:"\\xC4",brvbar:"\\xA6",ccedil:"\\xE7",Ccedil:"\\xC7",cedil:"\\xB8",cent:"\\xA2",copy:"\\xA9",COPY:"\\xA9",curren:"\\xA4",deg:"\\xB0",divide:"\\xF7",eacute:"\\xE9",Eacute:"\\xC9",ecirc:"\\xEA",Ecirc:"\\xCA",egrave:"\\xE8",Egrave:"\\xC8",eth:"\\xF0",ETH:"\\xD0",euml:"\\xEB",Euml:"\\xCB",frac12:"\\xBD",frac14:"\\xBC",frac34:"\\xBE",gt:">",GT:">",iacute:"\\xED",Iacute:"\\xCD",icirc:"\\xEE",Icirc:"\\xCE",iexcl:"\\xA1",igrave:"\\xEC",Igrave:"\\xCC",iquest:"\\xBF",iuml:"\\xEF",Iuml:"\\xCF",laquo:"\\xAB",lt:"<",LT:"<",macr:"\\xAF",micro:"\\xB5",middot:"\\xB7",nbsp:"\\xA0",not:"\\xAC",ntilde:"\\xF1",Ntilde:"\\xD1",oacute:"\\xF3",Oacute:"\\xD3",ocirc:"\\xF4",Ocirc:"\\xD4",ograve:"\\xF2",Ograve:"\\xD2",ordf:"\\xAA",ordm:"\\xBA",oslash:"\\xF8",Oslash:"\\xD8",otilde:"\\xF5",Otilde:"\\xD5",ouml:"\\xF6",Ouml:"\\xD6",para:"\\xB6",plusmn:"\\xB1",pound:"\\xA3",quot:\'"\',QUOT:\'"\',raquo:"\\xBB",reg:"\\xAE",REG:"\\xAE",sect:"\\xA7",shy:"\\xAD",sup1:"\\xB9",sup2:"\\xB2",sup3:"\\xB3",szlig:"\\xDF",thorn:"\\xFE",THORN:"\\xDE",times:"\\xD7",uacute:"\\xFA",Uacute:"\\xDA",ucirc:"\\xFB",Ucirc:"\\xDB",ugrave:"\\xF9",Ugrave:"\\xD9",uml:"\\xA8",uuml:"\\xFC",Uuml:"\\xDC",yacute:"\\xFD",Yacute:"\\xDD",yen:"\\xA5",yuml:"\\xFF"},A={0:"\\uFFFD",128:"\\u20AC",130:"\\u201A",131:"\\u0192",132:"\\u201E",133:"\\u2026",134:"\\u2020",135:"\\u2021",136:"\\u02C6",137:"\\u2030",138:"\\u0160",139:"\\u2039",140:"\\u0152",142:"\\u017D",145:"\\u2018",146:"\\u2019",147:"\\u201C",148:"\\u201D",149:"\\u2022",150:"\\u2013",151:"\\u2014",152:"\\u02DC",153:"\\u2122",154:"\\u0161",155:"\\u203A",156:"\\u0153",158:"\\u017E",159:"\\u0178"},y=[1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65e3,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111],w=String.fromCharCode,E={},z=E.hasOwnProperty,P=function(I,O){return z.call(I,O)},G=function(I,O){for(var D=-1,v=I.length;++D<v;)if(I[D]==O)return!0;return!1},R=function(I,O){if(!I)return O;var D={},v;for(v in O)D[v]=P(I,v)?I[v]:O[v];return D},V=function(I,O){var D="";return I>=55296&&I<=57343||I>1114111?(O&&S("character reference outside the permissible Unicode range"),"\\uFFFD"):P(A,I)?(O&&S("disallowed character reference"),A[I]):(O&&G(y,I)&&S("disallowed character reference"),I>65535&&(I-=65536,D+=w(I>>>10&1023|55296),I=56320|I&1023),D+=w(I),D)},X=function(I){return"&#x"+I.toString(16).toUpperCase()+";"},C=function(I){return"&#"+I+";"},S=function(I){throw Error("Parse error: "+I)},h=function(I,O){O=R(O,h.options);var D=O.strict;D&&b.test(I)&&S("forbidden code point");var v=O.encodeEverything,j=O.useNamedReferences,W=O.allowUnsafeSymbols,Z=O.decimal?C:X,ee=function(te){return Z(te.charCodeAt(0))};return v?(I=I.replace(i,function(te){return j&&P(u,te)?"&"+u[te]+";":ee(te)}),j&&(I=I.replace(/>\\u20D2/g,">⃒").replace(/<\\u20D2/g,"<⃒").replace(/fj/g,"fj")),j&&(I=I.replace(o,function(te){return"&"+u[te]+";"}))):j?(W||(I=I.replace(d,function(te){return"&"+u[te]+";"})),I=I.replace(/>\\u20D2/g,">⃒").replace(/<\\u20D2/g,"<⃒"),I=I.replace(o,function(te){return"&"+u[te]+";"})):W||(I=I.replace(d,ee)),I.replace(n,function(te){var K=te.charCodeAt(0),re=te.charCodeAt(1),le=(K-55296)*1024+re-56320+65536;return Z(le)}).replace(a,ee)};h.options={allowUnsafeSymbols:!1,encodeEverything:!1,strict:!1,useNamedReferences:!1,decimal:!1};var k=function(I,O){O=R(O,k.options);var D=O.strict;return D&&l.test(I)&&S("malformed character reference"),I.replace(f,function(v,j,W,Z,ee,te,K,re,le){var ue,fe,me,c,L,T;return j?(L=j,m[L]):W?(L=W,T=Z,T&&O.isAttributeValue?(D&&T=="="&&S("`&` did not start a character reference"),v):(D&&S("named character reference was not terminated by a semicolon"),g[L]+(T||""))):ee?(me=ee,fe=te,D&&!fe&&S("character reference was not terminated by a semicolon"),ue=parseInt(me,10),V(ue,D)):K?(c=K,fe=re,D&&!fe&&S("character reference was not terminated by a semicolon"),ue=parseInt(c,16),V(ue,D)):(D&&S("named character reference was not terminated by a semicolon"),v)})};k.options={isAttributeValue:!1,strict:!1};var Y=function(I){return I.replace(d,function(O){return p[O]})},F={version:"1.2.0",encode:h,decode:k,escape:Y,unescape:k};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd)define(function(){return F});else if(e&&!e.nodeType)if(t)t.exports=F;else for(var q in F)P(F,q)&&(e[q]=F[q]);else s.he=F})(nt)});var kt=ge((gr,It)=>{(function(s){typeof gr=="object"&&typeof It<"u"?It.exports=s():typeof define=="function"&&define.amd?define([],s):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=s()})(function(){return function s(e,t,r){function n(o,u){if(!t[o]){if(!e[o]){var d=typeof Ye=="function"&&Ye;if(!u&&d)return d(o,!0);if(i)return i(o,!0);var p=new Error("Cannot find module \'"+o+"\'");throw p.code="MODULE_NOT_FOUND",p}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(b){var f=e[o][1][b];return n(f||b)},l,l.exports,s,e,t,r)}return t[o].exports}for(var i=typeof Ye=="function"&&Ye,a=0;a<r.length;a++)n(r[a]);return n}({1:[function(s,e,t){"use strict";var r=s("./utils"),n=s("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.encode=function(a){for(var o,u,d,p,l,b,f,m=[],g=0,A=a.length,y=A,w=r.getTypeOf(a)!=="string";g<a.length;)y=A-g,d=w?(o=a[g++],u=g<A?a[g++]:0,g<A?a[g++]:0):(o=a.charCodeAt(g++),u=g<A?a.charCodeAt(g++):0,g<A?a.charCodeAt(g++):0),p=o>>2,l=(3&o)<<4|u>>4,b=1<y?(15&u)<<2|d>>6:64,f=2<y?63&d:64,m.push(i.charAt(p)+i.charAt(l)+i.charAt(b)+i.charAt(f));return m.join("")},t.decode=function(a){var o,u,d,p,l,b,f=0,m=0,g="data:";if(a.substr(0,g.length)===g)throw new Error("Invalid base64 input, it looks like a data url.");var A,y=3*(a=a.replace(/[^A-Za-z0-9\\+\\/\\=]/g,"")).length/4;if(a.charAt(a.length-1)===i.charAt(64)&&y--,a.charAt(a.length-2)===i.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(A=n.uint8array?new Uint8Array(0|y):new Array(0|y);f<a.length;)o=i.indexOf(a.charAt(f++))<<2|(p=i.indexOf(a.charAt(f++)))>>4,u=(15&p)<<4|(l=i.indexOf(a.charAt(f++)))>>2,d=(3&l)<<6|(b=i.indexOf(a.charAt(f++))),A[m++]=o,l!==64&&(A[m++]=u),b!==64&&(A[m++]=d);return A}},{"./support":30,"./utils":32}],2:[function(s,e,t){"use strict";var r=s("./external"),n=s("./stream/DataWorker"),i=s("./stream/Crc32Probe"),a=s("./stream/DataLengthProbe");function o(u,d,p,l,b){this.compressedSize=u,this.uncompressedSize=d,this.crc32=p,this.compression=l,this.compressedContent=b}o.prototype={getContentWorker:function(){var u=new n(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new n(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(u,d,p){return u.pipe(new i).pipe(new a("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new a("compressedSize")).withStreamInfo("compression",d)},e.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(s,e,t){"use strict";var r=s("./stream/GenericWorker");t.STORE={magic:"\\0\\0",compressWorker:function(n){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},t.DEFLATE=s("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(s,e,t){"use strict";var r=s("./utils"),n=function(){for(var i,a=[],o=0;o<256;o++){i=o;for(var u=0;u<8;u++)i=1&i?3988292384^i>>>1:i>>>1;a[o]=i}return a}();e.exports=function(i,a){return i!==void 0&&i.length?r.getTypeOf(i)!=="string"?function(o,u,d,p){var l=n,b=p+d;o^=-1;for(var f=p;f<b;f++)o=o>>>8^l[255&(o^u[f])];return-1^o}(0|a,i,i.length,0):function(o,u,d,p){var l=n,b=p+d;o^=-1;for(var f=p;f<b;f++)o=o>>>8^l[255&(o^u.charCodeAt(f))];return-1^o}(0|a,i,i.length,0):0}},{"./utils":32}],5:[function(s,e,t){"use strict";t.base64=!1,t.binary=!1,t.dir=!1,t.createFolders=!0,t.date=null,t.compression=null,t.compressionOptions=null,t.comment=null,t.unixPermissions=null,t.dosPermissions=null},{}],6:[function(s,e,t){"use strict";var r=null;r=typeof Promise<"u"?Promise:s("lie"),e.exports={Promise:r}},{lie:37}],7:[function(s,e,t){"use strict";var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",n=s("pako"),i=s("./utils"),a=s("./stream/GenericWorker"),o=r?"uint8array":"array";function u(d,p){a.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}t.magic="\\b\\0",i.inherits(u,a),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(o,d.data),!1)},u.prototype.flush=function(){a.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},t.compressWorker=function(d){return new u("Deflate",d)},t.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(s,e,t){"use strict";function r(l,b){var f,m="";for(f=0;f<b;f++)m+=String.fromCharCode(255&l),l>>>=8;return m}function n(l,b,f,m,g,A){var y,w,E=l.file,z=l.compression,P=A!==o.utf8encode,G=i.transformTo("string",A(E.name)),R=i.transformTo("string",o.utf8encode(E.name)),V=E.comment,X=i.transformTo("string",A(V)),C=i.transformTo("string",o.utf8encode(V)),S=R.length!==E.name.length,h=C.length!==V.length,k="",Y="",F="",q=E.dir,I=E.date,O={crc32:0,compressedSize:0,uncompressedSize:0};b&&!f||(O.crc32=l.crc32,O.compressedSize=l.compressedSize,O.uncompressedSize=l.uncompressedSize);var D=0;b&&(D|=8),P||!S&&!h||(D|=2048);var v=0,j=0;q&&(v|=16),g==="UNIX"?(j=798,v|=function(Z,ee){var te=Z;return Z||(te=ee?16893:33204),(65535&te)<<16}(E.unixPermissions,q)):(j=20,v|=function(Z){return 63&(Z||0)}(E.dosPermissions)),y=I.getUTCHours(),y<<=6,y|=I.getUTCMinutes(),y<<=5,y|=I.getUTCSeconds()/2,w=I.getUTCFullYear()-1980,w<<=4,w|=I.getUTCMonth()+1,w<<=5,w|=I.getUTCDate(),S&&(Y=r(1,1)+r(u(G),4)+R,k+="up"+r(Y.length,2)+Y),h&&(F=r(1,1)+r(u(X),4)+C,k+="uc"+r(F.length,2)+F);var W="";return W+=`\n\\0`,W+=r(D,2),W+=z.magic,W+=r(y,2),W+=r(w,2),W+=r(O.crc32,4),W+=r(O.compressedSize,4),W+=r(O.uncompressedSize,4),W+=r(G.length,2),W+=r(k.length,2),{fileRecord:d.LOCAL_FILE_HEADER+W+G+k,dirRecord:d.CENTRAL_FILE_HEADER+r(j,2)+W+r(X.length,2)+"\\0\\0\\0\\0"+r(v,4)+r(m,4)+G+k+X}}var i=s("../utils"),a=s("../stream/GenericWorker"),o=s("../utf8"),u=s("../crc32"),d=s("../signature");function p(l,b,f,m){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=f,this.encodeFileName=m,this.streamFiles=l,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(p,a),p.prototype.push=function(l){var b=l.meta.percent||0,f=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(l):(this.bytesWritten+=l.data.length,a.prototype.push.call(this,{data:l.data,meta:{currentFile:this.currentFile,percent:f?(b+100*(f-m-1))/f:100}}))},p.prototype.openedSource=function(l){this.currentSourceOffset=this.bytesWritten,this.currentFile=l.file.name;var b=this.streamFiles&&!l.file.dir;if(b){var f=n(l,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(l){this.accumulate=!1;var b=this.streamFiles&&!l.file.dir,f=n(l,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),b)this.push({data:function(m){return d.DATA_DESCRIPTOR+r(m.crc32,4)+r(m.compressedSize,4)+r(m.uncompressedSize,4)}(l),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var l=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var f=this.bytesWritten-l,m=function(g,A,y,w,E){var z=i.transformTo("string",E(w));return d.CENTRAL_DIRECTORY_END+"\\0\\0\\0\\0"+r(g,2)+r(g,2)+r(A,4)+r(y,4)+r(z.length,2)+z}(this.dirRecords.length,f,l,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(l){this._sources.push(l);var b=this;return l.on("data",function(f){b.processChunk(f)}),l.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),l.on("error",function(f){b.error(f)}),this},p.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(l){var b=this._sources;if(!a.prototype.error.call(this,l))return!1;for(var f=0;f<b.length;f++)try{b[f].error(l)}catch{}return!0},p.prototype.lock=function(){a.prototype.lock.call(this);for(var l=this._sources,b=0;b<l.length;b++)l[b].lock()},e.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(s,e,t){"use strict";var r=s("../compressions"),n=s("./ZipFileWorker");t.generateWorker=function(i,a,o){var u=new n(a.streamFiles,o,a.platform,a.encodeFileName),d=0;try{i.forEach(function(p,l){d++;var b=function(A,y){var w=A||y,E=r[w];if(!E)throw new Error(w+" is not a valid compression method !");return E}(l.options.compression,a.compression),f=l.options.compressionOptions||a.compressionOptions||{},m=l.dir,g=l.date;l._compressWorker(b,f).withStreamInfo("file",{name:p,dir:m,date:g,comment:l.comment||"",unixPermissions:l.unixPermissions,dosPermissions:l.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(p){u.error(p)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(s,e,t){"use strict";function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var n=new r;for(var i in this)typeof this[i]!="function"&&(n[i]=this[i]);return n}}(r.prototype=s("./object")).loadAsync=s("./load"),r.support=s("./support"),r.defaults=s("./defaults"),r.version="3.10.0",r.loadAsync=function(n,i){return new r().loadAsync(n,i)},r.external=s("./external"),e.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(s,e,t){"use strict";var r=s("./utils"),n=s("./external"),i=s("./utf8"),a=s("./zipEntries"),o=s("./stream/Crc32Probe"),u=s("./nodejsUtils");function d(p){return new n.Promise(function(l,b){var f=p.decompressed.getContentWorker().pipe(new o);f.on("error",function(m){b(m)}).on("end",function(){f.streamInfo.crc32!==p.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):l()}).resume()})}e.exports=function(p,l){var b=this;return l=r.extend(l||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),u.isNode&&u.isStream(p)?n.Promise.reject(new Error("JSZip can\'t accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",p,!0,l.optimizedBinaryString,l.base64).then(function(f){var m=new a(l);return m.load(f),m}).then(function(f){var m=[n.Promise.resolve(f)],g=f.files;if(l.checkCRC32)for(var A=0;A<g.length;A++)m.push(d(g[A]));return n.Promise.all(m)}).then(function(f){for(var m=f.shift(),g=m.files,A=0;A<g.length;A++){var y=g[A],w=y.fileNameStr,E=r.resolve(y.fileNameStr);b.file(E,y.decompressed,{binary:!0,optimizedBinaryString:!0,date:y.date,dir:y.dir,comment:y.fileCommentStr.length?y.fileCommentStr:null,unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions,createFolders:l.createFolders}),y.dir||(b.file(E).unsafeOriginalName=w)}return m.zipComment.length&&(b.comment=m.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(s,e,t){"use strict";var r=s("../utils"),n=s("../stream/GenericWorker");function i(a,o){n.call(this,"Nodejs stream input adapter for "+a),this._upstreamEnded=!1,this._bindStream(o)}r.inherits(i,n),i.prototype._bindStream=function(a){var o=this;(this._stream=a).pause(),a.on("data",function(u){o.push({data:u,meta:{percent:0}})}).on("error",function(u){o.isPaused?this.generatedError=u:o.error(u)}).on("end",function(){o.isPaused?o._upstreamEnded=!0:o.end()})},i.prototype.pause=function(){return!!n.prototype.pause.call(this)&&(this._stream.pause(),!0)},i.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},e.exports=i},{"../stream/GenericWorker":28,"../utils":32}],13:[function(s,e,t){"use strict";var r=s("readable-stream").Readable;function n(i,a,o){r.call(this,a),this._helper=i;var u=this;i.on("data",function(d,p){u.push(d)||u._helper.pause(),o&&o(p)}).on("error",function(d){u.emit("error",d)}).on("end",function(){u.push(null)})}s("../utils").inherits(n,r),n.prototype._read=function(){this._helper.resume()},e.exports=n},{"../utils":32,"readable-stream":16}],14:[function(s,e,t){"use strict";e.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,n){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,n);if(typeof r=="number")throw new Error(\'The "data" argument must not be a number\');return new Buffer(r,n)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var n=new Buffer(r);return n.fill(0),n},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(s,e,t){"use strict";function r(E,z,P){var G,R=i.getTypeOf(z),V=i.extend(P||{},u);V.date=V.date||new Date,V.compression!==null&&(V.compression=V.compression.toUpperCase()),typeof V.unixPermissions=="string"&&(V.unixPermissions=parseInt(V.unixPermissions,8)),V.unixPermissions&&16384&V.unixPermissions&&(V.dir=!0),V.dosPermissions&&16&V.dosPermissions&&(V.dir=!0),V.dir&&(E=g(E)),V.createFolders&&(G=m(E))&&A.call(this,G,!0);var X=R==="string"&&V.binary===!1&&V.base64===!1;P&&P.binary!==void 0||(V.binary=!X),(z instanceof d&&z.uncompressedSize===0||V.dir||!z||z.length===0)&&(V.base64=!1,V.binary=!0,z="",V.compression="STORE",R="string");var C=null;C=z instanceof d||z instanceof a?z:b.isNode&&b.isStream(z)?new f(E,z):i.prepareContent(E,z,V.binary,V.optimizedBinaryString,V.base64);var S=new p(E,C,V);this.files[E]=S}var n=s("./utf8"),i=s("./utils"),a=s("./stream/GenericWorker"),o=s("./stream/StreamHelper"),u=s("./defaults"),d=s("./compressedObject"),p=s("./zipObject"),l=s("./generate"),b=s("./nodejsUtils"),f=s("./nodejs/NodejsStreamInputAdapter"),m=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var z=E.lastIndexOf("/");return 0<z?E.substring(0,z):""},g=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},A=function(E,z){return z=z!==void 0?z:u.createFolders,E=g(E),this.files[E]||r.call(this,E,null,{dir:!0,createFolders:z}),this.files[E]};function y(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var w={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var z,P,G;for(z in this.files)G=this.files[z],(P=z.slice(this.root.length,z.length))&&z.slice(0,this.root.length)===this.root&&E(P,G)},filter:function(E){var z=[];return this.forEach(function(P,G){E(P,G)&&z.push(G)}),z},file:function(E,z,P){if(arguments.length!==1)return E=this.root+E,r.call(this,E,z,P),this;if(y(E)){var G=E;return this.filter(function(V,X){return!X.dir&&G.test(V)})}var R=this.files[this.root+E];return R&&!R.dir?R:null},folder:function(E){if(!E)return this;if(y(E))return this.filter(function(R,V){return V.dir&&E.test(R)});var z=this.root+E,P=A.call(this,z),G=this.clone();return G.root=P.name,G},remove:function(E){E=this.root+E;var z=this.files[E];if(z||(E.slice(-1)!=="/"&&(E+="/"),z=this.files[E]),z&&!z.dir)delete this.files[E];else for(var P=this.filter(function(R,V){return V.name.slice(0,E.length)===E}),G=0;G<P.length;G++)delete this.files[P[G].name];return this},generate:function(E){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var z,P={};try{if((P=i.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:n.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");i.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var G=P.comment||this.comment||"";z=l.generateWorker(this,P,G)}catch(R){(z=new a("error")).error(R)}return new o(z,P.type||"string",P.mimeType)},generateAsync:function(E,z){return this.generateInternalStream(E).accumulate(z)},generateNodeStream:function(E,z){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(z)}};e.exports=w},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(s,e,t){e.exports=s("stream")},{stream:void 0}],17:[function(s,e,t){"use strict";var r=s("./DataReader");function n(i){r.call(this,i);for(var a=0;a<this.data.length;a++)i[a]=255&i[a]}s("../utils").inherits(n,r),n.prototype.byteAt=function(i){return this.data[this.zero+i]},n.prototype.lastIndexOfSignature=function(i){for(var a=i.charCodeAt(0),o=i.charCodeAt(1),u=i.charCodeAt(2),d=i.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===a&&this.data[p+1]===o&&this.data[p+2]===u&&this.data[p+3]===d)return p-this.zero;return-1},n.prototype.readAndCheckSignature=function(i){var a=i.charCodeAt(0),o=i.charCodeAt(1),u=i.charCodeAt(2),d=i.charCodeAt(3),p=this.readData(4);return a===p[0]&&o===p[1]&&u===p[2]&&d===p[3]},n.prototype.readData=function(i){if(this.checkOffset(i),i===0)return[];var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./DataReader":18}],18:[function(s,e,t){"use strict";var r=s("../utils");function n(i){this.data=i,this.length=i.length,this.index=0,this.zero=0}n.prototype={checkOffset:function(i){this.checkIndex(this.index+i)},checkIndex:function(i){if(this.length<this.zero+i||i<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+i+"). Corrupted zip ?")},setIndex:function(i){this.checkIndex(i),this.index=i},skip:function(i){this.setIndex(this.index+i)},byteAt:function(i){},readInt:function(i){var a,o=0;for(this.checkOffset(i),a=this.index+i-1;a>=this.index;a--)o=(o<<8)+this.byteAt(a);return this.index+=i,o},readString:function(i){return r.transformTo("string",this.readData(i))},readData:function(i){},lastIndexOfSignature:function(i){},readAndCheckSignature:function(i){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},e.exports=n},{"../utils":32}],19:[function(s,e,t){"use strict";var r=s("./Uint8ArrayReader");function n(i){r.call(this,i)}s("../utils").inherits(n,r),n.prototype.readData=function(i){this.checkOffset(i);var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(s,e,t){"use strict";var r=s("./DataReader");function n(i){r.call(this,i)}s("../utils").inherits(n,r),n.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},n.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},n.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},n.prototype.readData=function(i){this.checkOffset(i);var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./DataReader":18}],21:[function(s,e,t){"use strict";var r=s("./ArrayReader");function n(i){r.call(this,i)}s("../utils").inherits(n,r),n.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var a=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(s,e,t){"use strict";var r=s("../utils"),n=s("../support"),i=s("./ArrayReader"),a=s("./StringReader"),o=s("./NodeBufferReader"),u=s("./Uint8ArrayReader");e.exports=function(d){var p=r.getTypeOf(d);return r.checkSupport(p),p!=="string"||n.uint8array?p==="nodebuffer"?new o(d):n.uint8array?new u(r.transformTo("uint8array",d)):new i(r.transformTo("array",d)):new a(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(s,e,t){"use strict";t.LOCAL_FILE_HEADER="PK",t.CENTRAL_FILE_HEADER="PK",t.CENTRAL_DIRECTORY_END="PK",t.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\\x07",t.ZIP64_CENTRAL_DIRECTORY_END="PK",t.DATA_DESCRIPTOR="PK\\x07\\b"},{}],24:[function(s,e,t){"use strict";var r=s("./GenericWorker"),n=s("../utils");function i(a){r.call(this,"ConvertWorker to "+a),this.destType=a}n.inherits(i,r),i.prototype.processChunk=function(a){this.push({data:n.transformTo(this.destType,a.data),meta:a.meta})},e.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(s,e,t){"use strict";var r=s("./GenericWorker"),n=s("../crc32");function i(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}s("../utils").inherits(i,r),i.prototype.processChunk=function(a){this.streamInfo.crc32=n(a.data,this.streamInfo.crc32||0),this.push(a)},e.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(s,e,t){"use strict";var r=s("../utils"),n=s("./GenericWorker");function i(a){n.call(this,"DataLengthProbe for "+a),this.propName=a,this.withStreamInfo(a,0)}r.inherits(i,n),i.prototype.processChunk=function(a){if(a){var o=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=o+a.data.length}n.prototype.processChunk.call(this,a)},e.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(s,e,t){"use strict";var r=s("../utils"),n=s("./GenericWorker");function i(a){n.call(this,"DataWorker");var o=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,a.then(function(u){o.dataIsReady=!0,o.data=u,o.max=u&&u.length||0,o.type=r.getTypeOf(u),o.isPaused||o._tickAndRepeat()},function(u){o.error(u)})}r.inherits(i,n),i.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var a=null,o=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":a=this.data.substring(this.index,o);break;case"uint8array":a=this.data.subarray(this.index,o);break;case"array":case"nodebuffer":a=this.data.slice(this.index,o)}return this.index=o,this.push({data:a,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(s,e,t){"use strict";function r(n){this.name=n||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(n){this.emit("data",n)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(n){this.emit("error",n)}return!0},error:function(n){return!this.isFinished&&(this.isPaused?this.generatedError=n:(this.isFinished=!0,this.emit("error",n),this.previous&&this.previous.error(n),this.cleanUp()),!0)},on:function(n,i){return this._listeners[n].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(n,i){if(this._listeners[n])for(var a=0;a<this._listeners[n].length;a++)this._listeners[n][a].call(this,i)},pipe:function(n){return n.registerPrevious(this)},registerPrevious:function(n){if(this.isLocked)throw new Error("The stream \'"+this+"\' has already been used.");this.streamInfo=n.streamInfo,this.mergeStreamInfo(),this.previous=n;var i=this;return n.on("data",function(a){i.processChunk(a)}),n.on("end",function(){i.end()}),n.on("error",function(a){i.error(a)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var n=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),n=!0),this.previous&&this.previous.resume(),!n},flush:function(){},processChunk:function(n){this.push(n)},withStreamInfo:function(n,i){return this.extraStreamInfo[n]=i,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var n in this.extraStreamInfo)this.extraStreamInfo.hasOwnProperty(n)&&(this.streamInfo[n]=this.extraStreamInfo[n])},lock:function(){if(this.isLocked)throw new Error("The stream \'"+this+"\' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var n="Worker "+this.name;return this.previous?this.previous+" -> "+n:n}},e.exports=r},{}],29:[function(s,e,t){"use strict";var r=s("../utils"),n=s("./ConvertWorker"),i=s("./GenericWorker"),a=s("../base64"),o=s("../support"),u=s("../external"),d=null;if(o.nodestream)try{d=s("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,f){return new u.Promise(function(m,g){var A=[],y=b._internalType,w=b._outputType,E=b._mimeType;b.on("data",function(z,P){A.push(z),f&&f(P)}).on("error",function(z){A=[],g(z)}).on("end",function(){try{var z=function(P,G,R){switch(P){case"blob":return r.newBlob(r.transformTo("arraybuffer",G),R);case"base64":return a.encode(G);default:return r.transformTo(P,G)}}(w,function(P,G){var R,V=0,X=null,C=0;for(R=0;R<G.length;R++)C+=G[R].length;switch(P){case"string":return G.join("");case"array":return Array.prototype.concat.apply([],G);case"uint8array":for(X=new Uint8Array(C),R=0;R<G.length;R++)X.set(G[R],V),V+=G[R].length;return X;case"nodebuffer":return Buffer.concat(G);default:throw new Error("concat : unsupported type \'"+P+"\'")}}(y,A),E);m(z)}catch(P){g(P)}A=[]}).resume()})}function l(b,f,m){var g=f;switch(f){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=f,this._mimeType=m,r.checkSupport(g),this._worker=b.pipe(new n(g)),b.lock()}catch(A){this._worker=new i("error"),this._worker.error(A)}}l.prototype={accumulate:function(b){return p(this,b)},on:function(b,f){var m=this;return b==="data"?this._worker.on(b,function(g){f.call(m,g.data,g.meta)}):this._worker.on(b,function(){r.delay(f,arguments,m)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},b)}},e.exports=l},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(s,e,t){"use strict";if(t.base64=!0,t.array=!0,t.string=!0,t.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",t.nodebuffer=typeof Buffer<"u",t.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")t.blob=!1;else{var r=new ArrayBuffer(0);try{t.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);n.append(r),t.blob=n.getBlob("application/zip").size===0}catch{t.blob=!1}}}try{t.nodestream=!!s("readable-stream").Readable}catch{t.nodestream=!1}},{"readable-stream":16}],31:[function(s,e,t){"use strict";for(var r=s("./utils"),n=s("./support"),i=s("./nodejsUtils"),a=s("./stream/GenericWorker"),o=new Array(256),u=0;u<256;u++)o[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;o[254]=o[254]=1;function d(){a.call(this,"utf-8 decode"),this.leftOver=null}function p(){a.call(this,"utf-8 encode")}t.utf8encode=function(l){return n.nodebuffer?i.newBufferFrom(l,"utf-8"):function(b){var f,m,g,A,y,w=b.length,E=0;for(A=0;A<w;A++)(64512&(m=b.charCodeAt(A)))==55296&&A+1<w&&(64512&(g=b.charCodeAt(A+1)))==56320&&(m=65536+(m-55296<<10)+(g-56320),A++),E+=m<128?1:m<2048?2:m<65536?3:4;for(f=n.uint8array?new Uint8Array(E):new Array(E),A=y=0;y<E;A++)(64512&(m=b.charCodeAt(A)))==55296&&A+1<w&&(64512&(g=b.charCodeAt(A+1)))==56320&&(m=65536+(m-55296<<10)+(g-56320),A++),m<128?f[y++]=m:(m<2048?f[y++]=192|m>>>6:(m<65536?f[y++]=224|m>>>12:(f[y++]=240|m>>>18,f[y++]=128|m>>>12&63),f[y++]=128|m>>>6&63),f[y++]=128|63&m);return f}(l)},t.utf8decode=function(l){return n.nodebuffer?r.transformTo("nodebuffer",l).toString("utf-8"):function(b){var f,m,g,A,y=b.length,w=new Array(2*y);for(f=m=0;f<y;)if((g=b[f++])<128)w[m++]=g;else if(4<(A=o[g]))w[m++]=65533,f+=A-1;else{for(g&=A===2?31:A===3?15:7;1<A&&f<y;)g=g<<6|63&b[f++],A--;1<A?w[m++]=65533:g<65536?w[m++]=g:(g-=65536,w[m++]=55296|g>>10&1023,w[m++]=56320|1023&g)}return w.length!==m&&(w.subarray?w=w.subarray(0,m):w.length=m),r.applyFromCharCode(w)}(l=r.transformTo(n.uint8array?"uint8array":"array",l))},r.inherits(d,a),d.prototype.processChunk=function(l){var b=r.transformTo(n.uint8array?"uint8array":"array",l.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var f=b;(b=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),b.set(f,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var m=function(A,y){var w;for((y=y||A.length)>A.length&&(y=A.length),w=y-1;0<=w&&(192&A[w])==128;)w--;return w<0||w===0?y:w+o[A[w]]>y?w:y}(b),g=b;m!==b.length&&(n.uint8array?(g=b.subarray(0,m),this.leftOver=b.subarray(m,b.length)):(g=b.slice(0,m),this.leftOver=b.slice(m,b.length))),this.push({data:t.utf8decode(g),meta:l.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:t.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},t.Utf8DecodeWorker=d,r.inherits(p,a),p.prototype.processChunk=function(l){this.push({data:t.utf8encode(l.data),meta:l.meta})},t.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(s,e,t){"use strict";var r=s("./support"),n=s("./base64"),i=s("./nodejsUtils"),a=s("./external");function o(f){return f}function u(f,m){for(var g=0;g<f.length;++g)m[g]=255&f.charCodeAt(g);return m}s("setimmediate"),t.newBlob=function(f,m){t.checkSupport("blob");try{return new Blob([f],{type:m})}catch{try{var g=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return g.append(f),g.getBlob(m)}catch{throw new Error("Bug : can\'t construct the Blob.")}}};var d={stringifyByChunk:function(f,m,g){var A=[],y=0,w=f.length;if(w<=g)return String.fromCharCode.apply(null,f);for(;y<w;)m==="array"||m==="nodebuffer"?A.push(String.fromCharCode.apply(null,f.slice(y,Math.min(y+g,w)))):A.push(String.fromCharCode.apply(null,f.subarray(y,Math.min(y+g,w)))),y+=g;return A.join("")},stringifyByChar:function(f){for(var m="",g=0;g<f.length;g++)m+=String.fromCharCode(f[g]);return m},applyCanBeUsed:{uint8array:function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,i.allocBuffer(1)).length===1}catch{return!1}}()}};function p(f){var m=65536,g=t.getTypeOf(f),A=!0;if(g==="uint8array"?A=d.applyCanBeUsed.uint8array:g==="nodebuffer"&&(A=d.applyCanBeUsed.nodebuffer),A)for(;1<m;)try{return d.stringifyByChunk(f,g,m)}catch{m=Math.floor(m/2)}return d.stringifyByChar(f)}function l(f,m){for(var g=0;g<f.length;g++)m[g]=f[g];return m}t.applyFromCharCode=p;var b={};b.string={string:o,array:function(f){return u(f,new Array(f.length))},arraybuffer:function(f){return b.string.uint8array(f).buffer},uint8array:function(f){return u(f,new Uint8Array(f.length))},nodebuffer:function(f){return u(f,i.allocBuffer(f.length))}},b.array={string:p,array:o,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return i.newBufferFrom(f)}},b.arraybuffer={string:function(f){return p(new Uint8Array(f))},array:function(f){return l(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:o,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return i.newBufferFrom(new Uint8Array(f))}},b.uint8array={string:p,array:function(f){return l(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:o,nodebuffer:function(f){return i.newBufferFrom(f)}},b.nodebuffer={string:p,array:function(f){return l(f,new Array(f.length))},arraybuffer:function(f){return b.nodebuffer.uint8array(f).buffer},uint8array:function(f){return l(f,new Uint8Array(f.length))},nodebuffer:o},t.transformTo=function(f,m){if(m=m||"",!f)return m;t.checkSupport(f);var g=t.getTypeOf(m);return b[g][f](m)},t.resolve=function(f){for(var m=f.split("/"),g=[],A=0;A<m.length;A++){var y=m[A];y==="."||y===""&&A!==0&&A!==m.length-1||(y===".."?g.pop():g.push(y))}return g.join("/")},t.getTypeOf=function(f){return typeof f=="string"?"string":Object.prototype.toString.call(f)==="[object Array]"?"array":r.nodebuffer&&i.isBuffer(f)?"nodebuffer":r.uint8array&&f instanceof Uint8Array?"uint8array":r.arraybuffer&&f instanceof ArrayBuffer?"arraybuffer":void 0},t.checkSupport=function(f){if(!r[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},t.MAX_VALUE_16BITS=65535,t.MAX_VALUE_32BITS=-1,t.pretty=function(f){var m,g,A="";for(g=0;g<(f||"").length;g++)A+="\\\\x"+((m=f.charCodeAt(g))<16?"0":"")+m.toString(16).toUpperCase();return A},t.delay=function(f,m,g){setImmediate(function(){f.apply(g||null,m||[])})},t.inherits=function(f,m){function g(){}g.prototype=m.prototype,f.prototype=new g},t.extend=function(){var f,m,g={};for(f=0;f<arguments.length;f++)for(m in arguments[f])arguments[f].hasOwnProperty(m)&&g[m]===void 0&&(g[m]=arguments[f][m]);return g},t.prepareContent=function(f,m,g,A,y){return a.Promise.resolve(m).then(function(w){return r.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new a.Promise(function(E,z){var P=new FileReader;P.onload=function(G){E(G.target.result)},P.onerror=function(G){z(G.target.error)},P.readAsArrayBuffer(w)}):w}).then(function(w){var E=t.getTypeOf(w);return E?(E==="arraybuffer"?w=t.transformTo("uint8array",w):E==="string"&&(y?w=n.decode(w):g&&A!==!0&&(w=function(z){return u(z,r.uint8array?new Uint8Array(z.length):new Array(z.length))}(w))),w):a.Promise.reject(new Error("Can\'t read the data of \'"+f+"\'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(s,e,t){"use strict";var r=s("./reader/readerFor"),n=s("./utils"),i=s("./signature"),a=s("./zipEntry"),o=(s("./utf8"),s("./support"));function u(d){this.files=[],this.loadOptions=d}u.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+n.pretty(p)+", expected "+n.pretty(d)+")")}},isSignature:function(d,p){var l=this.reader.index;this.reader.setIndex(d);var b=this.reader.readString(4)===p;return this.reader.setIndex(l),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),p=o.uint8array?"uint8array":"array",l=n.transformTo(p,d);this.zipComment=this.loadOptions.decodeFileName(l)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,p,l,b=this.zip64EndOfCentralSize-44;0<b;)d=this.reader.readInt(2),p=this.reader.readInt(4),l=this.reader.readData(p),this.zip64ExtensibleData[d]={id:d,length:p,value:l}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,p;for(d=0;d<this.files.length;d++)p=this.files[d],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(i.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(i.CENTRAL_FILE_HEADER);)(d=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(i.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,i.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can\'t find end of central directory"):new Error("Can\'t find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var p=d;if(this.checkSignature(i.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===n.MAX_VALUE_16BITS||this.diskWithCentralDirStart===n.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===n.MAX_VALUE_16BITS||this.centralDirRecords===n.MAX_VALUE_16BITS||this.centralDirSize===n.MAX_VALUE_32BITS||this.centralDirOffset===n.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can\'t find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,i.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can\'t find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var l=this.centralDirOffset+this.centralDirSize;this.zip64&&(l+=20,l+=12+this.zip64EndOfCentralSize);var b=p-l;if(0<b)this.isSignature(p,i.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(d){this.reader=r(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},e.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utf8":31,"./utils":32,"./zipEntry":34}],34:[function(s,e,t){"use strict";var r=s("./reader/readerFor"),n=s("./utils"),i=s("./compressedObject"),a=s("./crc32"),o=s("./utf8"),u=s("./compressions"),d=s("./support");function p(l,b){this.options=l,this.loadOptions=b}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(l){var b,f;if(l.skip(22),this.fileNameLength=l.readInt(2),f=l.readInt(2),this.fileName=l.readData(this.fileNameLength),l.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn\'t get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=function(m){for(var g in u)if(u.hasOwnProperty(g)&&u[g].magic===m)return u[g];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+n.pretty(this.compressionMethod)+" unknown (inner file : "+n.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,b,l.readData(this.compressedSize))},readCentralPart:function(l){this.versionMadeBy=l.readInt(2),l.skip(2),this.bitFlag=l.readInt(2),this.compressionMethod=l.readString(2),this.date=l.readDate(),this.crc32=l.readInt(4),this.compressedSize=l.readInt(4),this.uncompressedSize=l.readInt(4);var b=l.readInt(2);if(this.extraFieldsLength=l.readInt(2),this.fileCommentLength=l.readInt(2),this.diskNumberStart=l.readInt(2),this.internalFileAttributes=l.readInt(2),this.externalFileAttributes=l.readInt(4),this.localHeaderOffset=l.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");l.skip(b),this.readExtraFields(l),this.parseZIP64ExtraField(l),this.fileComment=l.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var l=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),l==0&&(this.dosPermissions=63&this.externalFileAttributes),l==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(l){if(this.extraFields[1]){var b=r(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=b.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=b.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=b.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=b.readInt(4))}},readExtraFields:function(l){var b,f,m,g=l.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});l.index+4<g;)b=l.readInt(2),f=l.readInt(2),m=l.readData(f),this.extraFields[b]={id:b,length:f,value:m};l.setIndex(g)},handleUTF8:function(){var l=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=o.utf8decode(this.fileName),this.fileCommentStr=o.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var f=n.transformTo(l,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var g=n.transformTo(l,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(g)}}},findExtraFieldUnicodePath:function(){var l=this.extraFields[28789];if(l){var b=r(l.value);return b.readInt(1)!==1||a(this.fileName)!==b.readInt(4)?null:o.utf8decode(b.readData(l.length-5))}return null},findExtraFieldUnicodeComment:function(){var l=this.extraFields[25461];if(l){var b=r(l.value);return b.readInt(1)!==1||a(this.fileComment)!==b.readInt(4)?null:o.utf8decode(b.readData(l.length-5))}return null}},e.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(s,e,t){"use strict";function r(b,f,m){this.name=b,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=f,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var n=s("./stream/StreamHelper"),i=s("./stream/DataWorker"),a=s("./utf8"),o=s("./compressedObject"),u=s("./stream/GenericWorker");r.prototype={internalStream:function(b){var f=null,m="string";try{if(!b)throw new Error("No output type specified.");var g=(m=b.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),f=this._decompressWorker();var A=!this._dataBinary;A&&!g&&(f=f.pipe(new a.Utf8EncodeWorker)),!A&&g&&(f=f.pipe(new a.Utf8DecodeWorker))}catch(y){(f=new u("error")).error(y)}return new n(f,m,"")},async:function(b,f){return this.internalStream(b).accumulate(f)},nodeStream:function(b,f){return this.internalStream(b||"nodebuffer").toNodejsStream(f)},_compressWorker:function(b,f){if(this._data instanceof o&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new a.Utf8EncodeWorker)),o.createWorkerFrom(m,b,f)},_decompressWorker:function(){return this._data instanceof o?this._data.getContentWorker():this._data instanceof u?this._data:new i(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},l=0;l<d.length;l++)r.prototype[d[l]]=p;e.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(s,e,t){(function(r){"use strict";var n,i,a=r.MutationObserver||r.WebKitMutationObserver;if(a){var o=0,u=new a(b),d=r.document.createTextNode("");u.observe(d,{characterData:!0}),n=function(){d.data=o=++o%2}}else if(r.setImmediate||r.MessageChannel===void 0)n="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var f=r.document.createElement("script");f.onreadystatechange=function(){b(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},r.document.documentElement.appendChild(f)}:function(){setTimeout(b,0)};else{var p=new r.MessageChannel;p.port1.onmessage=b,n=function(){p.port2.postMessage(0)}}var l=[];function b(){var f,m;i=!0;for(var g=l.length;g;){for(m=l,l=[],f=-1;++f<g;)m[f]();g=l.length}i=!1}e.exports=function(f){l.push(f)!==1||i||n()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(s,e,t){"use strict";var r=s("immediate");function n(){}var i={},a=["REJECTED"],o=["FULFILLED"],u=["PENDING"];function d(g){if(typeof g!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,g!==n&&f(this,g)}function p(g,A,y){this.promise=g,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof y=="function"&&(this.onRejected=y,this.callRejected=this.otherCallRejected)}function l(g,A,y){r(function(){var w;try{w=A(y)}catch(E){return i.reject(g,E)}w===g?i.reject(g,new TypeError("Cannot resolve promise with itself")):i.resolve(g,w)})}function b(g){var A=g&&g.then;if(g&&(typeof g=="object"||typeof g=="function")&&typeof A=="function")return function(){A.apply(g,arguments)}}function f(g,A){var y=!1;function w(P){y||(y=!0,i.reject(g,P))}function E(P){y||(y=!0,i.resolve(g,P))}var z=m(function(){A(E,w)});z.status==="error"&&w(z.value)}function m(g,A){var y={};try{y.value=g(A),y.status="success"}catch(w){y.status="error",y.value=w}return y}(e.exports=d).prototype.finally=function(g){if(typeof g!="function")return this;var A=this.constructor;return this.then(function(y){return A.resolve(g()).then(function(){return y})},function(y){return A.resolve(g()).then(function(){throw y})})},d.prototype.catch=function(g){return this.then(null,g)},d.prototype.then=function(g,A){if(typeof g!="function"&&this.state===o||typeof A!="function"&&this.state===a)return this;var y=new this.constructor(n);return this.state!==u?l(y,this.state===o?g:A,this.outcome):this.queue.push(new p(y,g,A)),y},p.prototype.callFulfilled=function(g){i.resolve(this.promise,g)},p.prototype.otherCallFulfilled=function(g){l(this.promise,this.onFulfilled,g)},p.prototype.callRejected=function(g){i.reject(this.promise,g)},p.prototype.otherCallRejected=function(g){l(this.promise,this.onRejected,g)},i.resolve=function(g,A){var y=m(b,A);if(y.status==="error")return i.reject(g,y.value);var w=y.value;if(w)f(g,w);else{g.state=o,g.outcome=A;for(var E=-1,z=g.queue.length;++E<z;)g.queue[E].callFulfilled(A)}return g},i.reject=function(g,A){g.state=a,g.outcome=A;for(var y=-1,w=g.queue.length;++y<w;)g.queue[y].callRejected(A);return g},d.resolve=function(g){return g instanceof this?g:i.resolve(new this(n),g)},d.reject=function(g){var A=new this(n);return i.reject(A,g)},d.all=function(g){var A=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=g.length,w=!1;if(!y)return this.resolve([]);for(var E=new Array(y),z=0,P=-1,G=new this(n);++P<y;)R(g[P],P);return G;function R(V,X){A.resolve(V).then(function(C){E[X]=C,++z!==y||w||(w=!0,i.resolve(G,E))},function(C){w||(w=!0,i.reject(G,C))})}},d.race=function(g){var A=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=g.length,w=!1;if(!y)return this.resolve([]);for(var E=-1,z=new this(n);++E<y;)P=g[E],A.resolve(P).then(function(G){w||(w=!0,i.resolve(z,G))},function(G){w||(w=!0,i.reject(z,G))});var P;return z}},{immediate:36}],38:[function(s,e,t){"use strict";var r={};(0,s("./lib/utils/common").assign)(r,s("./lib/deflate"),s("./lib/inflate"),s("./lib/zlib/constants")),e.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(s,e,t){"use strict";var r=s("./zlib/deflate"),n=s("./utils/common"),i=s("./utils/strings"),a=s("./zlib/messages"),o=s("./zlib/zstream"),u=Object.prototype.toString,d=0,p=-1,l=0,b=8;function f(g){if(!(this instanceof f))return new f(g);this.options=n.assign({level:p,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:l,to:""},g||{});var A=this.options;A.raw&&0<A.windowBits?A.windowBits=-A.windowBits:A.gzip&&0<A.windowBits&&A.windowBits<16&&(A.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var y=r.deflateInit2(this.strm,A.level,A.method,A.windowBits,A.memLevel,A.strategy);if(y!==d)throw new Error(a[y]);if(A.header&&r.deflateSetHeader(this.strm,A.header),A.dictionary){var w;if(w=typeof A.dictionary=="string"?i.string2buf(A.dictionary):u.call(A.dictionary)==="[object ArrayBuffer]"?new Uint8Array(A.dictionary):A.dictionary,(y=r.deflateSetDictionary(this.strm,w))!==d)throw new Error(a[y]);this._dict_set=!0}}function m(g,A){var y=new f(A);if(y.push(g,!0),y.err)throw y.msg||a[y.err];return y.result}f.prototype.push=function(g,A){var y,w,E=this.strm,z=this.options.chunkSize;if(this.ended)return!1;w=A===~~A?A:A===!0?4:0,typeof g=="string"?E.input=i.string2buf(g):u.call(g)==="[object ArrayBuffer]"?E.input=new Uint8Array(g):E.input=g,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new n.Buf8(z),E.next_out=0,E.avail_out=z),(y=r.deflate(E,w))!==1&&y!==d)return this.onEnd(y),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(i.buf2binstring(n.shrinkBuf(E.output,E.next_out))):this.onData(n.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&y!==1);return w===4?(y=r.deflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===d):w!==2||(this.onEnd(d),!(E.avail_out=0))},f.prototype.onData=function(g){this.chunks.push(g)},f.prototype.onEnd=function(g){g===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},t.Deflate=f,t.deflate=m,t.deflateRaw=function(g,A){return(A=A||{}).raw=!0,m(g,A)},t.gzip=function(g,A){return(A=A||{}).gzip=!0,m(g,A)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(s,e,t){"use strict";var r=s("./zlib/inflate"),n=s("./utils/common"),i=s("./utils/strings"),a=s("./zlib/constants"),o=s("./zlib/messages"),u=s("./zlib/zstream"),d=s("./zlib/gzheader"),p=Object.prototype.toString;function l(f){if(!(this instanceof l))return new l(f);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},f||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||f&&f.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var g=r.inflateInit2(this.strm,m.windowBits);if(g!==a.Z_OK)throw new Error(o[g]);this.header=new d,r.inflateGetHeader(this.strm,this.header)}function b(f,m){var g=new l(m);if(g.push(f,!0),g.err)throw g.msg||o[g.err];return g.result}l.prototype.push=function(f,m){var g,A,y,w,E,z,P=this.strm,G=this.options.chunkSize,R=this.options.dictionary,V=!1;if(this.ended)return!1;A=m===~~m?m:m===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof f=="string"?P.input=i.binstring2buf(f):p.call(f)==="[object ArrayBuffer]"?P.input=new Uint8Array(f):P.input=f,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new n.Buf8(G),P.next_out=0,P.avail_out=G),(g=r.inflate(P,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&R&&(z=typeof R=="string"?i.string2buf(R):p.call(R)==="[object ArrayBuffer]"?new Uint8Array(R):R,g=r.inflateSetDictionary(this.strm,z)),g===a.Z_BUF_ERROR&&V===!0&&(g=a.Z_OK,V=!1),g!==a.Z_STREAM_END&&g!==a.Z_OK)return this.onEnd(g),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&g!==a.Z_STREAM_END&&(P.avail_in!==0||A!==a.Z_FINISH&&A!==a.Z_SYNC_FLUSH)||(this.options.to==="string"?(y=i.utf8border(P.output,P.next_out),w=P.next_out-y,E=i.buf2string(P.output,y),P.next_out=w,P.avail_out=G-w,w&&n.arraySet(P.output,P.output,y,w,0),this.onData(E)):this.onData(n.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(V=!0)}while((0<P.avail_in||P.avail_out===0)&&g!==a.Z_STREAM_END);return g===a.Z_STREAM_END&&(A=a.Z_FINISH),A===a.Z_FINISH?(g=r.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===a.Z_OK):A!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),!(P.avail_out=0))},l.prototype.onData=function(f){this.chunks.push(f)},l.prototype.onEnd=function(f){f===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},t.Inflate=l,t.inflate=b,t.inflateRaw=function(f,m){return(m=m||{}).raw=!0,b(f,m)},t.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(s,e,t){"use strict";var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";t.assign=function(a){for(var o=Array.prototype.slice.call(arguments,1);o.length;){var u=o.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var d in u)u.hasOwnProperty(d)&&(a[d]=u[d])}}return a},t.shrinkBuf=function(a,o){return a.length===o?a:a.subarray?a.subarray(0,o):(a.length=o,a)};var n={arraySet:function(a,o,u,d,p){if(o.subarray&&a.subarray)a.set(o.subarray(u,u+d),p);else for(var l=0;l<d;l++)a[p+l]=o[u+l]},flattenChunks:function(a){var o,u,d,p,l,b;for(o=d=0,u=a.length;o<u;o++)d+=a[o].length;for(b=new Uint8Array(d),o=p=0,u=a.length;o<u;o++)l=a[o],b.set(l,p),p+=l.length;return b}},i={arraySet:function(a,o,u,d,p){for(var l=0;l<d;l++)a[p+l]=o[u+l]},flattenChunks:function(a){return[].concat.apply([],a)}};t.setTyped=function(a){a?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,n)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,i))},t.setTyped(r)},{}],42:[function(s,e,t){"use strict";var r=s("./common"),n=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch{n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{i=!1}for(var a=new r.Buf8(256),o=0;o<256;o++)a[o]=252<=o?6:248<=o?5:240<=o?4:224<=o?3:192<=o?2:1;function u(d,p){if(p<65537&&(d.subarray&&i||!d.subarray&&n))return String.fromCharCode.apply(null,r.shrinkBuf(d,p));for(var l="",b=0;b<p;b++)l+=String.fromCharCode(d[b]);return l}a[254]=a[254]=1,t.string2buf=function(d){var p,l,b,f,m,g=d.length,A=0;for(f=0;f<g;f++)(64512&(l=d.charCodeAt(f)))==55296&&f+1<g&&(64512&(b=d.charCodeAt(f+1)))==56320&&(l=65536+(l-55296<<10)+(b-56320),f++),A+=l<128?1:l<2048?2:l<65536?3:4;for(p=new r.Buf8(A),f=m=0;m<A;f++)(64512&(l=d.charCodeAt(f)))==55296&&f+1<g&&(64512&(b=d.charCodeAt(f+1)))==56320&&(l=65536+(l-55296<<10)+(b-56320),f++),l<128?p[m++]=l:(l<2048?p[m++]=192|l>>>6:(l<65536?p[m++]=224|l>>>12:(p[m++]=240|l>>>18,p[m++]=128|l>>>12&63),p[m++]=128|l>>>6&63),p[m++]=128|63&l);return p},t.buf2binstring=function(d){return u(d,d.length)},t.binstring2buf=function(d){for(var p=new r.Buf8(d.length),l=0,b=p.length;l<b;l++)p[l]=d.charCodeAt(l);return p},t.buf2string=function(d,p){var l,b,f,m,g=p||d.length,A=new Array(2*g);for(l=b=0;l<g;)if((f=d[l++])<128)A[b++]=f;else if(4<(m=a[f]))A[b++]=65533,l+=m-1;else{for(f&=m===2?31:m===3?15:7;1<m&&l<g;)f=f<<6|63&d[l++],m--;1<m?A[b++]=65533:f<65536?A[b++]=f:(f-=65536,A[b++]=55296|f>>10&1023,A[b++]=56320|1023&f)}return u(A,b)},t.utf8border=function(d,p){var l;for((p=p||d.length)>d.length&&(p=d.length),l=p-1;0<=l&&(192&d[l])==128;)l--;return l<0||l===0?p:l+a[d[l]]>p?l:p}},{"./common":41}],43:[function(s,e,t){"use strict";e.exports=function(r,n,i,a){for(var o=65535&r|0,u=r>>>16&65535|0,d=0;i!==0;){for(i-=d=2e3<i?2e3:i;u=u+(o=o+n[a++]|0)|0,--d;);o%=65521,u%=65521}return o|u<<16|0}},{}],44:[function(s,e,t){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(s,e,t){"use strict";var r=function(){for(var n,i=[],a=0;a<256;a++){n=a;for(var o=0;o<8;o++)n=1&n?3988292384^n>>>1:n>>>1;i[a]=n}return i}();e.exports=function(n,i,a,o){var u=r,d=o+a;n^=-1;for(var p=o;p<d;p++)n=n>>>8^u[255&(n^i[p])];return-1^n}},{}],46:[function(s,e,t){"use strict";var r,n=s("../utils/common"),i=s("./trees"),a=s("./adler32"),o=s("./crc32"),u=s("./messages"),d=0,p=4,l=0,b=-2,f=-1,m=4,g=2,A=8,y=9,w=286,E=30,z=19,P=2*w+1,G=15,R=3,V=258,X=V+R+1,C=42,S=113,h=1,k=2,Y=3,F=4;function q(c,L){return c.msg=u[L],L}function I(c){return(c<<1)-(4<c?9:0)}function O(c){for(var L=c.length;0<=--L;)c[L]=0}function D(c){var L=c.state,T=L.pending;T>c.avail_out&&(T=c.avail_out),T!==0&&(n.arraySet(c.output,L.pending_buf,L.pending_out,T,c.next_out),c.next_out+=T,L.pending_out+=T,c.total_out+=T,c.avail_out-=T,L.pending-=T,L.pending===0&&(L.pending_out=0))}function v(c,L){i._tr_flush_block(c,0<=c.block_start?c.block_start:-1,c.strstart-c.block_start,L),c.block_start=c.strstart,D(c.strm)}function j(c,L){c.pending_buf[c.pending++]=L}function W(c,L){c.pending_buf[c.pending++]=L>>>8&255,c.pending_buf[c.pending++]=255&L}function Z(c,L){var T,_,x=c.max_chain_length,B=c.strstart,U=c.prev_length,M=c.nice_match,N=c.strstart>c.w_size-X?c.strstart-(c.w_size-X):0,H=c.window,J=c.w_mask,$=c.prev,Q=c.strstart+V,ce=H[B+U-1],ne=H[B+U];c.prev_length>=c.good_match&&(x>>=2),M>c.lookahead&&(M=c.lookahead);do if(H[(T=L)+U]===ne&&H[T+U-1]===ce&&H[T]===H[B]&&H[++T]===H[B+1]){B+=2,T++;do;while(H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&B<Q);if(_=V-(Q-B),B=Q-V,U<_){if(c.match_start=L,M<=(U=_))break;ce=H[B+U-1],ne=H[B+U]}}while((L=$[L&J])>N&&--x!=0);return U<=c.lookahead?U:c.lookahead}function ee(c){var L,T,_,x,B,U,M,N,H,J,$=c.w_size;do{if(x=c.window_size-c.lookahead-c.strstart,c.strstart>=$+($-X)){for(n.arraySet(c.window,c.window,$,$,0),c.match_start-=$,c.strstart-=$,c.block_start-=$,L=T=c.hash_size;_=c.head[--L],c.head[L]=$<=_?_-$:0,--T;);for(L=T=$;_=c.prev[--L],c.prev[L]=$<=_?_-$:0,--T;);x+=$}if(c.strm.avail_in===0)break;if(U=c.strm,M=c.window,N=c.strstart+c.lookahead,H=x,J=void 0,J=U.avail_in,H<J&&(J=H),T=J===0?0:(U.avail_in-=J,n.arraySet(M,U.input,U.next_in,J,N),U.state.wrap===1?U.adler=a(U.adler,M,J,N):U.state.wrap===2&&(U.adler=o(U.adler,M,J,N)),U.next_in+=J,U.total_in+=J,J),c.lookahead+=T,c.lookahead+c.insert>=R)for(B=c.strstart-c.insert,c.ins_h=c.window[B],c.ins_h=(c.ins_h<<c.hash_shift^c.window[B+1])&c.hash_mask;c.insert&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[B+R-1])&c.hash_mask,c.prev[B&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=B,B++,c.insert--,!(c.lookahead+c.insert<R)););}while(c.lookahead<X&&c.strm.avail_in!==0)}function te(c,L){for(var T,_;;){if(c.lookahead<X){if(ee(c),c.lookahead<X&&L===d)return h;if(c.lookahead===0)break}if(T=0,c.lookahead>=R&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),T!==0&&c.strstart-T<=c.w_size-X&&(c.match_length=Z(c,T)),c.match_length>=R)if(_=i._tr_tally(c,c.strstart-c.match_start,c.match_length-R),c.lookahead-=c.match_length,c.match_length<=c.max_lazy_match&&c.lookahead>=R){for(c.match_length--;c.strstart++,c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart,--c.match_length!=0;);c.strstart++}else c.strstart+=c.match_length,c.match_length=0,c.ins_h=c.window[c.strstart],c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+1])&c.hash_mask;else _=i._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++;if(_&&(v(c,!1),c.strm.avail_out===0))return h}return c.insert=c.strstart<R-1?c.strstart:R-1,L===p?(v(c,!0),c.strm.avail_out===0?Y:F):c.last_lit&&(v(c,!1),c.strm.avail_out===0)?h:k}function K(c,L){for(var T,_,x;;){if(c.lookahead<X){if(ee(c),c.lookahead<X&&L===d)return h;if(c.lookahead===0)break}if(T=0,c.lookahead>=R&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),c.prev_length=c.match_length,c.prev_match=c.match_start,c.match_length=R-1,T!==0&&c.prev_length<c.max_lazy_match&&c.strstart-T<=c.w_size-X&&(c.match_length=Z(c,T),c.match_length<=5&&(c.strategy===1||c.match_length===R&&4096<c.strstart-c.match_start)&&(c.match_length=R-1)),c.prev_length>=R&&c.match_length<=c.prev_length){for(x=c.strstart+c.lookahead-R,_=i._tr_tally(c,c.strstart-1-c.prev_match,c.prev_length-R),c.lookahead-=c.prev_length-1,c.prev_length-=2;++c.strstart<=x&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),--c.prev_length!=0;);if(c.match_available=0,c.match_length=R-1,c.strstart++,_&&(v(c,!1),c.strm.avail_out===0))return h}else if(c.match_available){if((_=i._tr_tally(c,0,c.window[c.strstart-1]))&&v(c,!1),c.strstart++,c.lookahead--,c.strm.avail_out===0)return h}else c.match_available=1,c.strstart++,c.lookahead--}return c.match_available&&(_=i._tr_tally(c,0,c.window[c.strstart-1]),c.match_available=0),c.insert=c.strstart<R-1?c.strstart:R-1,L===p?(v(c,!0),c.strm.avail_out===0?Y:F):c.last_lit&&(v(c,!1),c.strm.avail_out===0)?h:k}function re(c,L,T,_,x){this.good_length=c,this.max_lazy=L,this.nice_length=T,this.max_chain=_,this.func=x}function le(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=A,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new n.Buf16(2*P),this.dyn_dtree=new n.Buf16(2*(2*E+1)),this.bl_tree=new n.Buf16(2*(2*z+1)),O(this.dyn_ltree),O(this.dyn_dtree),O(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(G+1),this.heap=new n.Buf16(2*w+1),O(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(2*w+1),O(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ue(c){var L;return c&&c.state?(c.total_in=c.total_out=0,c.data_type=g,(L=c.state).pending=0,L.pending_out=0,L.wrap<0&&(L.wrap=-L.wrap),L.status=L.wrap?C:S,c.adler=L.wrap===2?0:1,L.last_flush=d,i._tr_init(L),l):q(c,b)}function fe(c){var L=ue(c);return L===l&&function(T){T.window_size=2*T.w_size,O(T.head),T.max_lazy_match=r[T.level].max_lazy,T.good_match=r[T.level].good_length,T.nice_match=r[T.level].nice_length,T.max_chain_length=r[T.level].max_chain,T.strstart=0,T.block_start=0,T.lookahead=0,T.insert=0,T.match_length=T.prev_length=R-1,T.match_available=0,T.ins_h=0}(c.state),L}function me(c,L,T,_,x,B){if(!c)return b;var U=1;if(L===f&&(L=6),_<0?(U=0,_=-_):15<_&&(U=2,_-=16),x<1||y<x||T!==A||_<8||15<_||L<0||9<L||B<0||m<B)return q(c,b);_===8&&(_=9);var M=new le;return(c.state=M).strm=c,M.wrap=U,M.gzhead=null,M.w_bits=_,M.w_size=1<<M.w_bits,M.w_mask=M.w_size-1,M.hash_bits=x+7,M.hash_size=1<<M.hash_bits,M.hash_mask=M.hash_size-1,M.hash_shift=~~((M.hash_bits+R-1)/R),M.window=new n.Buf8(2*M.w_size),M.head=new n.Buf16(M.hash_size),M.prev=new n.Buf16(M.w_size),M.lit_bufsize=1<<x+6,M.pending_buf_size=4*M.lit_bufsize,M.pending_buf=new n.Buf8(M.pending_buf_size),M.d_buf=1*M.lit_bufsize,M.l_buf=3*M.lit_bufsize,M.level=L,M.strategy=B,M.method=T,fe(c)}r=[new re(0,0,0,0,function(c,L){var T=65535;for(T>c.pending_buf_size-5&&(T=c.pending_buf_size-5);;){if(c.lookahead<=1){if(ee(c),c.lookahead===0&&L===d)return h;if(c.lookahead===0)break}c.strstart+=c.lookahead,c.lookahead=0;var _=c.block_start+T;if((c.strstart===0||c.strstart>=_)&&(c.lookahead=c.strstart-_,c.strstart=_,v(c,!1),c.strm.avail_out===0)||c.strstart-c.block_start>=c.w_size-X&&(v(c,!1),c.strm.avail_out===0))return h}return c.insert=0,L===p?(v(c,!0),c.strm.avail_out===0?Y:F):(c.strstart>c.block_start&&(v(c,!1),c.strm.avail_out),h)}),new re(4,4,8,4,te),new re(4,5,16,8,te),new re(4,6,32,32,te),new re(4,4,16,16,K),new re(8,16,32,32,K),new re(8,16,128,128,K),new re(8,32,128,256,K),new re(32,128,258,1024,K),new re(32,258,258,4096,K)],t.deflateInit=function(c,L){return me(c,L,A,15,8,0)},t.deflateInit2=me,t.deflateReset=fe,t.deflateResetKeep=ue,t.deflateSetHeader=function(c,L){return c&&c.state?c.state.wrap!==2?b:(c.state.gzhead=L,l):b},t.deflate=function(c,L){var T,_,x,B;if(!c||!c.state||5<L||L<0)return c?q(c,b):b;if(_=c.state,!c.output||!c.input&&c.avail_in!==0||_.status===666&&L!==p)return q(c,c.avail_out===0?-5:b);if(_.strm=c,T=_.last_flush,_.last_flush=L,_.status===C)if(_.wrap===2)c.adler=0,j(_,31),j(_,139),j(_,8),_.gzhead?(j(_,(_.gzhead.text?1:0)+(_.gzhead.hcrc?2:0)+(_.gzhead.extra?4:0)+(_.gzhead.name?8:0)+(_.gzhead.comment?16:0)),j(_,255&_.gzhead.time),j(_,_.gzhead.time>>8&255),j(_,_.gzhead.time>>16&255),j(_,_.gzhead.time>>24&255),j(_,_.level===9?2:2<=_.strategy||_.level<2?4:0),j(_,255&_.gzhead.os),_.gzhead.extra&&_.gzhead.extra.length&&(j(_,255&_.gzhead.extra.length),j(_,_.gzhead.extra.length>>8&255)),_.gzhead.hcrc&&(c.adler=o(c.adler,_.pending_buf,_.pending,0)),_.gzindex=0,_.status=69):(j(_,0),j(_,0),j(_,0),j(_,0),j(_,0),j(_,_.level===9?2:2<=_.strategy||_.level<2?4:0),j(_,3),_.status=S);else{var U=A+(_.w_bits-8<<4)<<8;U|=(2<=_.strategy||_.level<2?0:_.level<6?1:_.level===6?2:3)<<6,_.strstart!==0&&(U|=32),U+=31-U%31,_.status=S,W(_,U),_.strstart!==0&&(W(_,c.adler>>>16),W(_,65535&c.adler)),c.adler=1}if(_.status===69)if(_.gzhead.extra){for(x=_.pending;_.gzindex<(65535&_.gzhead.extra.length)&&(_.pending!==_.pending_buf_size||(_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),D(c),x=_.pending,_.pending!==_.pending_buf_size));)j(_,255&_.gzhead.extra[_.gzindex]),_.gzindex++;_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),_.gzindex===_.gzhead.extra.length&&(_.gzindex=0,_.status=73)}else _.status=73;if(_.status===73)if(_.gzhead.name){x=_.pending;do{if(_.pending===_.pending_buf_size&&(_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),D(c),x=_.pending,_.pending===_.pending_buf_size)){B=1;break}B=_.gzindex<_.gzhead.name.length?255&_.gzhead.name.charCodeAt(_.gzindex++):0,j(_,B)}while(B!==0);_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),B===0&&(_.gzindex=0,_.status=91)}else _.status=91;if(_.status===91)if(_.gzhead.comment){x=_.pending;do{if(_.pending===_.pending_buf_size&&(_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),D(c),x=_.pending,_.pending===_.pending_buf_size)){B=1;break}B=_.gzindex<_.gzhead.comment.length?255&_.gzhead.comment.charCodeAt(_.gzindex++):0,j(_,B)}while(B!==0);_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),B===0&&(_.status=103)}else _.status=103;if(_.status===103&&(_.gzhead.hcrc?(_.pending+2>_.pending_buf_size&&D(c),_.pending+2<=_.pending_buf_size&&(j(_,255&c.adler),j(_,c.adler>>8&255),c.adler=0,_.status=S)):_.status=S),_.pending!==0){if(D(c),c.avail_out===0)return _.last_flush=-1,l}else if(c.avail_in===0&&I(L)<=I(T)&&L!==p)return q(c,-5);if(_.status===666&&c.avail_in!==0)return q(c,-5);if(c.avail_in!==0||_.lookahead!==0||L!==d&&_.status!==666){var M=_.strategy===2?function(N,H){for(var J;;){if(N.lookahead===0&&(ee(N),N.lookahead===0)){if(H===d)return h;break}if(N.match_length=0,J=i._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++,J&&(v(N,!1),N.strm.avail_out===0))return h}return N.insert=0,H===p?(v(N,!0),N.strm.avail_out===0?Y:F):N.last_lit&&(v(N,!1),N.strm.avail_out===0)?h:k}(_,L):_.strategy===3?function(N,H){for(var J,$,Q,ce,ne=N.window;;){if(N.lookahead<=V){if(ee(N),N.lookahead<=V&&H===d)return h;if(N.lookahead===0)break}if(N.match_length=0,N.lookahead>=R&&0<N.strstart&&($=ne[Q=N.strstart-1])===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]){ce=N.strstart+V;do;while($===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&Q<ce);N.match_length=V-(ce-Q),N.match_length>N.lookahead&&(N.match_length=N.lookahead)}if(N.match_length>=R?(J=i._tr_tally(N,1,N.match_length-R),N.lookahead-=N.match_length,N.strstart+=N.match_length,N.match_length=0):(J=i._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++),J&&(v(N,!1),N.strm.avail_out===0))return h}return N.insert=0,H===p?(v(N,!0),N.strm.avail_out===0?Y:F):N.last_lit&&(v(N,!1),N.strm.avail_out===0)?h:k}(_,L):r[_.level].func(_,L);if(M!==Y&&M!==F||(_.status=666),M===h||M===Y)return c.avail_out===0&&(_.last_flush=-1),l;if(M===k&&(L===1?i._tr_align(_):L!==5&&(i._tr_stored_block(_,0,0,!1),L===3&&(O(_.head),_.lookahead===0&&(_.strstart=0,_.block_start=0,_.insert=0))),D(c),c.avail_out===0))return _.last_flush=-1,l}return L!==p?l:_.wrap<=0?1:(_.wrap===2?(j(_,255&c.adler),j(_,c.adler>>8&255),j(_,c.adler>>16&255),j(_,c.adler>>24&255),j(_,255&c.total_in),j(_,c.total_in>>8&255),j(_,c.total_in>>16&255),j(_,c.total_in>>24&255)):(W(_,c.adler>>>16),W(_,65535&c.adler)),D(c),0<_.wrap&&(_.wrap=-_.wrap),_.pending!==0?l:1)},t.deflateEnd=function(c){var L;return c&&c.state?(L=c.state.status)!==C&&L!==69&&L!==73&&L!==91&&L!==103&&L!==S&&L!==666?q(c,b):(c.state=null,L===S?q(c,-3):l):b},t.deflateSetDictionary=function(c,L){var T,_,x,B,U,M,N,H,J=L.length;if(!c||!c.state||(B=(T=c.state).wrap)===2||B===1&&T.status!==C||T.lookahead)return b;for(B===1&&(c.adler=a(c.adler,L,J,0)),T.wrap=0,J>=T.w_size&&(B===0&&(O(T.head),T.strstart=0,T.block_start=0,T.insert=0),H=new n.Buf8(T.w_size),n.arraySet(H,L,J-T.w_size,T.w_size,0),L=H,J=T.w_size),U=c.avail_in,M=c.next_in,N=c.input,c.avail_in=J,c.next_in=0,c.input=L,ee(T);T.lookahead>=R;){for(_=T.strstart,x=T.lookahead-(R-1);T.ins_h=(T.ins_h<<T.hash_shift^T.window[_+R-1])&T.hash_mask,T.prev[_&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=_,_++,--x;);T.strstart=_,T.lookahead=R-1,ee(T)}return T.strstart+=T.lookahead,T.block_start=T.strstart,T.insert=T.lookahead,T.lookahead=0,T.match_length=T.prev_length=R-1,T.match_available=0,c.next_in=M,c.input=N,c.avail_in=U,T.wrap=B,l},t.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(s,e,t){"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(s,e,t){"use strict";e.exports=function(r,n){var i,a,o,u,d,p,l,b,f,m,g,A,y,w,E,z,P,G,R,V,X,C,S,h,k;i=r.state,a=r.next_in,h=r.input,o=a+(r.avail_in-5),u=r.next_out,k=r.output,d=u-(n-r.avail_out),p=u+(r.avail_out-257),l=i.dmax,b=i.wsize,f=i.whave,m=i.wnext,g=i.window,A=i.hold,y=i.bits,w=i.lencode,E=i.distcode,z=(1<<i.lenbits)-1,P=(1<<i.distbits)-1;e:do{y<15&&(A+=h[a++]<<y,y+=8,A+=h[a++]<<y,y+=8),G=w[A&z];t:for(;;){if(A>>>=R=G>>>24,y-=R,(R=G>>>16&255)===0)k[u++]=65535&G;else{if(!(16&R)){if((64&R)==0){G=w[(65535&G)+(A&(1<<R)-1)];continue t}if(32&R){i.mode=12;break e}r.msg="invalid literal/length code",i.mode=30;break e}V=65535&G,(R&=15)&&(y<R&&(A+=h[a++]<<y,y+=8),V+=A&(1<<R)-1,A>>>=R,y-=R),y<15&&(A+=h[a++]<<y,y+=8,A+=h[a++]<<y,y+=8),G=E[A&P];r:for(;;){if(A>>>=R=G>>>24,y-=R,!(16&(R=G>>>16&255))){if((64&R)==0){G=E[(65535&G)+(A&(1<<R)-1)];continue r}r.msg="invalid distance code",i.mode=30;break e}if(X=65535&G,y<(R&=15)&&(A+=h[a++]<<y,(y+=8)<R&&(A+=h[a++]<<y,y+=8)),l<(X+=A&(1<<R)-1)){r.msg="invalid distance too far back",i.mode=30;break e}if(A>>>=R,y-=R,(R=u-d)<X){if(f<(R=X-R)&&i.sane){r.msg="invalid distance too far back",i.mode=30;break e}if(S=g,(C=0)===m){if(C+=b-R,R<V){for(V-=R;k[u++]=g[C++],--R;);C=u-X,S=k}}else if(m<R){if(C+=b+m-R,(R-=m)<V){for(V-=R;k[u++]=g[C++],--R;);if(C=0,m<V){for(V-=R=m;k[u++]=g[C++],--R;);C=u-X,S=k}}}else if(C+=m-R,R<V){for(V-=R;k[u++]=g[C++],--R;);C=u-X,S=k}for(;2<V;)k[u++]=S[C++],k[u++]=S[C++],k[u++]=S[C++],V-=3;V&&(k[u++]=S[C++],1<V&&(k[u++]=S[C++]))}else{for(C=u-X;k[u++]=k[C++],k[u++]=k[C++],k[u++]=k[C++],2<(V-=3););V&&(k[u++]=k[C++],1<V&&(k[u++]=k[C++]))}break}}break}}while(a<o&&u<p);a-=V=y>>3,A&=(1<<(y-=V<<3))-1,r.next_in=a,r.next_out=u,r.avail_in=a<o?o-a+5:5-(a-o),r.avail_out=u<p?p-u+257:257-(u-p),i.hold=A,i.bits=y}},{}],49:[function(s,e,t){"use strict";var r=s("../utils/common"),n=s("./adler32"),i=s("./crc32"),a=s("./inffast"),o=s("./inftrees"),u=1,d=2,p=0,l=-2,b=1,f=852,m=592;function g(C){return(C>>>24&255)+(C>>>8&65280)+((65280&C)<<8)+((255&C)<<24)}function A(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function y(C){var S;return C&&C.state?(S=C.state,C.total_in=C.total_out=S.total=0,C.msg="",S.wrap&&(C.adler=1&S.wrap),S.mode=b,S.last=0,S.havedict=0,S.dmax=32768,S.head=null,S.hold=0,S.bits=0,S.lencode=S.lendyn=new r.Buf32(f),S.distcode=S.distdyn=new r.Buf32(m),S.sane=1,S.back=-1,p):l}function w(C){var S;return C&&C.state?((S=C.state).wsize=0,S.whave=0,S.wnext=0,y(C)):l}function E(C,S){var h,k;return C&&C.state?(k=C.state,S<0?(h=0,S=-S):(h=1+(S>>4),S<48&&(S&=15)),S&&(S<8||15<S)?l:(k.window!==null&&k.wbits!==S&&(k.window=null),k.wrap=h,k.wbits=S,w(C))):l}function z(C,S){var h,k;return C?(k=new A,(C.state=k).window=null,(h=E(C,S))!==p&&(C.state=null),h):l}var P,G,R=!0;function V(C){if(R){var S;for(P=new r.Buf32(512),G=new r.Buf32(32),S=0;S<144;)C.lens[S++]=8;for(;S<256;)C.lens[S++]=9;for(;S<280;)C.lens[S++]=7;for(;S<288;)C.lens[S++]=8;for(o(u,C.lens,0,288,P,0,C.work,{bits:9}),S=0;S<32;)C.lens[S++]=5;o(d,C.lens,0,32,G,0,C.work,{bits:5}),R=!1}C.lencode=P,C.lenbits=9,C.distcode=G,C.distbits=5}function X(C,S,h,k){var Y,F=C.state;return F.window===null&&(F.wsize=1<<F.wbits,F.wnext=0,F.whave=0,F.window=new r.Buf8(F.wsize)),k>=F.wsize?(r.arraySet(F.window,S,h-F.wsize,F.wsize,0),F.wnext=0,F.whave=F.wsize):(k<(Y=F.wsize-F.wnext)&&(Y=k),r.arraySet(F.window,S,h-k,Y,F.wnext),(k-=Y)?(r.arraySet(F.window,S,h-k,k,0),F.wnext=k,F.whave=F.wsize):(F.wnext+=Y,F.wnext===F.wsize&&(F.wnext=0),F.whave<F.wsize&&(F.whave+=Y))),0}t.inflateReset=w,t.inflateReset2=E,t.inflateResetKeep=y,t.inflateInit=function(C){return z(C,15)},t.inflateInit2=z,t.inflate=function(C,S){var h,k,Y,F,q,I,O,D,v,j,W,Z,ee,te,K,re,le,ue,fe,me,c,L,T,_,x=0,B=new r.Buf8(4),U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!C||!C.state||!C.output||!C.input&&C.avail_in!==0)return l;(h=C.state).mode===12&&(h.mode=13),q=C.next_out,Y=C.output,O=C.avail_out,F=C.next_in,k=C.input,I=C.avail_in,D=h.hold,v=h.bits,j=I,W=O,L=p;e:for(;;)switch(h.mode){case b:if(h.wrap===0){h.mode=13;break}for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(2&h.wrap&&D===35615){B[h.check=0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0),v=D=0,h.mode=2;break}if(h.flags=0,h.head&&(h.head.done=!1),!(1&h.wrap)||(((255&D)<<8)+(D>>8))%31){C.msg="incorrect header check",h.mode=30;break}if((15&D)!=8){C.msg="unknown compression method",h.mode=30;break}if(v-=4,c=8+(15&(D>>>=4)),h.wbits===0)h.wbits=c;else if(c>h.wbits){C.msg="invalid window size",h.mode=30;break}h.dmax=1<<c,C.adler=h.check=1,h.mode=512&D?10:12,v=D=0;break;case 2:for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(h.flags=D,(255&h.flags)!=8){C.msg="unknown compression method",h.mode=30;break}if(57344&h.flags){C.msg="unknown header flags set",h.mode=30;break}h.head&&(h.head.text=D>>8&1),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0)),v=D=0,h.mode=3;case 3:for(;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.head&&(h.head.time=D),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,B[2]=D>>>16&255,B[3]=D>>>24&255,h.check=i(h.check,B,4,0)),v=D=0,h.mode=4;case 4:for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.head&&(h.head.xflags=255&D,h.head.os=D>>8),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0)),v=D=0,h.mode=5;case 5:if(1024&h.flags){for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.length=D,h.head&&(h.head.extra_len=D),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0)),v=D=0}else h.head&&(h.head.extra=null);h.mode=6;case 6:if(1024&h.flags&&(I<(Z=h.length)&&(Z=I),Z&&(h.head&&(c=h.head.extra_len-h.length,h.head.extra||(h.head.extra=new Array(h.head.extra_len)),r.arraySet(h.head.extra,k,F,Z,c)),512&h.flags&&(h.check=i(h.check,k,Z,F)),I-=Z,F+=Z,h.length-=Z),h.length))break e;h.length=0,h.mode=7;case 7:if(2048&h.flags){if(I===0)break e;for(Z=0;c=k[F+Z++],h.head&&c&&h.length<65536&&(h.head.name+=String.fromCharCode(c)),c&&Z<I;);if(512&h.flags&&(h.check=i(h.check,k,Z,F)),I-=Z,F+=Z,c)break e}else h.head&&(h.head.name=null);h.length=0,h.mode=8;case 8:if(4096&h.flags){if(I===0)break e;for(Z=0;c=k[F+Z++],h.head&&c&&h.length<65536&&(h.head.comment+=String.fromCharCode(c)),c&&Z<I;);if(512&h.flags&&(h.check=i(h.check,k,Z,F)),I-=Z,F+=Z,c)break e}else h.head&&(h.head.comment=null);h.mode=9;case 9:if(512&h.flags){for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(D!==(65535&h.check)){C.msg="header crc mismatch",h.mode=30;break}v=D=0}h.head&&(h.head.hcrc=h.flags>>9&1,h.head.done=!0),C.adler=h.check=0,h.mode=12;break;case 10:for(;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}C.adler=h.check=g(D),v=D=0,h.mode=11;case 11:if(h.havedict===0)return C.next_out=q,C.avail_out=O,C.next_in=F,C.avail_in=I,h.hold=D,h.bits=v,2;C.adler=h.check=1,h.mode=12;case 12:if(S===5||S===6)break e;case 13:if(h.last){D>>>=7&v,v-=7&v,h.mode=27;break}for(;v<3;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}switch(h.last=1&D,v-=1,3&(D>>>=1)){case 0:h.mode=14;break;case 1:if(V(h),h.mode=20,S!==6)break;D>>>=2,v-=2;break e;case 2:h.mode=17;break;case 3:C.msg="invalid block type",h.mode=30}D>>>=2,v-=2;break;case 14:for(D>>>=7&v,v-=7&v;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if((65535&D)!=(D>>>16^65535)){C.msg="invalid stored block lengths",h.mode=30;break}if(h.length=65535&D,v=D=0,h.mode=15,S===6)break e;case 15:h.mode=16;case 16:if(Z=h.length){if(I<Z&&(Z=I),O<Z&&(Z=O),Z===0)break e;r.arraySet(Y,k,F,Z,q),I-=Z,F+=Z,O-=Z,q+=Z,h.length-=Z;break}h.mode=12;break;case 17:for(;v<14;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(h.nlen=257+(31&D),D>>>=5,v-=5,h.ndist=1+(31&D),D>>>=5,v-=5,h.ncode=4+(15&D),D>>>=4,v-=4,286<h.nlen||30<h.ndist){C.msg="too many length or distance symbols",h.mode=30;break}h.have=0,h.mode=18;case 18:for(;h.have<h.ncode;){for(;v<3;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.lens[U[h.have++]]=7&D,D>>>=3,v-=3}for(;h.have<19;)h.lens[U[h.have++]]=0;if(h.lencode=h.lendyn,h.lenbits=7,T={bits:h.lenbits},L=o(0,h.lens,0,19,h.lencode,0,h.work,T),h.lenbits=T.bits,L){C.msg="invalid code lengths set",h.mode=30;break}h.have=0,h.mode=19;case 19:for(;h.have<h.nlen+h.ndist;){for(;re=(x=h.lencode[D&(1<<h.lenbits)-1])>>>16&255,le=65535&x,!((K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(le<16)D>>>=K,v-=K,h.lens[h.have++]=le;else{if(le===16){for(_=K+2;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(D>>>=K,v-=K,h.have===0){C.msg="invalid bit length repeat",h.mode=30;break}c=h.lens[h.have-1],Z=3+(3&D),D>>>=2,v-=2}else if(le===17){for(_=K+3;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}v-=K,c=0,Z=3+(7&(D>>>=K)),D>>>=3,v-=3}else{for(_=K+7;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}v-=K,c=0,Z=11+(127&(D>>>=K)),D>>>=7,v-=7}if(h.have+Z>h.nlen+h.ndist){C.msg="invalid bit length repeat",h.mode=30;break}for(;Z--;)h.lens[h.have++]=c}}if(h.mode===30)break;if(h.lens[256]===0){C.msg="invalid code -- missing end-of-block",h.mode=30;break}if(h.lenbits=9,T={bits:h.lenbits},L=o(u,h.lens,0,h.nlen,h.lencode,0,h.work,T),h.lenbits=T.bits,L){C.msg="invalid literal/lengths set",h.mode=30;break}if(h.distbits=6,h.distcode=h.distdyn,T={bits:h.distbits},L=o(d,h.lens,h.nlen,h.ndist,h.distcode,0,h.work,T),h.distbits=T.bits,L){C.msg="invalid distances set",h.mode=30;break}if(h.mode=20,S===6)break e;case 20:h.mode=21;case 21:if(6<=I&&258<=O){C.next_out=q,C.avail_out=O,C.next_in=F,C.avail_in=I,h.hold=D,h.bits=v,a(C,W),q=C.next_out,Y=C.output,O=C.avail_out,F=C.next_in,k=C.input,I=C.avail_in,D=h.hold,v=h.bits,h.mode===12&&(h.back=-1);break}for(h.back=0;re=(x=h.lencode[D&(1<<h.lenbits)-1])>>>16&255,le=65535&x,!((K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(re&&(240&re)==0){for(ue=K,fe=re,me=le;re=(x=h.lencode[me+((D&(1<<ue+fe)-1)>>ue)])>>>16&255,le=65535&x,!(ue+(K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}D>>>=ue,v-=ue,h.back+=ue}if(D>>>=K,v-=K,h.back+=K,h.length=le,re===0){h.mode=26;break}if(32&re){h.back=-1,h.mode=12;break}if(64&re){C.msg="invalid literal/length code",h.mode=30;break}h.extra=15&re,h.mode=22;case 22:if(h.extra){for(_=h.extra;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.length+=D&(1<<h.extra)-1,D>>>=h.extra,v-=h.extra,h.back+=h.extra}h.was=h.length,h.mode=23;case 23:for(;re=(x=h.distcode[D&(1<<h.distbits)-1])>>>16&255,le=65535&x,!((K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if((240&re)==0){for(ue=K,fe=re,me=le;re=(x=h.distcode[me+((D&(1<<ue+fe)-1)>>ue)])>>>16&255,le=65535&x,!(ue+(K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}D>>>=ue,v-=ue,h.back+=ue}if(D>>>=K,v-=K,h.back+=K,64&re){C.msg="invalid distance code",h.mode=30;break}h.offset=le,h.extra=15&re,h.mode=24;case 24:if(h.extra){for(_=h.extra;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.offset+=D&(1<<h.extra)-1,D>>>=h.extra,v-=h.extra,h.back+=h.extra}if(h.offset>h.dmax){C.msg="invalid distance too far back",h.mode=30;break}h.mode=25;case 25:if(O===0)break e;if(Z=W-O,h.offset>Z){if((Z=h.offset-Z)>h.whave&&h.sane){C.msg="invalid distance too far back",h.mode=30;break}ee=Z>h.wnext?(Z-=h.wnext,h.wsize-Z):h.wnext-Z,Z>h.length&&(Z=h.length),te=h.window}else te=Y,ee=q-h.offset,Z=h.length;for(O<Z&&(Z=O),O-=Z,h.length-=Z;Y[q++]=te[ee++],--Z;);h.length===0&&(h.mode=21);break;case 26:if(O===0)break e;Y[q++]=h.length,O--,h.mode=21;break;case 27:if(h.wrap){for(;v<32;){if(I===0)break e;I--,D|=k[F++]<<v,v+=8}if(W-=O,C.total_out+=W,h.total+=W,W&&(C.adler=h.check=h.flags?i(h.check,Y,W,q-W):n(h.check,Y,W,q-W)),W=O,(h.flags?D:g(D))!==h.check){C.msg="incorrect data check",h.mode=30;break}v=D=0}h.mode=28;case 28:if(h.wrap&&h.flags){for(;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(D!==(4294967295&h.total)){C.msg="incorrect length check",h.mode=30;break}v=D=0}h.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return-4;case 32:default:return l}return C.next_out=q,C.avail_out=O,C.next_in=F,C.avail_in=I,h.hold=D,h.bits=v,(h.wsize||W!==C.avail_out&&h.mode<30&&(h.mode<27||S!==4))&&X(C,C.output,C.next_out,W-C.avail_out)?(h.mode=31,-4):(j-=C.avail_in,W-=C.avail_out,C.total_in+=j,C.total_out+=W,h.total+=W,h.wrap&&W&&(C.adler=h.check=h.flags?i(h.check,Y,W,C.next_out-W):n(h.check,Y,W,C.next_out-W)),C.data_type=h.bits+(h.last?64:0)+(h.mode===12?128:0)+(h.mode===20||h.mode===15?256:0),(j==0&&W===0||S===4)&&L===p&&(L=-5),L)},t.inflateEnd=function(C){if(!C||!C.state)return l;var S=C.state;return S.window&&(S.window=null),C.state=null,p},t.inflateGetHeader=function(C,S){var h;return C&&C.state?(2&(h=C.state).wrap)==0?l:((h.head=S).done=!1,p):l},t.inflateSetDictionary=function(C,S){var h,k=S.length;return C&&C.state?(h=C.state).wrap!==0&&h.mode!==11?l:h.mode===11&&n(1,S,k,0)!==h.check?-3:X(C,S,k,k)?(h.mode=31,-4):(h.havedict=1,p):l},t.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(s,e,t){"use strict";var r=s("../utils/common"),n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(u,d,p,l,b,f,m,g){var A,y,w,E,z,P,G,R,V,X=g.bits,C=0,S=0,h=0,k=0,Y=0,F=0,q=0,I=0,O=0,D=0,v=null,j=0,W=new r.Buf16(16),Z=new r.Buf16(16),ee=null,te=0;for(C=0;C<=15;C++)W[C]=0;for(S=0;S<l;S++)W[d[p+S]]++;for(Y=X,k=15;1<=k&&W[k]===0;k--);if(k<Y&&(Y=k),k===0)return b[f++]=20971520,b[f++]=20971520,g.bits=1,0;for(h=1;h<k&&W[h]===0;h++);for(Y<h&&(Y=h),C=I=1;C<=15;C++)if(I<<=1,(I-=W[C])<0)return-1;if(0<I&&(u===0||k!==1))return-1;for(Z[1]=0,C=1;C<15;C++)Z[C+1]=Z[C]+W[C];for(S=0;S<l;S++)d[p+S]!==0&&(m[Z[d[p+S]]++]=S);if(P=u===0?(v=ee=m,19):u===1?(v=n,j-=257,ee=i,te-=257,256):(v=a,ee=o,-1),C=h,z=f,q=S=D=0,w=-1,E=(O=1<<(F=Y))-1,u===1&&852<O||u===2&&592<O)return 1;for(;;){for(G=C-q,V=m[S]<P?(R=0,m[S]):m[S]>P?(R=ee[te+m[S]],v[j+m[S]]):(R=96,0),A=1<<C-q,h=y=1<<F;b[z+(D>>q)+(y-=A)]=G<<24|R<<16|V|0,y!==0;);for(A=1<<C-1;D&A;)A>>=1;if(A!==0?(D&=A-1,D+=A):D=0,S++,--W[C]==0){if(C===k)break;C=d[p+m[S]]}if(Y<C&&(D&E)!==w){for(q===0&&(q=Y),z+=h,I=1<<(F=C-q);F+q<k&&!((I-=W[F+q])<=0);)F++,I<<=1;if(O+=1<<F,u===1&&852<O||u===2&&592<O)return 1;b[w=D&E]=Y<<24|F<<16|z-f|0}}return D!==0&&(b[z+D]=C-q<<24|64<<16|0),g.bits=Y,0}},{"../utils/common":41}],51:[function(s,e,t){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(s,e,t){"use strict";var r=s("../utils/common"),n=0,i=1;function a(x){for(var B=x.length;0<=--B;)x[B]=0}var o=0,u=29,d=256,p=d+1+u,l=30,b=19,f=2*p+1,m=15,g=16,A=7,y=256,w=16,E=17,z=18,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],G=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],R=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X=new Array(2*(p+2));a(X);var C=new Array(2*l);a(C);var S=new Array(512);a(S);var h=new Array(256);a(h);var k=new Array(u);a(k);var Y,F,q,I=new Array(l);function O(x,B,U,M,N){this.static_tree=x,this.extra_bits=B,this.extra_base=U,this.elems=M,this.max_length=N,this.has_stree=x&&x.length}function D(x,B){this.dyn_tree=x,this.max_code=0,this.stat_desc=B}function v(x){return x<256?S[x]:S[256+(x>>>7)]}function j(x,B){x.pending_buf[x.pending++]=255&B,x.pending_buf[x.pending++]=B>>>8&255}function W(x,B,U){x.bi_valid>g-U?(x.bi_buf|=B<<x.bi_valid&65535,j(x,x.bi_buf),x.bi_buf=B>>g-x.bi_valid,x.bi_valid+=U-g):(x.bi_buf|=B<<x.bi_valid&65535,x.bi_valid+=U)}function Z(x,B,U){W(x,U[2*B],U[2*B+1])}function ee(x,B){for(var U=0;U|=1&x,x>>>=1,U<<=1,0<--B;);return U>>>1}function te(x,B,U){var M,N,H=new Array(m+1),J=0;for(M=1;M<=m;M++)H[M]=J=J+U[M-1]<<1;for(N=0;N<=B;N++){var $=x[2*N+1];$!==0&&(x[2*N]=ee(H[$]++,$))}}function K(x){var B;for(B=0;B<p;B++)x.dyn_ltree[2*B]=0;for(B=0;B<l;B++)x.dyn_dtree[2*B]=0;for(B=0;B<b;B++)x.bl_tree[2*B]=0;x.dyn_ltree[2*y]=1,x.opt_len=x.static_len=0,x.last_lit=x.matches=0}function re(x){8<x.bi_valid?j(x,x.bi_buf):0<x.bi_valid&&(x.pending_buf[x.pending++]=x.bi_buf),x.bi_buf=0,x.bi_valid=0}function le(x,B,U,M){var N=2*B,H=2*U;return x[N]<x[H]||x[N]===x[H]&&M[B]<=M[U]}function ue(x,B,U){for(var M=x.heap[U],N=U<<1;N<=x.heap_len&&(N<x.heap_len&&le(B,x.heap[N+1],x.heap[N],x.depth)&&N++,!le(B,M,x.heap[N],x.depth));)x.heap[U]=x.heap[N],U=N,N<<=1;x.heap[U]=M}function fe(x,B,U){var M,N,H,J,$=0;if(x.last_lit!==0)for(;M=x.pending_buf[x.d_buf+2*$]<<8|x.pending_buf[x.d_buf+2*$+1],N=x.pending_buf[x.l_buf+$],$++,M===0?Z(x,N,B):(Z(x,(H=h[N])+d+1,B),(J=P[H])!==0&&W(x,N-=k[H],J),Z(x,H=v(--M),U),(J=G[H])!==0&&W(x,M-=I[H],J)),$<x.last_lit;);Z(x,y,B)}function me(x,B){var U,M,N,H=B.dyn_tree,J=B.stat_desc.static_tree,$=B.stat_desc.has_stree,Q=B.stat_desc.elems,ce=-1;for(x.heap_len=0,x.heap_max=f,U=0;U<Q;U++)H[2*U]!==0?(x.heap[++x.heap_len]=ce=U,x.depth[U]=0):H[2*U+1]=0;for(;x.heap_len<2;)H[2*(N=x.heap[++x.heap_len]=ce<2?++ce:0)]=1,x.depth[N]=0,x.opt_len--,$&&(x.static_len-=J[2*N+1]);for(B.max_code=ce,U=x.heap_len>>1;1<=U;U--)ue(x,H,U);for(N=Q;U=x.heap[1],x.heap[1]=x.heap[x.heap_len--],ue(x,H,1),M=x.heap[1],x.heap[--x.heap_max]=U,x.heap[--x.heap_max]=M,H[2*N]=H[2*U]+H[2*M],x.depth[N]=(x.depth[U]>=x.depth[M]?x.depth[U]:x.depth[M])+1,H[2*U+1]=H[2*M+1]=N,x.heap[1]=N++,ue(x,H,1),2<=x.heap_len;);x.heap[--x.heap_max]=x.heap[1],function(ne,ye){var Me,we,Oe,de,rt,Et,ve=ye.dyn_tree,fr=ye.max_code,Ei=ye.stat_desc.static_tree,Bi=ye.stat_desc.has_stree,Ii=ye.stat_desc.extra_bits,mr=ye.stat_desc.extra_base,je=ye.stat_desc.max_length,it=0;for(de=0;de<=m;de++)ne.bl_count[de]=0;for(ve[2*ne.heap[ne.heap_max]+1]=0,Me=ne.heap_max+1;Me<f;Me++)je<(de=ve[2*ve[2*(we=ne.heap[Me])+1]+1]+1)&&(de=je,it++),ve[2*we+1]=de,fr<we||(ne.bl_count[de]++,rt=0,mr<=we&&(rt=Ii[we-mr]),Et=ve[2*we],ne.opt_len+=Et*(de+rt),Bi&&(ne.static_len+=Et*(Ei[2*we+1]+rt)));if(it!==0){do{for(de=je-1;ne.bl_count[de]===0;)de--;ne.bl_count[de]--,ne.bl_count[de+1]+=2,ne.bl_count[je]--,it-=2}while(0<it);for(de=je;de!==0;de--)for(we=ne.bl_count[de];we!==0;)fr<(Oe=ne.heap[--Me])||(ve[2*Oe+1]!==de&&(ne.opt_len+=(de-ve[2*Oe+1])*ve[2*Oe],ve[2*Oe+1]=de),we--)}}(x,B),te(H,ce,x.bl_count)}function c(x,B,U){var M,N,H=-1,J=B[1],$=0,Q=7,ce=4;for(J===0&&(Q=138,ce=3),B[2*(U+1)+1]=65535,M=0;M<=U;M++)N=J,J=B[2*(M+1)+1],++$<Q&&N===J||($<ce?x.bl_tree[2*N]+=$:N!==0?(N!==H&&x.bl_tree[2*N]++,x.bl_tree[2*w]++):$<=10?x.bl_tree[2*E]++:x.bl_tree[2*z]++,H=N,ce=($=0)===J?(Q=138,3):N===J?(Q=6,3):(Q=7,4))}function L(x,B,U){var M,N,H=-1,J=B[1],$=0,Q=7,ce=4;for(J===0&&(Q=138,ce=3),M=0;M<=U;M++)if(N=J,J=B[2*(M+1)+1],!(++$<Q&&N===J)){if($<ce)for(;Z(x,N,x.bl_tree),--$!=0;);else N!==0?(N!==H&&(Z(x,N,x.bl_tree),$--),Z(x,w,x.bl_tree),W(x,$-3,2)):$<=10?(Z(x,E,x.bl_tree),W(x,$-3,3)):(Z(x,z,x.bl_tree),W(x,$-11,7));H=N,ce=($=0)===J?(Q=138,3):N===J?(Q=6,3):(Q=7,4)}}a(I);var T=!1;function _(x,B,U,M){W(x,(o<<1)+(M?1:0),3),function(N,H,J,$){re(N),$&&(j(N,J),j(N,~J)),r.arraySet(N.pending_buf,N.window,H,J,N.pending),N.pending+=J}(x,B,U,!0)}t._tr_init=function(x){T||(function(){var B,U,M,N,H,J=new Array(m+1);for(N=M=0;N<u-1;N++)for(k[N]=M,B=0;B<1<<P[N];B++)h[M++]=N;for(h[M-1]=N,N=H=0;N<16;N++)for(I[N]=H,B=0;B<1<<G[N];B++)S[H++]=N;for(H>>=7;N<l;N++)for(I[N]=H<<7,B=0;B<1<<G[N]-7;B++)S[256+H++]=N;for(U=0;U<=m;U++)J[U]=0;for(B=0;B<=143;)X[2*B+1]=8,B++,J[8]++;for(;B<=255;)X[2*B+1]=9,B++,J[9]++;for(;B<=279;)X[2*B+1]=7,B++,J[7]++;for(;B<=287;)X[2*B+1]=8,B++,J[8]++;for(te(X,p+1,J),B=0;B<l;B++)C[2*B+1]=5,C[2*B]=ee(B,5);Y=new O(X,P,d+1,p,m),F=new O(C,G,0,l,m),q=new O(new Array(0),R,0,b,A)}(),T=!0),x.l_desc=new D(x.dyn_ltree,Y),x.d_desc=new D(x.dyn_dtree,F),x.bl_desc=new D(x.bl_tree,q),x.bi_buf=0,x.bi_valid=0,K(x)},t._tr_stored_block=_,t._tr_flush_block=function(x,B,U,M){var N,H,J=0;0<x.level?(x.strm.data_type===2&&(x.strm.data_type=function($){var Q,ce=4093624447;for(Q=0;Q<=31;Q++,ce>>>=1)if(1&ce&&$.dyn_ltree[2*Q]!==0)return n;if($.dyn_ltree[18]!==0||$.dyn_ltree[20]!==0||$.dyn_ltree[26]!==0)return i;for(Q=32;Q<d;Q++)if($.dyn_ltree[2*Q]!==0)return i;return n}(x)),me(x,x.l_desc),me(x,x.d_desc),J=function($){var Q;for(c($,$.dyn_ltree,$.l_desc.max_code),c($,$.dyn_dtree,$.d_desc.max_code),me($,$.bl_desc),Q=b-1;3<=Q&&$.bl_tree[2*V[Q]+1]===0;Q--);return $.opt_len+=3*(Q+1)+5+5+4,Q}(x),N=x.opt_len+3+7>>>3,(H=x.static_len+3+7>>>3)<=N&&(N=H)):N=H=U+5,U+4<=N&&B!==-1?_(x,B,U,M):x.strategy===4||H===N?(W(x,2+(M?1:0),3),fe(x,X,C)):(W(x,4+(M?1:0),3),function($,Q,ce,ne){var ye;for(W($,Q-257,5),W($,ce-1,5),W($,ne-4,4),ye=0;ye<ne;ye++)W($,$.bl_tree[2*V[ye]+1],3);L($,$.dyn_ltree,Q-1),L($,$.dyn_dtree,ce-1)}(x,x.l_desc.max_code+1,x.d_desc.max_code+1,J+1),fe(x,x.dyn_ltree,x.dyn_dtree)),K(x),M&&re(x)},t._tr_tally=function(x,B,U){return x.pending_buf[x.d_buf+2*x.last_lit]=B>>>8&255,x.pending_buf[x.d_buf+2*x.last_lit+1]=255&B,x.pending_buf[x.l_buf+x.last_lit]=255&U,x.last_lit++,B===0?x.dyn_ltree[2*U]++:(x.matches++,B--,x.dyn_ltree[2*(h[U]+d+1)]++,x.dyn_dtree[2*v(B)]++),x.last_lit===x.lit_bufsize-1},t._tr_align=function(x){W(x,2,3),Z(x,y,X),function(B){B.bi_valid===16?(j(B,B.bi_buf),B.bi_buf=0,B.bi_valid=0):8<=B.bi_valid&&(B.pending_buf[B.pending++]=255&B.bi_buf,B.bi_buf>>=8,B.bi_valid-=8)}(x)}},{"../utils/common":41}],53:[function(s,e,t){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(s,e,t){(function(r){(function(n,i){"use strict";if(!n.setImmediate){var a,o,u,d,p=1,l={},b=!1,f=n.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(n);m=m&&m.setTimeout?m:n,a={}.toString.call(n.process)==="[object process]"?function(w){process.nextTick(function(){A(w)})}:function(){if(n.postMessage&&!n.importScripts){var w=!0,E=n.onmessage;return n.onmessage=function(){w=!1},n.postMessage("","*"),n.onmessage=E,w}}()?(d="setImmediate$"+Math.random()+"$",n.addEventListener?n.addEventListener("message",y,!1):n.attachEvent("onmessage",y),function(w){n.postMessage(d+w,"*")}):n.MessageChannel?((u=new MessageChannel).port1.onmessage=function(w){A(w.data)},function(w){u.port2.postMessage(w)}):f&&"onreadystatechange"in f.createElement("script")?(o=f.documentElement,function(w){var E=f.createElement("script");E.onreadystatechange=function(){A(w),E.onreadystatechange=null,o.removeChild(E),E=null},o.appendChild(E)}):function(w){setTimeout(A,0,w)},m.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var E=new Array(arguments.length-1),z=0;z<E.length;z++)E[z]=arguments[z+1];var P={callback:w,args:E};return l[p]=P,a(p),p++},m.clearImmediate=g}function g(w){delete l[w]}function A(w){if(b)setTimeout(A,0,w);else{var E=l[w];if(E){b=!0;try{(function(z){var P=z.callback,G=z.args;switch(G.length){case 0:P();break;case 1:P(G[0]);break;case 2:P(G[0],G[1]);break;case 3:P(G[0],G[1],G[2]);break;default:P.apply(i,G)}})(E)}finally{g(w),b=!1}}}}function y(w){w.source===n&&typeof w.data=="string"&&w.data.indexOf(d)===0&&A(+w.data.slice(d.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})});var Tt=ge(Ee=>{"use strict";var xr=":A-Za-z_\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D\\\\u037F-\\\\u1FFF\\\\u200C-\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD",Ui=xr+"\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040",yr="["+xr+"]["+Ui+"]*",Vi=new RegExp("^"+yr+"$"),Mi=function(s,e){let t=[],r=e.exec(s);for(;r;){let n=[];n.startIndex=e.lastIndex-r[0].length;let i=r.length;for(let a=0;a<i;a++)n.push(r[a]);t.push(n),r=e.exec(s)}return t},Oi=function(s){let e=Vi.exec(s);return!(e===null||typeof e>"u")};Ee.isExist=function(s){return typeof s<"u"};Ee.isEmptyObject=function(s){return Object.keys(s).length===0};Ee.merge=function(s,e,t){if(e){let r=Object.keys(e),n=r.length;for(let i=0;i<n;i++)t==="strict"?s[r[i]]=[e[r[i]]]:s[r[i]]=e[r[i]]}};Ee.getValue=function(s){return Ee.isExist(s)?s:""};Ee.isName=Oi;Ee.getAllMatches=Mi;Ee.nameRegexp=yr});var Rt=ge(vr=>{"use strict";var Pt=Tt(),ji={allowBooleanAttributes:!1,unpairedTags:[]};vr.validate=function(s,e){e=Object.assign({},ji,e);let t=[],r=!1,n=!1;s[0]==="\\uFEFF"&&(s=s.substr(1));for(let i=0;i<s.length;i++)if(s[i]==="<"&&s[i+1]==="?"){if(i+=2,i=_r(s,i),i.err)return i}else if(s[i]==="<"){let a=i;if(i++,s[i]==="!"){i=Dr(s,i);continue}else{let o=!1;s[i]==="/"&&(o=!0,i++);let u="";for(;i<s.length&&s[i]!==">"&&s[i]!==" "&&s[i]!==" "&&s[i]!==`\n`&&s[i]!=="\\r";i++)u+=s[i];if(u=u.trim(),u[u.length-1]==="/"&&(u=u.substring(0,u.length-1),i--),!Ki(u)){let l;return u.trim().length===0?l="Invalid space after \'<\'.":l="Tag \'"+u+"\' is an invalid name.",he("InvalidTag",l,be(s,i))}let d=$i(s,i);if(d===!1)return he("InvalidAttr","Attributes for \'"+u+"\' have open quote.",be(s,i));let p=d.value;if(i=d.index,p[p.length-1]==="/"){let l=i-p.length;p=p.substring(0,p.length-1);let b=Cr(p,e);if(b===!0)r=!0;else return he(b.err.code,b.err.msg,be(s,l+b.err.line))}else if(o)if(d.tagClosed){if(p.trim().length>0)return he("InvalidTag","Closing tag \'"+u+"\' can\'t have attributes or invalid starting.",be(s,a));{let l=t.pop();if(u!==l.tagName){let b=be(s,l.tagStartPos);return he("InvalidTag","Expected closing tag \'"+l.tagName+"\' (opened in line "+b.line+", col "+b.col+") instead of closing tag \'"+u+"\'.",be(s,a))}t.length==0&&(n=!0)}}else return he("InvalidTag","Closing tag \'"+u+"\' doesn\'t have proper closing.",be(s,i));else{let l=Cr(p,e);if(l!==!0)return he(l.err.code,l.err.msg,be(s,i-p.length+l.err.line));if(n===!0)return he("InvalidXml","Multiple possible root nodes found.",be(s,i));e.unpairedTags.indexOf(u)!==-1||t.push({tagName:u,tagStartPos:a}),r=!0}for(i++;i<s.length;i++)if(s[i]==="<")if(s[i+1]==="!"){i++,i=Dr(s,i);continue}else if(s[i+1]==="?"){if(i=_r(s,++i),i.err)return i}else break;else if(s[i]==="&"){let l=Xi(s,i);if(l==-1)return he("InvalidChar","char \'&\' is not expected.",be(s,i));i=l}else if(n===!0&&!wr(s[i]))return he("InvalidXml","Extra text at the end",be(s,i));s[i]==="<"&&i--}}else{if(wr(s[i]))continue;return he("InvalidChar","char \'"+s[i]+"\' is not expected.",be(s,i))}if(r){if(t.length==1)return he("InvalidTag","Unclosed tag \'"+t[0].tagName+"\'.",be(s,t[0].tagStartPos));if(t.length>0)return he("InvalidXml","Invalid \'"+JSON.stringify(t.map(i=>i.tagName),null,4).replace(/\\r?\\n/g,"")+"\' found.",{line:1,col:1})}else return he("InvalidXml","Start tag expected.",1);return!0};function wr(s){return s===" "||s===" "||s===`\n`||s==="\\r"}function _r(s,e){let t=e;for(;e<s.length;e++)if(s[e]=="?"||s[e]==" "){let r=s.substr(t,e-t);if(e>5&&r==="xml")return he("InvalidXml","XML declaration allowed only at the start of the document.",be(s,e));if(s[e]=="?"&&s[e+1]==">"){e++;break}else continue}return e}function Dr(s,e){if(s.length>e+5&&s[e+1]==="-"&&s[e+2]==="-"){for(e+=3;e<s.length;e++)if(s[e]==="-"&&s[e+1]==="-"&&s[e+2]===">"){e+=2;break}}else if(s.length>e+8&&s[e+1]==="D"&&s[e+2]==="O"&&s[e+3]==="C"&&s[e+4]==="T"&&s[e+5]==="Y"&&s[e+6]==="P"&&s[e+7]==="E"){let t=1;for(e+=8;e<s.length;e++)if(s[e]==="<")t++;else if(s[e]===">"&&(t--,t===0))break}else if(s.length>e+9&&s[e+1]==="["&&s[e+2]==="C"&&s[e+3]==="D"&&s[e+4]==="A"&&s[e+5]==="T"&&s[e+6]==="A"&&s[e+7]==="["){for(e+=8;e<s.length;e++)if(s[e]==="]"&&s[e+1]==="]"&&s[e+2]===">"){e+=2;break}}return e}var Yi=\'"\',Hi="\'";function $i(s,e){let t="",r="",n=!1;for(;e<s.length;e++){if(s[e]===Yi||s[e]===Hi)r===""?r=s[e]:r!==s[e]||(r="");else if(s[e]===">"&&r===""){n=!0;break}t+=s[e]}return r!==""?!1:{value:t,index:e,tagClosed:n}}var qi=new RegExp(`(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*([\'"])(([\\\\s\\\\S])*?)\\\\5)?`,"g");function Cr(s,e){let t=Pt.getAllMatches(s,qi),r={};for(let n=0;n<t.length;n++){if(t[n][1].length===0)return he("InvalidAttr","Attribute \'"+t[n][2]+"\' has no space in starting.",qe(t[n]));if(t[n][3]!==void 0&&t[n][4]===void 0)return he("InvalidAttr","Attribute \'"+t[n][2]+"\' is without value.",qe(t[n]));if(t[n][3]===void 0&&!e.allowBooleanAttributes)return he("InvalidAttr","boolean attribute \'"+t[n][2]+"\' is not allowed.",qe(t[n]));let i=t[n][2];if(!Qi(i))return he("InvalidAttr","Attribute \'"+i+"\' is an invalid name.",qe(t[n]));if(!r.hasOwnProperty(i))r[i]=1;else return he("InvalidAttr","Attribute \'"+i+"\' is repeated.",qe(t[n]))}return!0}function Ji(s,e){let t=/\\d/;for(s[e]==="x"&&(e++,t=/[\\da-fA-F]/);e<s.length;e++){if(s[e]===";")return e;if(!s[e].match(t))break}return-1}function Xi(s,e){if(e++,s[e]===";")return-1;if(s[e]==="#")return e++,Ji(s,e);let t=0;for(;e<s.length;e++,t++)if(!(s[e].match(/\\w/)&&t<20)){if(s[e]===";")break;return-1}return e}function he(s,e,t){return{err:{code:s,msg:e,line:t.line||t,col:t.col}}}function Qi(s){return Pt.isName(s)}function Ki(s){return Pt.isName(s)}function be(s,e){let t=s.substring(0,e).split(/\\r?\\n/);return{line:t.length,col:t[t.length-1].length+1}}function qe(s){return s.startIndex+s[1].length}});var Br=ge(Zt=>{var Er={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0},tagValueProcessor:function(s,e){return e},attributeValueProcessor:function(s,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1},en=function(s){return Object.assign({},Er,s)};Zt.buildOptions=en;Zt.defaultOptions=Er});var kr=ge((wa,Ir)=>{"use strict";var zt=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){this.child.push({[e]:t})}addChild(e){e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child})}};Ir.exports=zt});var Fr=ge((_a,Nr)=>{function tn(s,e){let t={};if(s[e+3]==="O"&&s[e+4]==="C"&&s[e+5]==="T"&&s[e+6]==="Y"&&s[e+7]==="P"&&s[e+8]==="E"){e=e+9;let r=1,n=!1,i=!1,a=!1,o="";for(;e<s.length;e++)if(s[e]==="<"){if(n&&s[e+1]==="!"&&s[e+2]==="E"&&s[e+3]==="N"&&s[e+4]==="T"&&s[e+5]==="I"&&s[e+6]==="T"&&s[e+7]==="Y")e+=7,i=!0;else if(n&&s[e+1]==="!"&&s[e+2]==="E"&&s[e+3]==="L"&&s[e+4]==="E"&&s[e+5]==="M"&&s[e+6]==="E"&&s[e+7]==="N"&&s[e+8]==="T")e+=8;else if(n&&s[e+1]==="!"&&s[e+2]==="A"&&s[e+3]==="T"&&s[e+4]==="T"&&s[e+5]==="L"&&s[e+6]==="I"&&s[e+7]==="S"&&s[e+8]==="T")e+=8;else if(n&&s[e+1]==="!"&&s[e+2]==="N"&&s[e+3]==="O"&&s[e+4]==="T"&&s[e+5]==="A"&&s[e+6]==="T"&&s[e+7]==="I"&&s[e+8]==="O"&&s[e+9]==="N")e+=9;else if(s[e+1]==="!"&&s[e+2]==="-"&&s[e+3]==="-")a=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(s[e]===">"){if(a)if(s[e-1]==="-"&&s[e-2]==="-")a=!1;else throw new Error("Invalid XML comment in DOCTYPE");else i&&(nn(o,t),i=!1);if(r--,r===0)break}else s[e]==="["?n=!0:o+=s[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:t,i:e}}var rn=RegExp(`^\\\\s([a-zA-z0-0]+)[ ]([\'"])([^&]+)\\\\2`);function nn(s,e){let t=rn.exec(s);t&&(e[t[1]]={regx:RegExp(`&${t[1]};`,"g"),val:t[3]})}Nr.exports=tn});var Tr=ge((Da,Sr)=>{var sn=/^[-+]?0x[a-fA-F0-9]+$/,an=/^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var on={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function un(s,e={}){if(e=Object.assign({},on,e),!s||typeof s!="string")return s;let t=s.trim();if(e.skipLike!==void 0&&e.skipLike.test(t))return s;if(e.hex&&sn.test(t))return Number.parseInt(t,16);{let r=an.exec(t);if(r){let n=r[1],i=r[2],a=ln(r[3]),o=r[4]||r[6];if(!e.leadingZeros&&i.length>0&&n&&t[2]!==".")return s;if(!e.leadingZeros&&i.length>0&&!n&&t[1]!==".")return s;{let u=Number(t),d=""+u;return d.search(/[eE]/)!==-1||o?e.eNotation?u:s:t.indexOf(".")!==-1?d==="0"&&a===""||d===a||n&&d==="-"+a?u:s:i?a===d||n+a===d?u:s:t===d||t===n+d?u:s}}else return s}}function ln(s){return s&&s.indexOf(".")!==-1&&(s=s.replace(/0+$/,""),s==="."?s="0":s[0]==="."?s="0"+s:s[s.length-1]==="."&&(s=s.substr(0,s.length-1))),s}Sr.exports=un});var Rr=ge((va,Pr)=>{"use strict";var Ut=Tt(),Je=kr(),cn=Fr(),dn=Tr(),Ca="<((!\\\\[CDATA\\\\[([\\\\s\\\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\\\/)(NAME)\\\\s*>))([^<]*)".replace(/NAME/g,Ut.nameRegexp),Lt=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={amp:{regex:/&(amp|#38|#x26);/g,val:"&"},apos:{regex:/&(apos|#39|#x27);/g,val:"\'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:\'"\'}},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\\xA2"},pound:{regex:/&(pound|#163);/g,val:"\\xA3"},yen:{regex:/&(yen|#165);/g,val:"\\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\\xA9"},reg:{regex:/&(reg|#174);/g,val:"\\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\\u20B9"}},this.addExternalEntities=hn,this.parseXml=bn,this.parseTextData=pn,this.resolveNameSpace=fn,this.buildAttributesMap=gn,this.isItStopNode=yn,this.replaceEntitiesValue=An,this.readStopNodeData=_n,this.saveTextToParentTag=xn}};function hn(s){let e=Object.keys(s);for(let t=0;t<e.length;t++){let r=e[t];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:s[r]}}}function pn(s,e,t,r,n,i,a){if(s!==void 0&&(this.options.trimValues&&!r&&(s=s.trim()),s.length>0)){a||(s=this.replaceEntitiesValue(s));let o=this.options.tagValueProcessor(e,s,t,n,i);return o==null?s:typeof o!=typeof s||o!==s?o:this.options.trimValues?Gt(s,this.options.parseTagValue,this.options.numberParseOptions):s.trim()===s?Gt(s,this.options.parseTagValue,this.options.numberParseOptions):s}}function fn(s){if(this.options.removeNSPrefix){let e=s.split(":"),t=s.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(s=t+e[1])}return s}var mn=new RegExp(`([^\\\\s=]+)\\\\s*(=\\\\s*([\'"])([\\\\s\\\\S]*?)\\\\3)?`,"gm");function gn(s,e){if(!this.options.ignoreAttributes&&typeof s=="string"){let t=Ut.getAllMatches(s,mn),r=t.length,n={};for(let i=0;i<r;i++){let a=this.resolveNameSpace(t[i][1]),o=t[i][4],u=this.options.attributeNamePrefix+a;if(a.length)if(o!==void 0){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);let d=this.options.attributeValueProcessor(a,o,e);d==null?n[u]=o:typeof d!=typeof o||d!==o?n[u]=d:n[u]=Gt(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[u]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){let i={};return i[this.options.attributesGroupName]=n,i}return n}}var bn=function(s){s=s.replace(/\\r\\n?/g,`\n`);let e=new Je("!xml"),t=e,r="",n="";for(let i=0;i<s.length;i++)if(s[i]==="<")if(s[i+1]==="/"){let o=Re(s,">",i,"Closing Tag is not closed."),u=s.substring(i+2,o).trim();if(this.options.removeNSPrefix){let d=u.indexOf(":");d!==-1&&(u=u.substr(d+1))}this.options.transformTagName&&(u=this.options.transformTagName(u)),t&&(r=this.saveTextToParentTag(r,t,n)),n=n.substr(0,n.lastIndexOf(".")),t=this.tagsNodeStack.pop(),r="",i=o}else if(s[i+1]==="?"){let o=Wt(s,i,!1,"?>");if(!o)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,t,n),!(this.options.ignoreDeclaration&&o.tagName==="?xml"||this.options.ignorePiTags)){let u=new Je(o.tagName);u.add(this.options.textNodeName,""),o.tagName!==o.tagExp&&o.attrExpPresent&&(u[":@"]=this.buildAttributesMap(o.tagExp,n)),t.addChild(u)}i=o.closeIndex+1}else if(s.substr(i+1,3)==="!--"){let o=Re(s,"-->",i+4,"Comment is not closed.");if(this.options.commentPropName){let u=s.substring(i+4,o-2);r=this.saveTextToParentTag(r,t,n),t.add(this.options.commentPropName,[{[this.options.textNodeName]:u}])}i=o}else if(s.substr(i+1,2)==="!D"){let o=cn(s,i);this.docTypeEntities=o.entities,i=o.i}else if(s.substr(i+1,2)==="!["){let o=Re(s,"]]>",i,"CDATA is not closed.")-2,u=s.substring(i+9,o);if(r=this.saveTextToParentTag(r,t,n),this.options.cdataPropName)t.add(this.options.cdataPropName,[{[this.options.textNodeName]:u}]);else{let d=this.parseTextData(u,t.tagname,n,!0,!1,!0);d==null&&(d=""),t.add(this.options.textNodeName,d)}i=o+2}else{let o=Wt(s,i,this.options.removeNSPrefix),u=o.tagName,d=o.tagExp,p=o.attrExpPresent,l=o.closeIndex;this.options.transformTagName&&(u=this.options.transformTagName(u)),t&&r&&t.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,t,n,!1)),u!==e.tagname&&(n+=n?"."+u:u);let b=t;if(b&&this.options.unpairedTags.indexOf(b.tagname)!==-1&&(t=this.tagsNodeStack.pop()),this.isItStopNode(this.options.stopNodes,n,u)){let f="";if(d.length>0&&d.lastIndexOf("/")===d.length-1)i=o.closeIndex;else if(this.options.unpairedTags.indexOf(u)!==-1)i=o.closeIndex;else{let g=this.readStopNodeData(s,u,l+1);if(!g)throw new Error(`Unexpected end of ${u}`);i=g.i,f=g.tagContent}let m=new Je(u);u!==d&&p&&(m[":@"]=this.buildAttributesMap(d,n)),f&&(f=this.parseTextData(f,u,n,!0,p,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),m.add(this.options.textNodeName,f),t.addChild(m)}else{if(d.length>0&&d.lastIndexOf("/")===d.length-1){u[u.length-1]==="/"?(u=u.substr(0,u.length-1),d=u):d=d.substr(0,d.length-1),this.options.transformTagName&&(u=this.options.transformTagName(u));let f=new Je(u);u!==d&&p&&(f[":@"]=this.buildAttributesMap(d,n)),n=n.substr(0,n.lastIndexOf(".")),t.addChild(f)}else{let f=new Je(u);this.tagsNodeStack.push(t),u!==d&&p&&(f[":@"]=this.buildAttributesMap(d,n)),t.addChild(f),t=f}r="",i=l}}else r+=s[i];return e.child},An=function(s){if(this.options.processEntities){for(let e in this.docTypeEntities){let t=this.docTypeEntities[e];s=s.replace(t.regx,t.val)}for(let e in this.lastEntities){let t=this.lastEntities[e];s=s.replace(t.regex,t.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){let t=this.htmlEntities[e];s=s.replace(t.regex,t.val)}}return s};function xn(s,e,t,r){return s&&(r===void 0&&(r=Object.keys(e.child).length===0),s=this.parseTextData(s,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),s!==void 0&&s!==""&&e.add(this.options.textNodeName,s),s=""),s}function yn(s,e,t){let r="*."+t;for(let n in s){let i=s[n];if(r===i||e===i)return!0}return!1}function wn(s,e,t=">"){let r,n="";for(let i=e;i<s.length;i++){let a=s[i];if(r)a===r&&(r="");else if(a===\'"\'||a==="\'")r=a;else if(a===t[0])if(t[1]){if(s[i+1]===t[1])return{data:n,index:i}}else return{data:n,index:i};else a===" "&&(a=" ");n+=a}}function Re(s,e,t,r){let n=s.indexOf(e,t);if(n===-1)throw new Error(r);return n+e.length-1}function Wt(s,e,t,r=">"){let n=wn(s,e+1,r);if(!n)return;let i=n.data,a=n.index,o=i.search(/\\s/),u=i,d=!0;if(o!==-1&&(u=i.substr(0,o).replace(/\\s\\s*$/,""),i=i.substr(o+1)),t){let p=u.indexOf(":");p!==-1&&(u=u.substr(p+1),d=u!==n.data.substr(p+1))}return{tagName:u,tagExp:i,closeIndex:a,attrExpPresent:d}}function _n(s,e,t){let r=t,n=1;for(;t<s.length;t++)if(s[t]==="<")if(s[t+1]==="/"){let i=Re(s,">",t,`${e} is not closed`);if(s.substring(t+2,i).trim()===e&&(n--,n===0))return{tagContent:s.substring(r,t),i};t=i}else if(s[t+1]==="?")t=Re(s,"?>",t+1,"StopNode is not closed.");else if(s.substr(t+1,3)==="!--")t=Re(s,"-->",t+3,"StopNode is not closed.");else if(s.substr(t+1,2)==="![")t=Re(s,"]]>",t,"StopNode is not closed.")-2;else{let i=Wt(s,t,">");i&&((i&&i.tagName)===e&&i.tagExp[i.tagExp.length-1]!=="/"&&n++,t=i.closeIndex)}}function Gt(s,e,t){if(e&&typeof s=="string"){let r=s.trim();return r==="true"?!0:r==="false"?!1:dn(s,t)}else return Ut.isExist(s)?s:""}Pr.exports=Lt});var Lr=ge(zr=>{"use strict";function Dn(s,e){return Zr(s,e)}function Zr(s,e,t){let r,n={};for(let i=0;i<s.length;i++){let a=s[i],o=Cn(a),u="";if(t===void 0?u=o:u=t+"."+o,o===e.textNodeName)r===void 0?r=a[o]:r+=""+a[o];else{if(o===void 0)continue;if(a[o]){let d=Zr(a[o],e,u),p=En(d,e);a[":@"]?vn(d,a[":@"],u,e):Object.keys(d).length===1&&d[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?d=d[e.textNodeName]:Object.keys(d).length===0&&(e.alwaysCreateTextNode?d[e.textNodeName]="":d=""),n[o]!==void 0&&n.hasOwnProperty(o)?(Array.isArray(n[o])||(n[o]=[n[o]]),n[o].push(d)):e.isArray(o,u,p)?n[o]=[d]:n[o]=d}}}return typeof r=="string"?r.length>0&&(n[e.textNodeName]=r):r!==void 0&&(n[e.textNodeName]=r),n}function Cn(s){let e=Object.keys(s);for(let t=0;t<e.length;t++){let r=e[t];if(r!==":@")return r}}function vn(s,e,t,r){if(e){let n=Object.keys(e),i=n.length;for(let a=0;a<i;a++){let o=n[a];r.isArray(o,t+"."+o,!0,!0)?s[o]=[e[o]]:s[o]=e[o]}}}function En(s,e){let t=Object.keys(s).length;return!!(t===0||t===1&&s[e.textNodeName])}zr.prettify=Dn});var Gr=ge((Ba,Wr)=>{var{buildOptions:Bn}=Br(),In=Rr(),{prettify:kn}=Lr(),Nn=Rt(),Vt=class{constructor(e){this.externalEntities={},this.options=Bn(e)}parse(e,t){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});let i=Nn.validate(e,t);if(i!==!0)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}let r=new In(this.options);r.addExternalEntities(this.externalEntities);let n=r.parseXml(e);return this.options.preserveOrder||n===void 0?n:kn(n,this.options)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can\'t have \'&\'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without \'&\' and \';\'. Eg. use \'#xD\' for \'
\'");this.externalEntities[e]=t}};Wr.exports=Vt});var jr=ge((Ia,Or)=>{var Fn=`\n`;function Sn(s,e){return Vr(s,e,"",0)}function Vr(s,e,t,r){let n="",i="";e.format&&e.indentBy.length>0&&(i=Fn+""+e.indentBy.repeat(r));for(let a=0;a<s.length;a++){let o=s[a],u=Tn(o),d="";if(t.length===0?d=u:d=`${t}.${u}`,u===e.textNodeName){let f=o[u];Pn(d,e)||(f=e.tagValueProcessor(u,f),f=Mr(f,e)),n+=i+f;continue}else if(u===e.cdataPropName){n+=i+`<![CDATA[${o[u][0][e.textNodeName]}]]>`;continue}else if(u===e.commentPropName){n+=i+`<!--${o[u][0][e.textNodeName]}-->`;continue}else if(u[0]==="?"){let f=Ur(o[":@"],e),m=u==="?xml"?"":i,g=o[u][0][e.textNodeName];g=g.length!==0?" "+g:"",n+=m+`<${u}${g}${f}?>`;continue}let p=Ur(o[":@"],e),l=i+`<${u}${p}`,b=Vr(o[u],e,d,r+1);e.unpairedTags.indexOf(u)!==-1?e.suppressUnpairedNode?n+=l+">":n+=l+"/>":(!b||b.length===0)&&e.suppressEmptyNode?n+=l+"/>":n+=l+`>${b}${i}</${u}>`}return n}function Tn(s){let e=Object.keys(s);for(let t=0;t<e.length;t++){let r=e[t];if(r!==":@")return r}}function Ur(s,e){let t="";if(s&&!e.ignoreAttributes)for(let r in s){let n=e.attributeValueProcessor(r,s[r]);n=Mr(n,e),n===!0&&e.suppressBooleanAttributes?t+=` ${r.substr(e.attributeNamePrefix.length)}`:t+=` ${r.substr(e.attributeNamePrefix.length)}="${n}"`}return t}function Pn(s,e){s=s.substr(0,s.length-e.textNodeName.length-1);let t=s.substr(s.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===s||e.stopNodes[r]==="*."+t)return!0;return!1}function Mr(s,e){if(s&&s.length>0&&e.processEntities)for(let t=0;t<e.entities.length;t++){let r=e.entities[t];s=s.replace(r.regex,r.val)}return s}Or.exports=Sn});var qr=ge((ka,$r)=>{"use strict";var Rn=jr(),Zn={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(s,e){return e},attributeValueProcessor:function(s,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("\'","g"),val:"'"},{regex:new RegExp(\'"\',"g"),val:"""}],processEntities:!0,stopNodes:[],transformTagName:!1};function Mt(s){this.options=Object.assign({},Zn,s),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Mn),this.processTextOrObjNode=Ln,this.options.format?(this.indentate=Vn,this.tagEndChar=`>\n`,this.newLine=`\n`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine=""),this.options.suppressEmptyNode?(this.buildTextNode=Un,this.buildObjNode=Wn):(this.buildTextNode=Hr,this.buildObjNode=Yr),this.buildTextValNode=Hr,this.buildObjectNode=Yr,this.replaceEntitiesValue=Gn,this.buildAttrPairStr=zn}Mt.prototype.build=function(s){return this.options.preserveOrder?Rn(s,this.options):(Array.isArray(s)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(s={[this.options.arrayNodeName]:s}),this.j2x(s,0).val)};Mt.prototype.j2x=function(s,e){let t="",r="";for(let n in s)if(!(typeof s[n]>"u"))if(s[n]===null)n[0]==="?"?r+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+n+"/"+this.tagEndChar;else if(s[n]instanceof Date)r+=this.buildTextNode(s[n],n,"",e);else if(typeof s[n]!="object"){let i=this.isAttribute(n);if(i)t+=this.buildAttrPairStr(i,""+s[n]);else if(n===this.options.textNodeName){let a=this.options.tagValueProcessor(n,""+s[n]);r+=this.replaceEntitiesValue(a)}else r+=this.buildTextNode(s[n],n,"",e)}else if(Array.isArray(s[n])){let i=s[n].length;for(let a=0;a<i;a++){let o=s[n][a];typeof o>"u"||(o===null?n[0]==="?"?r+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+n+"/"+this.tagEndChar:typeof o=="object"?r+=this.processTextOrObjNode(o,n,e):r+=this.buildTextNode(o,n,"",e))}}else if(this.options.attributesGroupName&&n===this.options.attributesGroupName){let i=Object.keys(s[n]),a=i.length;for(let o=0;o<a;o++)t+=this.buildAttrPairStr(i[o],""+s[n][i[o]])}else r+=this.processTextOrObjNode(s[n],n,e);return{attrStr:t,val:r}};function zn(s,e){return e=this.options.attributeValueProcessor(s,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+s:" "+s+\'="\'+e+\'"\'}function Ln(s,e,t){let r=this.j2x(s,t+1);return s[this.options.textNodeName]!==void 0&&Object.keys(s).length===1?this.buildTextNode(s[this.options.textNodeName],e,r.attrStr,t):this.buildObjNode(r.val,e,r.attrStr,t)}function Yr(s,e,t,r){let n="</"+e+this.tagEndChar,i="";return e[0]==="?"&&(i="?",n=""),t&&s.indexOf("<")===-1?this.indentate(r)+"<"+e+t+i+">"+s+n:this.options.commentPropName!==!1&&e===this.options.commentPropName&&i.length===0?this.indentate(r)+`<!--${s}-->`+this.newLine:this.indentate(r)+"<"+e+t+i+this.tagEndChar+s+this.indentate(r)+n}function Wn(s,e,t,r){return s!==""?this.buildObjectNode(s,e,t,r):e[0]==="?"?this.indentate(r)+"<"+e+t+"?"+this.tagEndChar:this.indentate(r)+"<"+e+t+"/"+this.tagEndChar}function Hr(s,e,t,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${s}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${s}-->`+this.newLine;{let n=this.options.tagValueProcessor(e,s);return n=this.replaceEntitiesValue(n),n===""&&this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode?this.indentate(r)+"<"+e+this.tagEndChar:this.indentate(r)+"<"+e+"/"+this.tagEndChar:this.indentate(r)+"<"+e+t+">"+n+"</"+e+this.tagEndChar}}function Gn(s){if(s&&s.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){let t=this.options.entities[e];s=s.replace(t.regex,t.val)}return s}function Un(s,e,t,r){return s===""&&this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode?this.indentate(r)+"<"+e+this.tagEndChar:this.indentate(r)+"<"+e+"/"+this.tagEndChar:s!==""?this.buildTextValNode(s,e,t,r):e[0]==="?"?this.indentate(r)+"<"+e+t+"?"+this.tagEndChar:this.indentate(r)+"<"+e+t+"/"+this.tagEndChar}function Vn(s){return this.options.indentBy.repeat(s)}function Mn(s){return s.startsWith(this.options.attributeNamePrefix)?s.substr(this.attrPrefixLen):!1}$r.exports=Mt});var ut=ge((Na,Jr)=>{"use strict";var On=Rt(),jn=Gr(),Yn=qr();Jr.exports={XMLParser:jn,XMLValidator:On,XMLBuilder:Yn}});var Di=Fe(st()),Ci=Fe(kt());var at=s=>{let e=Math.floor((s-5)/7*100+.5)/100;return Math.floor((e*7+5)/7*256)/256},Nt=s=>Math.floor((256*s+Math.floor(18.285714285714285))/256*7);var br="UEsDBAoAAAAAAAAAIQBi7p1okAQAAJAEAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjxUeXBlcyB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3BhY2thZ2UvMjAwNi9jb250ZW50LXR5cGVzIj48RGVmYXVsdCBFeHRlbnNpb249InJlbHMiIENvbnRlbnRUeXBlPSJhcHBsaWNhdGlvbi92bmQub3BlbnhtbGZvcm1hdHMtcGFja2FnZS5yZWxhdGlvbnNoaXBzK3htbCIvPjxEZWZhdWx0IEV4dGVuc2lvbj0ieG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24veG1sIi8+PE92ZXJyaWRlIFBhcnROYW1lPSIveGwvd29ya2Jvb2sueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LnNwcmVhZHNoZWV0bWwuc2hlZXQubWFpbit4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii94bC93b3Jrc2hlZXRzL3NoZWV0MS54bWwiIENvbnRlbnRUeXBlPSJhcHBsaWNhdGlvbi92bmQub3BlbnhtbGZvcm1hdHMtb2ZmaWNlZG9jdW1lbnQuc3ByZWFkc2hlZXRtbC53b3Jrc2hlZXQreG1sIi8+PE92ZXJyaWRlIFBhcnROYW1lPSIveGwvdGhlbWUvdGhlbWUxLnhtbCIgQ29udGVudFR5cGU9ImFwcGxpY2F0aW9uL3ZuZC5vcGVueG1sZm9ybWF0cy1vZmZpY2Vkb2N1bWVudC50aGVtZSt4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii94bC9zdHlsZXMueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LnNwcmVhZHNoZWV0bWwuc3R5bGVzK3htbCIvPjxPdmVycmlkZSBQYXJ0TmFtZT0iL3hsL3NoYXJlZFN0cmluZ3MueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LnNwcmVhZHNoZWV0bWwuc2hhcmVkU3RyaW5ncyt4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii9kb2NQcm9wcy9jb3JlLnhtbCIgQ29udGVudFR5cGU9ImFwcGxpY2F0aW9uL3ZuZC5vcGVueG1sZm9ybWF0cy1wYWNrYWdlLmNvcmUtcHJvcGVydGllcyt4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii9kb2NQcm9wcy9hcHAueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LmV4dGVuZGVkLXByb3BlcnRpZXMreG1sIi8+PC9UeXBlcz5QSwMECgAAAAAAAAAhALVVMCNMAgAATAIAAAsAAABfcmVscy8ucmVsczw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjxSZWxhdGlvbnNoaXBzIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvcGFja2FnZS8yMDA2L3JlbGF0aW9uc2hpcHMiPjxSZWxhdGlvbnNoaXAgSWQ9InJJZDMiIFR5cGU9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L3JlbGF0aW9uc2hpcHMvZXh0ZW5kZWQtcHJvcGVydGllcyIgVGFyZ2V0PSJkb2NQcm9wcy9hcHAueG1sIi8+PFJlbGF0aW9uc2hpcCBJZD0icklkMiIgVHlwZT0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3BhY2thZ2UvMjAwNi9yZWxhdGlvbnNoaXBzL21ldGFkYXRhL2NvcmUtcHJvcGVydGllcyIgVGFyZ2V0PSJkb2NQcm9wcy9jb3JlLnhtbCIvPjxSZWxhdGlvbnNoaXAgSWQ9InJJZDEiIFR5cGU9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L3JlbGF0aW9uc2hpcHMvb2ZmaWNlRG9jdW1lbnQiIFRhcmdldD0ieGwvd29ya2Jvb2sueG1sIi8+PC9SZWxhdGlvbnNoaXBzPlBLAwQKAAAAAAAAACEAunCeZsoGAADKBgAADwAAAHhsL3dvcmtib29rLnhtbDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjx3b3JrYm9vayB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3NwcmVhZHNoZWV0bWwvMjAwNi9tYWluIiB4bWxuczpyPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzIiB4bWxuczptYz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL21hcmt1cC1jb21wYXRpYmlsaXR5LzIwMDYiIG1jOklnbm9yYWJsZT0ieDE1IHhyIHhyNiB4cjEwIHhyMiIgeG1sbnM6eDE1PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvbWFpbiIgeG1sbnM6eHI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAxNC9yZXZpc2lvbiIgeG1sbnM6eHI2PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTYvcmV2aXNpb242IiB4bWxuczp4cjEwPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTYvcmV2aXNpb24xMCIgeG1sbnM6eHIyPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTUvcmV2aXNpb24yIj48ZmlsZVZlcnNpb24gYXBwTmFtZT0ieGwiIGxhc3RFZGl0ZWQ9IjciIGxvd2VzdEVkaXRlZD0iNyIgcnVwQnVpbGQ9IjIxMTI2Ii8+PHdvcmtib29rUHIgZGVmYXVsdFRoZW1lVmVyc2lvbj0iMTY2OTI1Ii8+PG1jOkFsdGVybmF0ZUNvbnRlbnQgeG1sbnM6bWM9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9tYXJrdXAtY29tcGF0aWJpbGl0eS8yMDA2Ij48bWM6Q2hvaWNlIFJlcXVpcmVzPSJ4MTUiPjx4MTVhYzphYnNQYXRoIHVybD0iSDpcVFJFQlx0cmViLWV4cG9ydFx0ZW1wbGF0ZVwiIHhtbG5zOngxNWFjPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvYWMiLz48L21jOkNob2ljZT48L21jOkFsdGVybmF0ZUNvbnRlbnQ+PHhyOnJldmlzaW9uUHRyIHJldklETGFzdFNhdmU9IjAiIGRvY3VtZW50SWQ9Ijhfe0Q4NThGOUY3LTBEOTItNEFFNC04QTQyLTQ4MENCMzU5QjYyRH0iIHhyNjpjb2F1dGhWZXJzaW9uTGFzdD0iNDAiIHhyNjpjb2F1dGhWZXJzaW9uTWF4PSI0MCIgeHIxMDp1aWRMYXN0U2F2ZT0iezAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMH0iLz48Ym9va1ZpZXdzPjx3b3JrYm9va1ZpZXcgeFdpbmRvdz0iMCIgeVdpbmRvdz0iMCIgd2luZG93V2lkdGg9IjI0NTcwIiB3aW5kb3dIZWlnaHQ9IjExMTMwIiB4cjI6dWlkPSJ7REU0RTdEMzUtNDkyRC00MEQ3LTk5MjUtNDY0N0Y1ODdFMURFfSIvPjwvYm9va1ZpZXdzPjxzaGVldHM+PHNoZWV0IG5hbWU9IlNoZWV0MSIgc2hlZXRJZD0iMSIgcjppZD0icklkMSIvPjwvc2hlZXRzPjxjYWxjUHIgY2FsY0lkPSIxOTEwMjkiLz48ZXh0THN0PjxleHQgdXJpPSJ7MTQwQTcwOTQtMEUzNS00ODkyLTg0MzItQzREMkU1N0VERUI1fSIgeG1sbnM6eDE1PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvbWFpbiI+PHgxNTp3b3JrYm9va1ByIGNoYXJ0VHJhY2tpbmdSZWZCYXNlPSIxIi8+PC9leHQ+PC9leHRMc3Q+PC93b3JrYm9vaz5QSwMECgAAAAAAAAAhAIE+lJe6AgAAugIAABoAAAB4bC9fcmVscy93b3JrYm9vay54bWwucmVsczw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjxSZWxhdGlvbnNoaXBzIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvcGFja2FnZS8yMDA2L3JlbGF0aW9uc2hpcHMiPjxSZWxhdGlvbnNoaXAgSWQ9InJJZDMiIFR5cGU9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L3JlbGF0aW9uc2hpcHMvc3R5bGVzIiBUYXJnZXQ9InN0eWxlcy54bWwiLz48UmVsYXRpb25zaGlwIElkPSJySWQyIiBUeXBlPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzL3RoZW1lIiBUYXJnZXQ9InRoZW1lL3RoZW1lMS54bWwiLz48UmVsYXRpb25zaGlwIElkPSJySWQxIiBUeXBlPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzL3dvcmtzaGVldCIgVGFyZ2V0PSJ3b3Jrc2hlZXRzL3NoZWV0MS54bWwiLz48UmVsYXRpb25zaGlwIElkPSJySWQ0IiBUeXBlPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzL3NoYXJlZFN0cmluZ3MiIFRhcmdldD0ic2hhcmVkU3RyaW5ncy54bWwiLz48L1JlbGF0aW9uc2hpcHM+UEsDBAoAAAAAAAAAIQACrURzpAMAAKQDAAAYAAAAeGwvd29ya3NoZWV0cy9zaGVldDEueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPHdvcmtzaGVldCB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3NwcmVhZHNoZWV0bWwvMjAwNi9tYWluIiB4bWxuczpyPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzIiB4bWxuczptYz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL21hcmt1cC1jb21wYXRpYmlsaXR5LzIwMDYiIG1jOklnbm9yYWJsZT0ieDE0YWMgeHIgeHIyIHhyMyIgeG1sbnM6eDE0YWM9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAwOS85L2FjIiB4bWxuczp4cj0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDE0L3JldmlzaW9uIiB4bWxuczp4cjI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAxNS9yZXZpc2lvbjIiIHhtbG5zOnhyMz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDE2L3JldmlzaW9uMyIgeHI6dWlkPSJ7MEQ4RTVDQTItNUM5RS00RDRCLTk0QzUtRjM1QzA0MUYzOUJEfSI+PGRpbWVuc2lvbiByZWY9IkExIi8+PHNoZWV0Vmlld3M+PHNoZWV0VmlldyB0YWJTZWxlY3RlZD0iMSIgd29ya2Jvb2tWaWV3SWQ9IjAiLz48L3NoZWV0Vmlld3M+PHNoZWV0Rm9ybWF0UHIgZGVmYXVsdFJvd0hlaWdodD0iMTUiIHgxNGFjOmR5RGVzY2VudD0iMC4yNSIvPjxzaGVldERhdGEvPjxwYWdlTWFyZ2lucyBsZWZ0PSIwLjciIHJpZ2h0PSIwLjciIHRvcD0iMC43NSIgYm90dG9tPSIwLjc1IiBoZWFkZXI9IjAuMyIgZm9vdGVyPSIwLjMiLz48L3dvcmtzaGVldD5QSwMECgAAAAAAAAAhAMEXEL7GIAAAxiAAABMAAAB4bC90aGVtZS90aGVtZTEueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPGE6dGhlbWUgeG1sbnM6YT0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL2RyYXdpbmdtbC8yMDA2L21haW4iIG5hbWU9Ik9mZmljZSBUaGVtZSI+PGE6dGhlbWVFbGVtZW50cz48YTpjbHJTY2hlbWUgbmFtZT0iT2ZmaWNlIj48YTpkazE+PGE6c3lzQ2xyIHZhbD0id2luZG93VGV4dCIgbGFzdENscj0iMDAwMDAwIi8+PC9hOmRrMT48YTpsdDE+PGE6c3lzQ2xyIHZhbD0id2luZG93IiBsYXN0Q2xyPSJGRkZGRkYiLz48L2E6bHQxPjxhOmRrMj48YTpzcmdiQ2xyIHZhbD0iNDQ1NDZBIi8+PC9hOmRrMj48YTpsdDI+PGE6c3JnYkNsciB2YWw9IkU3RTZFNiIvPjwvYTpsdDI+PGE6YWNjZW50MT48YTpzcmdiQ2xyIHZhbD0iNDQ3MkM0Ii8+PC9hOmFjY2VudDE+PGE6YWNjZW50Mj48YTpzcmdiQ2xyIHZhbD0iRUQ3RDMxIi8+PC9hOmFjY2VudDI+PGE6YWNjZW50Mz48YTpzcmdiQ2xyIHZhbD0iQTVBNUE1Ii8+PC9hOmFjY2VudDM+PGE6YWNjZW50ND48YTpzcmdiQ2xyIHZhbD0iRkZDMDAwIi8+PC9hOmFjY2VudDQ+PGE6YWNjZW50NT48YTpzcmdiQ2xyIHZhbD0iNUI5QkQ1Ii8+PC9hOmFjY2VudDU+PGE6YWNjZW50Nj48YTpzcmdiQ2xyIHZhbD0iNzBBRDQ3Ii8+PC9hOmFjY2VudDY+PGE6aGxpbms+PGE6c3JnYkNsciB2YWw9IjA1NjNDMSIvPjwvYTpobGluaz48YTpmb2xIbGluaz48YTpzcmdiQ2xyIHZhbD0iOTU0RjcyIi8+PC9hOmZvbEhsaW5rPjwvYTpjbHJTY2hlbWU+PGE6Zm9udFNjaGVtZSBuYW1lPSJPZmZpY2UiPjxhOm1ham9yRm9udD48YTpsYXRpbiB0eXBlZmFjZT0iQ2FsaWJyaSBMaWdodCIgcGFub3NlPSIwMjBGMDMwMjAyMDIwNDAzMDIwNCIvPjxhOmVhIHR5cGVmYWNlPSIiLz48YTpjcyB0eXBlZmFjZT0iIi8+PGE6Zm9udCBzY3JpcHQ9IkpwYW4iIHR5cGVmYWNlPSLmuLjjgrTjgrfjg4Pjgq8gTGlnaHQiLz48YTpmb250IHNjcmlwdD0iSGFuZyIgdHlwZWZhY2U9IuunkeydgCDqs6DrlJUiLz48YTpmb250IHNjcmlwdD0iSGFucyIgdHlwZWZhY2U9Iuetiee6vyBMaWdodCIvPjxhOmZvbnQgc2NyaXB0PSJIYW50IiB0eXBlZmFjZT0i5paw57Sw5piO6auUIi8+PGE6Zm9udCBzY3JpcHQ9IkFyYWIiIHR5cGVmYWNlPSJUaW1lcyBOZXcgUm9tYW4iLz48YTpmb250IHNjcmlwdD0iSGViciIgdHlwZWZhY2U9IlRpbWVzIE5ldyBSb21hbiIvPjxhOmZvbnQgc2NyaXB0PSJUaGFpIiB0eXBlZmFjZT0iVGFob21hIi8+PGE6Zm9udCBzY3JpcHQ9IkV0aGkiIHR5cGVmYWNlPSJOeWFsYSIvPjxhOmZvbnQgc2NyaXB0PSJCZW5nIiB0eXBlZmFjZT0iVnJpbmRhIi8+PGE6Zm9udCBzY3JpcHQ9Ikd1anIiIHR5cGVmYWNlPSJTaHJ1dGkiLz48YTpmb250IHNjcmlwdD0iS2htciIgdHlwZWZhY2U9Ik1vb2xCb3JhbiIvPjxhOmZvbnQgc2NyaXB0PSJLbmRhIiB0eXBlZmFjZT0iVHVuZ2EiLz48YTpmb250IHNjcmlwdD0iR3VydSIgdHlwZWZhY2U9IlJhYXZpIi8+PGE6Zm9udCBzY3JpcHQ9IkNhbnMiIHR5cGVmYWNlPSJFdXBoZW1pYSIvPjxhOmZvbnQgc2NyaXB0PSJDaGVyIiB0eXBlZmFjZT0iUGxhbnRhZ2VuZXQgQ2hlcm9rZWUiLz48YTpmb250IHNjcmlwdD0iWWlpaSIgdHlwZWZhY2U9Ik1pY3Jvc29mdCBZaSBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJUaWJ0IiB0eXBlZmFjZT0iTWljcm9zb2Z0IEhpbWFsYXlhIi8+PGE6Zm9udCBzY3JpcHQ9IlRoYWEiIHR5cGVmYWNlPSJNViBCb2xpIi8+PGE6Zm9udCBzY3JpcHQ9IkRldmEiIHR5cGVmYWNlPSJNYW5nYWwiLz48YTpmb250IHNjcmlwdD0iVGVsdSIgdHlwZWZhY2U9IkdhdXRhbWkiLz48YTpmb250IHNjcmlwdD0iVGFtbCIgdHlwZWZhY2U9IkxhdGhhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cmMiIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJPcnlhIiB0eXBlZmFjZT0iS2FsaW5nYSIvPjxhOmZvbnQgc2NyaXB0PSJNbHltIiB0eXBlZmFjZT0iS2FydGlrYSIvPjxhOmZvbnQgc2NyaXB0PSJMYW9vIiB0eXBlZmFjZT0iRG9rQ2hhbXBhIi8+PGE6Zm9udCBzY3JpcHQ9IlNpbmgiIHR5cGVmYWNlPSJJc2tvb2xhIFBvdGEiLz48YTpmb250IHNjcmlwdD0iTW9uZyIgdHlwZWZhY2U9Ik1vbmdvbGlhbiBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJWaWV0IiB0eXBlZmFjZT0iVGltZXMgTmV3IFJvbWFuIi8+PGE6Zm9udCBzY3JpcHQ9IlVpZ2giIHR5cGVmYWNlPSJNaWNyb3NvZnQgVWlnaHVyIi8+PGE6Zm9udCBzY3JpcHQ9Ikdlb3IiIHR5cGVmYWNlPSJTeWxmYWVuIi8+PGE6Zm9udCBzY3JpcHQ9IkFybW4iIHR5cGVmYWNlPSJBcmlhbCIvPjxhOmZvbnQgc2NyaXB0PSJCdWdpIiB0eXBlZmFjZT0iTGVlbGF3YWRlZSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJCb3BvIiB0eXBlZmFjZT0iTWljcm9zb2Z0IEpoZW5nSGVpIi8+PGE6Zm9udCBzY3JpcHQ9IkphdmEiIHR5cGVmYWNlPSJKYXZhbmVzZSBUZXh0Ii8+PGE6Zm9udCBzY3JpcHQ9Ikxpc3UiIHR5cGVmYWNlPSJTZWdvZSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJNeW1yIiB0eXBlZmFjZT0iTXlhbm1hciBUZXh0Ii8+PGE6Zm9udCBzY3JpcHQ9Ik5rb28iIHR5cGVmYWNlPSJFYnJpbWEiLz48YTpmb250IHNjcmlwdD0iT2xjayIgdHlwZWZhY2U9Ik5pcm1hbGEgVUkiLz48YTpmb250IHNjcmlwdD0iT3NtYSIgdHlwZWZhY2U9IkVicmltYSIvPjxhOmZvbnQgc2NyaXB0PSJQaGFnIiB0eXBlZmFjZT0iUGhhZ3NwYSIvPjxhOmZvbnQgc2NyaXB0PSJTeXJuIiB0eXBlZmFjZT0iRXN0cmFuZ2VsbyBFZGVzc2EiLz48YTpmb250IHNjcmlwdD0iU3lyaiIgdHlwZWZhY2U9IkVzdHJhbmdlbG8gRWRlc3NhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cmUiIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJTb3JhIiB0eXBlZmFjZT0iTmlybWFsYSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJUYWxlIiB0eXBlZmFjZT0iTWljcm9zb2Z0IFRhaSBMZSIvPjxhOmZvbnQgc2NyaXB0PSJUYWx1IiB0eXBlZmFjZT0iTWljcm9zb2Z0IE5ldyBUYWkgTHVlIi8+PGE6Zm9udCBzY3JpcHQ9IlRmbmciIHR5cGVmYWNlPSJFYnJpbWEiLz48L2E6bWFqb3JGb250PjxhOm1pbm9yRm9udD48YTpsYXRpbiB0eXBlZmFjZT0iQ2FsaWJyaSIgcGFub3NlPSIwMjBGMDUwMjAyMDIwNDAzMDIwNCIvPjxhOmVhIHR5cGVmYWNlPSIiLz48YTpjcyB0eXBlZmFjZT0iIi8+PGE6Zm9udCBzY3JpcHQ9IkpwYW4iIHR5cGVmYWNlPSLmuLjjgrTjgrfjg4Pjgq8iLz48YTpmb250IHNjcmlwdD0iSGFuZyIgdHlwZWZhY2U9IuunkeydgCDqs6DrlJUiLz48YTpmb250IHNjcmlwdD0iSGFucyIgdHlwZWZhY2U9Iuetiee6vyIvPjxhOmZvbnQgc2NyaXB0PSJIYW50IiB0eXBlZmFjZT0i5paw57Sw5piO6auUIi8+PGE6Zm9udCBzY3JpcHQ9IkFyYWIiIHR5cGVmYWNlPSJBcmlhbCIvPjxhOmZvbnQgc2NyaXB0PSJIZWJyIiB0eXBlZmFjZT0iQXJpYWwiLz48YTpmb250IHNjcmlwdD0iVGhhaSIgdHlwZWZhY2U9IlRhaG9tYSIvPjxhOmZvbnQgc2NyaXB0PSJFdGhpIiB0eXBlZmFjZT0iTnlhbGEiLz48YTpmb250IHNjcmlwdD0iQmVuZyIgdHlwZWZhY2U9IlZyaW5kYSIvPjxhOmZvbnQgc2NyaXB0PSJHdWpyIiB0eXBlZmFjZT0iU2hydXRpIi8+PGE6Zm9udCBzY3JpcHQ9IktobXIiIHR5cGVmYWNlPSJEYXVuUGVuaCIvPjxhOmZvbnQgc2NyaXB0PSJLbmRhIiB0eXBlZmFjZT0iVHVuZ2EiLz48YTpmb250IHNjcmlwdD0iR3VydSIgdHlwZWZhY2U9IlJhYXZpIi8+PGE6Zm9udCBzY3JpcHQ9IkNhbnMiIHR5cGVmYWNlPSJFdXBoZW1pYSIvPjxhOmZvbnQgc2NyaXB0PSJDaGVyIiB0eXBlZmFjZT0iUGxhbnRhZ2VuZXQgQ2hlcm9rZWUiLz48YTpmb250IHNjcmlwdD0iWWlpaSIgdHlwZWZhY2U9Ik1pY3Jvc29mdCBZaSBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJUaWJ0IiB0eXBlZmFjZT0iTWljcm9zb2Z0IEhpbWFsYXlhIi8+PGE6Zm9udCBzY3JpcHQ9IlRoYWEiIHR5cGVmYWNlPSJNViBCb2xpIi8+PGE6Zm9udCBzY3JpcHQ9IkRldmEiIHR5cGVmYWNlPSJNYW5nYWwiLz48YTpmb250IHNjcmlwdD0iVGVsdSIgdHlwZWZhY2U9IkdhdXRhbWkiLz48YTpmb250IHNjcmlwdD0iVGFtbCIgdHlwZWZhY2U9IkxhdGhhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cmMiIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJPcnlhIiB0eXBlZmFjZT0iS2FsaW5nYSIvPjxhOmZvbnQgc2NyaXB0PSJNbHltIiB0eXBlZmFjZT0iS2FydGlrYSIvPjxhOmZvbnQgc2NyaXB0PSJMYW9vIiB0eXBlZmFjZT0iRG9rQ2hhbXBhIi8+PGE6Zm9udCBzY3JpcHQ9IlNpbmgiIHR5cGVmYWNlPSJJc2tvb2xhIFBvdGEiLz48YTpmb250IHNjcmlwdD0iTW9uZyIgdHlwZWZhY2U9Ik1vbmdvbGlhbiBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJWaWV0IiB0eXBlZmFjZT0iQXJpYWwiLz48YTpmb250IHNjcmlwdD0iVWlnaCIgdHlwZWZhY2U9Ik1pY3Jvc29mdCBVaWdodXIiLz48YTpmb250IHNjcmlwdD0iR2VvciIgdHlwZWZhY2U9IlN5bGZhZW4iLz48YTpmb250IHNjcmlwdD0iQXJtbiIgdHlwZWZhY2U9IkFyaWFsIi8+PGE6Zm9udCBzY3JpcHQ9IkJ1Z2kiIHR5cGVmYWNlPSJMZWVsYXdhZGVlIFVJIi8+PGE6Zm9udCBzY3JpcHQ9IkJvcG8iIHR5cGVmYWNlPSJNaWNyb3NvZnQgSmhlbmdIZWkiLz48YTpmb250IHNjcmlwdD0iSmF2YSIgdHlwZWZhY2U9IkphdmFuZXNlIFRleHQiLz48YTpmb250IHNjcmlwdD0iTGlzdSIgdHlwZWZhY2U9IlNlZ29lIFVJIi8+PGE6Zm9udCBzY3JpcHQ9Ik15bXIiIHR5cGVmYWNlPSJNeWFubWFyIFRleHQiLz48YTpmb250IHNjcmlwdD0iTmtvbyIgdHlwZWZhY2U9IkVicmltYSIvPjxhOmZvbnQgc2NyaXB0PSJPbGNrIiB0eXBlZmFjZT0iTmlybWFsYSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJPc21hIiB0eXBlZmFjZT0iRWJyaW1hIi8+PGE6Zm9udCBzY3JpcHQ9IlBoYWciIHR5cGVmYWNlPSJQaGFnc3BhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cm4iIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJTeXJqIiB0eXBlZmFjZT0iRXN0cmFuZ2VsbyBFZGVzc2EiLz48YTpmb250IHNjcmlwdD0iU3lyZSIgdHlwZWZhY2U9IkVzdHJhbmdlbG8gRWRlc3NhIi8+PGE6Zm9udCBzY3JpcHQ9IlNvcmEiIHR5cGVmYWNlPSJOaXJtYWxhIFVJIi8+PGE6Zm9udCBzY3JpcHQ9IlRhbGUiIHR5cGVmYWNlPSJNaWNyb3NvZnQgVGFpIExlIi8+PGE6Zm9udCBzY3JpcHQ9IlRhbHUiIHR5cGVmYWNlPSJNaWNyb3NvZnQgTmV3IFRhaSBMdWUiLz48YTpmb250IHNjcmlwdD0iVGZuZyIgdHlwZWZhY2U9IkVicmltYSIvPjwvYTptaW5vckZvbnQ+PC9hOmZvbnRTY2hlbWU+PGE6Zm10U2NoZW1lIG5hbWU9Ik9mZmljZSI+PGE6ZmlsbFN0eWxlTHN0PjxhOnNvbGlkRmlsbD48YTpzY2hlbWVDbHIgdmFsPSJwaENsciIvPjwvYTpzb2xpZEZpbGw+PGE6Z3JhZEZpbGwgcm90V2l0aFNoYXBlPSIxIj48YTpnc0xzdD48YTpncyBwb3M9IjAiPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIj48YTpsdW1Nb2QgdmFsPSIxMTAwMDAiLz48YTpzYXRNb2QgdmFsPSIxMDUwMDAiLz48YTp0aW50IHZhbD0iNjcwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48YTpncyBwb3M9IjUwMDAwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6bHVtTW9kIHZhbD0iMTA1MDAwIi8+PGE6c2F0TW9kIHZhbD0iMTAzMDAwIi8+PGE6dGludCB2YWw9IjczMDAwIi8+PC9hOnNjaGVtZUNscj48L2E6Z3M+PGE6Z3MgcG9zPSIxMDAwMDAiPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIj48YTpsdW1Nb2QgdmFsPSIxMDUwMDAiLz48YTpzYXRNb2QgdmFsPSIxMDkwMDAiLz48YTp0aW50IHZhbD0iODEwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48L2E6Z3NMc3Q+PGE6bGluIGFuZz0iNTQwMDAwMCIgc2NhbGVkPSIwIi8+PC9hOmdyYWRGaWxsPjxhOmdyYWRGaWxsIHJvdFdpdGhTaGFwZT0iMSI+PGE6Z3NMc3Q+PGE6Z3MgcG9zPSIwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6c2F0TW9kIHZhbD0iMTAzMDAwIi8+PGE6bHVtTW9kIHZhbD0iMTAyMDAwIi8+PGE6dGludCB2YWw9Ijk0MDAwIi8+PC9hOnNjaGVtZUNscj48L2E6Z3M+PGE6Z3MgcG9zPSI1MDAwMCI+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiPjxhOnNhdE1vZCB2YWw9IjExMDAwMCIvPjxhOmx1bU1vZCB2YWw9IjEwMDAwMCIvPjxhOnNoYWRlIHZhbD0iMTAwMDAwIi8+PC9hOnNjaGVtZUNscj48L2E6Z3M+PGE6Z3MgcG9zPSIxMDAwMDAiPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIj48YTpsdW1Nb2QgdmFsPSI5OTAwMCIvPjxhOnNhdE1vZCB2YWw9IjEyMDAwMCIvPjxhOnNoYWRlIHZhbD0iNzgwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48L2E6Z3NMc3Q+PGE6bGluIGFuZz0iNTQwMDAwMCIgc2NhbGVkPSIwIi8+PC9hOmdyYWRGaWxsPjwvYTpmaWxsU3R5bGVMc3Q+PGE6bG5TdHlsZUxzdD48YTpsbiB3PSI2MzUwIiBjYXA9ImZsYXQiIGNtcGQ9InNuZyIgYWxnbj0iY3RyIj48YTpzb2xpZEZpbGw+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiLz48L2E6c29saWRGaWxsPjxhOnByc3REYXNoIHZhbD0ic29saWQiLz48YTptaXRlciBsaW09IjgwMDAwMCIvPjwvYTpsbj48YTpsbiB3PSIxMjcwMCIgY2FwPSJmbGF0IiBjbXBkPSJzbmciIGFsZ249ImN0ciI+PGE6c29saWRGaWxsPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIi8+PC9hOnNvbGlkRmlsbD48YTpwcnN0RGFzaCB2YWw9InNvbGlkIi8+PGE6bWl0ZXIgbGltPSI4MDAwMDAiLz48L2E6bG4+PGE6bG4gdz0iMTkwNTAiIGNhcD0iZmxhdCIgY21wZD0ic25nIiBhbGduPSJjdHIiPjxhOnNvbGlkRmlsbD48YTpzY2hlbWVDbHIgdmFsPSJwaENsciIvPjwvYTpzb2xpZEZpbGw+PGE6cHJzdERhc2ggdmFsPSJzb2xpZCIvPjxhOm1pdGVyIGxpbT0iODAwMDAwIi8+PC9hOmxuPjwvYTpsblN0eWxlTHN0PjxhOmVmZmVjdFN0eWxlTHN0PjxhOmVmZmVjdFN0eWxlPjxhOmVmZmVjdExzdC8+PC9hOmVmZmVjdFN0eWxlPjxhOmVmZmVjdFN0eWxlPjxhOmVmZmVjdExzdC8+PC9hOmVmZmVjdFN0eWxlPjxhOmVmZmVjdFN0eWxlPjxhOmVmZmVjdExzdD48YTpvdXRlclNoZHcgYmx1clJhZD0iNTcxNTAiIGRpc3Q9IjE5MDUwIiBkaXI9IjU0MDAwMDAiIGFsZ249ImN0ciIgcm90V2l0aFNoYXBlPSIwIj48YTpzcmdiQ2xyIHZhbD0iMDAwMDAwIj48YTphbHBoYSB2YWw9IjYzMDAwIi8+PC9hOnNyZ2JDbHI+PC9hOm91dGVyU2hkdz48L2E6ZWZmZWN0THN0PjwvYTplZmZlY3RTdHlsZT48L2E6ZWZmZWN0U3R5bGVMc3Q+PGE6YmdGaWxsU3R5bGVMc3Q+PGE6c29saWRGaWxsPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIi8+PC9hOnNvbGlkRmlsbD48YTpzb2xpZEZpbGw+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiPjxhOnRpbnQgdmFsPSI5NTAwMCIvPjxhOnNhdE1vZCB2YWw9IjE3MDAwMCIvPjwvYTpzY2hlbWVDbHI+PC9hOnNvbGlkRmlsbD48YTpncmFkRmlsbCByb3RXaXRoU2hhcGU9IjEiPjxhOmdzTHN0PjxhOmdzIHBvcz0iMCI+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiPjxhOnRpbnQgdmFsPSI5MzAwMCIvPjxhOnNhdE1vZCB2YWw9IjE1MDAwMCIvPjxhOnNoYWRlIHZhbD0iOTgwMDAiLz48YTpsdW1Nb2QgdmFsPSIxMDIwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48YTpncyBwb3M9IjUwMDAwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6dGludCB2YWw9Ijk4MDAwIi8+PGE6c2F0TW9kIHZhbD0iMTMwMDAwIi8+PGE6c2hhZGUgdmFsPSI5MDAwMCIvPjxhOmx1bU1vZCB2YWw9IjEwMzAwMCIvPjwvYTpzY2hlbWVDbHI+PC9hOmdzPjxhOmdzIHBvcz0iMTAwMDAwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6c2hhZGUgdmFsPSI2MzAwMCIvPjxhOnNhdE1vZCB2YWw9IjEyMDAwMCIvPjwvYTpzY2hlbWVDbHI+PC9hOmdzPjwvYTpnc0xzdD48YTpsaW4gYW5nPSI1NDAwMDAwIiBzY2FsZWQ9IjAiLz48L2E6Z3JhZEZpbGw+PC9hOmJnRmlsbFN0eWxlTHN0PjwvYTpmbXRTY2hlbWU+PC9hOnRoZW1lRWxlbWVudHM+PGE6b2JqZWN0RGVmYXVsdHMvPjxhOmV4dHJhQ2xyU2NoZW1lTHN0Lz48YTpleHRMc3Q+PGE6ZXh0IHVyaT0iezA1QTRDMjVDLTA4NUUtNDM0MC04NUEzLUE1NTMxRTUxMERCMn0iPjx0aG0xNTp0aGVtZUZhbWlseSB4bWxuczp0aG0xNT0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2UvdGhlbWVtbC8yMDEyL21haW4iIG5hbWU9Ik9mZmljZSBUaGVtZSIgaWQ9Ins2MkY5MzlCNi05M0FGLTREQjgtOUM2Qi1ENkM3REZEQzU4OUZ9IiB2aWQ9Ins0QTNDNDZFOC02MUNDLTQ2MDMtQTU4OS03NDIyQTQ3QThFNEF9Ii8+PC9hOmV4dD48L2E6ZXh0THN0PjwvYTp0aGVtZT5QSwMECgAAAAAAAAAhAHmhgGxSBgAAUgYAAA0AAAB4bC9zdHlsZXMueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPHN0eWxlU2hlZXQgeG1sbnM9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9zcHJlYWRzaGVldG1sLzIwMDYvbWFpbiIgeG1sbnM6bWM9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9tYXJrdXAtY29tcGF0aWJpbGl0eS8yMDA2IiBtYzpJZ25vcmFibGU9IngxNGFjIHgxNnIyIHhyIiB4bWxuczp4MTRhYz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDA5LzkvYWMiIHhtbG5zOngxNnIyPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTUvMDIvbWFpbiIgeG1sbnM6eHI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAxNC9yZXZpc2lvbiI+PGZvbnRzIGNvdW50PSIxIiB4MTRhYzprbm93bkZvbnRzPSIxIj48Zm9udD48c3ogdmFsPSIxMSIvPjxjb2xvciB0aGVtZT0iMSIvPjxuYW1lIHZhbD0iQ2FsaWJyaSIvPjxmYW1pbHkgdmFsPSIyIi8+PHNjaGVtZSB2YWw9Im1pbm9yIi8+PC9mb250PjwvZm9udHM+PGZpbGxzIGNvdW50PSIyIj48ZmlsbD48cGF0dGVybkZpbGwgcGF0dGVyblR5cGU9Im5vbmUiLz48L2ZpbGw+PGZpbGw+PHBhdHRlcm5GaWxsIHBhdHRlcm5UeXBlPSJncmF5MTI1Ii8+PC9maWxsPjwvZmlsbHM+PGJvcmRlcnMgY291bnQ9IjEiPjxib3JkZXI+PGxlZnQvPjxyaWdodC8+PHRvcC8+PGJvdHRvbS8+PGRpYWdvbmFsLz48L2JvcmRlcj48L2JvcmRlcnM+PGNlbGxTdHlsZVhmcyBjb3VudD0iMSI+PHhmIG51bUZtdElkPSIwIiBmb250SWQ9IjAiIGZpbGxJZD0iMCIgYm9yZGVySWQ9IjAiLz48L2NlbGxTdHlsZVhmcz48Y2VsbFhmcyBjb3VudD0iMSI+PHhmIG51bUZtdElkPSIwIiBmb250SWQ9IjAiIGZpbGxJZD0iMCIgYm9yZGVySWQ9IjAiIHhmSWQ9IjAiLz48L2NlbGxYZnM+PGNlbGxTdHlsZXMgY291bnQ9IjEiPjxjZWxsU3R5bGUgbmFtZT0iTm9ybWFsIiB4ZklkPSIwIiBidWlsdGluSWQ9IjAiLz48L2NlbGxTdHlsZXM+PGR4ZnMgY291bnQ9IjAiLz48dGFibGVTdHlsZXMgY291bnQ9IjAiIGRlZmF1bHRUYWJsZVN0eWxlPSJUYWJsZVN0eWxlTWVkaXVtMiIgZGVmYXVsdFBpdm90U3R5bGU9IlBpdm90U3R5bGVMaWdodDE2Ii8+PGV4dExzdD48ZXh0IHVyaT0ie0VCNzlERUYyLTgwQjgtNDNlNS05NUJELTU0Q0JEREY5MDIwQ30iIHhtbG5zOngxND0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDA5LzkvbWFpbiI+PHgxNDpzbGljZXJTdHlsZXMgZGVmYXVsdFNsaWNlclN0eWxlPSJTbGljZXJTdHlsZUxpZ2h0MSIvPjwvZXh0PjxleHQgdXJpPSJ7OTI2MEE1MTAtRjMwMS00NmE4LTg2MzUtRjUxMkQ2NEJFNUY1fSIgeG1sbnM6eDE1PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvbWFpbiI+PHgxNTp0aW1lbGluZVN0eWxlcyBkZWZhdWx0VGltZWxpbmVTdHlsZT0iVGltZVNsaWNlclN0eWxlTGlnaHQxIi8+PC9leHQ+PC9leHRMc3Q+PC9zdHlsZVNoZWV0PlBLAwQKAAAAAAAAACEA0IywC4EAAACBAAAAFAAAAHhsL3NoYXJlZFN0cmluZ3MueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPHNzdCB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3NwcmVhZHNoZWV0bWwvMjAwNi9tYWluIi8+UEsDBAoAAAAAAAAAIQDcCx83XQIAAF0CAAARAAAAZG9jUHJvcHMvY29yZS54bWw8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCIgc3RhbmRhbG9uZT0ieWVzIj8+DQo8Y3A6Y29yZVByb3BlcnRpZXMgeG1sbnM6Y3A9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9wYWNrYWdlLzIwMDYvbWV0YWRhdGEvY29yZS1wcm9wZXJ0aWVzIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmRjdGVybXM9Imh0dHA6Ly9wdXJsLm9yZy9kYy90ZXJtcy8iIHhtbG5zOmRjbWl0eXBlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvIiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIj48ZGM6Y3JlYXRvcj5kdW5jYW48L2RjOmNyZWF0b3I+PGNwOmxhc3RNb2RpZmllZEJ5PmR1bmNhbjwvY3A6bGFzdE1vZGlmaWVkQnk+PGRjdGVybXM6Y3JlYXRlZCB4c2k6dHlwZT0iZGN0ZXJtczpXM0NEVEYiPjIwMTktMDEtMzFUMTY6NDg6MDNaPC9kY3Rlcm1zOmNyZWF0ZWQ+PGRjdGVybXM6bW9kaWZpZWQgeHNpOnR5cGU9ImRjdGVybXM6VzNDRFRGIj4yMDE5LTAxLTMxVDE2OjQ4OjI4WjwvZGN0ZXJtczptb2RpZmllZD48L2NwOmNvcmVQcm9wZXJ0aWVzPlBLAwQKAAAAAAAAACEAYUkJEBEDAAARAwAAEAAAAGRvY1Byb3BzL2FwcC54bWw8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCIgc3RhbmRhbG9uZT0ieWVzIj8+DQo8UHJvcGVydGllcyB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL29mZmljZURvY3VtZW50LzIwMDYvZXh0ZW5kZWQtcHJvcGVydGllcyIgeG1sbnM6dnQ9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L2RvY1Byb3BzVlR5cGVzIj48QXBwbGljYXRpb24+TWljcm9zb2Z0IEV4Y2VsPC9BcHBsaWNhdGlvbj48RG9jU2VjdXJpdHk+MDwvRG9jU2VjdXJpdHk+PFNjYWxlQ3JvcD5mYWxzZTwvU2NhbGVDcm9wPjxIZWFkaW5nUGFpcnM+PHZ0OnZlY3RvciBzaXplPSIyIiBiYXNlVHlwZT0idmFyaWFudCI+PHZ0OnZhcmlhbnQ+PHZ0Omxwc3RyPldvcmtzaGVldHM8L3Z0Omxwc3RyPjwvdnQ6dmFyaWFudD48dnQ6dmFyaWFudD48dnQ6aTQ+MTwvdnQ6aTQ+PC92dDp2YXJpYW50PjwvdnQ6dmVjdG9yPjwvSGVhZGluZ1BhaXJzPjxUaXRsZXNPZlBhcnRzPjx2dDp2ZWN0b3Igc2l6ZT0iMSIgYmFzZVR5cGU9Imxwc3RyIj48dnQ6bHBzdHI+U2hlZXQxPC92dDpscHN0cj48L3Z0OnZlY3Rvcj48L1RpdGxlc09mUGFydHM+PENvbXBhbnk+PC9Db21wYW55PjxMaW5rc1VwVG9EYXRlPmZhbHNlPC9MaW5rc1VwVG9EYXRlPjxTaGFyZWREb2M+ZmFsc2U8L1NoYXJlZERvYz48SHlwZXJsaW5rc0NoYW5nZWQ+ZmFsc2U8L0h5cGVybGlua3NDaGFuZ2VkPjxBcHBWZXJzaW9uPjE2LjAzMDA8L0FwcFZlcnNpb24+PC9Qcm9wZXJ0aWVzPlBLAQIUAAoAAAAAAAAAIQBi7p1okAQAAJAEAAATAAAAAAAAAAAAAAAAAAAAAABbQ29udGVudF9UeXBlc10ueG1sUEsBAhQACgAAAAAAAAAhALVVMCNMAgAATAIAAAsAAAAAAAAAAAAAAAAAwQQAAF9yZWxzLy5yZWxzUEsBAhQACgAAAAAAAAAhALpwnmbKBgAAygYAAA8AAAAAAAAAAAAAAAAANgcAAHhsL3dvcmtib29rLnhtbFBLAQIUAAoAAAAAAAAAIQCBPpSXugIAALoCAAAaAAAAAAAAAAAAAAAAAC0OAAB4bC9fcmVscy93b3JrYm9vay54bWwucmVsc1BLAQIUAAoAAAAAAAAAIQACrURzpAMAAKQDAAAYAAAAAAAAAAAAAAAAAB8RAAB4bC93b3Jrc2hlZXRzL3NoZWV0MS54bWxQSwECFAAKAAAAAAAAACEAwRcQvsYgAADGIAAAEwAAAAAAAAAAAAAAAAD5FAAAeGwvdGhlbWUvdGhlbWUxLnhtbFBLAQIUAAoAAAAAAAAAIQB5oYBsUgYAAFIGAAANAAAAAAAAAAAAAAAAAPA1AAB4bC9zdHlsZXMueG1sUEsBAhQACgAAAAAAAAAhANCMsAuBAAAAgQAAABQAAAAAAAAAAAAAAAAAbTwAAHhsL3NoYXJlZFN0cmluZ3MueG1sUEsBAhQACgAAAAAAAAAhANwLHzddAgAAXQIAABEAAAAAAAAAAAAAAAAAID0AAGRvY1Byb3BzL2NvcmUueG1sUEsBAhQACgAAAAAAAAAhAGFJCRARAwAAEQMAABAAAAAAAAAAAAAAAAAArD8AAGRvY1Byb3BzL2FwcC54bWxQSwUGAAAAAAoACgCAAgAA60IAAAAA";var Ar=s=>typeof s=="object"&&typeof s.row<"u"&&typeof s.column<"u";var ae=class{start_;end_;constructor(e,t=e,r=!1){this.end_=this.PatchNull(t),this.start_=this.PatchNull(e),r&&this.Normalize()}static FromColumn(e){return new ae({row:1/0,column:e})}static FromRow(e){return new ae({row:e,column:1/0})}static ColumnToLabel(e){let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}static CellAddressToLabel(e,t=!1){return(t?`${e.sheet_id||0}!`:"")+(e.absolute_column?"$":"")+this.ColumnToLabel(e.column)+(e.absolute_row?"$":"")+(e.row+1)}static Join(e,...t){let r=new ae(e.start,e.end);for(let n of t)n&&(r.ConsumeAddress(n.start),r.ConsumeAddress(n.end));return r}static Bleed(e,t=1){return new ae({row:Math.max(0,e.start.row-t),column:Math.max(0,e.start.column-t),sheet_id:e.start.sheet_id},{row:e.end.row+t,column:e.end.column+t})}get start(){return{...this.start_}}set start(e){this.start_=e}get end(){return{...this.end_}}set end(e){this.end_=e}get rows(){return this.start_.row===1/0||this.end_.row===1/0?1/0:this.end_.row-this.start_.row+1}get columns(){return this.start_.column===1/0||this.end_.column===1/0?1/0:this.end_.column-this.start_.column+1}get count(){return this.rows*this.columns}get entire_sheet(){return this.entire_row&&this.entire_column}get entire_column(){return this.start_.row===1/0}get entire_row(){return this.start_.column===1/0}PatchNull(e){let t={...e};return t.row===null&&(t.row=1/0),t.column===null&&(t.column=1/0),t}SetSheetID(e){this.start_.sheet_id=e}Normalize(){let e={...this.start_},t={...this.end_};e.row===1/0||t.row===1/0?e.row=t.row=1/0:e.row>t.row&&(e.row=this.end_.row,e.absolute_row=this.end_.absolute_row,t.row=this.start_.row,t.absolute_row=this.start_.absolute_row),e.column===1/0||t.column===1/0?e.column=t.column=1/0:e.column>t.column&&(e.column=this.end_.column,e.absolute_column=this.end_.absolute_column,t.column=this.start_.column,t.absolute_column=this.start_.absolute_column),this.start_=e,this.end_=t}TopLeft(){let e={row:0,column:0};return this.entire_row||(e.column=this.start.column),this.entire_column||(e.row=this.start.row),e}BottomRight(){let e={row:0,column:0};return this.entire_row||(e.column=this.end.column),this.entire_column||(e.row=this.end.row),e}ContainsRow(e){return this.entire_column||e>=this.start_.row&&e<=this.end_.row}ContainsColumn(e){return this.entire_row||e>=this.start_.column&&e<=this.end_.column}Contains(e){return(this.entire_column||e.row>=this.start_.row&&e.row<=this.end_.row)&&(this.entire_row||e.column>=this.start_.column&&e.column<=this.end_.column)}ContainsArea(e){return this.start.column<=e.start.column&&this.end.column>=e.end.column&&this.start.row<=e.start.row&&this.end.row>=e.end.row}Intersects(e){return!(e.start.column>this.end.column||this.start.column>e.end.column||e.start.row>this.end.row||this.start.row>e.end.row)}Equals(e){return e.start_.row===this.start_.row&&e.start_.column===this.start_.column&&e.end_.row===this.end_.row&&e.end_.column===this.end_.column}Clone(){return new ae(this.start,this.end)}Array(){if(this.entire_column||this.entire_row)throw new Error("can\'t convert infinite area to array");let e=new Array(this.rows*this.columns),t=this.start_.sheet_id,r=0;for(let n=this.start_.row;n<=this.end_.row;n++)for(let i=this.start_.column;i<=this.end_.column;i++)e[r++]={row:n,column:i,sheet_id:t};return e}get left(){let e=new ae(this.start_,this.end_);return e.end_.column=e.start_.column,e}get right(){let e=new ae(this.start_,this.end_);return e.start_.column=e.end_.column,e}get top(){let e=new ae(this.start_,this.end_);return e.end_.row=e.start_.row,e}get bottom(){let e=new ae(this.start_,this.end_);return e.start_.row=e.end_.row,e}Shift(e,t){return this.start_.row+=e,this.start_.column+=t,this.end_.row+=e,this.end_.column+=t,this}ConsumeAddress(e){this.entire_row||(e.column<this.start_.column&&(this.start_.column=e.column),e.column>this.end_.column&&(this.end_.column=e.column)),this.entire_column||(e.row<this.start_.row&&(this.start_.row=e.row),e.row>this.end_.row&&(this.end_.row=e.row))}ConsumeArea(e){this.ConsumeAddress(e.start),this.ConsumeAddress(e.end)}Resize(e,t){return this.end_.row=this.start_.row+e-1,this.end_.column=this.start_.column+t-1,this}Iterate(e){if(this.entire_column||this.entire_row){console.warn("don\'t iterate infinite area");return}for(let t=this.start_.column;t<=this.end_.column;t++)for(let r=this.start_.row;r<=this.end_.row;r++)e({column:t,row:r,sheet_id:this.start_.sheet_id})}get spreadsheet_label(){let e;return this.entire_sheet?"":this.entire_column?(e=ae.ColumnToLabel(this.start_.column),e+=":"+ae.ColumnToLabel(this.end_.column),e):this.entire_row?(e=String(this.start_.row+1),e+=":"+(this.end_.row+1),e):(e=ae.CellAddressToLabel(this.start_),this.columns>1||this.rows>1?e+":"+ae.CellAddressToLabel(this.end_):e)}toJSON(){return{start:{...this.start_},end:{...this.end_}}}};var Zi=s=>typeof s=="object"&&!!s&&typeof s.real=="number"&&typeof s.imaginary=="number";var Ft=s=>typeof s=="object"&&!!s&&typeof s.value=="number"&&typeof s.unit=="string";var Se=s=>{switch(typeof s){case"undefined":return 0;case"number":return 3;case"boolean":return 4;case"object":return s===null?0:Zi(s)?7:Ft(s)?9:5;case"string":return s[0]==="="?1:2;default:return 6}};var Ae=class{static StringToColumn(e){let t=0;e=e.toUpperCase();for(let r=0;r<e.length;r++)t*=26,t+=e.charCodeAt(r)-64;return t-1}value;type=0;calculated;calculated_type;formatted;rendered_type;style;area;merge_area;renderer_data;render_clean=[];note;hyperlink;editing;render_function;click_function;validation;constructor(e,t){typeof e<"u"&&this.Set(e,t)}ValueIsNumber(){return this.type===3}ValueIsFormula(){return this.type===1}ValueIsBoolean(){return this.type===4}ValueIsComplex(){return this.type===7}FlushStyle(){this.formatted=this.rendered_type=this.style=void 0,this.render_clean=[]}FlushArray(){this.area=void 0}FlushCache(){this.calculated=this.calculated_type=this.formatted=this.rendered_type=this.render_function=this.click_function=void 0,this.render_clean=[]}Reset(){this.type=0,this.value=this.note=this.hyperlink=this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.area=this.renderer_data=this.render_function=this.click_function=void 0,this.render_clean=[]}Set(e,t=Se(e)){this.value=e,this.type=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.render_function=this.click_function=this.area=void 0,this.render_clean=[]}SetCalculatedValue(e,t=Se(e)){this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}SetCalculatedValueOrError(e,t){typeof t>"u"&&(typeof e=="object"&&e.error?(t=6,e=e.error):t=Se(e)),this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}GetValue(){return this.calculated_type?this.calculated:typeof this.value=="string"&&this.value[0]==="\'"?this.value.slice(1):this.value}GetValue4(){return this.calculated_type?{type:this.calculated_type,value:this.calculated}:this.type===1?{type:3,value:0}:{type:this.type,value:typeof this.value=="string"&&this.value[0]==="\'"?this.value.slice(1):this.value}}SetNote(e){this.note=e,this.render_clean=[]}SetCalculationError(e="ERR"){this.SetCalculatedValue(e,6)}SetArray(e){this.type=0,this.value=this.formatted=this.rendered_type=this.style=this.hyperlink=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}SetArrayHead(e,t){this.type=Se(t),this.value=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}};var zi=s=>!s.cells,Li=s=>!!s[0]&&zi(s[0]),Wi=s=>!!s[0]&&s[0].row!==void 0,ot=class{data=[];rows_=0;columns_=0;get rows(){return this.rows_}get columns(){return this.columns_}EnsureRow(e){this.rows_=Math.max(e+1,this.rows_)}EnsureColumn(e){this.columns_=Math.max(e+1,this.columns_)}InsertColumns(e=0,t=1){let r=JSON.parse(JSON.stringify(this.data[13]));this.data=this.data.map(n=>{if(n.length>=e){let i=n.slice(0,e),a=e+t,o=n.slice(e);for(let u=0;u<o.length;u++)i[a++]=o[u];return i}return n}),this.columns_+=t}DeleteColumns(e,t=1){this.data.forEach(r=>r.splice(e,t)),this.columns_-=t}DeleteRows(e,t=1){this.data.splice(e,t),this.rows_-=t}InsertRows(e=0,t=1){let r=[e,0,[]];for(let n=1;n<t;n++)r.push([]);Array.prototype.splice.apply(this.data,r),this.rows_+=t}GetCell(e,t){let{row:r,column:n}=e;if(!this.data[r])if(t)this.data[r]=[],this.rows_=Math.max(this.rows_,r+1);else return;return this.data[r][n]||t&&(this.data[r][n]=new Ae,this.columns_=Math.max(this.columns_,n+1)),this.data[r][n]}EnsureCell(e){let{row:t,column:r}=e,n=this.data[t];n||(this.data[t]=n=[],this.rows_=Math.max(this.rows_,t+1));let i=n[r];return i||(i=n[r]=new Ae,this.columns_=Math.max(this.columns_,r+1)),i}FromArray(e=[],t=!1){this.data=[];let r=0,n=0;if(t){n=e.length;for(let i=0;i<n;i++){let a=e[i];r=Math.max(r,a.length);for(let o=0;o<a.length;o++)this.data[o]||(this.data[o]=[]),this.data[o][i]=new Ae(a[o])}}else{r=e.length;for(let i=0;i<r;i++){let a=[],o=e[i];n=Math.max(n,o.length);for(let u=0;u<o.length;u++)a[u]=new Ae(o[u]);this.data[i]=a}}this.rows_=r,this.columns_=n}FromJSON(e=[],t){if(this.data=[],!Li(e)){let r=[];if(Wi(e))for(let n of e)for(let i of n.cells)r.push({...i,row:n.row});else for(let n of e)for(let i of n.cells)r.push({...i,column:n.column});e=r}for(let r of e){this.data[r.row]||(this.data[r.row]=[]);let n=new Ae(r.value);if(typeof r.calculated<"u"&&n.SetCalculatedValue(r.calculated,r.calculated_type),t&&typeof r.style_ref<"u"&&(n.style=t[r.style_ref]),typeof r.note<"u"&&(n.note=r.note),typeof r.hyperlink<"u"&&(n.hyperlink=r.hyperlink),this.data[r.row][r.column]&&this.data[r.row][r.column].area&&(n.area=this.data[r.row][r.column].area),this.data[r.row][r.column]=n,r.area){let i=new ae(r.area.start,r.area.end);for(let a=i.start.row;a<=i.end.row;a++)for(let o=i.start.column;o<=i.end.column;o++)this.data[a]||(this.data[a]=[]),this.data[a][o]||(this.data[a][o]=new Ae),this.data[a][o].area=i}if(r.merge_area){let i=new ae(r.merge_area.start,r.merge_area.end);for(let a=i.start.row;a<=i.end.row;a++)for(let o=i.start.column;o<=i.end.column;o++)this.data[a]||(this.data[a]=[]),this.data[a][o]||(this.data[a][o]=new Ae),this.data[a][o].merge_area=i}r.validation&&(n.validation=r.validation)}this.rows_=this.data.length,this.columns_=this.data.reduce((r,n)=>Math.max(r,n.length),0)}toJSON(e={}){let t=0,r=0,n=this.data.length-1,i;e.subset&&(t=e.subset.start.column,r=e.subset.start.row,n=e.subset.end.row);let a=[],o=-1,u=-1,d={},p={};for(let l=r;l<=n;l++)if(this.data[l]){let b=this.data[l];i=b.length-1,e.subset&&(i=e.subset.end.column);for(let f=t;f<=i;f++){let m=b[f],g=m&&m.merge_area&&m.merge_area.start.row===l&&m.merge_area.start.column===f,A=m&&m.area&&m.area.start.row===l&&m.area.start.column===f,y=m?m.type===2&&!m.value:!0;if(m&&(!y||e.preserve_empty_strings)&&(g||m.type||m.calculated_type&&e.expand_arrays||m.calculated_type&&e.calculated_value||m.validation||e.decorated_cells&&m.style&&(m.style.fill||m.style.border_bottom||m.style.border_top||m.style.border_left||m.style.border_right))){let w={row:l,column:f,value:m.value};m.note&&(w.note=m.note),m.hyperlink&&(w.hyperlink=m.hyperlink),e.preserve_type&&(w.type=m.type),e.sheet_id&&(w.sheet_id=e.sheet_id),e.calculated_value&&typeof m.calculated<"u"&&(w.calculated=m.calculated,(e.preserve_type||m.calculated_type===6)&&(w.calculated_type=m.calculated_type)),m.area&&A&&(w.area=m.area.toJSON()),m.merge_area&&(w.merge_area=m.merge_area.toJSON()),m.validation&&(w.validation=m.validation),e.cell_style_refs&&e.cell_style_refs[f]&&e.cell_style_refs[f][l]&&(w.style_ref=e.cell_style_refs[f][l],e.cell_style_refs[f][l]=0),d[l]=l,p[f]=f,o=Math.max(l,o),u=Math.max(f,u),a.push(w)}}}if(e.nested){let l=Object.keys(d),b=Object.keys(p);if(l.length<=b.length&&l.length){let f={},m=[];for(let g of a){let{row:A,...y}=g;f[g.row]||(f[g.row]=[]),f[g.row].push(y)}for(let g of l){let A=Number(g);m.push({row:A,cells:f[A]})}return{data:m,rows:o,columns:u+1}}else if(b.length){let f={},m=[];for(let g of a){let{column:A,...y}=g;f[g.column]||(f[g.column]=[]),f[g.column].push(y)}for(let g of b){let A=Number(g);m.push({column:A,cells:f[A]})}return{data:m,rows:o,columns:u+1}}}return{data:a,rows:o+1,columns:u+1}}GetAll(e=!1){return this.GetRange({row:0,column:0},{row:this.rows_-1,column:this.columns_-1},e)}Normalize2(e,t){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),t.column===1/0&&(t={...t,column:this.columns_-1}),t.row===1/0&&(t={...t,row:this.rows_-1}),{from:e,to:t}}Normalize1(e){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),e}RawValue(e,t=e){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].value:void 0;let r=[],n=this.data.slice(e.row,t.row+1),i=e.column,a=t.column+1;for(let o of n){let u=[];for(let d=i,p=0;d<a;d++,p++){let l=o[d];u.push(l?l.value:void 0)}r.push(u)}return r}GetRange(e,t,r=!1){if(t?{from:e,to:t}=this.Normalize2(e,t):e=this.Normalize1(e),!t||e===t||e.column===t.column&&e.row===t.row)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue():void 0;let n=[];if(r)for(let i=e.column;i<=t.column;i++){let a=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][i]?a.push(this.data[o][i].GetValue()):a.push(void 0);n.push(a)}else for(let i=e.row;i<=t.row;i++){let a=[];for(let o=e.column;o<=t.column;o++)this.data[i]&&this.data[i][o]?a.push(this.data[i][o].GetValue()):a.push(void 0);n.push(a)}return n}GetRange4(e,t=e,r=!1){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue4():{value:void 0,type:0};let n=[];if(r)for(let i=e.column;i<=t.column;i++){let a=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][i]?a.push(this.data[o][i].GetValue4()):a.push({type:0});n.push(a)}else for(let i=e.row;i<=t.row;i++){let a=[];for(let o=e.column;o<=t.column;o++)this.data[i]&&this.data[i][o]?a.push(this.data[i][o].GetValue4()):a.push({type:0});n.push(a)}return{type:8,value:n}}Apply(e,t,r=!1){if(Ar(e)&&(e=new ae(e)),e.entire_column||e.entire_row)throw new Error("don\'t iterate infinite cells");let n=e.start,i=e.end;if(r)for(let a=n.row;a<=i.row;a++){this.data[a]||(this.data[a]=[]);let o=this.data[a];for(let u=n.column;u<=i.column;u++)o[u]||(o[u]=new Ae),t(o[u],u,a)}else for(let a=n.row;a<=i.row;a++)if(this.data[a]){let o=this.data[a];for(let u=n.column;u<=i.column;u++)o[u]&&t(o[u],u,a)}}SetArea(e,t){if(ArrayBuffer.isView(t))throw new Error("ABIV");if(Array.isArray(t))for(let r=e.start.row,n=0;r<=e.end.row;r++,n++){this.data[r]||(this.data[r]=[]);let i=this.data[r];if(t[n])for(let a=e.start.column,o=0;a<=e.end.column;a++,o++)i[a]||(i[a]=new Ae),i[a].Set(t[n][o])}else{let r=Se(t);for(let n=e.start.row;n<=e.end.row;n++){this.data[n]||(this.data[n]=[]);let i=this.data[n];for(let a=e.start.column;a<=e.end.column;a++)i[a]||(i[a]=new Ae),i[a].Set(t,r)}}this.rows_=Math.max(this.rows_,e.end.row+1),this.columns_=Math.max(this.columns_,e.end.column+1)}IterateAll(e){for(let t of this.data)if(t)for(let r of t)r&&e(r)}FlushCellStyles(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushStyle()}FlushCachedValues(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushCache()}};var oe=class{static UpdateLocale(e){if(e)this.locale=e;else if(typeof self<"u"){let n=self?.document?.location;if(n&&n.search&&/locale=([^?&]+?)(?:\\?|$|&)/.test(n.search)){let i=n.search.match(/locale=(.*?)(?:\\?|$|&)/);i&&(this.locale=i[1]),console.info("override locale",this.locale)}else typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]?this.locale=navigator.languages[0]:this.locale=navigator.language)}let t=new Intl.NumberFormat(this.locale,{minimumFractionDigits:1}).format(3.3).replace(/\\d/g,"");this.decimal_separator=t===","?",":".",this.decimal_separator===","?(this.argument_separator=";",this.grouping_separator=" "):(this.argument_separator=",",this.grouping_separator=",");let r=new Date(2e3,0,2,12,0,0,0);this.UpdateDateComponent(0,0,r),r=new Date(2e3,1,7,12,0,0,0),this.UpdateDateComponent(1,1,r),r=new Date(2e3,2,7,12,0,0,0),this.UpdateDateComponent(2,2,r),r=new Date(2e3,3,5,12,0,0,0),this.UpdateDateComponent(3,3,r),r=new Date(2e3,4,4,12,0,0,0),this.UpdateDateComponent(4,4,r),r=new Date(2e3,5,2,12,0,0,0),this.UpdateDateComponent(5,5,r),r=new Date(2e3,6,1,12,0,0,0),this.UpdateDateComponent(6,6,r),r=new Date(2e3,7,1,12,0,0,0),this.UpdateDateComponent(7,-1,r),r=new Date(2e3,8,1,12,0,0,0),this.UpdateDateComponent(8,-1,r),r=new Date(2e3,9,1,12,0,0,0),this.UpdateDateComponent(9,-1,r),r=new Date(2e3,10,1,12,0,0,0),this.UpdateDateComponent(10,-1,r),r=new Date(2e3,11,1,12,0,0,0),this.UpdateDateComponent(11,-1,r)}static UpdateDateComponent(e,t,r){t>=0&&(this.date_components.short_days[t]=r.toLocaleString(this.locale,{weekday:"short"}),this.date_components.long_days[t]=r.toLocaleString(this.locale,{weekday:"long"})),e>=0&&(this.date_components.short_months[e]=r.toLocaleString(this.locale,{month:"short"}),this.date_components.long_months[e]=r.toLocaleString(this.locale,{month:"long"}))}};ie(oe,"locale","en-us"),ie(oe,"decimal_separator","."),ie(oe,"argument_separator",","),ie(oe,"grouping_separator",","),ie(oe,"date_components",{short_days:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],long_days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],short_months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],long_months:["January","February","March","April","May","June","July","August","September","October","November","December"]});oe.UpdateLocale();var pe;(f=>{let s=JSON.stringify({}),e;(w=>(w.None="",w.Left="left",w.Center="center",w.Right="right"))(e=f.HorizontalAlign||={});let t;(w=>(w.None="",w.Top="top",w.Bottom="bottom",w.Middle="middle"))(t=f.VerticalAlign||={}),f.DefaultProperties={horizontal_align:"",vertical_align:"",number_format:"General",nan:"NaN",font_size:{unit:"pt",value:10.5},font_face:"sans-serif",bold:!1,italic:!1,underline:!1,strike:!1,text:{theme:1},border_top:0,border_left:0,border_right:0,border_bottom:0},f.CompositeBorders=m=>({top:{width:m.border_top||0,color:m.border_top_fill||{}},left:{width:m.border_left||0,color:m.border_left_fill||{}},right:{width:m.border_right||0,color:m.border_right_fill||{}},bottom:{width:m.border_bottom||0,color:m.border_bottom_fill||{}}}),f.Merge=(m,g,A=!0)=>{let y=A?{...m,...g}:{...g};return JSON.parse(JSON.stringify(y))},f.Composite=m=>JSON.parse(JSON.stringify(m.reduce((g,A)=>({...g,...A}),{}))),f.Empty=m=>JSON.stringify(m)===s,f.ValidColor=m=>!!(m&&!m.none&&(m.text||m.theme||m.theme===0)),f.ParseFontSize=(m="",g="em")=>{let A=m.match(/(-*[\\d.]+)\\s*(\\S*)/);if(A){let y=Number(A[1]);if(!y||isNaN(y)||y<0)return{};let w=A[2].toLowerCase()||g;if(w==="pt"||w==="em"||w==="%"||w==="px")return{font_size:{unit:w,value:y}}}return{}},f.RelativeFontSize=(m,g)=>{let A=12,y=12;switch(m.font_size?.unit){case"pt":if(!m.font_size.value)return 1;y=m.font_size.value;break;case"px":if(!m.font_size.value)return 1;y=Math.round(m.font_size.value*300/4)/100;break;case"em":return m.font_size.value||1;case"%":return(m.font_size.value||100)/100;default:return 1}switch(g.font_size?.unit){case"pt":if(!g.font_size.value)return 1;A=g.font_size.value;break;case"px":if(!g.font_size.value)return 1;A=Math.round(g.font_size.value*300/4)/100;break;default:return 1}return y/A},f.FontSize=(m,g=!0)=>{let A=m.font_size?.value;switch(m.font_size?.unit){case"pt":return(A||12)+"pt";case"px":return g?Math.round((A||16)*300/4)/100+"pt":(A||16)+"px";case"em":return(A||1)+"em";case"%":return(A||100)+"%"}return""},f.Font=(m,g=1)=>{let A=[];return m.bold&&A.push("bold"),m.italic&&A.push("italic"),A.push(((m.font_size?.value||0)*g).toFixed(2)+(m.font_size?.unit||"pt")),A.push(m.font_face||""),A.join(" ")}})(pe||={});var St=class{Darken(e,t,r,n,i=!1){let{h:a,s:o,l:u}=this.RGBToHSL(e,t,r);return i?u-=u*n/100:u-=n/100,u=Math.max(0,Math.min(1,u)),this.HSLToRGB(a,o,u)}Lighten(e,t,r,n,i=!1){let{h:a,s:o,l:u}=this.RGBToHSL(e,t,r);return i?u+=u*n/100:u+=n/100,u=Math.max(0,Math.min(1,u)),this.HSLToRGB(a,o,u)}RGBToHSL(e,t,r){e/=255,t/=255,r/=255;let n=Math.max(e,t,r),i=Math.min(e,t,r),a=0,o=0,u=(n+i)/2;if(n===i)a=o=0;else{let d=n-i;switch(o=u>.5?d/(2-n-i):d/(n+i),n){case e:a=(t-r)/d+(t<r?6:0);break;case t:a=(r-e)/d+2;break;case r:a=(e-t)/d+4;break}a/=6}return{h:a*360,s:o,l:u}}HSLToRGB(e,t,r){let n,i,a;if(t===0)n=i=a=r;else{e=e/360;let o=r<.5?r*(1+t):r+t-r*t,u=2*r-o;n=this.HueToRGB(u,o,e+1/3),i=this.HueToRGB(u,o,e),a=this.HueToRGB(u,o,e-1/3)}return{r:Math.round(n*255),g:Math.round(i*255),b:Math.round(a*255)}}HueToRGB(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e}},Gi=new St;var xt=Fe(ut());var Xr=Fe(st()),Fa=Fe(ut()),Qr=(s,e)=>Xr.decode(e),Kr={ignoreAttributes:!1,attributeNamePrefix:"__",trimValues:!1,textNodeName:"text__",tagValueProcessor:Qr,ignoreDeclaration:!0},lt={ignoreAttributes:!1,attributesGroupName:"a$",attributeNamePrefix:"",textNodeName:"t$",trimValues:!1,ignoreDeclaration:!0,isArray:(s,e,t,r)=>/Relationship$/.test(s),tagValueProcessor:Qr},se=class{static FindChild(e={},t){let r=t.split("/");for(let n of r)if(e=e[n],!e)return;return e}static FindAll(e={},t){let r=t.split("/");if(r[0]==="."&&r.shift(),r[0]==="..")throw new Error("invalid path (no access to parent)");if(r[0]==="")throw new Error("invalid path (no access to root)");if(r[0]==="**")throw new Error("ENOTIMPL");return this.FindAllTail(e,r)}static FindAllTail(e,t){if(Array.isArray(e))return e.reduce((r,n)=>r.concat(this.FindAllTail(n,t)),[]);for(let r=0;r<t.length;r++){let n=t[r];if(n==="*"?e=Object.keys(e).filter(i=>i!=="a$"&&i!=="t$").map(i=>e[i]):e=e[n],!e)return[];if(Array.isArray(e)){if(r===t.length-1||e.length===0)return e;let i=t.slice(1);return e.reduce((a,o)=>a.concat(this.FindAllTail(o,i)),[])}}return[e]}};var We=class{strings=[];reverse={};FromXML(e){this.strings=[],this.reverse={};let t=0;for(let r of se.FindAll(e,"sst/si")){if(r.t){let n="";typeof r.t=="string"?n=r.t:r.t.t$&&(n=r.t.t$),this.strings[t]=n,this.reverse[n]=t}else if(r.r){let i=se.FindAll(r.r,"t").map(a=>typeof a=="string"?a:a.t$||"").join("");this.strings[t]=i,this.reverse[i]=t}else console.warn(` ** unexpected shared string @ ${t}`),console.info(r);t++}}Get(e){return this.strings[e]}Ensure(e){e[0]==="\'"&&(e=e.substring(1));let t=this.reverse[e];return typeof t=="number"||(t=this.strings.length,this.strings.push(e),this.reverse[e]=t),t}};var Ot=class{colors={};FromXML(e){let t=Object.keys(e)[0],r="",n=t.toString().match(/^(.*?):/);if(n&&(r=n[1]+":"),e[t]&&e[t][`${r}themeElements`]){let i=e[t][`${r}themeElements`][`${r}clrScheme`];for(let a of Ot.color_map){let o=i[`${r}${a}`],u,d="rgb";o[`${r}srgbClr`]?(d="rgb",u=o[`${r}srgbClr`].a$.val||""):o[`${r}sysClr`]&&(d="system",u=o[`${r}sysClr`].a$.lastClr||""),this.colors[a]={name:a,value:u,type:d}}}}},Be=Ot;ie(Be,"color_map",["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"]);var Ie=class{date_format=!1;string_format=!1;fraction_format=!1;twelve_hour=!1;fraction_denominator=0;fraction_integer=!0;fraction_align=0;fraction_denominator_digits=0;integer_min_digits=0;decimal_min_digits=0;decimal_max_digits=0;grouping=!1;has_number_format=!1;prefix=[{text:""}];suffix=[{text:""}];scaling=0;percent=!1;exponential=!1;has_asterisk=!1};var ei=42,ti=95,jt=63,ct=48,ri=46,Yt=44,ii=37,Ht=34,Xe=35,ni=59,dt=92,si=64,$n=91,qn=93,ai=69,oi=101,Jn=72,Xn=104,Qn=77,Kn=109,es=83,ts=115,rs=68,is=100,ns=89,ss=121,as=65,os=97;var xe=class{static Parse(e){if(this.pattern=e,this.characters=e.split("").map(t=>t.charCodeAt(0)),this.char_index=0,this.current_section=new Ie,this.sections=[this.current_section],this.ParseDatePattern())return this.sections;for(this.char_index=0,this.current_section=new Ie,this.sections=[this.current_section];this.char_index<this.characters.length;)this.ConsumeChar();return this.sections}static ConsumeString(){let e="";for(this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case dt:this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index+1<this.characters.length&&(e+=this.pattern[++this.char_index]);break;case Ht:return this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated string")}static ConsumeFormatting(){let e="";for(++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case dt:throw new Error("invalid escape character in formatting block");case qn:return this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated format")}static ScanFractionFormat(){let e=/^([#?]+ +){0,1}([#?]+)\\/([#?0-9]+)(?:$|[^#?0-9])/,r=this.pattern.substr(this.char_index).match(e);if(!r)return!1;let n=(r[1]||"").length+r[2].length+r[3].length+1;this.current_section.fraction_format=!0,this.current_section.fraction_integer=!!r[1];let i=Number(r[3]);return isNaN(i)||(this.current_section.fraction_denominator=i),this.current_section.decimal_max_digits=this.current_section.fraction_denominator_digits=r[3].length,this.char_index+=n,this.current_section.has_number_format=!0,!0}static ConsumeNumberFormat(){let e=0;for(this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case this.group_separator:{let r=!1;for(let n=this.char_index+1;!r&&n<this.characters.length;n++){let i=this.characters[n];if(i===this.decimal_mark||i===Xe||i===ct)r=!0;else if(i!==Yt)break}if(r){if(e===1)throw new Error("invalid grouping in decimal part");this.current_section.grouping=!0}else this.current_section.scaling=(this.current_section.scaling||1)*1e3}break;case this.decimal_mark:if(e===1)throw new Error("too many decimal marks");e=1;break;case Xe:e===1?this.current_section.decimal_max_digits++:this.current_section.integer_min_digits&&this.current_section.integer_min_digits++;break;case ct:e===1?(this.current_section.decimal_max_digits++,this.current_section.decimal_min_digits=this.current_section.decimal_max_digits):this.current_section.integer_min_digits++;break;default:return}}static AppendCharAsText(e=!0){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=this.pattern[this.char_index]:this.current_section.prefix[this.current_section.prefix.length-1].text+=this.pattern[this.char_index],e&&this.char_index++}static AppendString(e){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=e:this.current_section.prefix[this.current_section.prefix.length-1].text+=e}static AppendTextPart(e){this.current_section.has_number_format?(this.current_section.suffix.push(e),this.current_section.suffix.push({text:""})):(this.current_section.prefix.push(e),this.current_section.prefix.push({text:""}))}static ConsumeChar(){let e=this.characters[this.char_index];if(!((e===jt||e===Xe)&&!this.current_section.has_number_format&&!this.current_section.string_format&&this.ScanFractionFormat()))switch(e){case ni:this.char_index++,this.current_section=new Ie,this.sections.length===3&&(this.current_section.string_format=!0),this.sections.push(this.current_section);break;case si:this.char_index++,this.AppendTextPart({text:"@",flag:5}),this.current_section.string_format=!0;break;case ct:case Xe:case ri:case Yt:!this.current_section.has_number_format&&!this.current_section.string_format?(this.ConsumeNumberFormat(),this.current_section.has_number_format=!0):this.AppendCharAsText();break;case $n:this.AppendTextPart({text:this.ConsumeFormatting(),flag:6});break;case Ht:this.AppendString(this.ConsumeString());break;case jt:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case ti:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case ei:if(this.current_section.has_asterisk)throw new Error("we don\'t support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case oi:case ai:this.current_section.percent||this.current_section.exponential||this.current_section.string_format?this.AppendCharAsText():(this.current_section.exponential=!0,this.char_index++);break;case ii:!this.current_section.exponential&&!this.current_section.string_format&&(this.current_section.percent=!0),this.AppendCharAsText();break;case dt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}static ParseDatePattern(){for(this.date_pattern=!0;this.date_pattern&&this.char_index<this.pattern.length;)this.DatePatternConsumeChar();if(this.date_pattern){this.date_pattern=!1;for(let e of this.sections)for(let t of e.prefix)t.flag&&t.flag&7&&(this.date_pattern=!0)}return this.date_pattern&&(this.sections[0].date_format=!0,this.sections[0].prefix.forEach((e,t)=>{if(e.flag===3&&(e.text==="mm"||e.text==="m")){if(t)for(let r=t-1;r;r--){let n=this.sections[0].prefix[r];if(n.flag===3){/h/i.test(n.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}if(t<this.sections[0].prefix.length-1)for(let r=t+1;r<this.sections[0].prefix.length;r++){let n=this.sections[0].prefix[r];if(n.flag===3){/s/i.test(n.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}}})),this.date_pattern}static ConsumeDatePart(){let e=this.pattern[this.char_index++],t=e.toLowerCase(),r={text:e,flag:3};for(;this.pattern[this.char_index]&&this.pattern[this.char_index].toLowerCase()===t;)r.text+=this.pattern[this.char_index++];if(t==="s"&&this.pattern[this.char_index]===".")for(r.text+=this.pattern[this.char_index++];this.pattern[this.char_index]==="0";)r.text+=this.pattern[this.char_index++];return r}static ConsumeAMPM(){let e=this.pattern.substr(this.char_index,5);if(e==="am/pm"||e==="AM/PM")return this.char_index+=5,this.sections[0].twelve_hour=!0,{text:e,flag:3};if(e=this.pattern.substr(this.char_index,3),e==="a/p"||e==="A/P")return this.char_index+=3,this.sections[0].twelve_hour=!0,{text:e,flag:3}}static DatePatternConsumeChar(){switch(this.characters[this.char_index]){case ni:this.char_index=this.characters.length;break;case ct:case Xe:case oi:case ai:case ii:case si:this.date_pattern=!1;break;case Jn:case Xn:case Qn:case Kn:case es:case ts:case rs:case is:case ns:case ss:this.AppendTextPart(this.ConsumeDatePart());break;case as:case os:{let t=this.ConsumeAMPM();t?this.AppendTextPart(t):this.AppendCharAsText()}break;case Ht:this.AppendString(this.ConsumeString());break;case jt:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case ti:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case ei:if(this.current_section.has_asterisk)throw new Error("we don\'t support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case dt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}};ie(xe,"date_pattern",!1),ie(xe,"pattern",""),ie(xe,"char_index",0),ie(xe,"characters",[]),ie(xe,"sections",[]),ie(xe,"current_section",new Ie),ie(xe,"preserve_formatting_characters",!1),ie(xe,"decimal_mark",ri),ie(xe,"group_separator",Yt);var us=s=>(s>=60&&s--,new Date(-22090752e5+864e5*s)),ui=(s,e=!0)=>{if(e){let t=new Date(s),r=new Date;r.setUTCMilliseconds(t.getUTCMilliseconds()),r.setUTCSeconds(t.getUTCSeconds()),r.setUTCMinutes(t.getUTCMinutes()),r.setUTCHours(t.getHours()),r.setUTCDate(t.getDate()),r.setUTCMonth(t.getMonth()),r.setUTCFullYear(t.getFullYear()),s=r.getTime()}return s=(s+22090752e5)/864e5,s>=60&&s++,s},ke=class{magic_decimal=!1;transform_value;_pattern="";sections;decimal_zero_regexp=[];cloned=[];get pattern(){return this._pattern}get date_format(){return this.sections[0]&&this.sections[0].date_format}constructor(e){if(this._pattern=e,this.sections=xe.Parse(e),this.sections.length||(this.sections=[]),this.sections[0]||(this.sections[0]=new Ie),this.sections[1]||(this.sections[1]={...this.sections[0]},this.sections[1].prefix=JSON.parse(JSON.stringify(this.sections[1].prefix)),this.sections[1].suffix=JSON.parse(JSON.stringify(this.sections[1].suffix)),this.sections[1].prefix.push({text:"-"}),this.cloned[1]=!0),this.sections[2]||(this.sections[2]={...this.sections[0]},this.cloned[2]=!0),!this.sections[3]){for(let t of this.sections[0].prefix)if(t.flag===5){this.sections[3]={...this.sections[0]},this.sections[3].string_format=!0,this.cloned[3]=!0;break}}this.decimal_zero_regexp=this.sections.map(t=>{if(t.decimal_max_digits>t.decimal_min_digits)return new RegExp(`0{1,${t.decimal_max_digits-t.decimal_min_digits}}(?:$|e)`)})}static FormatPartsAsText(e,t=0){let r=-1,n=e.map((i,a)=>{switch(i.flag){case 2:return r=a,i.text;case 1:return i.text.replace(/./g," ");case 6:return"";default:return i.text}});if(r>=0&&t){let i=n.reduce((o,u,d)=>d===r?o:o+u.length,0),a="";for(let o=0;o<t-i;o++)a+=n[r];n[r]=a}return n.join("")}SetDecimal(e){for(let t of this.sections)t.fraction_format||(t.decimal_min_digits=e,t.decimal_max_digits=e)}IncreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.min(e.fraction_denominator_digits+1,4)):(e.decimal_min_digits++,e.decimal_max_digits=e.decimal_min_digits)})}DecreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.max(e.fraction_denominator_digits-1,1)):(e.decimal_min_digits=Math.max(0,e.decimal_min_digits-1),e.decimal_max_digits=e.decimal_min_digits)})}AddGrouping(){this.sections.forEach(e=>{e.grouping=!0})}RemoveGrouping(){this.sections.forEach(e=>{e.grouping=!1})}ToggleGrouping(){let e=!this.sections[0].grouping;this.sections.forEach(t=>{t.grouping=e})}toString(){return this.sections[0].date_format?this._pattern:this.sections.filter((e,t)=>!this.cloned[t]).map(e=>{let t="",r=0;if(e.fraction_format){e.fraction_integer&&(t+="? ");let n="";for(let i=0;i<e.fraction_denominator_digits;i++)n+="#";t+=n,t+="/",e.fraction_denominator?t+=e.fraction_denominator:t+=n}else if(e.has_number_format){for(r=0;r<e.integer_min_digits;r++)t+="0";if(e.grouping&&(t.length<4&&(t=("####"+t).slice(-4)),t=t.replace(/[\\d#]{1,3}(?=([\\d#]{3})+(?![\\d#]))/g,"$&,")),e.decimal_max_digits||e.decimal_min_digits){for(t+=".",r=0;r<e.decimal_min_digits;r++)t+="0";for(;r<e.decimal_max_digits;r++)t+="#"}if(e.scaling){let n=Math.log10(e.scaling)/3;for(r=0;r<n;r++)t+=","}e.exponential&&(t+="e")}return e.prefix.map(n=>n.flag===1?n.text==="0"?"?":"_"+n.text:n.flag===2?"*"+n.text:n.flag===6?"["+n.text+"]":n.text).join("")+t+e.suffix.map(n=>n.flag===1?n.text==="0"?"?":"_"+n.text:n.flag===2?"*"+n.text:n.text).join("")}).join(";")}FormatDimensionedQuantity(e){if(this.transform_value){let r=this.transform_value(e);if(Ft(r))e=r;else return typeof r=="string"?r:this.FormatParts(r)}let t=this.FormatParts(e.value||0);return e.unit&&t.push({text:" "},{text:e.unit}),t}FormatComplex(e){let t=[],r=[],n=!1,i=!!e.imaginary;i&&(t=this.FormatParts(e.imaginary),i=t.some(u=>/[1-9]/.test(u.text)),t.length===1&&this.sections[0].integer_min_digits<=1&&t[0].text==="1"?(t[0].text="",n=!0):t.length===1&&this.sections[1].integer_min_digits<=1&&t[0].text==="-1"&&(t[0].text="-",n=!0));let a=!!e.real;a&&(r=this.FormatParts(e.real),a=r.some(u=>/[1-9]/.test(u.text)));let o=[];if(a||!a&&!i){if(o.push(...r),i){let u=Math.abs(e.imaginary);o.push({text:e.imaginary<0?` ${ke.minus_character} `:" + "});let d=n?[]:this.FormatParts(Math.abs(e.imaginary));o.push(...d,{text:ke.imaginary_character})}}else i&&o.push(...t,{text:ke.imaginary_character});return o}FormatParts(e){if(typeof e!="number"&&!this.sections[3])return[{text:e.toString()}];let{parts:t,section:r}=this.BaseFormat(e),n=[];if(r.date_format||r.string_format)for(let i of t)typeof i=="string"?n.push({text:i}):n.push(i);else this.magic_decimal&&t[1]===""&&t.splice(1,1),n=[...r.prefix.map(i=>({...i})),{text:r.has_number_format?t.join(oe.decimal_separator):""},...r.suffix.map(i=>({...i}))];for(let i=1;i<n.length;i++)n[i].flag===n[i-1].flag&&(n[i].text=n[i-1].text+n[i].text,n[i-1].text="");return n.filter(i=>i.text)}Format(e,t=0){return ke.FormatPartsAsText(this.FormatParts(e),t)}ZeroPad(e,t){for(;e.length<t;)e="0"+e;return e}DateFormat(e){let t=us(e),r=this.sections[0],n=t.getUTCHours();return r.twelve_hour&&(n>12&&(n-=12),n===0&&(n=12)),{parts:r.prefix.map(a=>{if(a.flag===4)return a.text==="mm"?{text:this.ZeroPad(t.getUTCMinutes().toString(),2)}:{text:this.ZeroPad(t.getUTCMinutes().toString(),1)};if(a.flag===3){switch(a.text.toLowerCase()){case"am/pm":case"a/p":{let u=a.text.split("/");return{text:t.getUTCHours()>12?u[1]:u[0]}}case"mmmmm":return{text:oe.date_components.long_months[t.getUTCMonth()][0]};case"mmmm":return a.text==="MMMM"?{text:oe.date_components.long_months[t.getUTCMonth()].toUpperCase()}:{text:oe.date_components.long_months[t.getUTCMonth()]};case"mmm":return a.text==="MMM"?{text:oe.date_components.short_months[t.getUTCMonth()].toUpperCase()}:{text:oe.date_components.short_months[t.getUTCMonth()]};case"mm":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),2)};case"m":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),1)};case"ddddd":case"dddd":return a.text==="DDDDD"||a.text==="DDDD"?{text:oe.date_components.long_days[t.getUTCDay()].toUpperCase()}:{text:oe.date_components.long_days[t.getUTCDay()]};case"ddd":return a.text==="DDD"?{text:oe.date_components.short_days[t.getUTCDay()].toUpperCase()}:{text:oe.date_components.short_days[t.getUTCDay()]};case"dd":return{text:this.ZeroPad(t.getUTCDate().toString(),2)};case"d":return{text:this.ZeroPad(t.getUTCDate().toString(),1)};case"yyyy":case"yyy":return{text:t.getUTCFullYear().toString()};case"yy":case"y":return{text:this.ZeroPad((t.getUTCFullYear()%100).toString(),2)};case"hh":return{text:this.ZeroPad(n.toString(),2)};case"h":return{text:this.ZeroPad(n.toString(),1)};case"ss":return{text:this.ZeroPad(t.getUTCSeconds().toString(),2)};case"s":return{text:this.ZeroPad(t.getUTCSeconds().toString(),1)}}let o=a.text.match(/^(s+)\\.(0+)$/);if(o)return{text:this.ZeroPad(t.getUTCSeconds().toString(),o[1].length)+oe.decimal_separator+(t.getUTCMilliseconds()/1e3).toFixed(o[2].length).substr(2)}}return{...a}}),section:r}}StringFormat(e,t){let r=[];for(let n of t.prefix)n.flag===5?r.push({text:e}):r.push({...n});return{parts:r,section:t}}Round2(e,t){let r=Math.pow(10,t);return Math.round(r*e)/r}FormatFraction(e,t){t.percent&&(e*=100);let r={denominator:1,numerator:Math.round(e),error:Math.abs(Math.round(e)-e)};if(t.fraction_denominator)r.denominator=t.fraction_denominator,r.numerator=Math.round(e*r.denominator);else if(r.error){let i=ke.fraction_limits[t.fraction_denominator_digits-1]||ke.fraction_limits[0];for(let a=2;a<=i;a++){let o=Math.round(e*a),u=Math.abs(o/a-e);if(u<r.error&&(r={numerator:o,denominator:a,error:u},!u))break}}let n=[];if(t.fraction_integer){let i=Math.floor(r.numerator/r.denominator);r.numerator%=r.denominator,(i||!r.numerator)&&(n.push(i.toString()),r.numerator&&n.push(" "))}else r.numerator||n.push("0");return r.numerator&&(n.push(r.numerator.toString()),n.push("/"),n.push(r.denominator.toString())),n.join("")}BaseFormat(e){if(this.sections[0].date_format)return this.DateFormat(Number(e));if(typeof e!="number")return this.StringFormat(e.toString(),this.sections[3]);let t=this.sections[0],r=this.decimal_zero_regexp[0];e<0&&(t=this.sections[1]);let n=t.percent?t.decimal_max_digits+2:t.decimal_max_digits,i=Math.pow(10,-n)/2,a=Math.abs(e);if(a<i&&(t=this.sections[2],r=this.decimal_zero_regexp[2]),t.scaling&&(a/=t.scaling,a<i&&(t=this.sections[2],r=this.decimal_zero_regexp[2])),t.string_format)return this.StringFormat(e.toString(),t);let o="";if(t.fraction_format)return{parts:[this.FormatFraction(a,t)],section:t};t.exponential?o=a.toExponential(t.decimal_max_digits):(t.percent&&(a*=100),o=this.Round2(a,t.decimal_max_digits).toFixed(t.decimal_max_digits)),r&&(o=o.replace(r,""));let u=o.split(".");for(;u[0].length<t.integer_min_digits;)u[0]=("0000000000000000"+u[0]).slice(-t.integer_min_digits);return t.integer_min_digits===0&&u[0]==="0"&&(u[0]=""),t.grouping&&(u[0]=u[0].replace(ke.grouping_regexp,"$&"+oe.grouping_separator)),{parts:u,section:t}}},_e=ke;ie(_e,"grouping_regexp",/\\d{1,3}(?=(\\d{3})+(?!\\d))/g),ie(_e,"fraction_limits",[9,99,999,9999]),ie(_e,"imaginary_character","\\u{1D456}"),ie(_e,"minus_character","-");var De=class{static Get(e,t=!1){if(t&&e==="General")return this.complex_general;let r=this.symbolc_name_map[e.toLowerCase()],n=this.cache[r||e];return n||(n=new _e(e),this.cache[e]=n),n}static Equals(e,t){if(e===t)return!0;let r=this.Get(e),n=this.Get(t);return r.pattern===n.pattern}static Translate(e){let t=this.symbolc_name_map[e.toLowerCase()];return t?this.cache[t].toString():e}static SymbolicName(e){for(let t of Object.keys(this.base_formats))if(e===this.base_formats[t])return t;return null}static InitCache(){for(let e of Object.keys(this.base_formats))this.cache[e]=new _e(this.base_formats[e]),this.symbolc_name_map[e.toLowerCase()]=e;this.cache.General.magic_decimal=!0,this.complex_general=new _e("0.###"),this.complex_general.magic_decimal=!0;for(let e of Object.keys(this.aliases))this.cache[e]=this.cache[this.aliases[e]],this.symbolc_name_map[e.toLowerCase()]=e}};ie(De,"cache",{}),ie(De,"complex_general"),ie(De,"symbolc_name_map",{}),ie(De,"base_formats",{Accounting:"_(#,##0.00_);(#,##0.00);-???",Number:"0.00",Integer:"0",Percent:"0.00%",General:"0.######",Fraction:"# ?/?",Dollar:"$* _(#,##0.00_);$* (#,##0.00);$* -???",Exponential:"0.000e","Short Date":"mm/dd/yy","Long Date":"dddd, mmm d yyyy",Timestamp:"mm-dd-yy hh:mm:ss"}),ie(De,"aliases",{Scientific:"Exponential",Percentage:"Percent",Currency:"Dollar"});De.InitCache();var li=new Date().getUTCFullYear(),$t=class{compare_day;compare_month;TestDate(e){let t=Date.parse(e);if(isNaN(t))return!1;let r=new Date(t),i=e.replace(/[\\d\\-\\\\/,.\\s]+/g," ").toLocaleLowerCase().split(/\\s+/).map(u=>u.trim()).filter(u=>!!u);if(!i.length)return t;if(!this.compare_month){this.compare_month={};for(let u=0;u<12;u++)this.compare_month[oe.date_components.long_months[u].toLocaleLowerCase().replace(/\\./,"")]=u,this.compare_month[oe.date_components.short_months[u].toLocaleLowerCase().replace(/\\./,"")]=u}if(!this.compare_day){this.compare_day={};for(let u=0;u<7;u++)this.compare_day[oe.date_components.long_days[u].toLocaleLowerCase().replace(/\\./,"")]=u,this.compare_day[oe.date_components.short_days[u].toLocaleLowerCase().replace(/\\./,"")]=u}let a=!1,o=!1;for(let u of i){let d=!1;for(let[p,l]of Object.entries(this.compare_month))if(u===p){if(a||r.getUTCMonth()!==l)return!1;d=!0,a=!0}if(!d){for(let[p,l]of Object.entries(this.compare_day))if(u===p){if(o||r.getUTCDay()!==l)return!1;d=!0,o=!0}}if(!d)return!1}return o&&!a?!1:t}TryParse(e=""){let t=0;if(e[0]==="\'")return{value:e,type:2};if(e==="")return{value:e,type:2};if(e==="NaN")return{value:NaN,type:3,hints:1};let r=e.trim(),n=r.match(/^[$](.*?)$/);n&&(r=n[1],t|=8);let i=r.match(/^\\((.*?)\\)$/);i&&(r=i[1],t|=32);let a=r.match(/^(.*?)%\\s*$/);a&&(r=a[1],t|=4),oe.decimal_separator==="."?/,/.test(r)&&(r=r.replace(/,/g,""),t|=16):(r=r.replace(/(\\d)\\s+/g,"$1"),r=r.replace(/\\./g,""),r=r.replace(/,/,"."));let o=Number(r);if(o===null||isNaN(o)){let u=e.toLowerCase();if(u==="false")return{value:!1,type:4};if(u==="true")return{value:!0,type:4};let d=this.TestDate(e);if(d!==!1&&!isNaN(d)){let p=new Date(d),l=p.getUTCFullYear();if(l>=li-200&&l<=li+200)return t=64,(p.getHours()||p.getMinutes()||p.getSeconds())&&(t|=128),{value:ui(d),type:3,hints:t}}return{value:e,type:2}}if(i&&(o=-o),a){let u=o<0?-1:1,d=(u*o).toString().split(".");d[0]=("00"+d[0]).replace(/(\\d\\d)$/,".$1"),o=Number(d.join(""))*u}return/e/.test(e)&&(t|=2),{value:o,type:3,hints:t}}},io=new $t;var ci=Fe(st()),qt={top:{},left:{},bottom:{},right:{},diagonal:{}},ht=class{theme=new Be;cell_xfs=[];fonts=[];borders=[];fills=[];number_formats=[];base_number_format_id=200;modified=!1;Clamp(e,t,r){return Math.max(t,Math.min(e,r))}TintColor(e,t){let r=parseInt(e.substr(0,2),16),n=parseInt(e.substr(2,2),16),i=parseInt(e.substr(4,2),16);return t<0?(r=Math.round(r*t+r),n=Math.round(n*t+n),i=Math.round(i*t+i)):(r=Math.round((255-r)*t+r),n=Math.round((255-n)*t+n),i=Math.round((255-i)*t+i)),[r,n,i].map(a=>{let o=this.Clamp(a,0,255).toString(16);return o.length<2?"0"+o:o}).join("")}StyleOptionsFromProperties(e){let t=JSON.parse(JSON.stringify(e));for(let d of Object.keys(t))t[d]==="none"&&delete t[d];let r={},n={pattern_type:"none"},i=JSON.parse(JSON.stringify(qt)),a={font:r,border:i};t.number_format&&(a.number_format={format:De.Translate(t.number_format),symbolic_name:t.number_format}),t.font_size?.unit&&t.font_size.value&&(t.font_size.unit!=="pt"?console.warn("can\'t handle non-point font (FIXME)"):r.size=t.font_size.value),t.bold&&(r.bold=!0),t.italic&&(r.italic=!0),t.underline&&(r.underline=!0),t.text&&(t.text.text?r.color_argb=t.text.text:typeof t.text.theme=="number"&&(r.color_theme=t.text.theme,t.text.tint&&(r.color_tint=t.text.tint)));let o=(d,p)=>{d.width&&(p.style="thin",d.color.text?p.rgba=d.color.text:typeof d.color.theme=="number"?(p.theme=d.color.theme,d.color.tint&&(p.tint=d.color.tint)):p.color=64)},u=pe.CompositeBorders(t);switch(o(u.top,i.top),o(u.left,i.left),o(u.right,i.right),o(u.bottom,i.bottom),t.vertical_align){case pe.VerticalAlign.Top:a.vertical_alignment="top";break;case pe.VerticalAlign.Middle:a.vertical_alignment="center";break}switch(t.horizontal_align){case pe.HorizontalAlign.Center:a.horizontal_alignment="center";break;case pe.HorizontalAlign.Left:a.horizontal_alignment="left";break;case pe.HorizontalAlign.Right:a.horizontal_alignment="right";break}return t.fill&&(n.pattern_type="solid",t.fill.text?n.fg_color={argb:t.fill.text}:typeof t.fill.theme=="number"?(n.fg_color={theme:t.fill.theme},t.fill.tint&&(n.fg_color.tint=t.fill.tint)):n.fg_color={theme:1},a.fill=n),t.wrap&&(a.wrap=!0),a}CellXfToStyle(e){let t={},r=ht.default_styles[e.number_format];if(!r){for(let u of this.number_formats)if(u.id===e.number_format&&u.format){r=u.format;break}}if(r){let u=/\\[\\$(.)-[0-9A-Za-z]{1,4}\\]/g;r=r.replace(u,"$1");let d=/\\[\\$-[0-9A-Za-z]{1,4}\\]/g;r=r.replace(d,""),t.number_format=r}let n=this.fonts[0],i=this.fonts[e.font||0];i&&(i.bold&&(t.bold=!0),i.italic&&(t.italic=!0),i.underline&&(t.underline=!0),i.strike&&(t.strike=!0),n&&n.size&&i.size&&n.size!==i.size&&(t.font_size={value:100*i.size/n.size,unit:"%"}),i.color_argb?t.text={text:"#"+(i.color_argb.length>6?i.color_argb.substr(i.color_argb.length-6):i.color_argb)}:typeof i.color_theme=="number"&&(t.text={theme:i.color_theme}));let a=this.fills[e.fill||0];if(a&&a.pattern_type!=="none"){if(a.pattern_type==="gray"){let u=Math.round((a.pattern_gray||0)/1e3*255);t.fill={text:`rgb(${u}, ${u}, ${u})`}}a.pattern_type==="solid"&&a.fg_color&&(a.fg_color.argb?t.fill={text:"#"+(a.fg_color.argb.length>6?a.fg_color.argb.substr(a.fg_color.argb.length-6):a.fg_color.argb)}:typeof a.fg_color.theme=="number"&&(t.fill={theme:a.fg_color.theme},a.fg_color.tint&&(t.fill.tint=Math.round(a.fg_color.tint*1e3)/1e3)))}switch(e.horizontal_alignment){case"center":t.horizontal_align=pe.HorizontalAlign.Center;break;case"right":t.horizontal_align=pe.HorizontalAlign.Right;break;case"left":t.horizontal_align=pe.HorizontalAlign.Left;break}switch(e.vertical_alignment){case"center":t.vertical_align=pe.VerticalAlign.Middle;break;case"top":t.vertical_align=pe.VerticalAlign.Top;break;case"bottom":t.vertical_align=pe.VerticalAlign.Bottom;break}e.wrap_text&&(t.wrap=!0);let o=this.borders[e.border||0];return o&&(o.bottom.style&&(o.bottom.style==="double"?t.border_bottom=2:t.border_bottom=1),o.left.style&&(t.border_left=1),o.top.style&&(t.border_top=1),o.right.style&&(t.border_right=1)),t}CellXfToStyles(){return this.cell_xfs.map(e=>this.CellXfToStyle(e))}EnsureNumberFormat(e){if(typeof e.format>"u"||e.symbolic_name&&/^general$/i.test(e.symbolic_name))return 0;for(let r=0;r<100;r++){let n=ht.default_styles[r];if(n&&n===e.format)return r}for(let r of this.number_formats)if(r.format===e.format)return r.id||0;this.modified=!0;let t={id:this.base_number_format_id++,format:e.format};return this.number_formats.push(t),t.id}CompareBorderEdge(e,t){return e.color===t.color&&e.rgba===t.rgba&&e.style===t.style&&e.theme===t.theme&&e.tint===t.tint}CompareBorder(e,t){return this.CompareBorderEdge(e.top,t.top)&&this.CompareBorderEdge(e.left,t.left)&&this.CompareBorderEdge(e.bottom,t.bottom)&&this.CompareBorderEdge(e.right,t.right)&&this.CompareBorderEdge(e.diagonal,t.diagonal)}EnsureBorder(e){for(let r=0;r<this.borders.length;r++){let n=this.borders[r];if(this.CompareBorder(n,e))return r}this.modified=!0;let t=JSON.parse(JSON.stringify(e));return this.borders.push(t),this.borders.length-1}MatchColor(e,t){return!e&&!t?!0:!e||!t?!1:e.argb===t.argb&&e.indexed===t.indexed&&e.theme===t.theme&&e.tint===t.tint}EnsureFill(e){for(let r=0;r<this.fills.length;r++){let n=this.fills[r];if(this.MatchColor(e.bg_color,n.bg_color)&&this.MatchColor(e.fg_color,n.fg_color)&&e.pattern_gray===n.pattern_gray&&e.pattern_type===n.pattern_type)return r}this.modified=!0;let t={...e};return this.fills.push(t),this.fills.length-1}EnsureFont(e){let t={...this.fonts[0],...e};for(let r=0;r<this.fonts.length;r++){let n=this.fonts[r];if(n.bold===t.bold&&n.italic===t.italic&&n.underline===t.underline&&n.size===t.size&&n.strike===t.strike&&n.color_argb===t.color_argb&&n.color_theme===t.color_theme&&n.color_tint===t.color_tint&&n.family===t.family)return r}return this.modified=!0,this.fonts.push(t),this.fonts.length-1}EnsureStyle(e){let t=this.EnsureFont(e.font||{}),r=this.EnsureBorder(e.border||qt),n=this.EnsureNumberFormat(e.number_format||{}),i=this.EnsureFill(e.fill||{pattern_type:"none"});for(let o=0;o<this.cell_xfs.length;o++){let u=this.cell_xfs[o];if(u.font===t&&u.fill===i&&u.border===r&&u.number_format===n&&!!u.wrap_text==!!e.wrap&&(!e.horizontal_alignment&&!u.horizontal_alignment||e.horizontal_alignment===u.horizontal_alignment)&&(!e.vertical_alignment&&!u.vertical_alignment||e.vertical_alignment===u.vertical_alignment))return o}this.modified=!0;let a={font:t,fill:i,border:r,number_format:n};return e.horizontal_alignment&&(a.horizontal_alignment=e.horizontal_alignment),e.vertical_alignment&&(a.vertical_alignment=e.vertical_alignment),e.wrap&&(a.wrap_text=!0),this.cell_xfs.push(a),this.cell_xfs.length-1}FromXML(e,t){let r=se.FindAll.bind(se,e);this.theme=t;let n=r("styleSheet/numFmts/numFmt");this.number_formats=n.map(i=>({id:Number(i.a$?.numFmtId||0),format:ci.decode(i.a$?.formatCode||"")})),n=r("styleSheet/borders/border"),this.borders=n.map(i=>{let a=JSON.parse(JSON.stringify(qt));return i.left&&(a.left.style=i.left.a$.style,a.left.color=Number(i.left.color?.a$?.indexed)),i.right&&(a.right.style=i.right.a$.style,a.right.color=Number(i.right.color?.a$?.indexed)),i.top&&(a.top.style=i.top.a$.style,a.top.color=Number(i.top.color?.a$?.indexed)),i.bottom&&(a.bottom.style=i.bottom.a$.style,a.bottom.color=Number(i.bottom.color?.a$?.indexed)),a}),n=r("styleSheet/cellXfs/xf"),this.cell_xfs=n.map(i=>{let a={number_format:Number(i.a$.numFmtId),font:Number(i.a$.fontId),fill:Number(i.a$.fillId),border:Number(i.a$.borderId),xfid:Number(i.a$.xfId)};return i.alignment&&(a.horizontal_alignment=i.alignment.a$.horizontal,a.vertical_alignment=i.alignment.a$.vertical,a.wrap_text=!!i.alignment.a$.wrapText),a}),n=r("styleSheet/fills/fill"),this.fills=n.map(i=>{let a={pattern_type:"none"};if(i.patternFill){let o=i.patternFill.a$?.patternType;switch(o){case"none":case void 0:break;case"solid":a.pattern_type="solid",i.patternFill.fgColor&&(a.fg_color={theme:i.patternFill.fgColor.a$?.theme?Number(i.patternFill.fgColor.a$.theme):void 0,indexed:i.patternFill.fgColor.a$?.indexed?Number(i.patternFill.fgColor.a$.indexed):void 0,tint:i.patternFill.fgColor.a$?.tint?Number(i.patternFill.fgColor.a$.tint):void 0,argb:i.patternFill.fgColor.a$?.rgb});break;default:{let u=o?.match(/^gray(\\d+)$/);if(u){a.pattern_type="gray",a.pattern_gray=Number(u[1]);break}}}}return a}),n=r("styleSheet/fonts/font"),this.fonts=n.map(i=>{let a={};return a.italic=typeof i.i<"u",a.bold=typeof i.b<"u",a.underline=typeof i.u<"u",a.strike=typeof i.strike<"u",i.sz&&(a.size=Number(i.sz.a$.val)),i.scheme&&(a.scheme=i.scheme.a$.val),i.name&&(a.name=i.name.a$.val),i.family&&(a.family=Number(i.family.a$.val)),i.color&&(i.color.a$?.theme&&(a.color_theme=Number(i.color.a$.theme)),i.color.a$?.tint&&(a.color_tint=Number(i.color.a$.tint)),i.color.a$?.rgb&&(a.color_argb=i.color.a$.rgb)),a})}},Ze=ht;ie(Ze,"default_styles",{0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"mm-dd-yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",37:"#,##0 ;(#,##0)",38:"#,##0 ;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@"});var Ce=(s,e,t,r)=>{let i=`rId${Object.keys(s).length+1}`;return s[i]={id:i,type:e,target:t,mode:r},i};var sr=/[\\s-+=<>!()]/;var Jt=34,Xt=39,ls=160,cs=32,ds=9,hs=10,ps=13,Ne=48,Qe=57,Qt=46,Kt=43,Ke=45,di=40,er=41,pt=44,fs=37,tr=95,ft=36,ms=123,gs=125,hi=91,pi=93,bs=33,fi=59,As=35,Ge=65,et=97,xs=69,ys=101,mt=90,gt=122,ws=105;var rr=192,ir=312,nr={"==":6,"!=":6,"<>":6,"=":6,"<":7,">":7,"<=":7,">=":7,"+":9,"-":9,"&":9,"*":10,"/":10,"^":11,":":13},_s=Object.keys(nr).sort((s,e)=>e.length-s.length),Ds={"-":100,"+":100},Ue=class{argument_separator=",";decimal_mark=".";flags={spreadsheet_semantics:!0,dimensioned_quantities:!1,fractions:!0};r1c1_regex=/[rR]((?:\\[[-+]{0,1}\\d+\\]|\\d+))[cC]((?:\\[[-+]{0,1}\\d+\\]|\\d+))$/;argument_separator_char=pt;decimal_mark_char=Qt;imaginary_char=ws;imaginary_number="i";id_counter=0;expression="";data=[];index=0;length=0;valid=!0;error_position;error;dependencies={addresses:{},ranges:{}};address_refcount={};full_reference_list=[];Walk(e,t){switch(e.type){case"address":case"missing":case"literal":case"complex":case"identifier":case"operator":t(e);return;case"dimensioned":t(e)&&(this.Walk(e.expression,t),this.Walk(e.unit,t));return;case"range":t(e)&&(this.Walk(e.start,t),this.Walk(e.end,t));return;case"binary":t(e)&&(this.Walk(e.left,t),this.Walk(e.right,t));return;case"unary":t(e)&&this.Walk(e.operand,t);return;case"group":t(e)&&e.elements.forEach(r=>this.Walk(r,t));return;case"call":t(e)&&e.args.forEach(r=>this.Walk(r,t))}}Transpose(e){let t=e.length,r=[],n=0;for(let i=0;i<t;i++)Array.isArray(e[i])&&(n=Math.max(n,e[i].length));for(let i=0;i<n;i++){r[i]=[];for(let a=0;a<t;a++)r[i][a]=e[a][i]}return r}Render(e,t={rows:0,columns:0},r="(missing)",n,i,a){let o=this.argument_separator+" ";i===","?o=", ":i===";"&&(o="; ");let u=this.imaginary_number;a&&(u=a);let d=n===","?",":".",p=this.decimal_mark===","?/,/:/\\./;switch(e.type){case"address":return this.AddressLabel(e,t);case"range":return this.AddressLabel(e.start,t)+":"+this.AddressLabel(e.end,t);case"missing":return r;case"array":return"{"+this.Transpose(e.values).map(l=>l.map(b=>typeof b=="string"?\'"\'+b+\'"\':b).join(", ")).join("; ")+"}";case"binary":return this.Render(e.left,t,r,n,i)+" "+e.operator+" "+this.Render(e.right,t,r,n,i);case"unary":return e.operator+this.Render(e.operand,t,r,n,i);case"complex":if(e.real){let l=Math.abs(e.imaginary);return`${e.real||0}${e.imaginary<0?" - ":" + "}${l===1?"":l}i`}else return e.imaginary===-1?"-i":e.imaginary===1?"i":`${e.imaginary}i`;break;case"literal":if(typeof e.value=="string")return\'"\'+e.value.replace(/"/g,\'""\')+\'"\';if(n&&typeof e.value=="number")if(e.text){let l=e.text;return n===","&&this.decimal_mark==="."&&(l=l.replace(/,/g,"")),l.replace(p,d)}else return e.value.toString().replace(/\\./,d);else if(e.text)return e.text;return e.value.toString();case"identifier":return e.name;case"operator":return"["+e.operator+"]";case"group":return e.explicit?"("+e.elements.map(l=>this.Render(l,t,r,n,i)).join(o)+")":e.elements.map(l=>this.Render(l,t,r,n,i)).join(o);case"call":return e.name+"("+e.args.map(l=>this.Render(l,t,r,n,i)).join(o)+")";case"dimensioned":return this.Render(e.expression)+" "+this.Render(e.unit)}return"??"}Parse(e){switch(e=e.trim(),e[0]==="="&&(e=e.substr(1).trim()),this.expression=e,this.data=[],this.length=e.length,this.index=0,this.valid=!0,this.error_position=void 0,this.error=void 0,this.dependencies.addresses={},this.dependencies.ranges={},this.address_refcount={},this.full_reference_list=[],this.id_counter=0,this.argument_separator){case";":this.argument_separator_char=fi;break;default:this.argument_separator_char=pt;break}switch(this.decimal_mark){case",":this.decimal_mark_char=pt;break;default:this.decimal_mark_char=Qt;break}for(let n=0;n<this.length;n++)this.data[n]=e.charCodeAt(n);let t=this.ParseGeneric(),r={};for(let n of Object.keys(this.dependencies.addresses))this.address_refcount[n]&&(r[n]=this.dependencies.addresses[n]);return this.dependencies.addresses=r,{expression:t||void 0,valid:this.valid,error:this.error,error_position:this.error_position,dependencies:this.dependencies,separator:this.argument_separator,decimal_mark:this.decimal_mark,full_reference_list:this.full_reference_list.slice(0)}}ColumnLabel(e){if(e===1/0)return"";let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}AddressLabel(e,t){let r=e.column;!e.absolute_column&&e.column!==1/0&&(r+=t.columns);let n=e.row;if(!e.absolute_row&&e.row!==1/0&&(n+=t.rows),n<0||r<0||n===1/0&&r===1/0)return"#REF";let i="";return e.sheet&&(i=(sr.test(e.sheet)?"\'"+e.sheet+"\'":e.sheet)+"!"),n===1/0?i+(e.absolute_column?"$":"")+this.ColumnLabel(r):r===1/0?i+(e.absolute_row?"$":"")+(n+1):i+(e.absolute_column?"$":"")+this.ColumnLabel(r)+(e.absolute_row?"$":"")+(n+1)}ParseGeneric(e=[0]){let t=[];for(;this.index<this.length;){let r=this.ParseNext(t.length===0);if(typeof r=="number"){if(e.some(n=>r===n))break;if(r===di){this.index++;let n=this.ParseGeneric([er]);this.index++,n&&t.push({type:"group",id:this.id_counter++,elements:[n],explicit:!0})}else{let n=this.ConsumeOperator();n?t.push(n):(this.error=`unexpected character [1]: ${String.fromCharCode(r)}, ${r}`,this.valid=!1,this.index++)}}else t.push(r)}if(t.length){if(t=this.BinaryToRange2(t),this.flags.fractions){let r=[],n=a=>a.type==="literal"&&typeof a.value=="number"&&a.value%1===0,i=0;for(;i<t.length-3;i++)if(n(t[i])&&n(t[i+1])&&t[i+2].type==="operator"&&t[i+2].operator==="/"&&n(t[i+3])){let a=t[i],o=t[i+1],u=t[i+3],d=(a.value<0?-1:1)*(o.value/u.value);i+=3,r.push({id:t[i].id,type:"literal",text:this.expression.substring(a.position,u.position+1),value:a.value+d,position:a.position})}else r.push(t[i]);for(;i<t.length;i++)r.push(t[i]);t=r}if(t=t.map(r=>r.type==="identifier"&&r.name===this.imaginary_number?{type:"complex",real:0,imaginary:1,position:r.position,text:r.name,id:this.id_counter++}:r),this.flags.dimensioned_quantities){let r=[],n;for(let i=0;i<t.length;i++){let a=t[i];if(!n)n=a;else if(a.type==="identifier"&&(n.type==="literal"||n.type==="group"||n.type==="call")){let o=a;for(;t[i+1]?.type==="identifier";)o.name+=" "+t[++i].name;r.push({type:"dimensioned",expression:n,unit:a,id:this.id_counter++}),n=void 0}else r.push(n),n=a}n&&r.push(n),t=r}}return t.length===0?null:t.length===1?t[0]:this.BinaryToComplex(this.ArrangeUnits(t))}UnitToAddress(e){if(e.type==="literal"){if(typeof e.value=="number"&&e.value>0&&!/\\./.test(e.text||""))return{type:"address",position:e.position,label:e.value.toString(),row:e.value-1,id:this.id_counter++,column:1/0}}else{let t,r=e.name,n=r.split("!");if(n.length>1&&(t=n.slice(0,n.length-1).join("!"),r=r.substr(t.length+1),t[0]==="\'"))if(t.length>1&&t[t.length-1]==="\'")t=t.substr(1,t.length-2);else return;let i=r[0]==="$";r=(i?r.substr(1):r).toUpperCase();let a=Number(r);if(isNaN(a)){if(/[A-Z]{1,3}/.test(r)){let o=-1;for(let u=0;u<r.length;u++){let d=r[u].charCodeAt(0);o=26*(1+o)+(d-Ge)}return{type:"address",position:e.position,absolute_column:i,label:e.name,column:o,id:this.id_counter++,row:1/0,sheet:t}}}else if(a>0&&a!==1/0&&!/\\./.test(r))return{type:"address",position:e.position,absolute_row:i,label:e.name,row:a-1,id:this.id_counter++,column:1/0,sheet:t}}}BinaryToRange2(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=e[r+1],a=e[r+2],o,u="",d;if(n&&i&&a&&i.type==="operator"&&i.operator===":"){if(n.type==="address"&&a.type==="address"){let p=n.position+n.label.length,l=a.position;o={type:"range",id:this.id_counter++,position:n.position,start:n,end:a,label:n.label+this.expression.substring(p,l)+a.label},u=o.start.label+":"+o.end.label,this.address_refcount[o.start.label]--,this.address_refcount[o.end.label]--;let b=[n.position,a.position];this.full_reference_list=this.full_reference_list.filter(f=>f.position!==b[0]&&f.position!==b[1])}else if((n.type==="literal"||n.type==="identifier")&&(a.type==="literal"||a.type==="identifier")){let p=this.UnitToAddress(n);if(!p&&n.type==="literal"&&typeof n.value=="number"&&n.value<0){let b={...n,text:(n.text||"").replace(/^-/,""),position:n.position+1,value:-n.value};p=this.UnitToAddress(b),p&&(d={type:"operator",operator:"-",position:n.position,id:this.id_counter++})}let l=this.UnitToAddress(a);p&&l&&(p.column===1/0&&l.column===1/0||p.row===1/0&&l.row===1/0)&&(u=p.label+":"+l.label,o={type:"range",id:this.id_counter++,position:p.position,start:p,end:l,label:u})}}o?(d&&t.push(d),t.push(o),this.dependencies.ranges[u]=o,this.full_reference_list.push(o),r+=2):t.push(n)}return t}BinaryToComplex(e){if(e.type==="binary")if((e.operator==="+"||e.operator==="-")&&e.left.type==="literal"&&typeof e.left.value=="number"&&e.right.type==="complex"&&!e.right.composited){let t="";t=this.expression.substring(e.left.position,e.right.position+(e.right.text?.length||0));let r=e.right.imaginary;return e.operator==="-"&&(r=-r),{type:"complex",position:e.left.position,text:t,id:this.id_counter++,imaginary:r,real:e.left.value,composited:!0}}else e.left=this.BinaryToComplex(e.left),e.right=this.BinaryToComplex(e.right);else if(e.type==="unary"&&(e.operator==="-"||e.operator==="+")&&e.operand.type==="complex"&&e.operand.text===this.imaginary_number)return{...e.operand,position:e.position,text:this.expression.substring(e.position,e.operand.position+(e.operand.text||"").length),imaginary:e.operand.imaginary*(e.operator==="-"?-1:1)};return e}BinaryToRangeX(e){if(e.type==="binary"){if(e.operator===":"){let t,r="";if(e.left.type==="address"&&e.right.type==="address"){let n=e.left.position+e.left.label.length,i=e.right.position;t={type:"range",id:this.id_counter++,position:e.left.position,start:e.left,end:e.right,label:e.left.label+this.expression.substring(n,i)+e.right.label},r=t.start.label+":"+t.end.label,this.address_refcount[t.start.label]--,this.address_refcount[t.end.label]--;let a=[e.left.position,e.right.position];this.full_reference_list=this.full_reference_list.filter(o=>o.position!==a[0]&&o.position!==a[1])}else if((e.left.type==="literal"||e.left.type==="identifier")&&(e.right.type==="literal"||e.right.type==="identifier")){let n=this.UnitToAddress(e.left),i=this.UnitToAddress(e.right);n&&i&&(n.column===1/0&&i.column===1/0||n.row===1/0&&i.row===1/0)&&(r=n.label+":"+i.label,t={type:"range",id:this.id_counter++,position:e.left.position,start:n,end:i,label:r})}if(t)return this.dependencies.ranges[r]=t,this.full_reference_list.push(t),t;this.error="unexpected character: :",this.valid=!1}e.left=this.BinaryToRangeX(e.left),e.right=this.BinaryToRangeX(e.right)}return e}ArrangeUnits(e){if(e.length===0)return{type:"missing",id:this.id_counter++};if(e.length===1)return e[0];let t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.type==="operator")if(t.length===0||t[t.length-1].type==="operator")if(Ds[n.operator]){let i=this.BinaryToComplex(this.ArrangeUnits(e.slice(r+1)));if(!this.valid)return{type:"group",id:this.id_counter++,elements:e,explicit:!1};i.type==="binary"?(i.left={type:"unary",id:this.id_counter++,operator:n.operator,operand:i.left,position:n.position},n=i):n={type:"unary",id:this.id_counter++,operator:n.operator,operand:i,position:n.position},r=e.length}else return this.error=`unexpected character [2]: ${n.operator}`,this.error_position=n.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1};else{t.push(n);continue}if(t.length<2)t.push(n);else if(t[t.length-1].type==="operator"){let i=t[t.length-2],a=t[t.length-1],o=a.operator,u={type:"binary",id:this.id_counter++,left:i,operator:o,position:a.position,right:n};i.type==="binary"&&nr[o]>nr[i.operator]&&(u.left=i.left,u.operator=i.operator,u.position=i.position,u.right={type:"binary",id:this.id_counter++,left:i.right,right:n,operator:o,position:a.position}),t.splice(-2,2,u)}else return this.error="multiple expressions",this.error_position=n.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1}}return t[0]}ParseNext(e=!0){this.ConsumeWhiteSpace();let t=this.data[this.index];if(t===Jt)return{type:"literal",id:this.id_counter++,position:this.index,value:this.ConsumeString()};if(t>=Ne&&t<=Qe||t===this.decimal_mark_char)return this.ConsumeNumber();if(t===ms)return this.ConsumeArray();if(e&&(t===Ke||t===Kt)){let r=this.data[this.index+1];if(r>=Ne&&r<=Qe||r===this.decimal_mark_char)return this.ConsumeNumber()}else if(t>=Ge&&t<=mt||t>=et&&t<=gt||t===tr||t===As||t===Xt||t===ft||t>=rr&&t<=ir)return this.ConsumeToken(t);return t}ConsumeArray(){let e={type:"array",id:this.id_counter++,values:[],position:this.index};this.index++;let t=0,r=0;for(;this.index<this.length;){let n=this.ParseNext(),i=this.index;if(typeof n=="number")switch(this.index++,n){case fi:r++,t=0;break;case pt:t++;break;case gs:return e;default:this.valid&&(this.error="invalid character in array literal",this.error_position=i,this.valid=!1);break}else switch(n.type){case"literal":e.values[t]||(e.values[t]=[]),e.values[t][r]=n.value;break;default:this.valid&&(this.error="invalid value in array literal",this.error_position=i,this.valid=!1);break}}return e}ConsumeOperator(){for(let e of _s)if(this.expression.substr(this.index,e.length)===e){let t=this.index;return this.index+=e.length,{type:"operator",id:this.id_counter++,operator:e,position:t}}return null}ConsumeArguments(){this.index++;let e=0,t=[];for(;this.index<this.length;){let r=this.ParseGeneric([this.argument_separator_char,er]);r!==null&&t.push(r);let n=this.data[this.index];if(n===this.argument_separator_char){this.index++,e++;for(let i=t.length;i<e;i++)t.push({type:"missing",id:this.id_counter++})}else if(n===er)return this.index++,t}return t}ConsumeToken(e){let t=[e],r=this.index,n=e===Xt,i=!1;for(++this.index;this.index<this.length;this.index++){let d=this.data[this.index];if(d>=Ge&&d<=mt||d>=et&&d<=gt||d>=rr&&d<=ir||d===tr||d===ft||d===Qt||d===bs||n||d>=Ne&&d<=Qe||this.flags.r1c1&&(d===hi||d===pi||d===Ke&&i))t.push(d),d===hi&&(i=!0),d===pi&&(i=!1),d===Xt&&(n=!1);else break}let a=t.map(d=>String.fromCharCode(d)).join("");if(n)return this.error="unbalanced single quote",this.error_position=r,this.valid=!1,{type:"identifier",id:this.id_counter++,name:a,position:r};if(a.toLowerCase()==="true")return{type:"literal",id:this.id_counter++,value:!0,position:r};if(a.toLowerCase()==="false")return{type:"literal",id:this.id_counter++,value:!1,position:r};if(this.ConsumeWhiteSpace(),this.data[this.index]===di){let d=this.ConsumeArguments();return{type:"call",id:this.id_counter++,name:a,args:d,position:r}}if(this.flags.spreadsheet_semantics){let d=this.ConsumeAddress(a,r);if(d)return d}let u={type:"identifier",id:this.id_counter++,name:a,position:r};return this.full_reference_list.push(u),u}ConsumeAddress(e,t){let r=t,n=e.length,i,a=e.split("!");if(a.length>1&&(i=a.slice(0,a.length-1).join("!"),t+=i.length+1),this.flags.r1c1){let l=a[a.length-1].match(this.r1c1_regex);if(l){let b={type:"address",id:this.id_counter++,label:e,row:0,column:0,position:r,sheet:i,r1c1:!0};return l[1][0]==="["?(b.offset_row=!0,b.row=Number(l[1].substring(1,l[1].length-1))):b.row=Number(l[1])-1,l[2][0]==="["?(b.offset_column=!0,b.column=Number(l[2].substring(1,l[2].length-1))):b.column=Number(l[2])-1,b}}let o=this.ConsumeAddressColumn(t);if(!o)return null;t=o.position;let u=this.ConsumeAddressRow(t);if(!u)return null;t=u.position;let d=i?i+e.substr(i.length,t-r).toUpperCase():e.substr(0,t-r).toUpperCase();i&&i[0]==="\'"&&(i=i.substr(1,i.length-2));let p={type:"address",id:this.id_counter++,label:d,row:u.row,column:o.column,absolute_row:u.absolute,absolute_column:o.absolute,position:r,sheet:i};return n!==t-r?null:(this.dependencies.addresses[p.label]=p,this.address_refcount[p.label]=(this.address_refcount[p.label]||0)+1,this.full_reference_list.push(p),p)}ConsumeAddressRow(e){let t=this.data[e]===ft;t&&e++;let r=e,n=0;for(;;e++){let i=this.data[e];if(i>=Ne&&i<=Qe)n*=10,n+=i-Ne;else break}return r===e?!1:{absolute:t,row:n-1,position:e}}ConsumeAddressColumn(e){let t=-1,r=0,n=this.data[e]===ft;for(n&&e++;;e++,r++){if(r>=4)return!1;let i=this.data[e];if(i>=Ge&&i<=mt)t=26*(1+t)+(i-Ge);else if(i>=et&&i<=gt)t=26*(1+t)+(i-et);else break}return t<0?!1:{absolute:n,column:t,position:e}}ConsumeNumber(){let e=this.index,t=0,r=!1,n=!1,i=0,a=0,o=0,u="integer",d=0,p=!1,l=this.index;for(;this.index<this.length;this.index++,d++){let f=this.data[this.index];if(f===this.decimal_mark_char)if(u==="integer")u="fraction";else break;else if(f===fs){i/=100,o/=100,this.index++;break}else if(f===Kt||f===Ke)if(d===0)f===Ke&&(n=!0);else break;else if(f===xs||f===ys)if(u==="integer"||u==="fraction")u="exponent",this.index<this.length-1&&(this.data[this.index+1]===Kt?this.index++:this.data[this.index+1]===Ke&&(this.index++,r=!0));else break;else if(f===this.imaginary_char){let m=this.data[this.index+1];if(m>=Ge&&m<=mt||m>=et&&m<=gt||m>=rr&&m<=ir||m===tr)break;if(u==="integer"||u==="fraction"){this.index++,p=!0;break}}else if(f>=Ne&&f<=Qe)switch(u){case"integer":i=i*10+(f-Ne);break;case"fraction":o=o*10+(f-Ne),a++;break;case"exponent":t=t*10+(f-Ne);break}else break}let b=i+o/Math.pow(10,a);return u==="exponent"&&(b=b*Math.pow(10,(r?-1:1)*t)),p?{type:"complex",id:this.id_counter++,position:e,imaginary:n?-b:b,real:0,text:this.expression.substring(l,this.index)||""}:{type:"literal",id:this.id_counter++,position:e,value:n?-b:b,text:this.expression.substring(l,this.index)||""}}ConsumeString(){this.index++;let e=[];for(;this.index<this.length;this.index++){let t=this.data[this.index];if(t===Jt&&(this.index++,this.index>=this.length||this.data[this.index]!==Jt))break;e.push(t)}return e.map(t=>String.fromCharCode(t)).join("")}ConsumeWhiteSpace(){for(;this.index<this.length;){let e=this.data[this.index];if(e===cs||e===ds||e===hs||e===ps||e===ls)this.index++;else return}}};var or=class{constructor(){}static get instance(){return this._instance}HTML(e){let t=[];for(let r of e){let n=[];for(let i of r)i.pre&&n.push("<pre>"),i.emphasis&&n.push("<em>"),i.strong&&n.push("<strong>"),i.strike&&n.push("<strike>"),n.push(i.text),i.strike&&n.push("</strike>"),i.strong&&n.push("</strong>"),i.emphasis&&n.push("</em>"),i.pre&&n.push("</pre>");t.push(n.join(""))}return t.join(`<br/>\n`)}Dummy(e=""){return e.split(/\\n/).map(t=>[{text:t}])}Parse(e=""){let t=this.Tokenize(e);for(let r=0;r<t.length;r++){let n=t[r];if(n.type==="delimeter"){let i=t[r-1],a=t[r+1],o=!i||i.type==="whitespace"||i.type==="newline",u=i&&i.type==="text"&&/[^\\w\\d]$/.test(i.text),d=!a||a.type==="whitespace"||a.type==="newline",p=a&&a.type==="text"&&/^[^\\w\\d]/.test(a.text);n.left_flanking=!d&&(!p||o),n.right_flanking=!o&&(!u||d)}}return this.ApplyFormatting(t),this.Consolidate(t)}IsWhitespace(e){return e===" "||e===" "}IsNewline(e){return e==="\\r"||e===`\n`}IsDelimeter(e){return e==="*"||e==="_"||e==="~"}Consolidate(e){let t=[],r={},n=[],i={type:"text",text:""};for(let a of e)if(a.type==="newline")i.text.length&&n.push(i),i={...r,text:"",type:"text"},t.push(n),n=[];else switch((!!r.strong!=!!a.strong||!!r.emphasis!=!!a.emphasis||!!r.strike!=!!a.strike)&&(r.strong=!!a.strong,r.emphasis=!!a.emphasis,r.strike=!!a.strike,i.text.length&&n.push(i),i={...r,text:"",type:"text"}),a.type){case"text":case"whitespace":i.text+=a.text;break;case"delimeter":for(let o=0;o<a.length;o++)i.text+=a.char;break}return i.text.length&&n.push(i),n.length&&t.push(n),t}ApplyFormatting(e,t){let r=0,n=e.length;for(r=0;r<n;r++){let i=e[r];if(i.type==="delimeter"){if(t&&i.right_flanking&&t.char===i.char&&i.length>0)return{index:r,token:i};if(i.left_flanking){let a=this.ApplyFormatting(e.slice(r+1),i);if(a.token){let o=Math.min(a.token.length,i.length),u=i.char==="~",d=!u&&!!(o%2),p=!u&&o>=2;for(let l=r+1;l<=r+a.index;l++)e[l].strong=!!e[l].strong||p,e[l].emphasis=!!e[l].emphasis||d,e[l].strike=!!e[l].strike||u;a.token.length-=o,i.length-=o,i.length>0?r--:r+=a.index}}}}return{index:r}}Tokenize(e=""){let t=[],r=e.length,n=0,i=!1,a="";for(n=0;n<r;n++){let o=e[n];if(this.IsWhitespace(o)){a&&t.push({type:"text",text:a});let u=o;for(;;){let d=e[n+1];if(this.IsWhitespace(d))u+=d,n++;else break}t.push({type:"whitespace",text:u}),i=!1,a=""}else if(this.IsNewline(o)){a&&t.push({type:"text",text:a});let u=o;for(;;){let d=e[n+1];if(this.IsNewline(d))u+=d,n++;else break}t.push({type:"newline",text:u}),i=!1,a=""}else if(i)a+=o,i=!1;else if(this.IsDelimeter(o)){a&&t.push({type:"text",text:a});let u=o;for(;;){let d=e[n+1];if(d===o)u+=d,n++;else break}t.push({type:"delimeter",text:u,char:o,length:u.length}),i=!1,a=""}else o==="\\\\"?i=!0:a+=o}return a&&t.push({type:"text",text:a}),t}},ar=or;ie(ar,"_instance",new or);var mi={"c:tx":{"c:strRef":{"c:f":"","c:strCache":{"c:ptCount":{a$:{val:"1"}},"c:pt":{a$:{idx:"0"},"c:v":""}}}},"c:overlay":{a$:{val:"0"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"1400",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",spc:"0",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}}},gi={"c:tx":{"c:rich":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"1400",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",spc:"0",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:r":{"a:rPr":{a$:{lang:""}},"a:t":""}}}},"c:overlay":{a$:{val:"0"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"1400",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",spc:"0",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}}},bt={"c:chartSpace":{a$:{"xmlns:c":"http://schemas.openxmlformats.org/drawingml/2006/chart","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:c16r2":"http://schemas.microsoft.com/office/drawing/2015/06/chart"},"c:date1904":{a$:{val:"0"}},"c:lang":{a$:{val:"en-US"}},"c:roundedCorners":{a$:{val:"0"}},"mc:AlternateContent":{a$:{"xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006"},"mc:Choice":{a$:{Requires:"c14","xmlns:c14":"http://schemas.microsoft.com/office/drawing/2007/8/2/chart"},"c14:style":{a$:{val:"102"}}},"mc:Fallback":{"c:style":{a$:{val:"2"}}}},"c:chart":{},"c:spPr":{"a:solidFill":{"a:schemeClr":{a$:{val:"bg1"}}},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:printSettings":{"c:headerFooter":{},"c:pageMargins":{a$:{b:"0.75",l:"0.7",r:"0.7",t:"0.75",header:"0.3",footer:"0.3"}},"c:pageSetup":{}}}};var bi={"c:idx":{a$:{val:"0"}},"c:order":{a$:{val:"0"}},"c:spPr":{"a:solidFill":{"a:schemeClr":{a$:{val:"accent1"}}},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:invertIfNegative":{a$:{val:"0"}},"c:val":{"c:numRef":{"c:f":""}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000000-F52E-47BC-822F-A046A80610BE}"}}}}},Ai={"c:title":{},"c:autoTitleDeleted":{a$:{val:"0"}},"c:plotArea":{"c:layout":{},"c:barChart":{"c:barDir":{a$:{val:"col"}},"c:grouping":{a$:{val:"clustered"}},"c:varyColors":{a$:{val:"0"}},"c:ser":[],"c:dLbls":{"c:showLegendKey":{a$:{val:"0"}},"c:showVal":{a$:{val:"0"}},"c:showCatName":{a$:{val:"0"}},"c:showSerName":{a$:{val:"0"}},"c:showPercent":{a$:{val:"0"}},"c:showBubbleSize":{a$:{val:"0"}}},"c:gapWidth":{a$:{val:"219"}},"c:overlap":{a$:{val:"-27"}},"c:axId":[{a$:{val:"47003664"}},{a$:{val:"1789284464"}}]},"c:catAx":{"c:axId":{a$:{val:"47003664"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"b"}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"1789284464"}},"c:crosses":{a$:{val:"autoZero"}},"c:auto":{a$:{val:"1"}},"c:lblAlgn":{a$:{val:"ctr"}},"c:lblOffset":{a$:{val:"100"}},"c:noMultiLvlLbl":{a$:{val:"0"}}},"c:valAx":{"c:axId":{a$:{val:"1789284464"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"l"}},"c:majorGridlines":{"c:spPr":{"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}}},"c:numFmt":{a$:{formatCode:"General",sourceLinked:"1"}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"47003664"}},"c:crosses":{a$:{val:"autoZero"}},"c:crossBetween":{a$:{val:"between"}}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}}},"c:plotVisOnly":{a$:{val:"1"}},"c:dispBlanksAs":{a$:{val:"gap"}},"c:extLst":{"c:ext":{a$:{uri:"{56B9EC1D-385E-4148-901F-78D8002777C0}","xmlns:c16r3":"http://schemas.microsoft.com/office/drawing/2017/03/chart"},"c16r3:dataDisplayOptions16":{"c16r3:dispNaAsBlank":{a$:{val:"1"}}}}},"c:showDLblsOverMax":{a$:{val:"0"}}};var xi={"c:title":{},"c:autoTitleDeleted":{a$:{val:"0"}},"c:plotArea":{"c:layout":{},"c:doughnutChart":{"c:varyColors":{a$:{val:"1"}},"c:ser":{"c:idx":{a$:{val:"0"}},"c:order":{a$:{val:"0"}},"c:dPt":{"c:idx":{a$:{val:"3"}},"c:bubble3D":{a$:{val:"0"}},"c:spPr":{"a:solidFill":{"a:schemeClr":{a$:{val:"accent4"}}},"a:ln":{a$:{w:"19050"},"a:solidFill":{"a:schemeClr":{a$:{val:"lt1"}}}},"a:effectLst":{}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000007-E886-49A6-AE6D-C67D8A27530F}"}}}}},"c:cat":{"c:strRef":{"c:f":""}},"c:val":{"c:numRef":{"c:f":""}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000000-3689-4BB4-A84F-05B9F3BBE577}"}}}}},"c:dLbls":{"c:showLegendKey":{a$:{val:"0"}},"c:showVal":{a$:{val:"0"}},"c:showCatName":{a$:{val:"0"}},"c:showSerName":{a$:{val:"0"}},"c:showPercent":{a$:{val:"0"}},"c:showBubbleSize":{a$:{val:"0"}},"c:showLeaderLines":{a$:{val:"1"}}},"c:firstSliceAng":{a$:{val:"0"}},"c:holeSize":{a$:{val:"75"}}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}}},"c:legend":{"c:legendPos":{a$:{val:"b"}},"c:overlay":{a$:{val:"0"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{a$:{rtl:"0"},"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}}},"c:plotVisOnly":{a$:{val:"1"}},"c:dispBlanksAs":{a$:{val:"gap"}},"c:extLst":{"c:ext":{a$:{uri:"{56B9EC1D-385E-4148-901F-78D8002777C0}","xmlns:c16r3":"http://schemas.microsoft.com/office/drawing/2017/03/chart"},"c16r3:dataDisplayOptions16":{"c16r3:dispNaAsBlank":{a$:{val:"1"}}}}},"c:showDLblsOverMax":{a$:{val:"0"}}};var yi={"c:title":{},"c:autoTitleDeleted":{a$:{val:"0"}},"c:plotArea":{"c:layout":{},"c:scatterChart":{"c:scatterStyle":{a$:{val:"lineMarker"}},"c:varyColors":{a$:{val:"0"}},"c:ser":[],"c:dLbls":{"c:showLegendKey":{a$:{val:"0"}},"c:showVal":{a$:{val:"0"}},"c:showCatName":{a$:{val:"0"}},"c:showSerName":{a$:{val:"0"}},"c:showPercent":{a$:{val:"0"}},"c:showBubbleSize":{a$:{val:"0"}}},"c:axId":[{a$:{val:"2028657983"}},{a$:{val:"2023395087"}}]},"c:valAx":[{"c:axId":{a$:{val:"2028657983"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"b"}},"c:majorGridlines":{"c:spPr":{"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"25000"}},"a:lumOff":{a$:{val:"75000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"2023395087"}},"c:crosses":{a$:{val:"autoZero"}},"c:crossBetween":{a$:{val:"midCat"}}},{"c:axId":{a$:{val:"2023395087"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"l"}},"c:majorGridlines":{"c:spPr":{"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}}},"c:numFmt":{a$:{formatCode:"0.00",sourceLinked:"1"}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"25000"}},"a:lumOff":{a$:{val:"75000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"2028657983"}},"c:crosses":{a$:{val:"autoZero"}},"c:crossBetween":{a$:{val:"midCat"}}}],"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}}},"c:plotVisOnly":{a$:{val:"1"}},"c:dispBlanksAs":{a$:{val:"gap"}},"c:extLst":{"c:ext":{a$:{uri:"{56B9EC1D-385E-4148-901F-78D8002777C0}","xmlns:c16r3":"http://schemas.microsoft.com/office/drawing/2017/03/chart"},"c16r3:dataDisplayOptions16":{"c16r3:dispNaAsBlank":{a$:{val:"1"}}}}},"c:showDLblsOverMax":{a$:{val:"0"}}},wi={"c:spPr":{"a:ln":{a$:{w:"19050",cap:"rnd"},"a:solidFill":{"a:schemeClr":{a$:{val:"accent1"}}},"a:round":{}},"a:effectLst":{}},"c:marker":{"c:symbol":{a$:{val:"none"}}},"c:xVal":{"c:numRef":{"c:f":""}},"c:yVal":{"c:numRef":{"c:f":""}},"c:smooth":{a$:{val:"0"}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000000-1F6C-44A9-AA4F-6706F20CC72E}"}}}}};var ur=class{constructor(e,t=ur.next_chart_index++){this.options=e;this.index=t}relationships={};UpdateChartTitle(e){let t=this.options.title||{type:"literal",value:""};if(t&&t.type==="literal"){let r=JSON.parse(JSON.stringify(gi)),n=r["c:tx"]["c:rich"]["a:p"];n["a:r"]={"a:rPr":{a$:{lang:oe.locale}},"a:t":t.value},e["c:title"]=r}else if(t){let r=JSON.parse(JSON.stringify(mi));r["c:tx"]["c:strRef"]["c:f"]=t.label,e["c:title"]=r}}toJSON(){switch(this.options.type){case"column":case"bar":return this.CreateBarChart();case"scatter":case"scatter2":return this.CreateScatterChart();case"donut":return this.CreateDonutChart();default:console.info("unhandled chart type",this.options.type)}return this.CreateBarChart()}CreateScatterChart(){let e=JSON.parse(JSON.stringify(bt)),t=e["c:chartSpace"],r=JSON.parse(JSON.stringify(yi));this.options.smooth&&(r["c:plotArea"]["c:scatterChart"]["c:scatterStyle"].a$.val="smoothMarker"),t["c:chart"]=r,this.UpdateChartTitle(t["c:chart"]);let n=t["c:chart"]["c:plotArea"]["c:scatterChart"]["c:ser"],i=!1;for(let a=0;a<this.options.data.length;a++){let o=JSON.parse(JSON.stringify(wi));if(o["c:idx"]={a$:{val:a.toString()}},o["c:order"]={a$:{val:a.toString()}},this.options.names&&this.options.names[a]){let u=this.options.names[a];switch(u.type){case"literal":o["c:tx"]={"c:v":u.value.toString()},i=!0;break;case"range":case"address":o["c:tx"]={"c:strRef":{"c:f":u.label}},i=!0;break}}o["c:spPr"]["a:ln"]["a:solidFill"]["a:schemeClr"].a$.val=`accent${a+1}`,o["c:yVal"]["c:numRef"]["c:f"]=this.options.data[a]?.label,this.options.labels2&&this.options.labels2[a]&&(o["c:xVal"]["c:numRef"]["c:f"]=this.options.labels2[a]?.label),this.options.smooth&&(o["c:smooth"]={a$:{val:1}}),n.push(o)}return i&&(t["c:chart"]["c:legend"]={"c:legendPos":{a$:{val:"b"}},"c:overlay":{a$:{val:"0"}}}),e}CreateDonutChart(){let e=JSON.parse(JSON.stringify(bt)),t=e["c:chartSpace"],r=JSON.parse(JSON.stringify(xi));t["c:chart"]=r,this.UpdateChartTitle(t["c:chart"]);let n=r["c:plotArea"]["c:doughnutChart"];return n&&(n["c:ser"]["c:cat"]["c:strRef"]["c:f"]=this.options.labels?.label||"",n["c:ser"]["c:val"]["c:numRef"]["c:f"]=this.options.data[0]?.label||""),e}CreateBarChart(){let e=JSON.parse(JSON.stringify(bt)),t=e["c:chartSpace"],r=JSON.parse(JSON.stringify(Ai));t["c:chart"]=r,this.UpdateChartTitle(t["c:chart"]);let n=r["c:plotArea"]["c:barChart"];if(n){let i=n["c:barDir"];i&&(i.a$.val=this.options.type==="bar"?"bar":"col");let a=n["c:ser"];for(let o=0;o<this.options.data.length;o++){let u=JSON.parse(JSON.stringify(bi));u["c:idx"]={a$:{val:o.toString()}},u["c:order"]={a$:{val:o.toString()}},u["c:spPr"]["a:solidFill"]["a:schemeClr"].a$.val=`accent${o+1}`,!o&&this.options.labels&&(u["c:cat"]={"c:strRef":{"c:f":this.options.labels.label}}),u["c:val"]["c:numRef"]["c:f"]=this.options.data[o]?.label,a.push(u)}}return e}},ze=ur;ie(ze,"next_chart_index",1);var lr=class{constructor(e,t=lr.next_image_index++){this.options=e;this.index=t;switch(e.mimetype){case"svg+xml":this.extension="svg";break;case"image/png":this.extension="png";break;case"jpg":this.extension="jpeg";break;case"svg":case"png":case"jpeg":case"gif":this.extension=e.mimetype;break;default:console.warn("unhandled mime type",e.mimetype);break}}extension=""},tt=lr;ie(tt,"next_image_index",1);var _i=9525,cr=class{constructor(e=cr.next_drawing_index++){this.index=e}sheet_drawing_relationship=0;charts=[];images=[];relationships={};AddImage(e,t){let r=new tt(e);if(r.extension){let n=Ce(this.relationships,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`../media/image${r.index}.${r.extension}`);this.images.push({image:r,relationship:n,anchor:t})}}AddChart(e,t){let r=new ze(e),n=Ce(this.relationships,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",`../charts/chart${r.index}.xml`);this.charts.push({chart:r,anchor:t,relationship:n})}CornerToJSON(e){return{"xdr:col":e.column,"xdr:colOff":(e.column_offset||0)*_i,"xdr:row":e.row,"xdr:rowOff":(e.row_offset||0)*_i}}AnchorToJSON(e){return{"xdr:from":{...this.CornerToJSON(e.from)},"xdr:to":{...this.CornerToJSON(e.to)}}}toJSON(){let e=this.images.map(n=>({a$:{editAs:"oneCell"},...this.AnchorToJSON(n.anchor),"xdr:pic":{"xdr:nvPicPr":{"xdr:cNvPr":{a$:{id:n.image.index+1,name:"Image "+n.image.index}},"xdr:cNvPicPr":{"a:picLocks":{a$:{noChangeAspect:1}}}},"xdr:blipFill":{"a:blip":{a$:n.image.extension==="svg"?{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships"}:{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:embed":n.relationship},"a:extLst":{"a:ext":[{a$:{uri:"{28A0092B-C50C-407E-A947-70E740481C1C}"},"a14:useLocalDpi":{a$:{"xmlns:a14":"http://schemas.microsoft.com/office/drawing/2010/main",val:0}}},n.image.extension==="svg"?{a$:{uri:"{96DAC541-7B7A-43D3-8B79-37D633B846F1}"},"asvg:svgBlip":{a$:{"xmlns:asvg":"http://schemas.microsoft.com/office/drawing/2016/SVG/main","r:embed":n.relationship}}}:void 0]}},"a:stretch":{"a:fillRect":{}}},"xdr:spPr":{"a:xfrm":{"a:off":{a$:{x:0,y:0}},"a:ext":{a$:{cx:4057650,cy:6172200}}},"a:prstGeom":{a$:{prst:"rect"},"a:avLst":{}}}},"xdr:clientData":{}})),t=this.charts.map(n=>({...this.AnchorToJSON(n.anchor),"xdr:graphicFrame":{a$:{macro:""},"xdr:nvGraphicFramePr":{"xdr:cNvPr":{a$:{id:n.chart.index+1,name:`Chart ${n.chart.index}`}},"xdr:cNvGraphicFramePr":{}},"xdr:xfrm":{"a:off":{a$:{x:0,y:0}},"a:ext":{a$:{cx:0,cy:0}}},"a:graphic":{"a:graphicData":{a$:{uri:"http://schemas.openxmlformats.org/drawingml/2006/chart"},"c:chart":{a$:{"xmlns:c":"http://schemas.openxmlformats.org/drawingml/2006/chart","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:id":n.relationship}}}}},"xdr:clientData":{}}));return{"xdr:wsDr":{a$:{"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"},"xdr:twoCellAnchor":[...t,...e]}}}},Ve=cr;ie(Ve,"next_drawing_index",1);var Te=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n`,At=class{zip;xmloptions={format:!0,attributesGroupName:"a$",textNodeName:"t$",ignoreAttributes:!1,suppressEmptyNode:!0,tagValueProcessor:(e,t)=>typeof t=="string"?Di.encode(t,{useNamedReferences:!0}):t};xmlbuilder1=new xt.XMLBuilder(this.xmloptions);xmlparser2=new xt.XMLParser(lt);parser=new Ue;decorated_functions={};async Init(e={}){for(let t of Object.keys(e))this.decorated_functions[t.toLowerCase()]=e[t];this.zip=await new Ci.default().loadAsync(br,{base64:!0})}async WriteRels(e,t,r=!1){if(!this.zip)throw new Error("missing zip");let n=Object.keys(e),i={Relationships:{a$:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},Relationship:n.map(o=>{let u=e[o],d={Id:u.id,Target:u.target,Type:u.type};return u.mode&&(d.TargetMode=u.mode),{a$:d}})}},a=Te+this.xmlbuilder1.build(i);r&&console.info(a),await this.zip?.file(t,a)}async WriteStyleCache(e){if(!this.zip)throw new Error("missing zip");let t=p=>{let l={};return p.indexed!==void 0&&(l.indexed=p.indexed),p.theme!==void 0&&(l.theme=p.theme),p.tint!==void 0&&(l.tint=p.tint),p.argb!==void 0&&(l.rgb=p.argb),l},r=e.cell_xfs.map(p=>{let l={a$:{numFmtId:p.number_format,fontId:p.font,fillId:p.fill,borderId:p.border}};return(p.horizontal_alignment||p.vertical_alignment||p.wrap_text)&&(l.alignment={a$:{}},p.horizontal_alignment&&(l.alignment.a$.horizontal=p.horizontal_alignment),p.vertical_alignment&&(l.alignment.a$.vertical=p.vertical_alignment),p.wrap_text&&(l.alignment.a$.wrapText=1)),l}),n=p=>{if(p.color)return{indexed:p.color};if(p.rgba)return{rgb:p.rgba};if(p.theme){let l={theme:p.theme};return p.tint&&(l.tint=p.tint),l}},i=e.borders.map(p=>{let l={left:{},right:{},top:{},bottom:{},diagonal:{}};if(p.top.style){l.top.a$={style:p.top.style};let b=n(p.top);b&&(l.top.color={a$:b})}if(p.left.style){l.left.a$={style:p.left.style};let b=n(p.left);b&&(l.left.color={a$:b})}if(p.bottom.style){l.bottom.a$={style:p.bottom.style};let b=n(p.bottom);b&&(l.bottom.color={a$:b})}if(p.right.style){l.right.a$={style:p.right.style};let b=n(p.right);b&&(l.right.color={a$:b})}if(p.diagonal.style){l.diagonal.a$={style:p.diagonal.style};let b=n(p.diagonal);b&&(l.diagonal.color={a$:b})}return l}),a=e.fills.map(p=>{let l={a$:{patternType:p.pattern_type}};return p.pattern_gray!==void 0&&(l.a$.patternType=`gray${p.pattern_gray}`),p.bg_color&&(l.bgColor={a$:t(p.bg_color)}),p.fg_color&&(l.fgColor={a$:t(p.fg_color)}),{patternFill:l}}),o=e.fonts.map(p=>{let l={};return p.bold&&(l.b=""),p.italic&&(l.i=""),p.underline&&(l.u=""),p.strike&&(l.strike=""),p.size!==void 0&&(l.sz={a$:{val:p.size}}),p.family!==void 0&&(l.family={a$:{val:p.family}}),p.name!==void 0&&(l.name={a$:{val:p.name}}),p.scheme!==void 0&&(l.scheme={a$:{val:p.scheme}}),p.color_argb!==void 0?l.color={a$:{rgb:p.color_argb}}:p.color_theme!==void 0&&(l.color={a$:{theme:p.color_theme}},p.color_tint&&(l.color.a$.tint=p.color_tint)),l}),u={styleSheet:{a$:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac x16r2 xr","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac","xmlns:x16r2":"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision"}}};e.number_formats.length&&(u.styleSheet.numFmts={a$:{count:e.number_formats.length},numFmt:e.number_formats.map(p=>({a$:{numFmtId:p.id,formatCode:p.format}}))}),o.length&&(u.styleSheet.fonts={a$:{count:o.length},font:o}),a.length&&(u.styleSheet.fills={a$:{count:a.length},fill:a}),i.length&&(u.styleSheet.borders={a$:{count:i.length},border:i}),r.length&&(u.styleSheet.cellXfs={a$:{count:r.length},xf:r});let d=Te+this.xmlbuilder1.build(u);await this.zip?.file("xl/styles.xml",d)}async WriteSharedStrings(e){if(!this.zip)throw new Error("missing zip");let t={sst:{a$:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",count:e.strings.length,uniqueCount:e.strings.length},si:[...e.strings.map(n=>({t:n}))]}},r=Te+this.xmlbuilder1.build(t);await this.zip?.file("xl/sharedStrings.xml",r)}StyleFromCell(e,t,r,n,i={}){let a=e.styles||e.cell_style_refs||[],o=[e.sheet_style];if(e.row_pattern&&e.row_pattern.length&&o.push(e.row_pattern[r%e.row_pattern.length]),e.row_style){let d=e.row_style[r];typeof d=="number"&&(d=a[d]),d&&o.push(d)}if(e.column_style){let d=e.column_style[n];typeof d=="number"&&(d=a[d]),d&&o.push(d)}o.push(i);let u=t.StyleOptionsFromProperties(pe.Composite(o));return t.EnsureStyle(u)}NormalizeAddress(e,t){let r=e.type==="address"?[e]:[e.start,e.end];for(let n of r)n.absolute_row=!0,n.absolute_column=!0,n.sheet||(n.sheet=t.name);return e.type==="range"&&(e.end.sheet=void 0),e.label=this.parser.Render(e),e}AnnotationLayoutToAnchor(e,t){let r=n=>{let i=t.column_width&&t.column_width[n.address.column]?t.column_width[n.address.column]:t.default_column_width||100,a=t.row_height&&t.row_height[n.address.row]?t.row_height[n.address.row]:t.default_row_height||20;return{...n.address,row_offset:Math.round(n.offset.y*a),column_offset:Math.round(n.offset.x*i)}};return{from:r(e.tl),to:r(e.br)}}AnnotationRectToAnchor(e,t){let r={from:{row:-1,column:-1},to:{row:-1,column:-1}},n={...e,right:e.left+e.width,bottom:e.top+e.height};for(let i=0,a=0;a<1e3;a++){let o=t.column_width&&t.column_width[a]?t.column_width[a]:t.default_column_width||100;if(r.from.column<0&&n.left<=i+o&&(r.from.column=a,r.from.column_offset=n.left-i),r.to.column<0&&n.right<=i+o){r.to.column=a,r.to.column_offset=n.right-i;break}i+=o}for(let i=0,a=0;a<1e3;a++){let o=t.row_height&&t.row_height[a]?t.row_height[a]:t.default_row_height||20;if(r.from.row<0&&n.top<=i+o&&(r.from.row=a,r.from.row_offset=n.top-i),r.to.row<0&&n.bottom<=i+o){r.to.row=a,r.to.row_offset=n.bottom-i;break}i+=o}return r}ParseImages(e){let t=[];for(let r of e.annotations||[])if(r.type==="image"&&r.data?.src){let n=r.data.src,i=n.match(/^data:image\\/([^;]*?);base64,/);if(i){let a=n.substr(i[0].length),o=i[1],u={data:a,mimetype:o,encoding:"base64"};switch(o){case"svg+xml":case"webp":case"jpeg":case"jpg":case"image/png":case"png":case"gif":r.rect?t.push({anchor:this.AnnotationRectToAnchor(r.rect,e),options:u}):r.layout?t.push({anchor:this.AnnotationLayoutToAnchor(r.layout,e),options:u}):console.warn("annotation missing layout");break;default:console.info("unhandled image type",o);break}}}return t}ParseCharts(e){let t=[],r=(n,i)=>{if(n.type==="range")i.data.push(this.NormalizeAddress(n,e));else if(n.type==="call"){if(/group/i.test(n.name))for(let a of n.args||[])r(a,i);else if(/series/i.test(n.name)){let[a,o,u]=n.args;u&&u.type==="range"?(i.data.push(this.NormalizeAddress(u,e)),a&&(i.names||(i.names=[]),a.type==="address"&&this.NormalizeAddress(a,e),a.type==="range"?(this.NormalizeAddress(a.start,e),i.names[i.data.length-1]=a.start):i.names[i.data.length-1]=a),i.labels2||(i.labels2=[]),o&&o.type==="range"&&(i.labels2[i.data.length-1]=this.NormalizeAddress(o,e))):console.info("invalid series missing Y")}}};for(let n of e.annotations||[]){let i=this.parser.Parse(n.formula||"");if(i.expression&&i.expression.type==="call"){let a="";switch(i.expression.name.toLowerCase()){case"line.chart":a="scatter";break;case"scatter.line":a="scatter2";break;case"donut.chart":a="donut";break;case"bar.chart":a="bar";break;case"column.chart":a="column";break}if(a==="column"||a==="donut"||a==="bar"||a==="scatter"||a==="scatter2"){let o={type:a,data:[]},u=a==="scatter2"?1:2,d=i.expression.args[u];if(d&&d.type==="literal"?o.title=d:d&&d.type==="address"&&(o.title=this.NormalizeAddress(d,e)),i.expression.args[0]){let p=i.expression.args[0];if(a==="scatter2"||a==="bar"||a==="column"||a==="scatter")r(p,o);else if(p.type==="range")o.data.push(this.NormalizeAddress(p,e));else if(p.type==="call"&&/group/i.test(p.name))for(let l of p.args)l.type==="range"?o.data.push(this.NormalizeAddress(l,e)):l.type==="call"&&/series/i.test(l.name)&&l.args[2]&&l.args[2].type==="range"&&o.data.push(this.NormalizeAddress(l.args[2],e));else p.type==="call"&&/series/i.test(p.name)&&p.args[2]&&p.args[2].type==="range"&&o.data.push(this.NormalizeAddress(p.args[2],e))}a!=="scatter2"&&i.expression.args[1]&&i.expression.args[1].type==="range"&&(o.labels=this.NormalizeAddress(i.expression.args[1],e)),(a==="scatter"&&i.expression.args[4]&&i.expression.args[4].type==="literal"&&i.expression.args[4].value.toString().toLowerCase()==="smooth"||a==="scatter2"&&i.expression.args[2]&&i.expression.args[2].type==="literal"&&/smooth/i.test(i.expression.args[2].value.toString()))&&(o.smooth=!0),n.rect?t.push({anchor:this.AnnotationRectToAnchor(n.rect,e),options:o}):n.layout?t.push({anchor:this.AnnotationLayoutToAnchor(n.layout,e),options:o}):console.warn("annotation missing layout")}}}return t}FormulaText(e){if(e[0]!=="=")return e;let t=this.parser.Parse(e);return t.expression?(this.parser.Walk(t.expression,r=>{if(r.type==="call"){let n=r.name.toLowerCase();this.decorated_functions[n]&&(r.name=this.decorated_functions[n]+"."+r.name)}return!0}),this.parser.Render(t.expression,void 0,"")):(console.warn("parsing function failed"),console.warn(e),e.substr(1))}async Export(e){let t=0,r=[];for(let y=0;y<e.sheet_data.length;y++){let w=e.sheet_data[y],E=w.id||0;E&&(r[E]=w.name||""),E===e.active_sheet&&(t=y)}let n=new We,i=new Ze,a=new Be,o=await this.zip?.file("xl/theme/theme1.xml")?.async("text");a.FromXML(this.xmlparser2.parse(o||"")),o=await this.zip?.file("xl/styles.xml")?.async("text"),i.FromXML(this.xmlparser2.parse(o||""),a),Ve.next_drawing_index=1,ze.next_chart_index=1;let u=[];for(let y=0;y<e.sheet_data.length;y++){let w=e.sheet_data[y],E={},z={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac xr xr2 xr3","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision","xmlns:xr2":"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2","xmlns:xr3":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3","xr:uid":"{D37933E2-499F-4789-8D13-194E11B743FC}"},P=w.default_row_height?w.default_row_height/20*15:15,G={worksheet:{a$:{...z},dimension:{a$:{ref:"A1"}},sheetViews:{sheetView:{a$:{workbookViewId:0}}},sheetFormatPr:{a$:P===15?{"x14ac:dyDescent":.25}:{defaultRowHeight:P,customHeight:1,"x14ac:dyDescent":.25}},cols:{},sheetData:{},mergeCells:{a$:{count:0}},dataValidations:{},hyperlinks:{},pageMargins:{a$:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3}},drawing:{},extLst:{ext:{a$:{uri:"{05C60535-1F16-4fd2-B633-F4F36F0B64E0}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}}}}},R=w.styles||w.cell_style_refs||[],V=new ot;V.FromJSON(w.data,R);for(let D of w.cell_styles){let v=V.EnsureCell(D);v.style||(v.style=R[D.ref])}let X={start:{row:V.rows+1,column:V.columns+1},end:{row:V.rows+1,column:V.columns+1}},C={row:[]},S=[],h=[],k=[],Y=[];for(let D=0;D<V.data.length;D++)if(V.data[D]&&V.data[D].length){D<X.start.row&&(X.start.row=D);let v={start:-1,end:-1},j=[];for(let W=0;W<V.data[D].length;W++){let Z=V.data[D][W];if(Z){if(Z.merge_area&&Z.merge_area.start.row===D&&Z.merge_area.start.column===W&&k.push(new ae(Z.merge_area.start,Z.merge_area.end)),Z.hyperlink){let ue=Ce(E,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",Z.hyperlink,"External");S.push({rel:ue,target:Z.hyperlink,address:{row:D,column:W}})}if(Z.validation&&(Z.validation.type===0||Z.validation.type===2)&&Y.push({address:{row:D,column:W},validation:Z.validation}),Z.type===1&&/^=?sparkline\\./i.test(Z.value)){h.push({address:{row:D,column:W},formula:Z.value,style:Z.style});continue}W<X.start.column&&(X.start.column=W),v.start<0&&(v.start=W),v.end=W;let ee=this.StyleFromCell(w,i,D,W,Z.style),te,K,re;switch(Z.type){case 1:switch(re=this.FormulaText(Z.value),Z.calculated_type){case 2:te=Z.calculated,K="str";break;case 3:te=Z.calculated;break;case 4:te=Z.calculated?1:0,K="b";break}break;case 2:te=n.Ensure(Z.value),K="s";break;case 3:te=Z.value;break;case 4:te=Z.value?1:0,K="b";break}Z.area&&Z.area.start.row===D&&Z.area.start.column===W&&typeof re=="string"&&(re={t$:re,a$:{t:"array",ref:Z.area.spreadsheet_label}});let le={a$:{r:ae.CellAddressToLabel({row:D,column:W})}};K!==void 0&&(le.a$.t=K),ee!==void 0&&(le.a$.s=ee),re!==void 0&&(le.f=re),te!==void 0&&(le.v=te),j.push(le)}}if(j.length){let W={a$:{r:D+1,spans:`${v.start+1}:${v.end+1}`},c:j};w.row_height&&typeof w.row_height[D]=="number"&&w.row_height[D]!==w.default_row_height&&(W.a$.customHeight=1,W.a$.ht=w.row_height[D]*3/4),C.row.push(W)}}let F=[];w.default_column_width&&(G.worksheet.sheetFormatPr.a$.defaultColWidth=at(w.default_column_width));for(let D=0;D<w.columns;D++){let v={index:D};w.column_width&&w.default_column_width&&typeof w.column_width[D]=="number"&&w.column_width[D]!==w.default_column_width&&(v.width=at(w.column_width[D]));let j=w.column_style[D];typeof j=="number"&&(j=R[j]),j&&(v.style=i.EnsureStyle(i.StyleOptionsFromProperties(j))),(v.style!==void 0||v.width!==void 0)&&(F[D]=v)}if(F.length)for(let D of F)G.worksheet.cols.col=F.map(v=>{let j={min:v.index+1,max:v.index+1};return v.style!==void 0&&(j.style=v.style),v.width!==void 0?(j.width=v.width,j.customWidth=1):j.width=at(w.default_column_width||90),{a$:j}});else delete G.worksheet.cols;Y.length?G.worksheet.dataValidations={a$:{count:Y.length},dataValidation:Y.map(D=>{let v={a$:{type:"list",allowBlank:1,showInputMessage:1,showErrorMessage:1,sqref:new ae(D.address).spreadsheet_label}};if(D.validation.type===2){let j=new ae({...D.validation.area.start,absolute_column:!0,absolute_row:!0},{...D.validation.area.end,absolute_column:!0,absolute_row:!0});v.formula1=`${j.spreadsheet_label}`}else D.validation.type===0&&(v.formula1=`"${D.validation.list.join(",")}"`);return v})}:delete G.worksheet.dataValidations,k.length?(G.worksheet.mergeCells.a$.count=k.length,G.worksheet.mergeCells.mergeCell=k.map(D=>({a$:{ref:D.spreadsheet_label}}))):delete G.worksheet.mergeCells,S.length?G.worksheet.hyperlinks.hyperlink=S.map(D=>({a$:{"r:id":D.rel,ref:new ae(D.address).spreadsheet_label,"xr:uid":"{0C6B7792-7EA0-4932-BF15-D49C453C565D}"}})):delete G.worksheet.hyperlinks,h.length?G.worksheet.extLst.ext["x14:sparklineGroups"]={a$:{"xmlns:xm":"http://schemas.microsoft.com/office/excel/2006/main"},"x14:sparklineGroup":h.map(D=>{let v=this.parser.Parse(D.formula),j="";if(v.expression&&v.expression.type==="call"&&v.expression.args.length>0){let Z=v.expression.args[0];if(Z.type==="range"||Z.type==="address"){let ee=Z.type==="range"?Z.start:Z;ee.sheet||(typeof ee.sheet_id<"u"?ee.sheet=r[ee.sheet_id]:ee.sheet=w.name),j=this.parser.Render(Z)}}let W={displayEmptyCellsAs:"gap"};return/column/i.test(D.formula)&&(W.type="column"),{a$:W,"x14:colorSeries":{a$:{rgb:"FF376092"}},"x14:sparklines":{"x14:sparkline":{"xm:f":j,"xm:sqref":new ae(D.address).spreadsheet_label}}}})}:delete G.worksheet.extLst,G.worksheet.sheetData=C;let q=this.ParseCharts(w),I=this.ParseImages(w);if(q.length||I.length){let D=new Ve;for(let W of q)D.AddChart(W.options,W.anchor);for(let W of I)D.AddImage(W.options,W.anchor);for(let{image:W}of D.images)await this.zip?.file(`xl/media/image${W.index}.${W.extension}`,W.options.data||"",{base64:W.options.encoding==="base64"});for(let{chart:W}of D.charts){let Z=W.toJSON(),ee=Te+this.xmlbuilder1.build(Z);await this.zip?.file(`xl/charts/chart${W.index}.xml`,ee),await this.WriteRels(W.relationships,`xl/charts/_rels/chart${W.index}.xml.rels`)}await this.WriteRels(D.relationships,`xl/drawings/_rels/drawing${D.index}.xml.rels`);let v=Te+this.xmlbuilder1.build(D.toJSON());await this.zip?.file(`xl/drawings/drawing${D.index}.xml`,v),u.push(D);let j=Ce(E,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",`../drawings/drawing${D.index}.xml`);G.worksheet.drawing={a$:{"r:id":j}}}else delete G.worksheet.drawing;G.worksheet.dimension.a$.ref=new ae(X.start,X.end).spreadsheet_label;let O=Te+this.xmlbuilder1.build(G);await this.zip?.file(`xl/worksheets/sheet${y+1}.xml`,O),Object.keys(E).length&&this.WriteRels(E,`xl/worksheets/_rels/sheet${y+1}.xml.rels`)}await this.WriteSharedStrings(n),await this.WriteStyleCache(i);let d={};Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles","styles.xml"),Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme","theme/theme1.xml"),Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings","sharedStrings.xml");let p=e.sheet_data.map((y,w)=>Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",`worksheets/sheet${w+1}.xml`));await this.WriteRels(d,"xl/_rels/workbook.xml.rels");let l={definedName:[]};if(e.named_ranges){let y=Object.keys(e.named_ranges);for(let w of y){let E="",z=new ae(e.named_ranges[w].start,e.named_ranges[w].end);if(z.start.absolute_column=z.start.absolute_row=!0,z.end.absolute_column=z.end.absolute_row=!0,z.start.sheet_id){for(let P of e.sheet_data)if(P.id===z.start.sheet_id){E=P.name||"";break}}E&&(sr.test(E)&&(E=`\'${E}\'`),E+="!"),l.definedName.push({a$:{name:w},t$:E+z.spreadsheet_label})}}if(e.named_expressions)for(let y of e.named_expressions)l.definedName.push({a$:{name:y.name},t$:y.expression});l.definedName.length||(l=void 0);let b={workbook:{a$:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x15 xr xr6 xr10 xr2","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision","xmlns:xr6":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision6","xmlns:xr10":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10","xmlns:xr2":"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"},workbookPr:{a$:{defaultThemeVersion:"166925"}},bookViews:{workbookView:{a$:{activeTab:t||0}}},sheets:{sheet:e.sheet_data.map((y,w)=>{let E={name:y.name||`Sheet${w+1}`,sheetId:w+1,"r:id":p[w]};return y.visible===!1&&(E.state="hidden"),{a$:E}})},definedNames:l}},f=Te+this.xmlbuilder1.build(b);await this.zip?.file("xl/workbook.xml",f);let m={};for(let y of u)for(let w of y.images)switch(w.image.extension){case"gif":case"png":case"jpeg":m[w.image.extension]="image/"+w.image.extension;break;case"svg":m.svg="image/svg+xml";break}let g={Types:{a$:{xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"},Default:[{a$:{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}},{a$:{Extension:"xml",ContentType:"application/xml"}},...Object.keys(m).map(y=>({a$:{Extension:y,ContentType:m[y]}}))],Override:[{a$:{PartName:"/xl/workbook.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"}},...e.sheet_data.map((y,w)=>({a$:{ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",PartName:`/xl/worksheets/sheet${w+1}.xml`}})),...u.reduce((y,w)=>y.concat([...w.charts.map(E=>({a$:{ContentType:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",PartName:`/xl/charts/chart${E.chart.index}.xml`}})),{a$:{ContentType:"application/vnd.openxmlformats-officedocument.drawing+xml",PartName:`/xl/drawings/drawing${w.index}.xml`}}]),[]),{a$:{PartName:"/xl/theme/theme1.xml",ContentType:"application/vnd.openxmlformats-officedocument.theme+xml"}},{a$:{PartName:"/xl/styles.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"}},{a$:{PartName:"/xl/sharedStrings.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"}},{a$:{PartName:"/docProps/core.xml",ContentType:"application/vnd.openxmlformats-package.core-properties+xml"}},{a$:{PartName:"/docProps/app.xml",ContentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml"}}]}},A=Te+this.xmlbuilder1.build(g);await this.zip?.file("[Content_Types].xml",A)}async AsBinaryString(e){if(!this.zip)throw new Error("missing zip");let t={type:"binarystring"};return typeof e<"u"&&(t.compression="DEFLATE",t.compressionOptions={level:e}),await this.zip.generateAsync(t)}async AsBlob(e){if(!this.zip)throw new Error("missing zip");let t={type:"blob"};return typeof e<"u"&&(t.compression="DEFLATE",t.compressionOptions={level:e}),await this.zip.generateAsync(t)}};var vi=Fe(kt());var hr=Fe(ut());var yt=s=>"row"in s&&"col"in s,Pe=s=>"from"in s&&"to"in s&&yt(s.from)&&yt(s.to),wt=(s,e)=>e.sheet===s.sheet&&e.row>=s.from.row&&e.row<=s.to.row&&e.col>=s.from.col&&e.col<=s.to.col,dr=(s,e=0,t=0)=>({from:{row:s.from.row+e,col:s.from.col+t,sheet:s.from.sheet},to:{row:s.to.row+e,col:s.to.col+t,sheet:s.to.sheet}});var _t=class{constructor(e={}){this.options=e}path;rels_path;rels={};sheet_data={};shared_strings;extent;visible_state;tab_selected=!1;default_width=0;drawings=[];TranslateAddress(e){e=e.toUpperCase();let t=e.match(/([A-Z]+\\d+):([A-Z]+\\d+)/);if(t)return{from:this.TranslateAddress(t[1]),to:this.TranslateAddress(t[2])};let r=0,n=0;if(t=e.match(/^([A-Z]+)(\\d+)$/),t){r=Number(t[2]),n=0;let i=t[1].length;for(let a=0;a<i;a++){let o=t[1].charCodeAt(a)-64;n=n*26+o}}return{row:r,col:n}}Address(e,t=!1){if(Pe(e))return this.Address(e.from,t)+":"+this.Address(e.to,t);let r="",n=e.col;for(;n>0;){let a=(n-1)%26+1;r=String.fromCharCode(64+a)+r,n=(n-a)/26}let i=e.sheet?`\'${e.sheet}\'!`:"";return t?`${i}$${r}$${e.row}`:i+r+e.row}NormalizeAddress(e){let t,r;return typeof e=="string"?(t=e.toUpperCase(),r=this.TranslateAddress(t)):(r=e,t=this.Address(r)),{a:t,rc:r}}Parse(){let e=this.sheet_data.worksheet?.dimension?.a$?.ref,t=this.TranslateAddress(e||"");Pe(t)?this.extent=JSON.parse(JSON.stringify(t)):this.extent={from:JSON.parse(JSON.stringify(t)),to:JSON.parse(JSON.stringify(t))}}};var Es=new hr.XMLParser(Kr),Le=new hr.XMLParser(lt);var Dt=class{constructor(e){this.zip=e}xml={};shared_strings=new We;style_cache=new Ze;theme=new Be;defined_names={};rels={};sheets=[];active_tab=0;get sheet_count(){return this.sheets.length}async ReadRels(e){let t={},r=await this.zip.file(e)?.async("text"),n=Le.parse(r||"");for(let i of n.Relationships?.Relationship||[]){let a=i.a$.Id;t[a]={id:a,type:i.a$.Type,target:i.a$.Target}}return t}async Init(){this.rels=await this.ReadRels("xl/_rels/workbook.xml.rels");let e=await this.zip.file("xl/sharedStrings.xml")?.async("text"),t=Le.parse(e||"");this.shared_strings.FromXML(t),e=await this.zip.file("xl/theme/theme1.xml")?.async("text"),t=Le.parse(e),this.theme.FromXML(t),e=await this.zip.file("xl/styles.xml")?.async("text"),t=Le.parse(e),this.style_cache.FromXML(t,this.theme),console.info({c:this.style_cache}),e=await this.zip.file("xl/workbook.xml")?.async("text"),t=Le.parse(e),this.defined_names={};let r=se.FindAll(t,"workbook/definedNames/definedName");for(let a of r){let o=a.a$?.name,u=a.t$||"";o&&u&&(this.defined_names[o]=u)}let n=se.FindAll(t,"workbook/bookViews/workbookView");n[0]?.a$?.activeTab&&(this.active_tab=Number(n[0].a$.activeTab)||0);let i=se.FindAll(t,"workbook/sheets/sheet");for(let a of i){let o=a.a$?.name;if(o){let u=a.a$.state,d=a.a$["r:id"],p=new _t({name:o,rid:d,id:Number(a.a$.sheetId)});u==="hidden"?p.visible_state=1:u==="veryHidden"&&(p.visible_state=2),p.shared_strings=this.shared_strings,p.path=`xl/${this.rels[d].target}`,p.rels_path=p.path.replace("worksheets","worksheets/_rels")+".rels",e=await this.zip.file(p.path)?.async("text"),p.sheet_data=Le.parse(e||""),p.rels=await this.ReadRels(p.rels_path),p.Parse(),this.sheets.push(p)}}}async ReadDrawing(e){let t=await this.zip.file(e.replace(/^../,"xl"))?.async("text");if(!t)return;let r=Le.parse(t),n=await this.ReadRels(e.replace(/^..\\/drawings/,"xl/drawings/_rels")+".rels"),i=[],a=se.FindAll(r,"xdr:wsDr/xdr:twoCellAnchor"),o=(u={})=>({column:u["xdr:col"]||0,column_offset:u["xdr:colOff"]||0,row:u["xdr:row"]||0,row_offset:u["xdr:rowOff"]||0});for(let u of a){let p={anchor:{from:o(u["xdr:from"]),to:o(u["xdr:to"])}},l=se.FindAll(u,"xdr:graphicFrame/a:graphic/a:graphicData/c:chart")[0];if(l&&l.a$&&l.a$["r:id"]){let b=n[l.a$["r:id"]];b&&b.target&&(p.chart=await this.ReadChart(b.target))}i.push(p)}return i}async ReadChart(e){let t=await this.zip.file(e.replace(/^../,"xl"))?.async("text");if(!t)return;let r=Es.parse(t),n={type:0},i=se.FindChild(r,"c:chartSpace/c:chart/c:title");if(i){let u=se.FindChild(i,"c:tx/c:strRef/c:f");if(u)typeof u=="string"?n.title=u:u.text__&&(n.title=u.text__);else{let d=se.FindAll(i,"c:tx/c:rich/a:p/a:r/a:t");n.title=\'"\'+d.join("")+\'"\'}}let a=(u,d=!1)=>{let p=[],l=u["c:ser"]||[];Array.isArray(l)||(l=[l]);for(let b of l){let f=p.length,m=b["c:order"];m&&(f=Number(m.__val||0)||0);let g={},A=se.FindChild(b,"c:tx/c:v");if(A){let y=A;y&&(g.title=`"${y}"`)}else A=se.FindChild(b,"c:tx/c:strRef/c:f"),A&&(g.title=A);if(d){let y=se.FindChild(b,"c:xVal/c:numRef/c:f");y&&(g.categories=y);let w=se.FindChild(b,"c:yVal/c:numRef/c:f");w&&(g.values=w)}else{let y=se.FindChild(b,"c:val/c:numRef/c:f");y&&(g.values=y);let w=se.FindChild(b,"c:cat/c:strRef/c:f");w||(w=se.FindChild(b,"c:cat/c:numRef/c:f")),w&&(g.categories=w)}p[f]=g}return p},o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:barChart");return o&&(n.type=2,o["c:barDir"]&&o["c:barDir"].__val==="col"&&(n.type=1),n.series=a(o)),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:lineChart"),o&&(n.type=3,n.series=a(o))),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:doughnutChart"),o&&(n.type=5,n.series=a(o))),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:pieChart"),o&&(n.type=6,n.series=a(o))),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:scatterChart"),o&&(n.type=4,n.series=a(o,!0))),n}GetNamedRanges(){return this.defined_names}};var Ct=class{parser=new Ue;workbook;archive;async Init(e){typeof e=="string"?this.archive=await(0,vi.default)().loadAsync(e):this.archive=e,this.archive&&(this.workbook=new Dt(this.archive),await this.workbook.Init())}SheetCount(){return this.workbook?.sheet_count||0}ParseCell(e,t,r,n,i,a,o){let u=t.a$?.r;if(!u){console.warn("cell missing address");return}let d=e.TranslateAddress(u);if(Pe(d)){console.warn("cell has range address");return}let p,l=0,b,f=0;if(t.a$?.t&&t.a$.t==="s"){if(l=2,typeof t.v!==void 0){let A=Number(t.v);!isNaN(A)&&e.shared_strings&&(p=e.shared_strings.Get(A)||"",p[0]==="="&&(p="\'"+p))}}else if(typeof t.f<"u"){l=1;let A=(typeof t.f=="string"?t.f:t.f.t$)||"";if(A){p="="+A.replace(/^_xll\\./g,"");let y=this.parser.Parse(A);y.expression&&(this.parser.Walk(y.expression,w=>(w.type==="call"&&/^_xll\\./.test(w.name)&&(w.name=w.name.substr(5)),!0)),p="="+this.parser.Render(y.expression,void 0,"")),typeof t.f!="string"&&t.f.a$?.t==="shared"&&t.f.a$.si&&(r[t.f.a$.si]={row:d.row-1,column:d.col-1,formula:p,parse_result:this.parser.Parse(p)})}else if(typeof t.f!="string"&&t.f.a$?.t==="shared"&&t.f.a$.si){let y=r[t.f.a$.si];y&&(y.parse_result.expression?p="="+this.parser.Render(y.parse_result.expression,{rows:d.row-1-y.row,columns:d.col-1-y.column},""):p=y.formula)}if(typeof t.f!="string"&&t.f.a$?.t==="array"){let y=e.TranslateAddress(t.f.a$.ref||"");Pe(y)&&n.push(dr(y,-1,-1))}if(typeof t.v<"u"){let y=Number(t.v.toString());isNaN(y)?(f=2,b=t.v.toString()):(f=3,b=y)}}else if(typeof t.v<"u"){let A=Number(t.v.toString());isNaN(A)?(l=2,p=t.v.toString()):(l=3,p=A)}let m={row:d.row-1,col:d.col-1};for(let A of n)wt(A,m)&&(m.row!==A.from.row||m.col!==A.from.col)&&(f=l,b=p,p=void 0,l=0);let g={row:m.row,column:m.col,value:p,type:l};typeof b<"u"&&(g.calculated_type=f,g.calculated=b),t.a$?.s&&(g.style_ref=Number(t.a$.s));for(let A of a)A.address.row===d.row&&A.address.col===d.col&&(g.hyperlink=A.reference);for(let A of o)if(A.address.row===m.row&&A.address.column===m.col){g.validation=A.validation;break}for(let A of i)wt(A,m)&&(g.merge_area={start:{row:A.from.row,column:A.from.col},end:{row:A.to.row,column:A.to.col}});for(let A of n)wt(A,m)&&(g.area={start:{row:A.from.row,column:A.from.col},end:{row:A.to.row,column:A.to.col}});return g}async GetSheet(e=0){if(!this.workbook)throw new Error("missing workbook");let t=this.workbook.sheets[e],r=[],n={},i=[],a=[],o=[],u=[],d=[],p=se.FindAll.bind(se,t.sheet_data),l=p("worksheet/mergeCells/mergeCell");for(let h of l)if(h.a$.ref){let k=t.TranslateAddress(h.a$.ref);Pe(k)&&a.push(dr(k,-1,-1))}let b=p("worksheet/dataValidations/dataValidation");for(let h of b){let k=h.a$?.type,Y=h.a$?.sqref,F=h.formula1;if(Y&&F&&k==="list"){let q,I,O=this.parser.Parse(Y);O.expression&&(O.expression.type==="address"?q=O.expression:O.expression.type==="range"&&(q=O.expression.start)),O=this.parser.Parse(F),O.expression&&(O.expression.type==="range"?I={type:2,area:O.expression}:O.expression.type==="literal"&&(I={type:0,list:O.expression.value.toString().split(/,/).map(D=>{let v=this.parser.Parse(D);if(v.expression?.type==="group"&&/\\s/.test(D))return D;if(v.expression?.type==="literal")return v.expression.value;if(v.expression?.type==="identifier")return v.expression.name})})),q&&I&&u.push({address:q,validation:I})}}let f=p("worksheet/hyperlinks/hyperlink");for(let h of f){let k=t.TranslateAddress(h.a$?.ref||"");Pe(k)&&(k=k.from);let Y="",F="";if(h.a$&&h.a$["r:id"]){Y="remote link";let q=t.rels[h.a$["r:id"]];q&&(F=q.target||"")}else F=h.__location||"",Y=h.__display||"";o.push({address:k,reference:F,text:Y})}let m=21,g=100,A=t.sheet_data.worksheet?.sheetFormatPr;if(A){if(A.a$?.defaultColWidth){let h=Number(A.a$.defaultColWidth);isNaN(h)||(g=Nt(h))}if(A.a$?.defaultRowHeight){let h=Number(A.a$.defaultRowHeight);isNaN(h)||(m=Math.round(h*4/3))}}let y=[],w=p("worksheet/sheetData/row");for(let h of w){let k=h.a$?.r?Number(h.a$.r):1,Y=m;if(h.a$?.ht){let q=Number(h.a$.ht);isNaN(q)||(Y=Math.round(q*4/3))}Y!==m&&(y[k-1]=Y);let F=h.c||[];Array.isArray(F)||(F=[F]);for(let q of F){let I=this.ParseCell(t,q,n,i,a,o,u);I&&r.push(I)}}let E=[],z=-1,P=[],G=p("worksheet/cols/col");for(let h of G){let k=Number(h.a$?.min),Y=Number(h.a$?.max);if(h.a$?.style){let F=Number(h.a$.style);if(!isNaN(k)&&!isNaN(Y)&&!isNaN(F))if(t.extent&&Y>=t.extent.to.col||Y-k>100)z=F;else for(let q=k;q<=Y;q++)E[q]=F}if(h.a$?.customWidth){let F=Number(h.a$.width);if(!isNaN(k)&&!isNaN(Y)&&!isNaN(F)&&Y!==16384){F=Nt(F);for(let q=k;q<=Y;q++)P[q-1]=F}}}let R=p("worksheet/drawing"),V=[];for(let h of R){let k=h.a$?h.a$["r:id"]:void 0;if(k){let Y="",F=t.rels[k];if(F&&(Y=F.target||""),Y){let q=await this.workbook.ReadDrawing(Y);q&&q.length&&V.push(...q)}}}let X=h=>{let k={address:{row:h.row,column:h.column},offset:{x:0,y:0}};if(h.row_offset){let Y=y[h.row];Y===void 0&&(Y=m),k.offset.y=h.row_offset/9525/Y}if(h.column_offset){let Y=P[h.column];Y===void 0&&(Y=g),k.offset.x=h.column_offset/9525/Y}return k};for(let h of V)if(h&&h.chart){let k={tl:X(h.anchor.from),br:X(h.anchor.to)},Y,F=[],q="",I=h.chart?.series;switch(h.chart.type){case 4:Y="treb-chart",q="Scatter.Line",I&&I.length&&(F[0]=`Group(${I.map(D=>`Series(${D.title||""},${D.categories||""},${D.values||""})`||"").join(", ")})`),F[1]=h.chart.title;break;case 5:case 6:q=h.chart.type===5?"Donut.Chart":"Pie.Chart",Y="treb-chart",I&&I[0]&&(F[0]=I[0].values,F[1]=I[0]?.categories||""),F[2]=h.chart.title;break;case 2:case 1:case 3:switch(F[2]=h.chart.title,Y="treb-chart",h.chart.type){case 2:q="Bar.Chart";break;case 1:q="Column.Chart";break;default:q="Line.Chart"}I&&(I.length>1?F[0]=`Group(${I.map(D=>`Series(${D.title||""},,${D.values||""})`||"").join(", ")})`:I.length===1&&(I[0].title?F[0]=`Series(${I[0].title||""},,${I[0].values||""})`:F[0]=I[0].values),F[1]=I[0]?.categories||"");break}let O=`=${q}(${F.join(", ")})`;Y&&O&&d.push({layout:k,type:Y,formula:O})}let C=p("worksheet/extLst/ext");for(let h of C){let k="";for(let F of Object.keys(h?.a$||{})){let q=F.match(/^xmlns:(.*)$/);if(q){k=q[1];break}}let Y=se.FindAll(h,`${k}:sparklineGroups/${k}:sparklineGroup`);for(let F of Y){let q="Sparkline.line",I="",O="";F.a$?.type==="column"&&(q="Sparkline.column");let D=se.FindAll(F,`${k}:sparklines/${k}:sparkline`);for(let v of D)for(let j of Object.keys(v))/:f$/.test(j)?O=v[j]:/:sqref$/.test(j)&&(I=v[j]);if(O&&I){let v=`=${q}(${O})`,j=t.TranslateAddress(I);if(yt(j)){let W={row:j.row-1,column:j.col-1,value:v,type:1},Z=!1;for(let ee of r)if(ee.row===W.row&&ee.column===W.column){Z=!0,ee.type=1,ee.value=v;break}Z||r.push(W)}}}}let S={name:t.options.name,cells:r,default_column_width:g,column_widths:P,row_heights:y,annotations:d,styles:this.workbook?.style_cache?.CellXfToStyles()||[]};return(t.visible_state===1||t.visible_state===2)&&(S.hidden=!0),z>=0&&(S.sheet_style=z),E.length&&(S.column_styles=E),S}};var vt=self,pr=new At,Bs=async s=>{if(s.sheet){await pr.Init(s.decorated||[]),await pr.Export(s.sheet);let e=await pr.AsBlob(1),t=e.slice(0,e.size,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");vt.postMessage({status:"complete",blob:t})}},Is=async s=>{let e=new Ct;try{await e.Init(s.data);let t=e.SheetCount(),r={sheets:[],names:e.workbook?.GetNamedRanges(),active_tab:e.workbook?.active_tab};for(let n=0;n<t;n++){let i=await e.GetSheet(n);i&&r.sheets.push(i)}vt.postMessage({status:"complete",results:r})}catch(t){console.warn("error importing xlsx file"),console.info(t),vt.postMessage({status:"error",data:t})}};vt.addEventListener("message",s=>{s.data&&s.data.command==="export"?Bs(s.data):s.data&&s.data.command==="import"&&Is(s.data)});})();\n/*!\n\nJSZip v3.10.0 - A JavaScript class for generating and reading zip files\n<http://stuartk.com/jszip>\n\n(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>\nDual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.\n\nJSZip uses the library pako released under the MIT license :\nhttps://github.com/nodeca/pako/blob/main/LICENSE\n*/\n/*! https://mths.be/he v1.2.0 by @mathias | MIT license */\n';rs&&(ne.export_worker_text=rs);var t_={version:"21.6.2",CreateSpreadsheet:c=>gt.Create(ne,c).sheet,SetScriptPath:c=>{ne.treb_base_path=c}};ne.BuildPath();export{t_ as TREB};
|
|
14
|
+
`)}SaveLocalFile(e="treb.json",t={}){let i=this.grid.model.document_name||"document",r,s,n=e.split(/\./).filter(a=>a.trim().length),o=n.length?n[n.length-1].toLowerCase():"treb";if(n.length<=1||e==="treb.json")if(e==="treb.json"&&(o=e),(o==="csv"||o==="tsv")&&this.grid.model.sheets.length>1){let a=this.grid.active_sheet.name;e=(i+"-"+a).toLowerCase().replace(/\W+/g,"-")+"."+o}else e=i.toLowerCase().replace(/\W+/g,"-")+"."+o;switch(o){case"csv":s=this.ExportDelimited({delimiter:","});break;case"tsv":s=this.ExportDelimited({delimiter:" "});break;case"treb":case"json":case"treb.json":r=this.SerializeDocument({...t}),s=JSON.stringify(r,void 0,t.pretty?2:void 0),this.last_save_version=this.file_version;break;default:throw new Error("invalid file type")}if(s&&e){let a=new Blob([s],{type:"text/plain;charset=utf-8"});Zi.saveAs(a,e,{autoBom:!1})}}LoadCSV(e,t){if(this.parent_view)return this.parent_view.LoadCSV(e,t);this.grid.FromCSV(e),this.ResetInternal(),this.grid.Update(!0),this.Publish({type:"load",source:t}),this.UpdateDocumentStyles()}ScrollOffset(e){return this.grid.ScrollOffset(e)}LoadDocument(e,t={}){if(this.parent_view)return this.parent_view.LoadDocument(e,t);if(t={flush:!0,recalculate:!1,...t},t.override_selection&&e.sheet_data){let i=Array.isArray(e.sheet_data)?e.sheet_data:[e.sheet_data];for(let r of i)if(r.id===t.override_selection.target.sheet_id){r.selection=t.override_selection;break}}if(this.ImportDocumentData(e,t.override_sheet),this.calculator.Reset(),e.rendered_values&&!t.recalculate?(this.grid.Update(),this.calculator.RebuildClean(!0)):this.Recalculate(),this.InflateAnnotations(),t.flush&&this.FlushUndo(),this.Publish({type:"load",source:t.source}),this.UpdateDocumentStyles(),this.loaded=!0,t.scroll){let i=t.scroll;se().then(()=>this.ScrollTo(i))}}SetNote(e,t){if(typeof e=="string"){let i=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(i)?i:i.start}this.grid.SetNote(e,t)}SetValidation(e,t,i){if(typeof e=="string"){let r=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(r)?r:r.start}if(typeof t>"u"||Array.isArray(t))this.grid.SetValidation(e,t,i);else{let r=this.calculator.ResolveArea(t,this.grid.active_sheet);this.grid.SetValidation(e,r,i)}}RemoveFunction(e){let t=e.toUpperCase();this.model.macro_functions.delete(t),this.UpdateAC()}DefineFunction(e,t="",i="0"){if(!e.length||/^[^A-Za-z]/.test(e)||/[^\w_.]/.test(e))throw new Error("invalid function name");typeof t=="string"&&(t=t?t.split(this.parser.argument_separator).map(r=>r.trim()):[]);for(let r of t)if(!r.length||/^[^A-Za-z]/.test(r)||/[^\w_.]/.test(r))throw new Error("invalid argument name");this.RemoveFunction(e),this.grid.model.macro_functions.set(e.toUpperCase(),{name:e,function_def:i,argument_names:t,expression:this.parser.Parse(i).expression}),this.UpdateAC()}SerializeDocument(e={}){let t=this.grid.Serialize({shrink:!0,...e}),i={app:"treb",version:"21.6.5",revision:this.file_version,name:this.grid.model.document_name,user_data:this.grid.model.user_data,decimal_mark:T.decimal_separator,...t};return e.rendered_values&&(i.rendered_values=!0),i}async Recalculate(e){let t;e&&e.type==="data"&&e.area&&(t=e.area),this.calculator.Calculate(t),this.grid.Update(!0),this.UpdateAnnotations(),this.Publish({type:"data"})}SaveLocalStorage(e=this.options.storage_key){if(!e){console.warn("not saving, no key");return}let t=JSON.stringify(this.SerializeDocument({rendered_values:!0,expand_arrays:!0}));localStorage.setItem(e,t)}Undo(){if(this.parent_view)return this.parent_view.Undo();if(this.undo_pointer<=1){console.warn("nothing to undo");return}let e=this.undo_stack[--this.undo_pointer-1],t=e.selection?JSON.parse(e.selection):void 0;this.LoadDocument(JSON.parse(e.data),{flush:!1,override_selection:t,source:"undo"})}About(){this.dialog?.ShowDialog({type:"about"})}ScrollTo(e,t={}){if(typeof e=="string"){let i=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(i)?i:i.start}t={x:!0,y:!0,smooth:!1,...t},this.grid.ScrollTo(e,t.x,t.y,t.smooth)}Resolve(e){let t=this.calculator.ResolveAddress(e,this.grid.active_sheet);return P(t)?t.sheet_id?t:void 0:t.start.sheet_id?t:void 0}Evaluate(e){return this.calculator.Evaluate(e)}GetSelection(e=!0){let t=this.grid.GetSelection();if(t.empty)return"";let i="";if(t.area.count>1?i=g.CellAddressToLabel(t.area.start)+":"+g.CellAddressToLabel(t.area.end):i=g.CellAddressToLabel(t.area.start),!e)return i;let r=t.area.start.sheet_id||this.grid.active_sheet.id,s=this.ResolveSheetName(r,!0);return s?s+"!"+i:i}ParseNumber(e){return ye.TryParse(e).value}FormatNumber(e,t="General"){return L.Get(t).Format(e)}ApplyBorders(e,t,i=1){this.grid.ApplyBorders(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0,t,void 0,i)}ApplyStyle(e,t={},i=!0){this.grid.ApplyStyle(e?this.calculator.ResolveArea(e,this.grid.active_sheet):void 0,t,i)}ClearName(e){this.grid.SetName(e)}DefineName(e,t){if(typeof t>"u"||t===null)throw new Error("invalid value (null or undefined)");if(typeof t=="object"&&(P(t)||ir(t))){this.grid.SetName(e,this.calculator.ResolveArea(t,this.grid.active_sheet));return}if(typeof t=="string"){let i=this.parser.Parse(t);if(!i.expression)throw new Error("invalid expression");switch(i.expression.type){case"address":case"range":this.grid.SetName(e,this.calculator.ResolveArea(i.expression,this.grid.active_sheet));return}this.grid.SetName(e,void 0,t)}else this.grid.SetName(e,void 0,t.toString())}SetLink(e,t=""){if(typeof e=="string"){let i=this.calculator.ResolveAddress(e,this.grid.active_sheet);e=P(i)?i:i.start}if(!e){let i=this.GetSelectionReference();if(i.empty)return;e=i.target}this.grid.SetLink(e,t)}Select(e){this.grid.SelectRange(this.calculator.ResolveArea(e,this.grid.active_sheet))}GetRange(e,t={}){if(!e){let i=this.GetSelectionReference();i.empty||(e=i.area)}if(!!e)return t.type||(t.formatted&&(t.type="formatted"),t.formula&&(t.type="formula")),this.grid.GetRange(this.calculator.ResolveAddress(e,this.grid.active_sheet),t.type)}GetStyle(e,t=!1){if(!e){let i=this.GetSelectionReference();i.empty||(e=i.area)}if(!!e)return this.grid.GetRangeStyle(this.calculator.ResolveAddress(e,this.grid.active_sheet),t)}SetRange(e,t=void 0,i={}){if(!e){let r=this.GetSelectionReference();r.empty||(e=r.area)}if(e){let r=this.calculator.ResolveArea(e,this.grid.active_sheet);if(i.spill&&Array.isArray(t)){let s=t.length,n=Math.max(0,...t.map(a=>a.length)),o={row:r.start.row+s+1,column:r.start.column+n+1};r.ConsumeAddress(o)}return this.grid.SetRange(r,t,i.recycle,i.transpose,i.array,!0)}}Subscribe(e){return this.events.Subscribe(e)}Cancel(e){this.events.Cancel(e)}Publish(e){this.events.Publish(e)}async ImportXLSX(e,t){if(this.parent_view)return this.parent_view.ImportXLSX(e,t);if(!this.export_worker){let i="treb-export-worker";this.export_worker=await this.LoadWorker(i)}return new Promise((i,r)=>{this.export_worker?(this.dialog?.ShowDialog({message:"Importing XLSX..."}),this.export_worker.onmessage=s=>{if(s.data){if(s.data.status==="error")return r(s.data.error||"unknown error");this.grid.FromImportData(s.data.results),this.ResetInternal(),this.grid.Update(),this.UpdateAC(),this.calculator.AttachModel(),this.Publish({type:"load",source:t}),this.UpdateDocumentStyles(),this.InflateAnnotations()}else return r("unknown error (missing data)");this.dialog?.HideDialog(),i()},this.export_worker.onerror=s=>{console.error("import worker error"),console.info(s),r(s)},this.export_worker.postMessage({command:"import",data:e})):r("worker failed")})}ResetInternal(){this.calculator.Reset(),this.FlushUndo(),this.file_version=this.last_save_version=0}HandleCellEvent(e){if(e.data?.type==="hyperlink"){let i="hyperlink invalid target",r=e.data.data||"";if(typeof r=="string"){if(/^https{0,1}:\/\//i.test(r)){if(!this.options.hyperlinks){console.warn("hyperlinks are disabled");return}let s=document.createElement("a");s.setAttribute("target",this.options.hyperlinks),s.setAttribute("href",r),s.setAttribute("noreferrer","true"),s.setAttribute("nofollow","true"),s.click();return}else{let s=this.parser.Parse(r);if(s.expression){if(s.expression.type==="address"){(s.expression.sheet||s.expression.sheet_id)&&this.ActivateSheet(s.expression.sheet||s.expression.sheet_id),this.Select(r);return}else if(s.expression.type==="range"){(s.expression.start.sheet||s.expression.start.sheet_id)&&this.ActivateSheet(s.expression.start.sheet||s.expression.start.sheet_id),this.Select(r);return}}}console.warn(i,2);return}}}OnSheetChange(e){for(let t of e.activate.annotations)this.InflateAnnotation(t),this.calculator.UpdateAnnotations(t,e.activate);this.UpdateAnnotations()}HandleDrag(e){if(e.dataTransfer&&e.dataTransfer.types){if(e.dataTransfer.types.some&&e.dataTransfer.types.some(t=>t==="Files"))e.preventDefault();else for(let t=0;t<e.dataTransfer.types.length;t++)if(e.dataTransfer.types[t]==="files"){e.preventDefault();return}}}HandleDrop(e){if(e.dataTransfer&&e.dataTransfer.files&&e.dataTransfer.files.length){e.preventDefault();let t=e.dataTransfer.files[0];/^image/.test(t.type)?this.InsertImageInternal(t):this.LoadFileInternal(t,"drag-and-drop").catch(()=>{})}}SelectFile2(e,t){if(!this.file_chooser){this.file_chooser=document.createElement("input"),this.file_chooser.type="file";let i=this.file_chooser;i.addEventListener("change",()=>{if(i.files&&i.files[0]){let r=i.files[0];switch(i.value="",this.file_chooser_operation){case 2:this.InsertImageInternal(r);break;case 1:this.LoadFileInternal(r,"local-file",!0);break;default:console.warn("file chooser: no operation");break}}})}if(!this.file_chooser)throw new Error("could not create file chooser");this.file_chooser_operation=t,this.file_chooser.accept=e||"",this.file_chooser.click()}async InsertImageInternal(e){if(this.options.max_file_size&&e.size>this.options.max_file_size){this.dialog?.ShowDialog({type:"error",message:"This file exceeds the allowed image size. Please try a smaller image.",title:"Error adding image",timeout:3e3,close_box:!0});return}let t=e;await new Promise((i,r)=>{let s=new FileReader;s.onload=async()=>{try{if(s.result){let n;if(typeof s.result=="string")n=s.result;else{n="";let l=new Uint8Array(s.result);for(let d=0;d<l.byteLength;d++)n+=String.fromCharCode(l[d])}let o=document.createElement("img");o.src=n,await Promise.resolve();let a=this.grid.CreateAnnotation({type:"image",formula:""},void 0,void 0,{top:30,left:30,width:o.width||300,height:o.height||300});a.data.src=n,a.data.original_size={width:o.width||300,height:o.height||300}}i()}catch(n){r(n)}},s.onabort=()=>{r("Aborted")},s.onerror=()=>{r("File error")},setTimeout(()=>{s.readAsDataURL(t)},100)})}LoadFileInternal(e,t,i=!0){if(!e)return Promise.resolve();let r=new FileReader;return new Promise((s,n)=>{let o=a=>{r.onload=null,r.onabort=null,r.onerror=null,a?(i&&(this.dialog?.ShowDialog({title:"Error reading file",close_box:!0,message:"Please make sure your file is a valid XLSX, CSV or TREB file.",type:"error",timeout:3e3}),console.error(a)),n(a)):s()};r.onload=()=>{try{if(r.result)if(/\.csv$/i.test(e.name))this.LoadCSV(r.result,t);else if(/\.xls[xm]$/i.test(e.name)){let a;if(typeof r.result=="string")a=r.result;else{a="";let l=new Uint8Array(r.result);for(let d=0;d<l.byteLength;d++)a+=String.fromCharCode(l[d])}this.ImportXLSX(a,t).then(()=>o()).catch(l=>o(l));return}else{let a=JSON.parse(r.result);this.LoadDocument(a,{source:t})}o()}catch(a){o(a?.toString())}},r.onabort=()=>{o("Aborted")},r.onerror=()=>{o("File error")},setTimeout(()=>{/\.xlsx$/i.test(e.name)?r.readAsBinaryString?r.readAsBinaryString(e):r.readAsArrayBuffer(e):r.readAsText(e)},100)})}UpdateAnnotations(){for(let e of this.grid.active_sheet.annotations){if(e.temp.vertex){let i=e.temp.vertex;if(i.state_id!==e.temp.state){e.temp.state=i.state_id;for(let r of e.view)r.dirty=!0}}let t=e.view[this.grid.view_index]||{};t.dirty&&(t.update_callback&&t.update_callback(),this.grid.AnnotationUpdated(e))}}RebuildAllAnnotations(){for(let e of this.grid.active_sheet.annotations){this.InflateAnnotation(e);let t=e.view[this.grid.view_index]||{};t.resize_callback&&t.resize_callback(),t.update_callback&&t.update_callback()}}InflateAnnotations(){for(let e of this.grid.active_sheet.annotations)this.InflateAnnotation(e)}InflateAnnotation(e){if(this.grid.headless)return;let t=e.view[this.grid.view_index]||{};if(t.inflated){e.dirty&&(t.resize_callback&&t.resize_callback(),e.dirty=!1);return}if(t.inflated=!0,e.dirty&&(e.dirty=!1),t.content_node&&e.data){if(e.type==="treb-chart"){let i=this.CreateChart();i.Initialize(t.content_node);let r=()=>{if(e.formula){let s=this.parser.Parse(e.formula);if(s&&s.expression&&s.expression.type==="call"){this.parser.Walk(s.expression,a=>((a.type==="address"||a.type==="range")&&this.calculator.ResolveSheetID(a,void 0,this.grid.active_sheet),!0));let n=s.expression.name.toLowerCase(),o=this.calculator.CalculateExpression(s.expression);i.Exec(n,o)}}i.Update()};t.resize_callback=()=>{this.grid.headless||(i.Resize(),i.Update())},t.update_callback=()=>{this.grid.headless||r()},t.node?.parentElement&&(this.grid.headless||r())}else if(e.type==="image"){let i=document.createElement("img");typeof e.data.src=="string"&&/^data:image/i.test(e.data.src)&&i.setAttribute("src",e.data.src),i.style.width="100%",i.style.height="100%",t.content_node.appendChild(i)}}}DocumentChange(e){se().then(()=>{this.file_version++,this.file_version>=65536&&(this.file_version=1);let t=JSON.stringify(this.SerializeDocument({optimize:"size",rendered_values:!0,expand_arrays:!0}));this.options.storage_key&&localStorage.setItem(this.options.storage_key,t),this.options.undo&&this.PushUndo(t,e,!1),this.Publish({type:"document-change"})})}PushUndo(e,t,i=!0){let r=t||this.last_selection;this.undo_stack[this.undo_pointer-1]&&(this.undo_stack[this.undo_pointer-1].selection=r),i&&(this.file_version++,this.file_version>=65536&&(this.file_version=1)),e||(e=JSON.stringify(this.SerializeDocument({optimize:"size",rendered_values:!0,expand_arrays:!0}))),this.undo_stack[this.undo_pointer++]={data:e,selection:void 0};let s=this.undo_stack.length;if(s>16){let n=s-16;this.undo_stack=this.undo_stack.slice(n),this.undo_pointer-=n}}FlushUndo(e=!0){this.undo_stack=[],this.undo_pointer=0,this.last_save_version=this.file_version,e&&this.PushUndo(void 0,void 0,!1)}UpdateSelection(e){this.last_selection=JSON.stringify(e),this.Publish({type:"selection"})}UpdateSelectionStyle(e){let t=this.grid.GetFreeze(),i={frozen:!!t.rows||!!t.columns};if(e||(e=this.grid.GetSelection()),e&&!e.empty){i.selection=e,i.merge=!1;let r=this.grid.active_sheet.CellData(e.target);i.merge=!!r.merge_area,i.merge&&r.merge_area&&(r.merge_area.start.row!==e.target.row||r.merge_area.start.column!==e.target.column)&&(r=this.grid.active_sheet.CellData(r.merge_area.start)),i.comment=r.note,i.style=r.style?{...r.style}:void 0}this.selection_state=i,this.toolbar?.UpdateState(i)}UpdateDocumentStyles(e=!0){if(!this.toolbar)return;let t={},i={};for(let r of this.grid.model.sheets.list)r.NumberFormatsAndColors(i,t);this.toolbar.UpdateDocumentStyles(Object.keys(t),Object.keys(i),e)}ConvertLocale(e){let t=new $e;t.flags={...this.parser.flags};let i,r;e.decimal_mark==="."?(t.decimal_mark=".",t.argument_separator=",",i=",",r=";"):(t.decimal_mark=",",t.argument_separator=";",i=".",r=",");let s=n=>{let o=t.Parse(n);if(!!o.expression)return"="+t.Render(o.expression,void 0,"",i,r)};if(e.macro_functions)for(let n of e.macro_functions){let o=s(n.function_def);o&&(n.function_def=o)}if(e.sheet_data){let n=Array.isArray(e.sheet_data)?e.sheet_data:[e.sheet_data];for(let o of n){if(o.annotations){for(let a of o.annotations)if(a.formula){let l=s(a.formula);l&&(a.formula=l)}}if(o.data?.length)for(let a of o.data){let l=oi(a)?[a]:a.cells;for(let d of l)if(d.value&&typeof d.value=="string"&&d.value[0]==="="){let u=s(d.value.slice(1));u&&(d.value=u)}}}}}CompareVersions(e="",t=""){let i=e.split(".").map(o=>Number(o)||0).concat([0,0,0]),r=t.split(".").map(o=>Number(o)||0).concat([0,0,0]),s=[0,1,2],n={match:0};for(let o=0;o<3;o++)if(i[o]!==r[o]){n.match=i[o]>r[o]?1:-1,n.level=s[o];break}return n}ImportDocumentData(e,t){this.file_version=e.revision||0;let i=[],r=this.CompareVersions(e.version,"21.6.5");r.match>0&&(r.level===0||r.level===1)&&console.warn(`The file you are opening was created with a newer version of TREB (${e.version} vs 21.6.5).
|
|
15
|
+
You may encounter compatibility errors.`),e.sheet_data&&(Array.isArray(e.sheet_data)?i=e.sheet_data:i.push(e.sheet_data)),e.decimal_mark&&e.decimal_mark!==T.decimal_separator&&this.ConvertLocale(e),this.grid.UpdateSheets(i,void 0,t||e.active_sheet);let s=this.grid.model;s.document_name=e.name,s.user_data=e.user_data,s.named_ranges.Reset();let n=e.named_ranges;if(!n&&i[0]&&i[0].named_ranges&&(n=i[0].named_ranges),n&&s.named_ranges.Deserialize(n),s.named_expressions.clear(),e.named_expressions)for(let o of e.named_expressions){let a=this.parser.Parse(o.expression);a.valid&&a.expression&&(this.parser.Walk(a.expression,l=>{if(l.type==="address"||l.type==="range"){if(l.type==="range"&&(l=l.start),!l.sheet_id&&l.sheet){let d=this.model.sheets.Find(l.sheet);d&&(l.sheet_id=d.id)}return l.sheet_id||(l.sheet_id=this.grid.active_sheet.id),!1}return!0}),s.named_expressions.set(o.name.toUpperCase(),a.expression))}if(s.macro_functions.clear(),e.macro_functions)for(let o of e.macro_functions)s.macro_functions.set(o.name.toUpperCase(),{...o,expression:this.parser.Parse(o.function_def||"").expression});this.UpdateAC()}async LoadWorker(e){if(Oe.export_worker_text)try{return new Worker(URL.createObjectURL(new Blob([Oe.export_worker_text],{type:"application/javascript"})))}catch(r){console.info("embedded worker failed"),console.error(r)}if(!Oe.treb_base_path)throw console.warn("worker path is not set. it you are loading TREB in an ESM module, please either include the script in a document <script/> tag, or call the method TREB.SetScriptPath() to set the load path for workers (this should be the path to TREB script files)."),new Error("worker path not set");/\.js$/.test(e)||(e+="-21.6.5.js");let t,i=Oe.treb_base_path;if(i&&(/\/$/.test(i)||(i+="/"),e=i+e),/^(http:|https:|\/\/)/.test(e)){let r=await fetch(e);if(!r.ok)throw new Error("Error loading worker script");let s=await r.text();t=new Worker(URL.createObjectURL(new Blob([s],{type:"application/javascript"})))}else{if(/^file:/.test(e))throw new Error("invalid URI");t=new Worker(e)}return t}HandleKeyDown(e){e.ctrlKey&&(e.code==="KeyZ"||e.key==="z")&&(e.stopPropagation(),e.preventDefault(),this.Undo())}ResolveSheetName(e,t=!1){let i=this.model.sheets.Find(e);if(i)return t&&st.test(i.name)?`'${i.name}'`:i.name}},ne=Oe;E(ne,"treb_base_path",""),E(ne,"export_worker_text",""),E(ne,"treb_embedded_script_path",""),E(ne,"enable_engine",!1),E(ne,"enable_formatter",!1);var Qi="sidebar-open",ri="toolbar-open";var er=class{constructor(e,t){this.base_type=e;let i=typeof t.container=="string"?document.querySelector(t.container):t.container;if(!i)throw new Error("missing container");i.classList.add("treb-container"),this.options={...ei,...t},window.getComputedStyle(i).position==="static"&&(i.style.position="relative");let s=i.getBoundingClientRect();!this.options.headless&&(!s.width||!s.height)&&i.classList.add("default-spreadsheet-size"),this.inner_container=document.createElement("div"),this.inner_container.classList.add("treb-views"),this.options.collapsed||i.classList.add("sidebar-open"),(this.options.toolbar==="show"||this.options.toolbar==="show-narrow")&&i.classList.add(ri),i.appendChild(this.inner_container),this.sheet=new e({...this.options,container:this.inner_container,resizable:!1}),this.sidebar=document.createElement("div"),this.sidebar.classList.add("embedded-spreadsheet-sidebar"),this.AddSidebarButton({icon:"treb-icon-reset",title:"Recalculate",click:()=>this.sheet.Recalculate()}),this.options.toolbar&&(this.toolbar_container=document.createElement("div"),this.toolbar_container.classList.add("toolbar-container"),this.toolbar_button=this.AddSidebarButton({icon:"treb-icon-toolbar",title:"Show Toolbar",click:()=>this.ToggleToolbar()}),i.appendChild(this.toolbar_container),this.sheet.toolbar_ctl={Show:a=>this.ShowToolbar(a)}),this.options.export&&this.AddSidebarButton({icon:"treb-icon-export",title:"Download as XLSX",click:()=>this.sheet.Export()}),this.options.revert&&this.AddSidebarButton({icon:"treb-icon-revert",title:"Revert to original version",click:()=>this.sheet.Revert()}),this.options.popout&&this.AddSidebarButton({icon:"treb-icon-popout",title:"Open in New Tab",click:()=>this.Popout()}),this.AddSidebarButton({icon:"treb-icon-about",title:"What's This?",click:()=>this.sheet.About()});let n=document.createElement("div");n.classList.add("sidebar-spacer"),this.sidebar.appendChild(n),this.AddSidebarButton({icon:"treb-icon-chevron-right",classes:"smaller",title:"Hide Sidebar",click:()=>this.HideSidebar()}),i.appendChild(this.sidebar);let o=this.AddSidebarButton({icon:"treb-icon-chevron-left",classes:["smaller","show-sidebar-button"],title:"Show Sidebar",click:()=>this.ShowSidebar()},void 0);if(i.appendChild(o),this.options.resizable){let a=i.querySelector(".treb-grid"),l=i.querySelector(".treb-layout-master");a&&Be.Create({container:i,node:a,resize_callback:()=>this.sheet.Resize(),layout_reference:l||void 0})}(this.options.toolbar==="show"||this.options.toolbar==="show-narrow")&&this.ShowToolbar(!0),t.container._spreadsheet=this.sheet}inner_container;sidebar;toolbar_container;toolbar_button;sheet;options;toolbar;static Create(e,t){return new er(e,t)}Popout(){let e=window.open("","_blank");if(!e)return;e.document.head.innerHTML=`<title>${this.sheet.document_name?`TREB: ${this.sheet.document_name}`:"TREB: Untitled Document"}</title><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='IE=edge'><meta name='viewport' content='width=device-width,initial-scale=1'><link rel='icon' type='image/svg+xml' href='https://treb.app/leaf.svg'>`;let t="treb-bundle";/\.js$/.test(t)||(t+=".js");let i=ne.treb_base_path;i&&(/\/$/.test(i)||(i+="/"),t=i+t);let r=e.document.createElement("script");r.src=t,r.setAttribute("type","text/javascript"),e.document.body.appendChild(r);let s=JSON.stringify(this.sheet.SerializeDocument({rendered_values:!0})),n=e.document.createElement("style");n.setAttribute("type","text/css"),n.textContent="*{box-sizing:border-box;padding:0;margin:0;}body,html{height:100%;width:100%;position:relative;}.treb{top:0;left:0;right:0;bottom:0;position:absolute;background:#fff;}",e.document.head.appendChild(n);let o=e.document.createElement("div");o.setAttribute("class","treb treb-fullscreen-padding"),e.document.body.appendChild(o);let a=window.screen.availWidth>=1200,l=e.document.createElement("script"),d={...this.options,container:void 0,network_document:void 0,storage_key:void 0,resizable:!1,export:!0,scroll:void 0,toolbar:a?"show":!0,file_menu:!0,prompt_save:!0,expand_formula_button:a,popout:!1,add_tab:!0,tab_bar:"auto",headless:!1,dnd:!0,collapsed:!a},u=(h,p)=>{let f=0,m=()=>{h.container=document.querySelector(".treb"),h.container&&window.TREB?(window.sheet=window.TREB.CreateSpreadsheet(h),window.sheet.LoadDocument(p)):++f<32&&setTimeout(()=>m(),100)};m()};l.textContent=`(${u.toString()})(${JSON.stringify(d)},${s})`,e.document.body.appendChild(l),e.document.close()}AddSidebarButton(e={},t=this.sidebar){let i=document.createElement("button");if(i.setAttribute("type","button"),i.classList.add("sidebar-button"),e.classes){let r=typeof e.classes=="string"?[e.classes]:e.classes;for(let s of r)i.classList.add(s)}if(e.title&&i.setAttribute("title",e.title),e.text&&(i.textContent=e.text),e.click){let r=e.click;i.addEventListener("click",()=>r())}if(e.icon&&i.classList.add("treb-icon",e.icon),t)if(typeof e.position=="number"){let s=t.children[e.position];s?t.insertBefore(i,s):t.appendChild(i)}else t.appendChild(i);return i}ToggleSidebar(){this.sidebar.parentElement.classList.toggle(Qi)}ShowSidebar(e=!0){let t=this.sidebar.parentElement;e?t.classList.add(Qi):t.classList.remove(Qi)}HideSidebar(){this.ShowSidebar(!1)}ToggleToolbar(){let e=this.toolbar_container?.parentElement;this.ShowToolbar(!e.classList.contains(ri))}ShowToolbar(e=!0){let t=this.toolbar_container?.parentElement,i="Hide Toolbar";e?(this.toolbar_container&&!this.toolbar&&(this.toolbar=this.sheet.CreateToolbar(this.toolbar_container)),t.classList.add(ri)):(t.classList.remove(ri),i="Show Toolbar"),this.toolbar_button&&this.toolbar_button.setAttribute("title",i)}HideToolbar(){this.ShowToolbar(!1)}},gt=er;E(gt,"symbols_injected",!1);var rs='"use strict";/*! TREB v21.6.5. Copyright 2018-2022 trebco, llc. All rights reserved. LGPL: https://treb.app/license */\n(()=>{var ki=Object.create;var Bt=Object.defineProperty;var Ni=Object.getOwnPropertyDescriptor;var Fi=Object.getOwnPropertyNames;var Si=Object.getPrototypeOf,Ti=Object.prototype.hasOwnProperty;var Pi=(s,e,t)=>e in s?Bt(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Ye=(s=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(s,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):s)(function(s){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error(\'Dynamic require of "\'+s+\'" is not supported\')});var ge=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Ri=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fi(e))!Ti.call(s,n)&&n!==t&&Bt(s,n,{get:()=>e[n],enumerable:!(r=Ni(e,n))||r.enumerable});return s};var Fe=(s,e,t)=>(t=s!=null?ki(Si(s)):{},Ri(e||!s||!s.__esModule?Bt(t,"default",{value:s,enumerable:!0}):t,s));var ie=(s,e,t)=>(Pi(s,typeof e!="symbol"?e+"":e,t),t);var st=ge((nt,He)=>{(function(s){var e=typeof nt=="object"&&nt,t=typeof He=="object"&&He&&He.exports==e&&He,r=typeof global=="object"&&global;(r.global===r||r.window===r)&&(s=r);var n=/[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g,i=/[\\x01-\\x7F]/g,a=/[\\x01-\\t\\x0B\\f\\x0E-\\x1F\\x7F\\x81\\x8D\\x8F\\x90\\x9D\\xA0-\\uFFFF]/g,o=/<\\u20D2|=\\u20E5|>\\u20D2|\\u205F\\u200A|\\u219D\\u0338|\\u2202\\u0338|\\u2220\\u20D2|\\u2229\\uFE00|\\u222A\\uFE00|\\u223C\\u20D2|\\u223D\\u0331|\\u223E\\u0333|\\u2242\\u0338|\\u224B\\u0338|\\u224D\\u20D2|\\u224E\\u0338|\\u224F\\u0338|\\u2250\\u0338|\\u2261\\u20E5|\\u2264\\u20D2|\\u2265\\u20D2|\\u2266\\u0338|\\u2267\\u0338|\\u2268\\uFE00|\\u2269\\uFE00|\\u226A\\u0338|\\u226A\\u20D2|\\u226B\\u0338|\\u226B\\u20D2|\\u227F\\u0338|\\u2282\\u20D2|\\u2283\\u20D2|\\u228A\\uFE00|\\u228B\\uFE00|\\u228F\\u0338|\\u2290\\u0338|\\u2293\\uFE00|\\u2294\\uFE00|\\u22B4\\u20D2|\\u22B5\\u20D2|\\u22D8\\u0338|\\u22D9\\u0338|\\u22DA\\uFE00|\\u22DB\\uFE00|\\u22F5\\u0338|\\u22F9\\u0338|\\u2933\\u0338|\\u29CF\\u0338|\\u29D0\\u0338|\\u2A6D\\u0338|\\u2A70\\u0338|\\u2A7D\\u0338|\\u2A7E\\u0338|\\u2AA1\\u0338|\\u2AA2\\u0338|\\u2AAC\\uFE00|\\u2AAD\\uFE00|\\u2AAF\\u0338|\\u2AB0\\u0338|\\u2AC5\\u0338|\\u2AC6\\u0338|\\u2ACB\\uFE00|\\u2ACC\\uFE00|\\u2AFD\\u20E5|[\\xA0-\\u0113\\u0116-\\u0122\\u0124-\\u012B\\u012E-\\u014D\\u0150-\\u017E\\u0192\\u01B5\\u01F5\\u0237\\u02C6\\u02C7\\u02D8-\\u02DD\\u0311\\u0391-\\u03A1\\u03A3-\\u03A9\\u03B1-\\u03C9\\u03D1\\u03D2\\u03D5\\u03D6\\u03DC\\u03DD\\u03F0\\u03F1\\u03F5\\u03F6\\u0401-\\u040C\\u040E-\\u044F\\u0451-\\u045C\\u045E\\u045F\\u2002-\\u2005\\u2007-\\u2010\\u2013-\\u2016\\u2018-\\u201A\\u201C-\\u201E\\u2020-\\u2022\\u2025\\u2026\\u2030-\\u2035\\u2039\\u203A\\u203E\\u2041\\u2043\\u2044\\u204F\\u2057\\u205F-\\u2063\\u20AC\\u20DB\\u20DC\\u2102\\u2105\\u210A-\\u2113\\u2115-\\u211E\\u2122\\u2124\\u2127-\\u2129\\u212C\\u212D\\u212F-\\u2131\\u2133-\\u2138\\u2145-\\u2148\\u2153-\\u215E\\u2190-\\u219B\\u219D-\\u21A7\\u21A9-\\u21AE\\u21B0-\\u21B3\\u21B5-\\u21B7\\u21BA-\\u21DB\\u21DD\\u21E4\\u21E5\\u21F5\\u21FD-\\u2205\\u2207-\\u2209\\u220B\\u220C\\u220F-\\u2214\\u2216-\\u2218\\u221A\\u221D-\\u2238\\u223A-\\u2257\\u2259\\u225A\\u225C\\u225F-\\u2262\\u2264-\\u228B\\u228D-\\u229B\\u229D-\\u22A5\\u22A7-\\u22B0\\u22B2-\\u22BB\\u22BD-\\u22DB\\u22DE-\\u22E3\\u22E6-\\u22F7\\u22F9-\\u22FE\\u2305\\u2306\\u2308-\\u2310\\u2312\\u2313\\u2315\\u2316\\u231C-\\u231F\\u2322\\u2323\\u232D\\u232E\\u2336\\u233D\\u233F\\u237C\\u23B0\\u23B1\\u23B4-\\u23B6\\u23DC-\\u23DF\\u23E2\\u23E7\\u2423\\u24C8\\u2500\\u2502\\u250C\\u2510\\u2514\\u2518\\u251C\\u2524\\u252C\\u2534\\u253C\\u2550-\\u256C\\u2580\\u2584\\u2588\\u2591-\\u2593\\u25A1\\u25AA\\u25AB\\u25AD\\u25AE\\u25B1\\u25B3-\\u25B5\\u25B8\\u25B9\\u25BD-\\u25BF\\u25C2\\u25C3\\u25CA\\u25CB\\u25EC\\u25EF\\u25F8-\\u25FC\\u2605\\u2606\\u260E\\u2640\\u2642\\u2660\\u2663\\u2665\\u2666\\u266A\\u266D-\\u266F\\u2713\\u2717\\u2720\\u2736\\u2758\\u2772\\u2773\\u27C8\\u27C9\\u27E6-\\u27ED\\u27F5-\\u27FA\\u27FC\\u27FF\\u2902-\\u2905\\u290C-\\u2913\\u2916\\u2919-\\u2920\\u2923-\\u292A\\u2933\\u2935-\\u2939\\u293C\\u293D\\u2945\\u2948-\\u294B\\u294E-\\u2976\\u2978\\u2979\\u297B-\\u297F\\u2985\\u2986\\u298B-\\u2996\\u299A\\u299C\\u299D\\u29A4-\\u29B7\\u29B9\\u29BB\\u29BC\\u29BE-\\u29C5\\u29C9\\u29CD-\\u29D0\\u29DC-\\u29DE\\u29E3-\\u29E5\\u29EB\\u29F4\\u29F6\\u2A00-\\u2A02\\u2A04\\u2A06\\u2A0C\\u2A0D\\u2A10-\\u2A17\\u2A22-\\u2A27\\u2A29\\u2A2A\\u2A2D-\\u2A31\\u2A33-\\u2A3C\\u2A3F\\u2A40\\u2A42-\\u2A4D\\u2A50\\u2A53-\\u2A58\\u2A5A-\\u2A5D\\u2A5F\\u2A66\\u2A6A\\u2A6D-\\u2A75\\u2A77-\\u2A9A\\u2A9D-\\u2AA2\\u2AA4-\\u2AB0\\u2AB3-\\u2AC8\\u2ACB\\u2ACC\\u2ACF-\\u2ADB\\u2AE4\\u2AE6-\\u2AE9\\u2AEB-\\u2AF3\\u2AFD\\uFB00-\\uFB04]|\\uD835[\\uDC9C\\uDC9E\\uDC9F\\uDCA2\\uDCA5\\uDCA6\\uDCA9-\\uDCAC\\uDCAE-\\uDCB9\\uDCBB\\uDCBD-\\uDCC3\\uDCC5-\\uDCCF\\uDD04\\uDD05\\uDD07-\\uDD0A\\uDD0D-\\uDD14\\uDD16-\\uDD1C\\uDD1E-\\uDD39\\uDD3B-\\uDD3E\\uDD40-\\uDD44\\uDD46\\uDD4A-\\uDD50\\uDD52-\\uDD6B]/g,u={"\\xAD":"shy","\\u200C":"zwnj","\\u200D":"zwj","\\u200E":"lrm","\\u2063":"ic","\\u2062":"it","\\u2061":"af","\\u200F":"rlm","\\u200B":"ZeroWidthSpace","\\u2060":"NoBreak","\\u0311":"DownBreve","\\u20DB":"tdot","\\u20DC":"DotDot"," ":"Tab","\\n":"NewLine","\\u2008":"puncsp","\\u205F":"MediumSpace","\\u2009":"thinsp","\\u200A":"hairsp","\\u2004":"emsp13","\\u2002":"ensp","\\u2005":"emsp14","\\u2003":"emsp","\\u2007":"numsp","\\xA0":"nbsp","\\u205F\\u200A":"ThickSpace","\\u203E":"oline",_:"lowbar","\\u2010":"dash","\\u2013":"ndash","\\u2014":"mdash","\\u2015":"horbar",",":"comma",";":"semi","\\u204F":"bsemi",":":"colon","\\u2A74":"Colone","!":"excl","\\xA1":"iexcl","?":"quest","\\xBF":"iquest",".":"period","\\u2025":"nldr","\\u2026":"mldr","\\xB7":"middot","\'":"apos","\\u2018":"lsquo","\\u2019":"rsquo","\\u201A":"sbquo","\\u2039":"lsaquo","\\u203A":"rsaquo",\'"\':"quot","\\u201C":"ldquo","\\u201D":"rdquo","\\u201E":"bdquo","\\xAB":"laquo","\\xBB":"raquo","(":"lpar",")":"rpar","[":"lsqb","]":"rsqb","{":"lcub","}":"rcub","\\u2308":"lceil","\\u2309":"rceil","\\u230A":"lfloor","\\u230B":"rfloor","\\u2985":"lopar","\\u2986":"ropar","\\u298B":"lbrke","\\u298C":"rbrke","\\u298D":"lbrkslu","\\u298E":"rbrksld","\\u298F":"lbrksld","\\u2990":"rbrkslu","\\u2991":"langd","\\u2992":"rangd","\\u2993":"lparlt","\\u2994":"rpargt","\\u2995":"gtlPar","\\u2996":"ltrPar","\\u27E6":"lobrk","\\u27E7":"robrk","\\u27E8":"lang","\\u27E9":"rang","\\u27EA":"Lang","\\u27EB":"Rang","\\u27EC":"loang","\\u27ED":"roang","\\u2772":"lbbrk","\\u2773":"rbbrk","\\u2016":"Vert","\\xA7":"sect","\\xB6":"para","@":"commat","*":"ast","/":"sol",undefined:null,"&":"amp","#":"num","%":"percnt","\\u2030":"permil","\\u2031":"pertenk","\\u2020":"dagger","\\u2021":"Dagger","\\u2022":"bull","\\u2043":"hybull","\\u2032":"prime","\\u2033":"Prime","\\u2034":"tprime","\\u2057":"qprime","\\u2035":"bprime","\\u2041":"caret","`":"grave","\\xB4":"acute","\\u02DC":"tilde","^":"Hat","\\xAF":"macr","\\u02D8":"breve","\\u02D9":"dot","\\xA8":"die","\\u02DA":"ring","\\u02DD":"dblac","\\xB8":"cedil","\\u02DB":"ogon","\\u02C6":"circ","\\u02C7":"caron","\\xB0":"deg","\\xA9":"copy","\\xAE":"reg","\\u2117":"copysr","\\u2118":"wp","\\u211E":"rx","\\u2127":"mho","\\u2129":"iiota","\\u2190":"larr","\\u219A":"nlarr","\\u2192":"rarr","\\u219B":"nrarr","\\u2191":"uarr","\\u2193":"darr","\\u2194":"harr","\\u21AE":"nharr","\\u2195":"varr","\\u2196":"nwarr","\\u2197":"nearr","\\u2198":"searr","\\u2199":"swarr","\\u219D":"rarrw","\\u219D\\u0338":"nrarrw","\\u219E":"Larr","\\u219F":"Uarr","\\u21A0":"Rarr","\\u21A1":"Darr","\\u21A2":"larrtl","\\u21A3":"rarrtl","\\u21A4":"mapstoleft","\\u21A5":"mapstoup","\\u21A6":"map","\\u21A7":"mapstodown","\\u21A9":"larrhk","\\u21AA":"rarrhk","\\u21AB":"larrlp","\\u21AC":"rarrlp","\\u21AD":"harrw","\\u21B0":"lsh","\\u21B1":"rsh","\\u21B2":"ldsh","\\u21B3":"rdsh","\\u21B5":"crarr","\\u21B6":"cularr","\\u21B7":"curarr","\\u21BA":"olarr","\\u21BB":"orarr","\\u21BC":"lharu","\\u21BD":"lhard","\\u21BE":"uharr","\\u21BF":"uharl","\\u21C0":"rharu","\\u21C1":"rhard","\\u21C2":"dharr","\\u21C3":"dharl","\\u21C4":"rlarr","\\u21C5":"udarr","\\u21C6":"lrarr","\\u21C7":"llarr","\\u21C8":"uuarr","\\u21C9":"rrarr","\\u21CA":"ddarr","\\u21CB":"lrhar","\\u21CC":"rlhar","\\u21D0":"lArr","\\u21CD":"nlArr","\\u21D1":"uArr","\\u21D2":"rArr","\\u21CF":"nrArr","\\u21D3":"dArr","\\u21D4":"iff","\\u21CE":"nhArr","\\u21D5":"vArr","\\u21D6":"nwArr","\\u21D7":"neArr","\\u21D8":"seArr","\\u21D9":"swArr","\\u21DA":"lAarr","\\u21DB":"rAarr","\\u21DD":"zigrarr","\\u21E4":"larrb","\\u21E5":"rarrb","\\u21F5":"duarr","\\u21FD":"loarr","\\u21FE":"roarr","\\u21FF":"hoarr","\\u2200":"forall","\\u2201":"comp","\\u2202":"part","\\u2202\\u0338":"npart","\\u2203":"exist","\\u2204":"nexist","\\u2205":"empty","\\u2207":"Del","\\u2208":"in","\\u2209":"notin","\\u220B":"ni","\\u220C":"notni","\\u03F6":"bepsi","\\u220F":"prod","\\u2210":"coprod","\\u2211":"sum","+":"plus","\\xB1":"pm","\\xF7":"div","\\xD7":"times","<":"lt","\\u226E":"nlt","<\\u20D2":"nvlt","=":"equals","\\u2260":"ne","=\\u20E5":"bne","\\u2A75":"Equal",">":"gt","\\u226F":"ngt",">\\u20D2":"nvgt","\\xAC":"not","|":"vert","\\xA6":"brvbar","\\u2212":"minus","\\u2213":"mp","\\u2214":"plusdo","\\u2044":"frasl","\\u2216":"setmn","\\u2217":"lowast","\\u2218":"compfn","\\u221A":"Sqrt","\\u221D":"prop","\\u221E":"infin","\\u221F":"angrt","\\u2220":"ang","\\u2220\\u20D2":"nang","\\u2221":"angmsd","\\u2222":"angsph","\\u2223":"mid","\\u2224":"nmid","\\u2225":"par","\\u2226":"npar","\\u2227":"and","\\u2228":"or","\\u2229":"cap","\\u2229\\uFE00":"caps","\\u222A":"cup","\\u222A\\uFE00":"cups","\\u222B":"int","\\u222C":"Int","\\u222D":"tint","\\u2A0C":"qint","\\u222E":"oint","\\u222F":"Conint","\\u2230":"Cconint","\\u2231":"cwint","\\u2232":"cwconint","\\u2233":"awconint","\\u2234":"there4","\\u2235":"becaus","\\u2236":"ratio","\\u2237":"Colon","\\u2238":"minusd","\\u223A":"mDDot","\\u223B":"homtht","\\u223C":"sim","\\u2241":"nsim","\\u223C\\u20D2":"nvsim","\\u223D":"bsim","\\u223D\\u0331":"race","\\u223E":"ac","\\u223E\\u0333":"acE","\\u223F":"acd","\\u2240":"wr","\\u2242":"esim","\\u2242\\u0338":"nesim","\\u2243":"sime","\\u2244":"nsime","\\u2245":"cong","\\u2247":"ncong","\\u2246":"simne","\\u2248":"ap","\\u2249":"nap","\\u224A":"ape","\\u224B":"apid","\\u224B\\u0338":"napid","\\u224C":"bcong","\\u224D":"CupCap","\\u226D":"NotCupCap","\\u224D\\u20D2":"nvap","\\u224E":"bump","\\u224E\\u0338":"nbump","\\u224F":"bumpe","\\u224F\\u0338":"nbumpe","\\u2250":"doteq","\\u2250\\u0338":"nedot","\\u2251":"eDot","\\u2252":"efDot","\\u2253":"erDot","\\u2254":"colone","\\u2255":"ecolon","\\u2256":"ecir","\\u2257":"cire","\\u2259":"wedgeq","\\u225A":"veeeq","\\u225C":"trie","\\u225F":"equest","\\u2261":"equiv","\\u2262":"nequiv","\\u2261\\u20E5":"bnequiv","\\u2264":"le","\\u2270":"nle","\\u2264\\u20D2":"nvle","\\u2265":"ge","\\u2271":"nge","\\u2265\\u20D2":"nvge","\\u2266":"lE","\\u2266\\u0338":"nlE","\\u2267":"gE","\\u2267\\u0338":"ngE","\\u2268\\uFE00":"lvnE","\\u2268":"lnE","\\u2269":"gnE","\\u2269\\uFE00":"gvnE","\\u226A":"ll","\\u226A\\u0338":"nLtv","\\u226A\\u20D2":"nLt","\\u226B":"gg","\\u226B\\u0338":"nGtv","\\u226B\\u20D2":"nGt","\\u226C":"twixt","\\u2272":"lsim","\\u2274":"nlsim","\\u2273":"gsim","\\u2275":"ngsim","\\u2276":"lg","\\u2278":"ntlg","\\u2277":"gl","\\u2279":"ntgl","\\u227A":"pr","\\u2280":"npr","\\u227B":"sc","\\u2281":"nsc","\\u227C":"prcue","\\u22E0":"nprcue","\\u227D":"sccue","\\u22E1":"nsccue","\\u227E":"prsim","\\u227F":"scsim","\\u227F\\u0338":"NotSucceedsTilde","\\u2282":"sub","\\u2284":"nsub","\\u2282\\u20D2":"vnsub","\\u2283":"sup","\\u2285":"nsup","\\u2283\\u20D2":"vnsup","\\u2286":"sube","\\u2288":"nsube","\\u2287":"supe","\\u2289":"nsupe","\\u228A\\uFE00":"vsubne","\\u228A":"subne","\\u228B\\uFE00":"vsupne","\\u228B":"supne","\\u228D":"cupdot","\\u228E":"uplus","\\u228F":"sqsub","\\u228F\\u0338":"NotSquareSubset","\\u2290":"sqsup","\\u2290\\u0338":"NotSquareSuperset","\\u2291":"sqsube","\\u22E2":"nsqsube","\\u2292":"sqsupe","\\u22E3":"nsqsupe","\\u2293":"sqcap","\\u2293\\uFE00":"sqcaps","\\u2294":"sqcup","\\u2294\\uFE00":"sqcups","\\u2295":"oplus","\\u2296":"ominus","\\u2297":"otimes","\\u2298":"osol","\\u2299":"odot","\\u229A":"ocir","\\u229B":"oast","\\u229D":"odash","\\u229E":"plusb","\\u229F":"minusb","\\u22A0":"timesb","\\u22A1":"sdotb","\\u22A2":"vdash","\\u22AC":"nvdash","\\u22A3":"dashv","\\u22A4":"top","\\u22A5":"bot","\\u22A7":"models","\\u22A8":"vDash","\\u22AD":"nvDash","\\u22A9":"Vdash","\\u22AE":"nVdash","\\u22AA":"Vvdash","\\u22AB":"VDash","\\u22AF":"nVDash","\\u22B0":"prurel","\\u22B2":"vltri","\\u22EA":"nltri","\\u22B3":"vrtri","\\u22EB":"nrtri","\\u22B4":"ltrie","\\u22EC":"nltrie","\\u22B4\\u20D2":"nvltrie","\\u22B5":"rtrie","\\u22ED":"nrtrie","\\u22B5\\u20D2":"nvrtrie","\\u22B6":"origof","\\u22B7":"imof","\\u22B8":"mumap","\\u22B9":"hercon","\\u22BA":"intcal","\\u22BB":"veebar","\\u22BD":"barvee","\\u22BE":"angrtvb","\\u22BF":"lrtri","\\u22C0":"Wedge","\\u22C1":"Vee","\\u22C2":"xcap","\\u22C3":"xcup","\\u22C4":"diam","\\u22C5":"sdot","\\u22C6":"Star","\\u22C7":"divonx","\\u22C8":"bowtie","\\u22C9":"ltimes","\\u22CA":"rtimes","\\u22CB":"lthree","\\u22CC":"rthree","\\u22CD":"bsime","\\u22CE":"cuvee","\\u22CF":"cuwed","\\u22D0":"Sub","\\u22D1":"Sup","\\u22D2":"Cap","\\u22D3":"Cup","\\u22D4":"fork","\\u22D5":"epar","\\u22D6":"ltdot","\\u22D7":"gtdot","\\u22D8":"Ll","\\u22D8\\u0338":"nLl","\\u22D9":"Gg","\\u22D9\\u0338":"nGg","\\u22DA\\uFE00":"lesg","\\u22DA":"leg","\\u22DB":"gel","\\u22DB\\uFE00":"gesl","\\u22DE":"cuepr","\\u22DF":"cuesc","\\u22E6":"lnsim","\\u22E7":"gnsim","\\u22E8":"prnsim","\\u22E9":"scnsim","\\u22EE":"vellip","\\u22EF":"ctdot","\\u22F0":"utdot","\\u22F1":"dtdot","\\u22F2":"disin","\\u22F3":"isinsv","\\u22F4":"isins","\\u22F5":"isindot","\\u22F5\\u0338":"notindot","\\u22F6":"notinvc","\\u22F7":"notinvb","\\u22F9":"isinE","\\u22F9\\u0338":"notinE","\\u22FA":"nisd","\\u22FB":"xnis","\\u22FC":"nis","\\u22FD":"notnivc","\\u22FE":"notnivb","\\u2305":"barwed","\\u2306":"Barwed","\\u230C":"drcrop","\\u230D":"dlcrop","\\u230E":"urcrop","\\u230F":"ulcrop","\\u2310":"bnot","\\u2312":"profline","\\u2313":"profsurf","\\u2315":"telrec","\\u2316":"target","\\u231C":"ulcorn","\\u231D":"urcorn","\\u231E":"dlcorn","\\u231F":"drcorn","\\u2322":"frown","\\u2323":"smile","\\u232D":"cylcty","\\u232E":"profalar","\\u2336":"topbot","\\u233D":"ovbar","\\u233F":"solbar","\\u237C":"angzarr","\\u23B0":"lmoust","\\u23B1":"rmoust","\\u23B4":"tbrk","\\u23B5":"bbrk","\\u23B6":"bbrktbrk","\\u23DC":"OverParenthesis","\\u23DD":"UnderParenthesis","\\u23DE":"OverBrace","\\u23DF":"UnderBrace","\\u23E2":"trpezium","\\u23E7":"elinters","\\u2423":"blank","\\u2500":"boxh","\\u2502":"boxv","\\u250C":"boxdr","\\u2510":"boxdl","\\u2514":"boxur","\\u2518":"boxul","\\u251C":"boxvr","\\u2524":"boxvl","\\u252C":"boxhd","\\u2534":"boxhu","\\u253C":"boxvh","\\u2550":"boxH","\\u2551":"boxV","\\u2552":"boxdR","\\u2553":"boxDr","\\u2554":"boxDR","\\u2555":"boxdL","\\u2556":"boxDl","\\u2557":"boxDL","\\u2558":"boxuR","\\u2559":"boxUr","\\u255A":"boxUR","\\u255B":"boxuL","\\u255C":"boxUl","\\u255D":"boxUL","\\u255E":"boxvR","\\u255F":"boxVr","\\u2560":"boxVR","\\u2561":"boxvL","\\u2562":"boxVl","\\u2563":"boxVL","\\u2564":"boxHd","\\u2565":"boxhD","\\u2566":"boxHD","\\u2567":"boxHu","\\u2568":"boxhU","\\u2569":"boxHU","\\u256A":"boxvH","\\u256B":"boxVh","\\u256C":"boxVH","\\u2580":"uhblk","\\u2584":"lhblk","\\u2588":"block","\\u2591":"blk14","\\u2592":"blk12","\\u2593":"blk34","\\u25A1":"squ","\\u25AA":"squf","\\u25AB":"EmptyVerySmallSquare","\\u25AD":"rect","\\u25AE":"marker","\\u25B1":"fltns","\\u25B3":"xutri","\\u25B4":"utrif","\\u25B5":"utri","\\u25B8":"rtrif","\\u25B9":"rtri","\\u25BD":"xdtri","\\u25BE":"dtrif","\\u25BF":"dtri","\\u25C2":"ltrif","\\u25C3":"ltri","\\u25CA":"loz","\\u25CB":"cir","\\u25EC":"tridot","\\u25EF":"xcirc","\\u25F8":"ultri","\\u25F9":"urtri","\\u25FA":"lltri","\\u25FB":"EmptySmallSquare","\\u25FC":"FilledSmallSquare","\\u2605":"starf","\\u2606":"star","\\u260E":"phone","\\u2640":"female","\\u2642":"male","\\u2660":"spades","\\u2663":"clubs","\\u2665":"hearts","\\u2666":"diams","\\u266A":"sung","\\u2713":"check","\\u2717":"cross","\\u2720":"malt","\\u2736":"sext","\\u2758":"VerticalSeparator","\\u27C8":"bsolhsub","\\u27C9":"suphsol","\\u27F5":"xlarr","\\u27F6":"xrarr","\\u27F7":"xharr","\\u27F8":"xlArr","\\u27F9":"xrArr","\\u27FA":"xhArr","\\u27FC":"xmap","\\u27FF":"dzigrarr","\\u2902":"nvlArr","\\u2903":"nvrArr","\\u2904":"nvHarr","\\u2905":"Map","\\u290C":"lbarr","\\u290D":"rbarr","\\u290E":"lBarr","\\u290F":"rBarr","\\u2910":"RBarr","\\u2911":"DDotrahd","\\u2912":"UpArrowBar","\\u2913":"DownArrowBar","\\u2916":"Rarrtl","\\u2919":"latail","\\u291A":"ratail","\\u291B":"lAtail","\\u291C":"rAtail","\\u291D":"larrfs","\\u291E":"rarrfs","\\u291F":"larrbfs","\\u2920":"rarrbfs","\\u2923":"nwarhk","\\u2924":"nearhk","\\u2925":"searhk","\\u2926":"swarhk","\\u2927":"nwnear","\\u2928":"toea","\\u2929":"tosa","\\u292A":"swnwar","\\u2933":"rarrc","\\u2933\\u0338":"nrarrc","\\u2935":"cudarrr","\\u2936":"ldca","\\u2937":"rdca","\\u2938":"cudarrl","\\u2939":"larrpl","\\u293C":"curarrm","\\u293D":"cularrp","\\u2945":"rarrpl","\\u2948":"harrcir","\\u2949":"Uarrocir","\\u294A":"lurdshar","\\u294B":"ldrushar","\\u294E":"LeftRightVector","\\u294F":"RightUpDownVector","\\u2950":"DownLeftRightVector","\\u2951":"LeftUpDownVector","\\u2952":"LeftVectorBar","\\u2953":"RightVectorBar","\\u2954":"RightUpVectorBar","\\u2955":"RightDownVectorBar","\\u2956":"DownLeftVectorBar","\\u2957":"DownRightVectorBar","\\u2958":"LeftUpVectorBar","\\u2959":"LeftDownVectorBar","\\u295A":"LeftTeeVector","\\u295B":"RightTeeVector","\\u295C":"RightUpTeeVector","\\u295D":"RightDownTeeVector","\\u295E":"DownLeftTeeVector","\\u295F":"DownRightTeeVector","\\u2960":"LeftUpTeeVector","\\u2961":"LeftDownTeeVector","\\u2962":"lHar","\\u2963":"uHar","\\u2964":"rHar","\\u2965":"dHar","\\u2966":"luruhar","\\u2967":"ldrdhar","\\u2968":"ruluhar","\\u2969":"rdldhar","\\u296A":"lharul","\\u296B":"llhard","\\u296C":"rharul","\\u296D":"lrhard","\\u296E":"udhar","\\u296F":"duhar","\\u2970":"RoundImplies","\\u2971":"erarr","\\u2972":"simrarr","\\u2973":"larrsim","\\u2974":"rarrsim","\\u2975":"rarrap","\\u2976":"ltlarr","\\u2978":"gtrarr","\\u2979":"subrarr","\\u297B":"suplarr","\\u297C":"lfisht","\\u297D":"rfisht","\\u297E":"ufisht","\\u297F":"dfisht","\\u299A":"vzigzag","\\u299C":"vangrt","\\u299D":"angrtvbd","\\u29A4":"ange","\\u29A5":"range","\\u29A6":"dwangle","\\u29A7":"uwangle","\\u29A8":"angmsdaa","\\u29A9":"angmsdab","\\u29AA":"angmsdac","\\u29AB":"angmsdad","\\u29AC":"angmsdae","\\u29AD":"angmsdaf","\\u29AE":"angmsdag","\\u29AF":"angmsdah","\\u29B0":"bemptyv","\\u29B1":"demptyv","\\u29B2":"cemptyv","\\u29B3":"raemptyv","\\u29B4":"laemptyv","\\u29B5":"ohbar","\\u29B6":"omid","\\u29B7":"opar","\\u29B9":"operp","\\u29BB":"olcross","\\u29BC":"odsold","\\u29BE":"olcir","\\u29BF":"ofcir","\\u29C0":"olt","\\u29C1":"ogt","\\u29C2":"cirscir","\\u29C3":"cirE","\\u29C4":"solb","\\u29C5":"bsolb","\\u29C9":"boxbox","\\u29CD":"trisb","\\u29CE":"rtriltri","\\u29CF":"LeftTriangleBar","\\u29CF\\u0338":"NotLeftTriangleBar","\\u29D0":"RightTriangleBar","\\u29D0\\u0338":"NotRightTriangleBar","\\u29DC":"iinfin","\\u29DD":"infintie","\\u29DE":"nvinfin","\\u29E3":"eparsl","\\u29E4":"smeparsl","\\u29E5":"eqvparsl","\\u29EB":"lozf","\\u29F4":"RuleDelayed","\\u29F6":"dsol","\\u2A00":"xodot","\\u2A01":"xoplus","\\u2A02":"xotime","\\u2A04":"xuplus","\\u2A06":"xsqcup","\\u2A0D":"fpartint","\\u2A10":"cirfnint","\\u2A11":"awint","\\u2A12":"rppolint","\\u2A13":"scpolint","\\u2A14":"npolint","\\u2A15":"pointint","\\u2A16":"quatint","\\u2A17":"intlarhk","\\u2A22":"pluscir","\\u2A23":"plusacir","\\u2A24":"simplus","\\u2A25":"plusdu","\\u2A26":"plussim","\\u2A27":"plustwo","\\u2A29":"mcomma","\\u2A2A":"minusdu","\\u2A2D":"loplus","\\u2A2E":"roplus","\\u2A2F":"Cross","\\u2A30":"timesd","\\u2A31":"timesbar","\\u2A33":"smashp","\\u2A34":"lotimes","\\u2A35":"rotimes","\\u2A36":"otimesas","\\u2A37":"Otimes","\\u2A38":"odiv","\\u2A39":"triplus","\\u2A3A":"triminus","\\u2A3B":"tritime","\\u2A3C":"iprod","\\u2A3F":"amalg","\\u2A40":"capdot","\\u2A42":"ncup","\\u2A43":"ncap","\\u2A44":"capand","\\u2A45":"cupor","\\u2A46":"cupcap","\\u2A47":"capcup","\\u2A48":"cupbrcap","\\u2A49":"capbrcup","\\u2A4A":"cupcup","\\u2A4B":"capcap","\\u2A4C":"ccups","\\u2A4D":"ccaps","\\u2A50":"ccupssm","\\u2A53":"And","\\u2A54":"Or","\\u2A55":"andand","\\u2A56":"oror","\\u2A57":"orslope","\\u2A58":"andslope","\\u2A5A":"andv","\\u2A5B":"orv","\\u2A5C":"andd","\\u2A5D":"ord","\\u2A5F":"wedbar","\\u2A66":"sdote","\\u2A6A":"simdot","\\u2A6D":"congdot","\\u2A6D\\u0338":"ncongdot","\\u2A6E":"easter","\\u2A6F":"apacir","\\u2A70":"apE","\\u2A70\\u0338":"napE","\\u2A71":"eplus","\\u2A72":"pluse","\\u2A73":"Esim","\\u2A77":"eDDot","\\u2A78":"equivDD","\\u2A79":"ltcir","\\u2A7A":"gtcir","\\u2A7B":"ltquest","\\u2A7C":"gtquest","\\u2A7D":"les","\\u2A7D\\u0338":"nles","\\u2A7E":"ges","\\u2A7E\\u0338":"nges","\\u2A7F":"lesdot","\\u2A80":"gesdot","\\u2A81":"lesdoto","\\u2A82":"gesdoto","\\u2A83":"lesdotor","\\u2A84":"gesdotol","\\u2A85":"lap","\\u2A86":"gap","\\u2A87":"lne","\\u2A88":"gne","\\u2A89":"lnap","\\u2A8A":"gnap","\\u2A8B":"lEg","\\u2A8C":"gEl","\\u2A8D":"lsime","\\u2A8E":"gsime","\\u2A8F":"lsimg","\\u2A90":"gsiml","\\u2A91":"lgE","\\u2A92":"glE","\\u2A93":"lesges","\\u2A94":"gesles","\\u2A95":"els","\\u2A96":"egs","\\u2A97":"elsdot","\\u2A98":"egsdot","\\u2A99":"el","\\u2A9A":"eg","\\u2A9D":"siml","\\u2A9E":"simg","\\u2A9F":"simlE","\\u2AA0":"simgE","\\u2AA1":"LessLess","\\u2AA1\\u0338":"NotNestedLessLess","\\u2AA2":"GreaterGreater","\\u2AA2\\u0338":"NotNestedGreaterGreater","\\u2AA4":"glj","\\u2AA5":"gla","\\u2AA6":"ltcc","\\u2AA7":"gtcc","\\u2AA8":"lescc","\\u2AA9":"gescc","\\u2AAA":"smt","\\u2AAB":"lat","\\u2AAC":"smte","\\u2AAC\\uFE00":"smtes","\\u2AAD":"late","\\u2AAD\\uFE00":"lates","\\u2AAE":"bumpE","\\u2AAF":"pre","\\u2AAF\\u0338":"npre","\\u2AB0":"sce","\\u2AB0\\u0338":"nsce","\\u2AB3":"prE","\\u2AB4":"scE","\\u2AB5":"prnE","\\u2AB6":"scnE","\\u2AB7":"prap","\\u2AB8":"scap","\\u2AB9":"prnap","\\u2ABA":"scnap","\\u2ABB":"Pr","\\u2ABC":"Sc","\\u2ABD":"subdot","\\u2ABE":"supdot","\\u2ABF":"subplus","\\u2AC0":"supplus","\\u2AC1":"submult","\\u2AC2":"supmult","\\u2AC3":"subedot","\\u2AC4":"supedot","\\u2AC5":"subE","\\u2AC5\\u0338":"nsubE","\\u2AC6":"supE","\\u2AC6\\u0338":"nsupE","\\u2AC7":"subsim","\\u2AC8":"supsim","\\u2ACB\\uFE00":"vsubnE","\\u2ACB":"subnE","\\u2ACC\\uFE00":"vsupnE","\\u2ACC":"supnE","\\u2ACF":"csub","\\u2AD0":"csup","\\u2AD1":"csube","\\u2AD2":"csupe","\\u2AD3":"subsup","\\u2AD4":"supsub","\\u2AD5":"subsub","\\u2AD6":"supsup","\\u2AD7":"suphsub","\\u2AD8":"supdsub","\\u2AD9":"forkv","\\u2ADA":"topfork","\\u2ADB":"mlcp","\\u2AE4":"Dashv","\\u2AE6":"Vdashl","\\u2AE7":"Barv","\\u2AE8":"vBar","\\u2AE9":"vBarv","\\u2AEB":"Vbar","\\u2AEC":"Not","\\u2AED":"bNot","\\u2AEE":"rnmid","\\u2AEF":"cirmid","\\u2AF0":"midcir","\\u2AF1":"topcir","\\u2AF2":"nhpar","\\u2AF3":"parsim","\\u2AFD":"parsl","\\u2AFD\\u20E5":"nparsl","\\u266D":"flat","\\u266E":"natur","\\u266F":"sharp","\\xA4":"curren","\\xA2":"cent",$:"dollar","\\xA3":"pound","\\xA5":"yen","\\u20AC":"euro","\\xB9":"sup1","\\xBD":"half","\\u2153":"frac13","\\xBC":"frac14","\\u2155":"frac15","\\u2159":"frac16","\\u215B":"frac18","\\xB2":"sup2","\\u2154":"frac23","\\u2156":"frac25","\\xB3":"sup3","\\xBE":"frac34","\\u2157":"frac35","\\u215C":"frac38","\\u2158":"frac45","\\u215A":"frac56","\\u215D":"frac58","\\u215E":"frac78","\\u{1D4B6}":"ascr","\\u{1D552}":"aopf","\\u{1D51E}":"afr","\\u{1D538}":"Aopf","\\u{1D504}":"Afr","\\u{1D49C}":"Ascr",\\u00AA:"ordf",\\u00E1:"aacute",\\u00C1:"Aacute",\\u00E0:"agrave",\\u00C0:"Agrave",\\u0103:"abreve",\\u0102:"Abreve",\\u00E2:"acirc",\\u00C2:"Acirc",\\u00E5:"aring",\\u00C5:"angst",\\u00E4:"auml",\\u00C4:"Auml",\\u00E3:"atilde",\\u00C3:"Atilde",\\u0105:"aogon",\\u0104:"Aogon",\\u0101:"amacr",\\u0100:"Amacr",\\u00E6:"aelig",\\u00C6:"AElig","\\u{1D4B7}":"bscr","\\u{1D553}":"bopf","\\u{1D51F}":"bfr","\\u{1D539}":"Bopf",\\u212C:"Bscr","\\u{1D505}":"Bfr","\\u{1D520}":"cfr","\\u{1D4B8}":"cscr","\\u{1D554}":"copf",\\u212D:"Cfr","\\u{1D49E}":"Cscr",\\u2102:"Copf",\\u0107:"cacute",\\u0106:"Cacute",\\u0109:"ccirc",\\u0108:"Ccirc",\\u010D:"ccaron",\\u010C:"Ccaron",\\u010B:"cdot",\\u010A:"Cdot",\\u00E7:"ccedil",\\u00C7:"Ccedil","\\u2105":"incare","\\u{1D521}":"dfr","\\u2146":"dd","\\u{1D555}":"dopf","\\u{1D4B9}":"dscr","\\u{1D49F}":"Dscr","\\u{1D507}":"Dfr","\\u2145":"DD","\\u{1D53B}":"Dopf",\\u010F:"dcaron",\\u010E:"Dcaron",\\u0111:"dstrok",\\u0110:"Dstrok",\\u00F0:"eth",\\u00D0:"ETH","\\u2147":"ee",\\u212F:"escr","\\u{1D522}":"efr","\\u{1D556}":"eopf",\\u2130:"Escr","\\u{1D508}":"Efr","\\u{1D53C}":"Eopf",\\u00E9:"eacute",\\u00C9:"Eacute",\\u00E8:"egrave",\\u00C8:"Egrave",\\u00EA:"ecirc",\\u00CA:"Ecirc",\\u011B:"ecaron",\\u011A:"Ecaron",\\u00EB:"euml",\\u00CB:"Euml",\\u0117:"edot",\\u0116:"Edot",\\u0119:"eogon",\\u0118:"Eogon",\\u0113:"emacr",\\u0112:"Emacr","\\u{1D523}":"ffr","\\u{1D557}":"fopf","\\u{1D4BB}":"fscr","\\u{1D509}":"Ffr","\\u{1D53D}":"Fopf",\\u2131:"Fscr",\\uFB00:"fflig",\\uFB03:"ffilig",\\uFB04:"ffllig",\\uFB01:"filig",fj:"fjlig",\\uFB02:"fllig",\\u0192:"fnof",\\u210A:"gscr","\\u{1D558}":"gopf","\\u{1D524}":"gfr","\\u{1D4A2}":"Gscr","\\u{1D53E}":"Gopf","\\u{1D50A}":"Gfr",\\u01F5:"gacute",\\u011F:"gbreve",\\u011E:"Gbreve",\\u011D:"gcirc",\\u011C:"Gcirc",\\u0121:"gdot",\\u0120:"Gdot",\\u0122:"Gcedil","\\u{1D525}":"hfr",\\u210E:"planckh","\\u{1D4BD}":"hscr","\\u{1D559}":"hopf",\\u210B:"Hscr",\\u210C:"Hfr",\\u210D:"Hopf",\\u0125:"hcirc",\\u0124:"Hcirc",\\u210F:"hbar",\\u0127:"hstrok",\\u0126:"Hstrok","\\u{1D55A}":"iopf","\\u{1D526}":"ifr","\\u{1D4BE}":"iscr","\\u2148":"ii","\\u{1D540}":"Iopf",\\u2110:"Iscr",\\u2111:"Im",\\u00ED:"iacute",\\u00CD:"Iacute",\\u00EC:"igrave",\\u00CC:"Igrave",\\u00EE:"icirc",\\u00CE:"Icirc",\\u00EF:"iuml",\\u00CF:"Iuml",\\u0129:"itilde",\\u0128:"Itilde",\\u0130:"Idot",\\u012F:"iogon",\\u012E:"Iogon",\\u012B:"imacr",\\u012A:"Imacr",\\u0133:"ijlig",\\u0132:"IJlig",\\u0131:"imath","\\u{1D4BF}":"jscr","\\u{1D55B}":"jopf","\\u{1D527}":"jfr","\\u{1D4A5}":"Jscr","\\u{1D50D}":"Jfr","\\u{1D541}":"Jopf",\\u0135:"jcirc",\\u0134:"Jcirc","\\u0237":"jmath","\\u{1D55C}":"kopf","\\u{1D4C0}":"kscr","\\u{1D528}":"kfr","\\u{1D4A6}":"Kscr","\\u{1D542}":"Kopf","\\u{1D50E}":"Kfr",\\u0137:"kcedil",\\u0136:"Kcedil","\\u{1D529}":"lfr","\\u{1D4C1}":"lscr",\\u2113:"ell","\\u{1D55D}":"lopf",\\u2112:"Lscr","\\u{1D50F}":"Lfr","\\u{1D543}":"Lopf",\\u013A:"lacute",\\u0139:"Lacute",\\u013E:"lcaron",\\u013D:"Lcaron",\\u013C:"lcedil",\\u013B:"Lcedil",\\u0142:"lstrok",\\u0141:"Lstrok",\\u0140:"lmidot",\\u013F:"Lmidot","\\u{1D52A}":"mfr","\\u{1D55E}":"mopf","\\u{1D4C2}":"mscr","\\u{1D510}":"Mfr","\\u{1D544}":"Mopf",\\u2133:"Mscr","\\u{1D52B}":"nfr","\\u{1D55F}":"nopf","\\u{1D4C3}":"nscr",\\u2115:"Nopf","\\u{1D4A9}":"Nscr","\\u{1D511}":"Nfr",\\u0144:"nacute",\\u0143:"Nacute",\\u0148:"ncaron",\\u0147:"Ncaron",\\u00F1:"ntilde",\\u00D1:"Ntilde",\\u0146:"ncedil",\\u0145:"Ncedil","\\u2116":"numero",\\u014B:"eng",\\u014A:"ENG","\\u{1D560}":"oopf","\\u{1D52C}":"ofr",\\u2134:"oscr","\\u{1D4AA}":"Oscr","\\u{1D512}":"Ofr","\\u{1D546}":"Oopf",\\u00BA:"ordm",\\u00F3:"oacute",\\u00D3:"Oacute",\\u00F2:"ograve",\\u00D2:"Ograve",\\u00F4:"ocirc",\\u00D4:"Ocirc",\\u00F6:"ouml",\\u00D6:"Ouml",\\u0151:"odblac",\\u0150:"Odblac",\\u00F5:"otilde",\\u00D5:"Otilde",\\u00F8:"oslash",\\u00D8:"Oslash",\\u014D:"omacr",\\u014C:"Omacr",\\u0153:"oelig",\\u0152:"OElig","\\u{1D52D}":"pfr","\\u{1D4C5}":"pscr","\\u{1D561}":"popf",\\u2119:"Popf","\\u{1D513}":"Pfr","\\u{1D4AB}":"Pscr","\\u{1D562}":"qopf","\\u{1D52E}":"qfr","\\u{1D4C6}":"qscr","\\u{1D4AC}":"Qscr","\\u{1D514}":"Qfr",\\u211A:"Qopf",\\u0138:"kgreen","\\u{1D52F}":"rfr","\\u{1D563}":"ropf","\\u{1D4C7}":"rscr",\\u211B:"Rscr",\\u211C:"Re",\\u211D:"Ropf",\\u0155:"racute",\\u0154:"Racute",\\u0159:"rcaron",\\u0158:"Rcaron",\\u0157:"rcedil",\\u0156:"Rcedil","\\u{1D564}":"sopf","\\u{1D4C8}":"sscr","\\u{1D530}":"sfr","\\u{1D54A}":"Sopf","\\u{1D516}":"Sfr","\\u{1D4AE}":"Sscr","\\u24C8":"oS",\\u015B:"sacute",\\u015A:"Sacute",\\u015D:"scirc",\\u015C:"Scirc",\\u0161:"scaron",\\u0160:"Scaron",\\u015F:"scedil",\\u015E:"Scedil",\\u00DF:"szlig","\\u{1D531}":"tfr","\\u{1D4C9}":"tscr","\\u{1D565}":"topf","\\u{1D4AF}":"Tscr","\\u{1D517}":"Tfr","\\u{1D54B}":"Topf",\\u0165:"tcaron",\\u0164:"Tcaron",\\u0163:"tcedil",\\u0162:"Tcedil","\\u2122":"trade",\\u0167:"tstrok",\\u0166:"Tstrok","\\u{1D4CA}":"uscr","\\u{1D566}":"uopf","\\u{1D532}":"ufr","\\u{1D54C}":"Uopf","\\u{1D518}":"Ufr","\\u{1D4B0}":"Uscr",\\u00FA:"uacute",\\u00DA:"Uacute",\\u00F9:"ugrave",\\u00D9:"Ugrave",\\u016D:"ubreve",\\u016C:"Ubreve",\\u00FB:"ucirc",\\u00DB:"Ucirc",\\u016F:"uring",\\u016E:"Uring",\\u00FC:"uuml",\\u00DC:"Uuml",\\u0171:"udblac",\\u0170:"Udblac",\\u0169:"utilde",\\u0168:"Utilde",\\u0173:"uogon",\\u0172:"Uogon",\\u016B:"umacr",\\u016A:"Umacr","\\u{1D533}":"vfr","\\u{1D567}":"vopf","\\u{1D4CB}":"vscr","\\u{1D519}":"Vfr","\\u{1D54D}":"Vopf","\\u{1D4B1}":"Vscr","\\u{1D568}":"wopf","\\u{1D4CC}":"wscr","\\u{1D534}":"wfr","\\u{1D4B2}":"Wscr","\\u{1D54E}":"Wopf","\\u{1D51A}":"Wfr",\\u0175:"wcirc",\\u0174:"Wcirc","\\u{1D535}":"xfr","\\u{1D4CD}":"xscr","\\u{1D569}":"xopf","\\u{1D54F}":"Xopf","\\u{1D51B}":"Xfr","\\u{1D4B3}":"Xscr","\\u{1D536}":"yfr","\\u{1D4CE}":"yscr","\\u{1D56A}":"yopf","\\u{1D4B4}":"Yscr","\\u{1D51C}":"Yfr","\\u{1D550}":"Yopf",\\u00FD:"yacute",\\u00DD:"Yacute",\\u0177:"ycirc",\\u0176:"Ycirc",\\u00FF:"yuml",\\u0178:"Yuml","\\u{1D4CF}":"zscr","\\u{1D537}":"zfr","\\u{1D56B}":"zopf",\\u2128:"Zfr",\\u2124:"Zopf","\\u{1D4B5}":"Zscr",\\u017A:"zacute",\\u0179:"Zacute",\\u017E:"zcaron",\\u017D:"Zcaron",\\u017C:"zdot",\\u017B:"Zdot",\\u01B5:"imped",\\u00FE:"thorn",\\u00DE:"THORN",\\u0149:"napos",\\u03B1:"alpha",\\u0391:"Alpha",\\u03B2:"beta",\\u0392:"Beta",\\u03B3:"gamma",\\u0393:"Gamma",\\u03B4:"delta",\\u0394:"Delta",\\u03B5:"epsi","\\u03F5":"epsiv",\\u0395:"Epsilon",\\u03DD:"gammad",\\u03DC:"Gammad",\\u03B6:"zeta",\\u0396:"Zeta",\\u03B7:"eta",\\u0397:"Eta",\\u03B8:"theta",\\u03D1:"thetav",\\u0398:"Theta",\\u03B9:"iota",\\u0399:"Iota",\\u03BA:"kappa",\\u03F0:"kappav",\\u039A:"Kappa",\\u03BB:"lambda",\\u039B:"Lambda",\\u03BC:"mu",\\u00B5:"micro",\\u039C:"Mu",\\u03BD:"nu",\\u039D:"Nu",\\u03BE:"xi",\\u039E:"Xi",\\u03BF:"omicron",\\u039F:"Omicron",\\u03C0:"pi",\\u03D6:"piv",\\u03A0:"Pi",\\u03C1:"rho",\\u03F1:"rhov",\\u03A1:"Rho",\\u03C3:"sigma",\\u03A3:"Sigma",\\u03C2:"sigmaf",\\u03C4:"tau",\\u03A4:"Tau",\\u03C5:"upsi",\\u03A5:"Upsilon",\\u03D2:"Upsi",\\u03C6:"phi",\\u03D5:"phiv",\\u03A6:"Phi",\\u03C7:"chi",\\u03A7:"Chi",\\u03C8:"psi",\\u03A8:"Psi",\\u03C9:"omega",\\u03A9:"ohm",\\u0430:"acy",\\u0410:"Acy",\\u0431:"bcy",\\u0411:"Bcy",\\u0432:"vcy",\\u0412:"Vcy",\\u0433:"gcy",\\u0413:"Gcy",\\u0453:"gjcy",\\u0403:"GJcy",\\u0434:"dcy",\\u0414:"Dcy",\\u0452:"djcy",\\u0402:"DJcy",\\u0435:"iecy",\\u0415:"IEcy",\\u0451:"iocy",\\u0401:"IOcy",\\u0454:"jukcy",\\u0404:"Jukcy",\\u0436:"zhcy",\\u0416:"ZHcy",\\u0437:"zcy",\\u0417:"Zcy",\\u0455:"dscy",\\u0405:"DScy",\\u0438:"icy",\\u0418:"Icy",\\u0456:"iukcy",\\u0406:"Iukcy",\\u0457:"yicy",\\u0407:"YIcy",\\u0439:"jcy",\\u0419:"Jcy",\\u0458:"jsercy",\\u0408:"Jsercy",\\u043A:"kcy",\\u041A:"Kcy",\\u045C:"kjcy",\\u040C:"KJcy",\\u043B:"lcy",\\u041B:"Lcy",\\u0459:"ljcy",\\u0409:"LJcy",\\u043C:"mcy",\\u041C:"Mcy",\\u043D:"ncy",\\u041D:"Ncy",\\u045A:"njcy",\\u040A:"NJcy",\\u043E:"ocy",\\u041E:"Ocy",\\u043F:"pcy",\\u041F:"Pcy",\\u0440:"rcy",\\u0420:"Rcy",\\u0441:"scy",\\u0421:"Scy",\\u0442:"tcy",\\u0422:"Tcy",\\u045B:"tshcy",\\u040B:"TSHcy",\\u0443:"ucy",\\u0423:"Ucy",\\u045E:"ubrcy",\\u040E:"Ubrcy",\\u0444:"fcy",\\u0424:"Fcy",\\u0445:"khcy",\\u0425:"KHcy",\\u0446:"tscy",\\u0426:"TScy",\\u0447:"chcy",\\u0427:"CHcy",\\u045F:"dzcy",\\u040F:"DZcy",\\u0448:"shcy",\\u0428:"SHcy",\\u0449:"shchcy",\\u0429:"SHCHcy",\\u044A:"hardcy",\\u042A:"HARDcy",\\u044B:"ycy",\\u042B:"Ycy",\\u044C:"softcy",\\u042C:"SOFTcy",\\u044D:"ecy",\\u042D:"Ecy",\\u044E:"yucy",\\u042E:"YUcy",\\u044F:"yacy",\\u042F:"YAcy",\\u2135:"aleph",\\u2136:"beth",\\u2137:"gimel",\\u2138:"daleth"},d=/["&\'<>`]/g,p={\'"\':""","&":"&","\'":"'","<":"<",">":">","`":"`"},l=/&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/,b=/[\\0-\\x08\\x0B\\x0E-\\x1F\\x7F-\\x9F\\uFDD0-\\uFDEF\\uFFFE\\uFFFF]|[\\uD83F\\uD87F\\uD8BF\\uD8FF\\uD93F\\uD97F\\uD9BF\\uD9FF\\uDA3F\\uDA7F\\uDABF\\uDAFF\\uDB3F\\uDB7F\\uDBBF\\uDBFF][\\uDFFE\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]/,f=/&(CounterClockwiseContourIntegral|DoubleLongLeftRightArrow|ClockwiseContourIntegral|NotNestedGreaterGreater|NotSquareSupersetEqual|DiacriticalDoubleAcute|NotRightTriangleEqual|NotSucceedsSlantEqual|NotPrecedesSlantEqual|CloseCurlyDoubleQuote|NegativeVeryThinSpace|DoubleContourIntegral|FilledVerySmallSquare|CapitalDifferentialD|OpenCurlyDoubleQuote|EmptyVerySmallSquare|NestedGreaterGreater|DoubleLongRightArrow|NotLeftTriangleEqual|NotGreaterSlantEqual|ReverseUpEquilibrium|DoubleLeftRightArrow|NotSquareSubsetEqual|NotDoubleVerticalBar|RightArrowLeftArrow|NotGreaterFullEqual|NotRightTriangleBar|SquareSupersetEqual|DownLeftRightVector|DoubleLongLeftArrow|leftrightsquigarrow|LeftArrowRightArrow|NegativeMediumSpace|blacktriangleright|RightDownVectorBar|PrecedesSlantEqual|RightDoubleBracket|SucceedsSlantEqual|NotLeftTriangleBar|RightTriangleEqual|SquareIntersection|RightDownTeeVector|ReverseEquilibrium|NegativeThickSpace|longleftrightarrow|Longleftrightarrow|LongLeftRightArrow|DownRightTeeVector|DownRightVectorBar|GreaterSlantEqual|SquareSubsetEqual|LeftDownVectorBar|LeftDoubleBracket|VerticalSeparator|rightleftharpoons|NotGreaterGreater|NotSquareSuperset|blacktriangleleft|blacktriangledown|NegativeThinSpace|LeftDownTeeVector|NotLessSlantEqual|leftrightharpoons|DoubleUpDownArrow|DoubleVerticalBar|LeftTriangleEqual|FilledSmallSquare|twoheadrightarrow|NotNestedLessLess|DownLeftTeeVector|DownLeftVectorBar|RightAngleBracket|NotTildeFullEqual|NotReverseElement|RightUpDownVector|DiacriticalTilde|NotSucceedsTilde|circlearrowright|NotPrecedesEqual|rightharpoondown|DoubleRightArrow|NotSucceedsEqual|NonBreakingSpace|NotRightTriangle|LessEqualGreater|RightUpTeeVector|LeftAngleBracket|GreaterFullEqual|DownArrowUpArrow|RightUpVectorBar|twoheadleftarrow|GreaterEqualLess|downharpoonright|RightTriangleBar|ntrianglerighteq|NotSupersetEqual|LeftUpDownVector|DiacriticalAcute|rightrightarrows|vartriangleright|UpArrowDownArrow|DiacriticalGrave|UnderParenthesis|EmptySmallSquare|LeftUpVectorBar|leftrightarrows|DownRightVector|downharpoonleft|trianglerighteq|ShortRightArrow|OverParenthesis|DoubleLeftArrow|DoubleDownArrow|NotSquareSubset|bigtriangledown|ntrianglelefteq|UpperRightArrow|curvearrowright|vartriangleleft|NotLeftTriangle|nleftrightarrow|LowerRightArrow|NotHumpDownHump|NotGreaterTilde|rightthreetimes|LeftUpTeeVector|NotGreaterEqual|straightepsilon|LeftTriangleBar|rightsquigarrow|ContourIntegral|rightleftarrows|CloseCurlyQuote|RightDownVector|LeftRightVector|nLeftrightarrow|leftharpoondown|circlearrowleft|SquareSuperset|OpenCurlyQuote|hookrightarrow|HorizontalLine|DiacriticalDot|NotLessGreater|ntriangleright|DoubleRightTee|InvisibleComma|InvisibleTimes|LowerLeftArrow|DownLeftVector|NotSubsetEqual|curvearrowleft|trianglelefteq|NotVerticalBar|TildeFullEqual|downdownarrows|NotGreaterLess|RightTeeVector|ZeroWidthSpace|looparrowright|LongRightArrow|doublebarwedge|ShortLeftArrow|ShortDownArrow|RightVectorBar|GreaterGreater|ReverseElement|rightharpoonup|LessSlantEqual|leftthreetimes|upharpoonright|rightarrowtail|LeftDownVector|Longrightarrow|NestedLessLess|UpperLeftArrow|nshortparallel|leftleftarrows|leftrightarrow|Leftrightarrow|LeftRightArrow|longrightarrow|upharpoonleft|RightArrowBar|ApplyFunction|LeftTeeVector|leftarrowtail|NotEqualTilde|varsubsetneqq|varsupsetneqq|RightTeeArrow|SucceedsEqual|SucceedsTilde|LeftVectorBar|SupersetEqual|hookleftarrow|DifferentialD|VerticalTilde|VeryThinSpace|blacktriangle|bigtriangleup|LessFullEqual|divideontimes|leftharpoonup|UpEquilibrium|ntriangleleft|RightTriangle|measuredangle|shortparallel|longleftarrow|Longleftarrow|LongLeftArrow|DoubleLeftTee|Poincareplane|PrecedesEqual|triangleright|DoubleUpArrow|RightUpVector|fallingdotseq|looparrowleft|PrecedesTilde|NotTildeEqual|NotTildeTilde|smallsetminus|Proportional|triangleleft|triangledown|UnderBracket|NotHumpEqual|exponentiale|ExponentialE|NotLessTilde|HilbertSpace|RightCeiling|blacklozenge|varsupsetneq|HumpDownHump|GreaterEqual|VerticalLine|LeftTeeArrow|NotLessEqual|DownTeeArrow|LeftTriangle|varsubsetneq|Intersection|NotCongruent|DownArrowBar|LeftUpVector|LeftArrowBar|risingdotseq|GreaterTilde|RoundImplies|SquareSubset|ShortUpArrow|NotSuperset|quaternions|precnapprox|backepsilon|preccurlyeq|OverBracket|blacksquare|MediumSpace|VerticalBar|circledcirc|circleddash|CircleMinus|CircleTimes|LessGreater|curlyeqprec|curlyeqsucc|diamondsuit|UpDownArrow|Updownarrow|RuleDelayed|Rrightarrow|updownarrow|RightVector|nRightarrow|nrightarrow|eqslantless|LeftCeiling|Equilibrium|SmallCircle|expectation|NotSucceeds|thickapprox|GreaterLess|SquareUnion|NotPrecedes|NotLessLess|straightphi|succnapprox|succcurlyeq|SubsetEqual|sqsupseteq|Proportion|Laplacetrf|ImaginaryI|supsetneqq|NotGreater|gtreqqless|NotElement|ThickSpace|TildeEqual|TildeTilde|Fouriertrf|rmoustache|EqualTilde|eqslantgtr|UnderBrace|LeftVector|UpArrowBar|nLeftarrow|nsubseteqq|subsetneqq|nsupseteqq|nleftarrow|succapprox|lessapprox|UpTeeArrow|upuparrows|curlywedge|lesseqqgtr|varepsilon|varnothing|RightFloor|complement|CirclePlus|sqsubseteq|Lleftarrow|circledast|RightArrow|Rightarrow|rightarrow|lmoustache|Bernoullis|precapprox|mapstoleft|mapstodown|longmapsto|dotsquare|downarrow|DoubleDot|nsubseteq|supsetneq|leftarrow|nsupseteq|subsetneq|ThinSpace|ngeqslant|subseteqq|HumpEqual|NotSubset|triangleq|NotCupCap|lesseqgtr|heartsuit|TripleDot|Leftarrow|Coproduct|Congruent|varpropto|complexes|gvertneqq|LeftArrow|LessTilde|supseteqq|MinusPlus|CircleDot|nleqslant|NotExists|gtreqless|nparallel|UnionPlus|LeftFloor|checkmark|CenterDot|centerdot|Mellintrf|gtrapprox|bigotimes|OverBrace|spadesuit|therefore|pitchfork|rationals|PlusMinus|Backslash|Therefore|DownBreve|backsimeq|backprime|DownArrow|nshortmid|Downarrow|lvertneqq|eqvparsl|imagline|imagpart|infintie|integers|Integral|intercal|LessLess|Uarrocir|intlarhk|sqsupset|angmsdaf|sqsubset|llcorner|vartheta|cupbrcap|lnapprox|Superset|SuchThat|succnsim|succneqq|angmsdag|biguplus|curlyvee|trpezium|Succeeds|NotTilde|bigwedge|angmsdah|angrtvbd|triminus|cwconint|fpartint|lrcorner|smeparsl|subseteq|urcorner|lurdshar|laemptyv|DDotrahd|approxeq|ldrushar|awconint|mapstoup|backcong|shortmid|triangle|geqslant|gesdotol|timesbar|circledR|circledS|setminus|multimap|naturals|scpolint|ncongdot|RightTee|boxminus|gnapprox|boxtimes|andslope|thicksim|angmsdaa|varsigma|cirfnint|rtriltri|angmsdab|rppolint|angmsdac|barwedge|drbkarow|clubsuit|thetasym|bsolhsub|capbrcup|dzigrarr|doteqdot|DotEqual|dotminus|UnderBar|NotEqual|realpart|otimesas|ulcorner|hksearow|hkswarow|parallel|PartialD|elinters|emptyset|plusacir|bbrktbrk|angmsdad|pointint|bigoplus|angmsdae|Precedes|bigsqcup|varkappa|notindot|supseteq|precneqq|precnsim|profalar|profline|profsurf|leqslant|lesdotor|raemptyv|subplus|notnivb|notnivc|subrarr|zigrarr|vzigzag|submult|subedot|Element|between|cirscir|larrbfs|larrsim|lotimes|lbrksld|lbrkslu|lozenge|ldrdhar|dbkarow|bigcirc|epsilon|simrarr|simplus|ltquest|Epsilon|luruhar|gtquest|maltese|npolint|eqcolon|npreceq|bigodot|ddagger|gtrless|bnequiv|harrcir|ddotseq|equivDD|backsim|demptyv|nsqsube|nsqsupe|Upsilon|nsubset|upsilon|minusdu|nsucceq|swarrow|nsupset|coloneq|searrow|boxplus|napprox|natural|asympeq|alefsym|congdot|nearrow|bigstar|diamond|supplus|tritime|LeftTee|nvinfin|triplus|NewLine|nvltrie|nvrtrie|nwarrow|nexists|Diamond|ruluhar|Implies|supmult|angzarr|suplarr|suphsub|questeq|because|digamma|Because|olcross|bemptyv|omicron|Omicron|rotimes|NoBreak|intprod|angrtvb|orderof|uwangle|suphsol|lesdoto|orslope|DownTee|realine|cudarrl|rdldhar|OverBar|supedot|lessdot|supdsub|topfork|succsim|rbrkslu|rbrksld|pertenk|cudarrr|isindot|planckh|lessgtr|pluscir|gesdoto|plussim|plustwo|lesssim|cularrp|rarrsim|Cayleys|notinva|notinvb|notinvc|UpArrow|Uparrow|uparrow|NotLess|dwangle|precsim|Product|curarrm|Cconint|dotplus|rarrbfs|ccupssm|Cedilla|cemptyv|notniva|quatint|frac35|frac38|frac45|frac56|frac58|frac78|tridot|xoplus|gacute|gammad|Gammad|lfisht|lfloor|bigcup|sqsupe|gbreve|Gbreve|lharul|sqsube|sqcups|Gcedil|apacir|llhard|lmidot|Lmidot|lmoust|andand|sqcaps|approx|Abreve|spades|circeq|tprime|divide|topcir|Assign|topbot|gesdot|divonx|xuplus|timesd|gesles|atilde|solbar|SOFTcy|loplus|timesb|lowast|lowbar|dlcorn|dlcrop|softcy|dollar|lparlt|thksim|lrhard|Atilde|lsaquo|smashp|bigvee|thinsp|wreath|bkarow|lsquor|lstrok|Lstrok|lthree|ltimes|ltlarr|DotDot|simdot|ltrPar|weierp|xsqcup|angmsd|sigmav|sigmaf|zeetrf|Zcaron|zcaron|mapsto|vsupne|thetav|cirmid|marker|mcomma|Zacute|vsubnE|there4|gtlPar|vsubne|bottom|gtrarr|SHCHcy|shchcy|midast|midcir|middot|minusb|minusd|gtrdot|bowtie|sfrown|mnplus|models|colone|seswar|Colone|mstpos|searhk|gtrsim|nacute|Nacute|boxbox|telrec|hairsp|Tcedil|nbumpe|scnsim|ncaron|Ncaron|ncedil|Ncedil|hamilt|Scedil|nearhk|hardcy|HARDcy|tcedil|Tcaron|commat|nequiv|nesear|tcaron|target|hearts|nexist|varrho|scedil|Scaron|scaron|hellip|Sacute|sacute|hercon|swnwar|compfn|rtimes|rthree|rsquor|rsaquo|zacute|wedgeq|homtht|barvee|barwed|Barwed|rpargt|horbar|conint|swarhk|roplus|nltrie|hslash|hstrok|Hstrok|rmoust|Conint|bprime|hybull|hyphen|iacute|Iacute|supsup|supsub|supsim|varphi|coprod|brvbar|agrave|Supset|supset|igrave|Igrave|notinE|Agrave|iiiint|iinfin|copysr|wedbar|Verbar|vangrt|becaus|incare|verbar|inodot|bullet|drcorn|intcal|drcrop|cularr|vellip|Utilde|bumpeq|cupcap|dstrok|Dstrok|CupCap|cupcup|cupdot|eacute|Eacute|supdot|iquest|easter|ecaron|Ecaron|ecolon|isinsv|utilde|itilde|Itilde|curarr|succeq|Bumpeq|cacute|ulcrop|nparsl|Cacute|nprcue|egrave|Egrave|nrarrc|nrarrw|subsup|subsub|nrtrie|jsercy|nsccue|Jsercy|kappav|kcedil|Kcedil|subsim|ulcorn|nsimeq|egsdot|veebar|kgreen|capand|elsdot|Subset|subset|curren|aacute|lacute|Lacute|emptyv|ntilde|Ntilde|lagran|lambda|Lambda|capcap|Ugrave|langle|subdot|emsp13|numero|emsp14|nvdash|nvDash|nVdash|nVDash|ugrave|ufisht|nvHarr|larrfs|nvlArr|larrhk|larrlp|larrpl|nvrArr|Udblac|nwarhk|larrtl|nwnear|oacute|Oacute|latail|lAtail|sstarf|lbrace|odblac|Odblac|lbrack|udblac|odsold|eparsl|lcaron|Lcaron|ograve|Ograve|lcedil|Lcedil|Aacute|ssmile|ssetmn|squarf|ldquor|capcup|ominus|cylcty|rharul|eqcirc|dagger|rfloor|rfisht|Dagger|daleth|equals|origof|capdot|equest|dcaron|Dcaron|rdquor|oslash|Oslash|otilde|Otilde|otimes|Otimes|urcrop|Ubreve|ubreve|Yacute|Uacute|uacute|Rcedil|rcedil|urcorn|parsim|Rcaron|Vdashl|rcaron|Tstrok|percnt|period|permil|Exists|yacute|rbrack|rbrace|phmmat|ccaron|Ccaron|planck|ccedil|plankv|tstrok|female|plusdo|plusdu|ffilig|plusmn|ffllig|Ccedil|rAtail|dfisht|bernou|ratail|Rarrtl|rarrtl|angsph|rarrpl|rarrlp|rarrhk|xwedge|xotime|forall|ForAll|Vvdash|vsupnE|preceq|bigcap|frac12|frac13|frac14|primes|rarrfs|prnsim|frac15|Square|frac16|square|lesdot|frac18|frac23|propto|prurel|rarrap|rangle|puncsp|frac25|Racute|qprime|racute|lesges|frac34|abreve|AElig|eqsim|utdot|setmn|urtri|Equal|Uring|seArr|uring|searr|dashv|Dashv|mumap|nabla|iogon|Iogon|sdote|sdotb|scsim|napid|napos|equiv|natur|Acirc|dblac|erarr|nbump|iprod|erDot|ucirc|awint|esdot|angrt|ncong|isinE|scnap|Scirc|scirc|ndash|isins|Ubrcy|nearr|neArr|isinv|nedot|ubrcy|acute|Ycirc|iukcy|Iukcy|xutri|nesim|caret|jcirc|Jcirc|caron|twixt|ddarr|sccue|exist|jmath|sbquo|ngeqq|angst|ccaps|lceil|ngsim|UpTee|delta|Delta|rtrif|nharr|nhArr|nhpar|rtrie|jukcy|Jukcy|kappa|rsquo|Kappa|nlarr|nlArr|TSHcy|rrarr|aogon|Aogon|fflig|xrarr|tshcy|ccirc|nleqq|filig|upsih|nless|dharl|nlsim|fjlig|ropar|nltri|dharr|robrk|roarr|fllig|fltns|roang|rnmid|subnE|subne|lAarr|trisb|Ccirc|acirc|ccups|blank|VDash|forkv|Vdash|langd|cedil|blk12|blk14|laquo|strns|diams|notin|vDash|larrb|blk34|block|disin|uplus|vdash|vBarv|aelig|starf|Wedge|check|xrArr|lates|lbarr|lBarr|notni|lbbrk|bcong|frasl|lbrke|frown|vrtri|vprop|vnsup|gamma|Gamma|wedge|xodot|bdquo|srarr|doteq|ldquo|boxdl|boxdL|gcirc|Gcirc|boxDl|boxDL|boxdr|boxdR|boxDr|TRADE|trade|rlhar|boxDR|vnsub|npart|vltri|rlarr|boxhd|boxhD|nprec|gescc|nrarr|nrArr|boxHd|boxHD|boxhu|boxhU|nrtri|boxHu|clubs|boxHU|times|colon|Colon|gimel|xlArr|Tilde|nsime|tilde|nsmid|nspar|THORN|thorn|xlarr|nsube|nsubE|thkap|xhArr|comma|nsucc|boxul|boxuL|nsupe|nsupE|gneqq|gnsim|boxUl|boxUL|grave|boxur|boxuR|boxUr|boxUR|lescc|angle|bepsi|boxvh|varpi|boxvH|numsp|Theta|gsime|gsiml|theta|boxVh|boxVH|boxvl|gtcir|gtdot|boxvL|boxVl|boxVL|crarr|cross|Cross|nvsim|boxvr|nwarr|nwArr|sqsup|dtdot|Uogon|lhard|lharu|dtrif|ocirc|Ocirc|lhblk|duarr|odash|sqsub|Hacek|sqcup|llarr|duhar|oelig|OElig|ofcir|boxvR|uogon|lltri|boxVr|csube|uuarr|ohbar|csupe|ctdot|olarr|olcir|harrw|oline|sqcap|omacr|Omacr|omega|Omega|boxVR|aleph|lneqq|lnsim|loang|loarr|rharu|lobrk|hcirc|operp|oplus|rhard|Hcirc|orarr|Union|order|ecirc|Ecirc|cuepr|szlig|cuesc|breve|reals|eDDot|Breve|hoarr|lopar|utrif|rdquo|Umacr|umacr|efDot|swArr|ultri|alpha|rceil|ovbar|swarr|Wcirc|wcirc|smtes|smile|bsemi|lrarr|aring|parsl|lrhar|bsime|uhblk|lrtri|cupor|Aring|uharr|uharl|slarr|rbrke|bsolb|lsime|rbbrk|RBarr|lsimg|phone|rBarr|rbarr|icirc|lsquo|Icirc|emacr|Emacr|ratio|simne|plusb|simlE|simgE|simeq|pluse|ltcir|ltdot|empty|xharr|xdtri|iexcl|Alpha|ltrie|rarrw|pound|ltrif|xcirc|bumpe|prcue|bumpE|asymp|amacr|cuvee|Sigma|sigma|iiint|udhar|iiota|ijlig|IJlig|supnE|imacr|Imacr|prime|Prime|image|prnap|eogon|Eogon|rarrc|mdash|mDDot|cuwed|imath|supne|imped|Amacr|udarr|prsim|micro|rarrb|cwint|raquo|infin|eplus|range|rangd|Ucirc|radic|minus|amalg|veeeq|rAarr|epsiv|ycirc|quest|sharp|quot|zwnj|Qscr|race|qscr|Qopf|qopf|qint|rang|Rang|Zscr|zscr|Zopf|zopf|rarr|rArr|Rarr|Pscr|pscr|prop|prod|prnE|prec|ZHcy|zhcy|prap|Zeta|zeta|Popf|popf|Zdot|plus|zdot|Yuml|yuml|phiv|YUcy|yucy|Yscr|yscr|perp|Yopf|yopf|part|para|YIcy|Ouml|rcub|yicy|YAcy|rdca|ouml|osol|Oscr|rdsh|yacy|real|oscr|xvee|andd|rect|andv|Xscr|oror|ordm|ordf|xscr|ange|aopf|Aopf|rHar|Xopf|opar|Oopf|xopf|xnis|rhov|oopf|omid|xmap|oint|apid|apos|ogon|ascr|Ascr|odot|odiv|xcup|xcap|ocir|oast|nvlt|nvle|nvgt|nvge|nvap|Wscr|wscr|auml|ntlg|ntgl|nsup|nsub|nsim|Nscr|nscr|nsce|Wopf|ring|npre|wopf|npar|Auml|Barv|bbrk|Nopf|nopf|nmid|nLtv|beta|ropf|Ropf|Beta|beth|nles|rpar|nleq|bnot|bNot|nldr|NJcy|rscr|Rscr|Vscr|vscr|rsqb|njcy|bopf|nisd|Bopf|rtri|Vopf|nGtv|ngtr|vopf|boxh|boxH|boxv|nges|ngeq|boxV|bscr|scap|Bscr|bsim|Vert|vert|bsol|bull|bump|caps|cdot|ncup|scnE|ncap|nbsp|napE|Cdot|cent|sdot|Vbar|nang|vBar|chcy|Mscr|mscr|sect|semi|CHcy|Mopf|mopf|sext|circ|cire|mldr|mlcp|cirE|comp|shcy|SHcy|vArr|varr|cong|copf|Copf|copy|COPY|malt|male|macr|lvnE|cscr|ltri|sime|ltcc|simg|Cscr|siml|csub|Uuml|lsqb|lsim|uuml|csup|Lscr|lscr|utri|smid|lpar|cups|smte|lozf|darr|Lopf|Uscr|solb|lopf|sopf|Sopf|lneq|uscr|spar|dArr|lnap|Darr|dash|Sqrt|LJcy|ljcy|lHar|dHar|Upsi|upsi|diam|lesg|djcy|DJcy|leqq|dopf|Dopf|dscr|Dscr|dscy|ldsh|ldca|squf|DScy|sscr|Sscr|dsol|lcub|late|star|Star|Uopf|Larr|lArr|larr|uopf|dtri|dzcy|sube|subE|Lang|lang|Kscr|kscr|Kopf|kopf|KJcy|kjcy|KHcy|khcy|DZcy|ecir|edot|eDot|Jscr|jscr|succ|Jopf|jopf|Edot|uHar|emsp|ensp|Iuml|iuml|eopf|isin|Iscr|iscr|Eopf|epar|sung|epsi|escr|sup1|sup2|sup3|Iota|iota|supe|supE|Iopf|iopf|IOcy|iocy|Escr|esim|Esim|imof|Uarr|QUOT|uArr|uarr|euml|IEcy|iecy|Idot|Euml|euro|excl|Hscr|hscr|Hopf|hopf|TScy|tscy|Tscr|hbar|tscr|flat|tbrk|fnof|hArr|harr|half|fopf|Fopf|tdot|gvnE|fork|trie|gtcc|fscr|Fscr|gdot|gsim|Gscr|gscr|Gopf|gopf|gneq|Gdot|tosa|gnap|Topf|topf|geqq|toea|GJcy|gjcy|tint|gesl|mid|Sfr|ggg|top|ges|gla|glE|glj|geq|gne|gEl|gel|gnE|Gcy|gcy|gap|Tfr|tfr|Tcy|tcy|Hat|Tau|Ffr|tau|Tab|hfr|Hfr|ffr|Fcy|fcy|icy|Icy|iff|ETH|eth|ifr|Ifr|Eta|eta|int|Int|Sup|sup|ucy|Ucy|Sum|sum|jcy|ENG|ufr|Ufr|eng|Jcy|jfr|els|ell|egs|Efr|efr|Jfr|uml|kcy|Kcy|Ecy|ecy|kfr|Kfr|lap|Sub|sub|lat|lcy|Lcy|leg|Dot|dot|lEg|leq|les|squ|div|die|lfr|Lfr|lgE|Dfr|dfr|Del|deg|Dcy|dcy|lne|lnE|sol|loz|smt|Cup|lrm|cup|lsh|Lsh|sim|shy|map|Map|mcy|Mcy|mfr|Mfr|mho|gfr|Gfr|sfr|cir|Chi|chi|nap|Cfr|vcy|Vcy|cfr|Scy|scy|ncy|Ncy|vee|Vee|Cap|cap|nfr|scE|sce|Nfr|nge|ngE|nGg|vfr|Vfr|ngt|bot|nGt|nis|niv|Rsh|rsh|nle|nlE|bne|Bfr|bfr|nLl|nlt|nLt|Bcy|bcy|not|Not|rlm|wfr|Wfr|npr|nsc|num|ocy|ast|Ocy|ofr|xfr|Xfr|Ofr|ogt|ohm|apE|olt|Rho|ape|rho|Rfr|rfr|ord|REG|ang|reg|orv|And|and|AMP|Rcy|amp|Afr|ycy|Ycy|yen|yfr|Yfr|rcy|par|pcy|Pcy|pfr|Pfr|phi|Phi|afr|Acy|acy|zcy|Zcy|piv|acE|acd|zfr|Zfr|pre|prE|psi|Psi|qfr|Qfr|zwj|Or|ge|Gg|gt|gg|el|oS|lt|Lt|LT|Re|lg|gl|eg|ne|Im|it|le|DD|wp|wr|nu|Nu|dd|lE|Sc|sc|pi|Pi|ee|af|ll|Ll|rx|gE|xi|pm|Xi|ic|pr|Pr|in|ni|mp|mu|ac|Mu|or|ap|Gt|GT|ii);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)(?!;)([=a-zA-Z0-9]?)|&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+)/g,m={aacute:"\\xE1",Aacute:"\\xC1",abreve:"\\u0103",Abreve:"\\u0102",ac:"\\u223E",acd:"\\u223F",acE:"\\u223E\\u0333",acirc:"\\xE2",Acirc:"\\xC2",acute:"\\xB4",acy:"\\u0430",Acy:"\\u0410",aelig:"\\xE6",AElig:"\\xC6",af:"\\u2061",afr:"\\u{1D51E}",Afr:"\\u{1D504}",agrave:"\\xE0",Agrave:"\\xC0",alefsym:"\\u2135",aleph:"\\u2135",alpha:"\\u03B1",Alpha:"\\u0391",amacr:"\\u0101",Amacr:"\\u0100",amalg:"\\u2A3F",amp:"&",AMP:"&",and:"\\u2227",And:"\\u2A53",andand:"\\u2A55",andd:"\\u2A5C",andslope:"\\u2A58",andv:"\\u2A5A",ang:"\\u2220",ange:"\\u29A4",angle:"\\u2220",angmsd:"\\u2221",angmsdaa:"\\u29A8",angmsdab:"\\u29A9",angmsdac:"\\u29AA",angmsdad:"\\u29AB",angmsdae:"\\u29AC",angmsdaf:"\\u29AD",angmsdag:"\\u29AE",angmsdah:"\\u29AF",angrt:"\\u221F",angrtvb:"\\u22BE",angrtvbd:"\\u299D",angsph:"\\u2222",angst:"\\xC5",angzarr:"\\u237C",aogon:"\\u0105",Aogon:"\\u0104",aopf:"\\u{1D552}",Aopf:"\\u{1D538}",ap:"\\u2248",apacir:"\\u2A6F",ape:"\\u224A",apE:"\\u2A70",apid:"\\u224B",apos:"\'",ApplyFunction:"\\u2061",approx:"\\u2248",approxeq:"\\u224A",aring:"\\xE5",Aring:"\\xC5",ascr:"\\u{1D4B6}",Ascr:"\\u{1D49C}",Assign:"\\u2254",ast:"*",asymp:"\\u2248",asympeq:"\\u224D",atilde:"\\xE3",Atilde:"\\xC3",auml:"\\xE4",Auml:"\\xC4",awconint:"\\u2233",awint:"\\u2A11",backcong:"\\u224C",backepsilon:"\\u03F6",backprime:"\\u2035",backsim:"\\u223D",backsimeq:"\\u22CD",Backslash:"\\u2216",Barv:"\\u2AE7",barvee:"\\u22BD",barwed:"\\u2305",Barwed:"\\u2306",barwedge:"\\u2305",bbrk:"\\u23B5",bbrktbrk:"\\u23B6",bcong:"\\u224C",bcy:"\\u0431",Bcy:"\\u0411",bdquo:"\\u201E",becaus:"\\u2235",because:"\\u2235",Because:"\\u2235",bemptyv:"\\u29B0",bepsi:"\\u03F6",bernou:"\\u212C",Bernoullis:"\\u212C",beta:"\\u03B2",Beta:"\\u0392",beth:"\\u2136",between:"\\u226C",bfr:"\\u{1D51F}",Bfr:"\\u{1D505}",bigcap:"\\u22C2",bigcirc:"\\u25EF",bigcup:"\\u22C3",bigodot:"\\u2A00",bigoplus:"\\u2A01",bigotimes:"\\u2A02",bigsqcup:"\\u2A06",bigstar:"\\u2605",bigtriangledown:"\\u25BD",bigtriangleup:"\\u25B3",biguplus:"\\u2A04",bigvee:"\\u22C1",bigwedge:"\\u22C0",bkarow:"\\u290D",blacklozenge:"\\u29EB",blacksquare:"\\u25AA",blacktriangle:"\\u25B4",blacktriangledown:"\\u25BE",blacktriangleleft:"\\u25C2",blacktriangleright:"\\u25B8",blank:"\\u2423",blk12:"\\u2592",blk14:"\\u2591",blk34:"\\u2593",block:"\\u2588",bne:"=\\u20E5",bnequiv:"\\u2261\\u20E5",bnot:"\\u2310",bNot:"\\u2AED",bopf:"\\u{1D553}",Bopf:"\\u{1D539}",bot:"\\u22A5",bottom:"\\u22A5",bowtie:"\\u22C8",boxbox:"\\u29C9",boxdl:"\\u2510",boxdL:"\\u2555",boxDl:"\\u2556",boxDL:"\\u2557",boxdr:"\\u250C",boxdR:"\\u2552",boxDr:"\\u2553",boxDR:"\\u2554",boxh:"\\u2500",boxH:"\\u2550",boxhd:"\\u252C",boxhD:"\\u2565",boxHd:"\\u2564",boxHD:"\\u2566",boxhu:"\\u2534",boxhU:"\\u2568",boxHu:"\\u2567",boxHU:"\\u2569",boxminus:"\\u229F",boxplus:"\\u229E",boxtimes:"\\u22A0",boxul:"\\u2518",boxuL:"\\u255B",boxUl:"\\u255C",boxUL:"\\u255D",boxur:"\\u2514",boxuR:"\\u2558",boxUr:"\\u2559",boxUR:"\\u255A",boxv:"\\u2502",boxV:"\\u2551",boxvh:"\\u253C",boxvH:"\\u256A",boxVh:"\\u256B",boxVH:"\\u256C",boxvl:"\\u2524",boxvL:"\\u2561",boxVl:"\\u2562",boxVL:"\\u2563",boxvr:"\\u251C",boxvR:"\\u255E",boxVr:"\\u255F",boxVR:"\\u2560",bprime:"\\u2035",breve:"\\u02D8",Breve:"\\u02D8",brvbar:"\\xA6",bscr:"\\u{1D4B7}",Bscr:"\\u212C",bsemi:"\\u204F",bsim:"\\u223D",bsime:"\\u22CD",bsol:"\\\\",bsolb:"\\u29C5",bsolhsub:"\\u27C8",bull:"\\u2022",bullet:"\\u2022",bump:"\\u224E",bumpe:"\\u224F",bumpE:"\\u2AAE",bumpeq:"\\u224F",Bumpeq:"\\u224E",cacute:"\\u0107",Cacute:"\\u0106",cap:"\\u2229",Cap:"\\u22D2",capand:"\\u2A44",capbrcup:"\\u2A49",capcap:"\\u2A4B",capcup:"\\u2A47",capdot:"\\u2A40",CapitalDifferentialD:"\\u2145",caps:"\\u2229\\uFE00",caret:"\\u2041",caron:"\\u02C7",Cayleys:"\\u212D",ccaps:"\\u2A4D",ccaron:"\\u010D",Ccaron:"\\u010C",ccedil:"\\xE7",Ccedil:"\\xC7",ccirc:"\\u0109",Ccirc:"\\u0108",Cconint:"\\u2230",ccups:"\\u2A4C",ccupssm:"\\u2A50",cdot:"\\u010B",Cdot:"\\u010A",cedil:"\\xB8",Cedilla:"\\xB8",cemptyv:"\\u29B2",cent:"\\xA2",centerdot:"\\xB7",CenterDot:"\\xB7",cfr:"\\u{1D520}",Cfr:"\\u212D",chcy:"\\u0447",CHcy:"\\u0427",check:"\\u2713",checkmark:"\\u2713",chi:"\\u03C7",Chi:"\\u03A7",cir:"\\u25CB",circ:"\\u02C6",circeq:"\\u2257",circlearrowleft:"\\u21BA",circlearrowright:"\\u21BB",circledast:"\\u229B",circledcirc:"\\u229A",circleddash:"\\u229D",CircleDot:"\\u2299",circledR:"\\xAE",circledS:"\\u24C8",CircleMinus:"\\u2296",CirclePlus:"\\u2295",CircleTimes:"\\u2297",cire:"\\u2257",cirE:"\\u29C3",cirfnint:"\\u2A10",cirmid:"\\u2AEF",cirscir:"\\u29C2",ClockwiseContourIntegral:"\\u2232",CloseCurlyDoubleQuote:"\\u201D",CloseCurlyQuote:"\\u2019",clubs:"\\u2663",clubsuit:"\\u2663",colon:":",Colon:"\\u2237",colone:"\\u2254",Colone:"\\u2A74",coloneq:"\\u2254",comma:",",commat:"@",comp:"\\u2201",compfn:"\\u2218",complement:"\\u2201",complexes:"\\u2102",cong:"\\u2245",congdot:"\\u2A6D",Congruent:"\\u2261",conint:"\\u222E",Conint:"\\u222F",ContourIntegral:"\\u222E",copf:"\\u{1D554}",Copf:"\\u2102",coprod:"\\u2210",Coproduct:"\\u2210",copy:"\\xA9",COPY:"\\xA9",copysr:"\\u2117",CounterClockwiseContourIntegral:"\\u2233",crarr:"\\u21B5",cross:"\\u2717",Cross:"\\u2A2F",cscr:"\\u{1D4B8}",Cscr:"\\u{1D49E}",csub:"\\u2ACF",csube:"\\u2AD1",csup:"\\u2AD0",csupe:"\\u2AD2",ctdot:"\\u22EF",cudarrl:"\\u2938",cudarrr:"\\u2935",cuepr:"\\u22DE",cuesc:"\\u22DF",cularr:"\\u21B6",cularrp:"\\u293D",cup:"\\u222A",Cup:"\\u22D3",cupbrcap:"\\u2A48",cupcap:"\\u2A46",CupCap:"\\u224D",cupcup:"\\u2A4A",cupdot:"\\u228D",cupor:"\\u2A45",cups:"\\u222A\\uFE00",curarr:"\\u21B7",curarrm:"\\u293C",curlyeqprec:"\\u22DE",curlyeqsucc:"\\u22DF",curlyvee:"\\u22CE",curlywedge:"\\u22CF",curren:"\\xA4",curvearrowleft:"\\u21B6",curvearrowright:"\\u21B7",cuvee:"\\u22CE",cuwed:"\\u22CF",cwconint:"\\u2232",cwint:"\\u2231",cylcty:"\\u232D",dagger:"\\u2020",Dagger:"\\u2021",daleth:"\\u2138",darr:"\\u2193",dArr:"\\u21D3",Darr:"\\u21A1",dash:"\\u2010",dashv:"\\u22A3",Dashv:"\\u2AE4",dbkarow:"\\u290F",dblac:"\\u02DD",dcaron:"\\u010F",Dcaron:"\\u010E",dcy:"\\u0434",Dcy:"\\u0414",dd:"\\u2146",DD:"\\u2145",ddagger:"\\u2021",ddarr:"\\u21CA",DDotrahd:"\\u2911",ddotseq:"\\u2A77",deg:"\\xB0",Del:"\\u2207",delta:"\\u03B4",Delta:"\\u0394",demptyv:"\\u29B1",dfisht:"\\u297F",dfr:"\\u{1D521}",Dfr:"\\u{1D507}",dHar:"\\u2965",dharl:"\\u21C3",dharr:"\\u21C2",DiacriticalAcute:"\\xB4",DiacriticalDot:"\\u02D9",DiacriticalDoubleAcute:"\\u02DD",DiacriticalGrave:"`",DiacriticalTilde:"\\u02DC",diam:"\\u22C4",diamond:"\\u22C4",Diamond:"\\u22C4",diamondsuit:"\\u2666",diams:"\\u2666",die:"\\xA8",DifferentialD:"\\u2146",digamma:"\\u03DD",disin:"\\u22F2",div:"\\xF7",divide:"\\xF7",divideontimes:"\\u22C7",divonx:"\\u22C7",djcy:"\\u0452",DJcy:"\\u0402",dlcorn:"\\u231E",dlcrop:"\\u230D",dollar:"$",dopf:"\\u{1D555}",Dopf:"\\u{1D53B}",dot:"\\u02D9",Dot:"\\xA8",DotDot:"\\u20DC",doteq:"\\u2250",doteqdot:"\\u2251",DotEqual:"\\u2250",dotminus:"\\u2238",dotplus:"\\u2214",dotsquare:"\\u22A1",doublebarwedge:"\\u2306",DoubleContourIntegral:"\\u222F",DoubleDot:"\\xA8",DoubleDownArrow:"\\u21D3",DoubleLeftArrow:"\\u21D0",DoubleLeftRightArrow:"\\u21D4",DoubleLeftTee:"\\u2AE4",DoubleLongLeftArrow:"\\u27F8",DoubleLongLeftRightArrow:"\\u27FA",DoubleLongRightArrow:"\\u27F9",DoubleRightArrow:"\\u21D2",DoubleRightTee:"\\u22A8",DoubleUpArrow:"\\u21D1",DoubleUpDownArrow:"\\u21D5",DoubleVerticalBar:"\\u2225",downarrow:"\\u2193",Downarrow:"\\u21D3",DownArrow:"\\u2193",DownArrowBar:"\\u2913",DownArrowUpArrow:"\\u21F5",DownBreve:"\\u0311",downdownarrows:"\\u21CA",downharpoonleft:"\\u21C3",downharpoonright:"\\u21C2",DownLeftRightVector:"\\u2950",DownLeftTeeVector:"\\u295E",DownLeftVector:"\\u21BD",DownLeftVectorBar:"\\u2956",DownRightTeeVector:"\\u295F",DownRightVector:"\\u21C1",DownRightVectorBar:"\\u2957",DownTee:"\\u22A4",DownTeeArrow:"\\u21A7",drbkarow:"\\u2910",drcorn:"\\u231F",drcrop:"\\u230C",dscr:"\\u{1D4B9}",Dscr:"\\u{1D49F}",dscy:"\\u0455",DScy:"\\u0405",dsol:"\\u29F6",dstrok:"\\u0111",Dstrok:"\\u0110",dtdot:"\\u22F1",dtri:"\\u25BF",dtrif:"\\u25BE",duarr:"\\u21F5",duhar:"\\u296F",dwangle:"\\u29A6",dzcy:"\\u045F",DZcy:"\\u040F",dzigrarr:"\\u27FF",eacute:"\\xE9",Eacute:"\\xC9",easter:"\\u2A6E",ecaron:"\\u011B",Ecaron:"\\u011A",ecir:"\\u2256",ecirc:"\\xEA",Ecirc:"\\xCA",ecolon:"\\u2255",ecy:"\\u044D",Ecy:"\\u042D",eDDot:"\\u2A77",edot:"\\u0117",eDot:"\\u2251",Edot:"\\u0116",ee:"\\u2147",efDot:"\\u2252",efr:"\\u{1D522}",Efr:"\\u{1D508}",eg:"\\u2A9A",egrave:"\\xE8",Egrave:"\\xC8",egs:"\\u2A96",egsdot:"\\u2A98",el:"\\u2A99",Element:"\\u2208",elinters:"\\u23E7",ell:"\\u2113",els:"\\u2A95",elsdot:"\\u2A97",emacr:"\\u0113",Emacr:"\\u0112",empty:"\\u2205",emptyset:"\\u2205",EmptySmallSquare:"\\u25FB",emptyv:"\\u2205",EmptyVerySmallSquare:"\\u25AB",emsp:"\\u2003",emsp13:"\\u2004",emsp14:"\\u2005",eng:"\\u014B",ENG:"\\u014A",ensp:"\\u2002",eogon:"\\u0119",Eogon:"\\u0118",eopf:"\\u{1D556}",Eopf:"\\u{1D53C}",epar:"\\u22D5",eparsl:"\\u29E3",eplus:"\\u2A71",epsi:"\\u03B5",epsilon:"\\u03B5",Epsilon:"\\u0395",epsiv:"\\u03F5",eqcirc:"\\u2256",eqcolon:"\\u2255",eqsim:"\\u2242",eqslantgtr:"\\u2A96",eqslantless:"\\u2A95",Equal:"\\u2A75",equals:"=",EqualTilde:"\\u2242",equest:"\\u225F",Equilibrium:"\\u21CC",equiv:"\\u2261",equivDD:"\\u2A78",eqvparsl:"\\u29E5",erarr:"\\u2971",erDot:"\\u2253",escr:"\\u212F",Escr:"\\u2130",esdot:"\\u2250",esim:"\\u2242",Esim:"\\u2A73",eta:"\\u03B7",Eta:"\\u0397",eth:"\\xF0",ETH:"\\xD0",euml:"\\xEB",Euml:"\\xCB",euro:"\\u20AC",excl:"!",exist:"\\u2203",Exists:"\\u2203",expectation:"\\u2130",exponentiale:"\\u2147",ExponentialE:"\\u2147",fallingdotseq:"\\u2252",fcy:"\\u0444",Fcy:"\\u0424",female:"\\u2640",ffilig:"\\uFB03",fflig:"\\uFB00",ffllig:"\\uFB04",ffr:"\\u{1D523}",Ffr:"\\u{1D509}",filig:"\\uFB01",FilledSmallSquare:"\\u25FC",FilledVerySmallSquare:"\\u25AA",fjlig:"fj",flat:"\\u266D",fllig:"\\uFB02",fltns:"\\u25B1",fnof:"\\u0192",fopf:"\\u{1D557}",Fopf:"\\u{1D53D}",forall:"\\u2200",ForAll:"\\u2200",fork:"\\u22D4",forkv:"\\u2AD9",Fouriertrf:"\\u2131",fpartint:"\\u2A0D",frac12:"\\xBD",frac13:"\\u2153",frac14:"\\xBC",frac15:"\\u2155",frac16:"\\u2159",frac18:"\\u215B",frac23:"\\u2154",frac25:"\\u2156",frac34:"\\xBE",frac35:"\\u2157",frac38:"\\u215C",frac45:"\\u2158",frac56:"\\u215A",frac58:"\\u215D",frac78:"\\u215E",frasl:"\\u2044",frown:"\\u2322",fscr:"\\u{1D4BB}",Fscr:"\\u2131",gacute:"\\u01F5",gamma:"\\u03B3",Gamma:"\\u0393",gammad:"\\u03DD",Gammad:"\\u03DC",gap:"\\u2A86",gbreve:"\\u011F",Gbreve:"\\u011E",Gcedil:"\\u0122",gcirc:"\\u011D",Gcirc:"\\u011C",gcy:"\\u0433",Gcy:"\\u0413",gdot:"\\u0121",Gdot:"\\u0120",ge:"\\u2265",gE:"\\u2267",gel:"\\u22DB",gEl:"\\u2A8C",geq:"\\u2265",geqq:"\\u2267",geqslant:"\\u2A7E",ges:"\\u2A7E",gescc:"\\u2AA9",gesdot:"\\u2A80",gesdoto:"\\u2A82",gesdotol:"\\u2A84",gesl:"\\u22DB\\uFE00",gesles:"\\u2A94",gfr:"\\u{1D524}",Gfr:"\\u{1D50A}",gg:"\\u226B",Gg:"\\u22D9",ggg:"\\u22D9",gimel:"\\u2137",gjcy:"\\u0453",GJcy:"\\u0403",gl:"\\u2277",gla:"\\u2AA5",glE:"\\u2A92",glj:"\\u2AA4",gnap:"\\u2A8A",gnapprox:"\\u2A8A",gne:"\\u2A88",gnE:"\\u2269",gneq:"\\u2A88",gneqq:"\\u2269",gnsim:"\\u22E7",gopf:"\\u{1D558}",Gopf:"\\u{1D53E}",grave:"`",GreaterEqual:"\\u2265",GreaterEqualLess:"\\u22DB",GreaterFullEqual:"\\u2267",GreaterGreater:"\\u2AA2",GreaterLess:"\\u2277",GreaterSlantEqual:"\\u2A7E",GreaterTilde:"\\u2273",gscr:"\\u210A",Gscr:"\\u{1D4A2}",gsim:"\\u2273",gsime:"\\u2A8E",gsiml:"\\u2A90",gt:">",Gt:"\\u226B",GT:">",gtcc:"\\u2AA7",gtcir:"\\u2A7A",gtdot:"\\u22D7",gtlPar:"\\u2995",gtquest:"\\u2A7C",gtrapprox:"\\u2A86",gtrarr:"\\u2978",gtrdot:"\\u22D7",gtreqless:"\\u22DB",gtreqqless:"\\u2A8C",gtrless:"\\u2277",gtrsim:"\\u2273",gvertneqq:"\\u2269\\uFE00",gvnE:"\\u2269\\uFE00",Hacek:"\\u02C7",hairsp:"\\u200A",half:"\\xBD",hamilt:"\\u210B",hardcy:"\\u044A",HARDcy:"\\u042A",harr:"\\u2194",hArr:"\\u21D4",harrcir:"\\u2948",harrw:"\\u21AD",Hat:"^",hbar:"\\u210F",hcirc:"\\u0125",Hcirc:"\\u0124",hearts:"\\u2665",heartsuit:"\\u2665",hellip:"\\u2026",hercon:"\\u22B9",hfr:"\\u{1D525}",Hfr:"\\u210C",HilbertSpace:"\\u210B",hksearow:"\\u2925",hkswarow:"\\u2926",hoarr:"\\u21FF",homtht:"\\u223B",hookleftarrow:"\\u21A9",hookrightarrow:"\\u21AA",hopf:"\\u{1D559}",Hopf:"\\u210D",horbar:"\\u2015",HorizontalLine:"\\u2500",hscr:"\\u{1D4BD}",Hscr:"\\u210B",hslash:"\\u210F",hstrok:"\\u0127",Hstrok:"\\u0126",HumpDownHump:"\\u224E",HumpEqual:"\\u224F",hybull:"\\u2043",hyphen:"\\u2010",iacute:"\\xED",Iacute:"\\xCD",ic:"\\u2063",icirc:"\\xEE",Icirc:"\\xCE",icy:"\\u0438",Icy:"\\u0418",Idot:"\\u0130",iecy:"\\u0435",IEcy:"\\u0415",iexcl:"\\xA1",iff:"\\u21D4",ifr:"\\u{1D526}",Ifr:"\\u2111",igrave:"\\xEC",Igrave:"\\xCC",ii:"\\u2148",iiiint:"\\u2A0C",iiint:"\\u222D",iinfin:"\\u29DC",iiota:"\\u2129",ijlig:"\\u0133",IJlig:"\\u0132",Im:"\\u2111",imacr:"\\u012B",Imacr:"\\u012A",image:"\\u2111",ImaginaryI:"\\u2148",imagline:"\\u2110",imagpart:"\\u2111",imath:"\\u0131",imof:"\\u22B7",imped:"\\u01B5",Implies:"\\u21D2",in:"\\u2208",incare:"\\u2105",infin:"\\u221E",infintie:"\\u29DD",inodot:"\\u0131",int:"\\u222B",Int:"\\u222C",intcal:"\\u22BA",integers:"\\u2124",Integral:"\\u222B",intercal:"\\u22BA",Intersection:"\\u22C2",intlarhk:"\\u2A17",intprod:"\\u2A3C",InvisibleComma:"\\u2063",InvisibleTimes:"\\u2062",iocy:"\\u0451",IOcy:"\\u0401",iogon:"\\u012F",Iogon:"\\u012E",iopf:"\\u{1D55A}",Iopf:"\\u{1D540}",iota:"\\u03B9",Iota:"\\u0399",iprod:"\\u2A3C",iquest:"\\xBF",iscr:"\\u{1D4BE}",Iscr:"\\u2110",isin:"\\u2208",isindot:"\\u22F5",isinE:"\\u22F9",isins:"\\u22F4",isinsv:"\\u22F3",isinv:"\\u2208",it:"\\u2062",itilde:"\\u0129",Itilde:"\\u0128",iukcy:"\\u0456",Iukcy:"\\u0406",iuml:"\\xEF",Iuml:"\\xCF",jcirc:"\\u0135",Jcirc:"\\u0134",jcy:"\\u0439",Jcy:"\\u0419",jfr:"\\u{1D527}",Jfr:"\\u{1D50D}",jmath:"\\u0237",jopf:"\\u{1D55B}",Jopf:"\\u{1D541}",jscr:"\\u{1D4BF}",Jscr:"\\u{1D4A5}",jsercy:"\\u0458",Jsercy:"\\u0408",jukcy:"\\u0454",Jukcy:"\\u0404",kappa:"\\u03BA",Kappa:"\\u039A",kappav:"\\u03F0",kcedil:"\\u0137",Kcedil:"\\u0136",kcy:"\\u043A",Kcy:"\\u041A",kfr:"\\u{1D528}",Kfr:"\\u{1D50E}",kgreen:"\\u0138",khcy:"\\u0445",KHcy:"\\u0425",kjcy:"\\u045C",KJcy:"\\u040C",kopf:"\\u{1D55C}",Kopf:"\\u{1D542}",kscr:"\\u{1D4C0}",Kscr:"\\u{1D4A6}",lAarr:"\\u21DA",lacute:"\\u013A",Lacute:"\\u0139",laemptyv:"\\u29B4",lagran:"\\u2112",lambda:"\\u03BB",Lambda:"\\u039B",lang:"\\u27E8",Lang:"\\u27EA",langd:"\\u2991",langle:"\\u27E8",lap:"\\u2A85",Laplacetrf:"\\u2112",laquo:"\\xAB",larr:"\\u2190",lArr:"\\u21D0",Larr:"\\u219E",larrb:"\\u21E4",larrbfs:"\\u291F",larrfs:"\\u291D",larrhk:"\\u21A9",larrlp:"\\u21AB",larrpl:"\\u2939",larrsim:"\\u2973",larrtl:"\\u21A2",lat:"\\u2AAB",latail:"\\u2919",lAtail:"\\u291B",late:"\\u2AAD",lates:"\\u2AAD\\uFE00",lbarr:"\\u290C",lBarr:"\\u290E",lbbrk:"\\u2772",lbrace:"{",lbrack:"[",lbrke:"\\u298B",lbrksld:"\\u298F",lbrkslu:"\\u298D",lcaron:"\\u013E",Lcaron:"\\u013D",lcedil:"\\u013C",Lcedil:"\\u013B",lceil:"\\u2308",lcub:"{",lcy:"\\u043B",Lcy:"\\u041B",ldca:"\\u2936",ldquo:"\\u201C",ldquor:"\\u201E",ldrdhar:"\\u2967",ldrushar:"\\u294B",ldsh:"\\u21B2",le:"\\u2264",lE:"\\u2266",LeftAngleBracket:"\\u27E8",leftarrow:"\\u2190",Leftarrow:"\\u21D0",LeftArrow:"\\u2190",LeftArrowBar:"\\u21E4",LeftArrowRightArrow:"\\u21C6",leftarrowtail:"\\u21A2",LeftCeiling:"\\u2308",LeftDoubleBracket:"\\u27E6",LeftDownTeeVector:"\\u2961",LeftDownVector:"\\u21C3",LeftDownVectorBar:"\\u2959",LeftFloor:"\\u230A",leftharpoondown:"\\u21BD",leftharpoonup:"\\u21BC",leftleftarrows:"\\u21C7",leftrightarrow:"\\u2194",Leftrightarrow:"\\u21D4",LeftRightArrow:"\\u2194",leftrightarrows:"\\u21C6",leftrightharpoons:"\\u21CB",leftrightsquigarrow:"\\u21AD",LeftRightVector:"\\u294E",LeftTee:"\\u22A3",LeftTeeArrow:"\\u21A4",LeftTeeVector:"\\u295A",leftthreetimes:"\\u22CB",LeftTriangle:"\\u22B2",LeftTriangleBar:"\\u29CF",LeftTriangleEqual:"\\u22B4",LeftUpDownVector:"\\u2951",LeftUpTeeVector:"\\u2960",LeftUpVector:"\\u21BF",LeftUpVectorBar:"\\u2958",LeftVector:"\\u21BC",LeftVectorBar:"\\u2952",leg:"\\u22DA",lEg:"\\u2A8B",leq:"\\u2264",leqq:"\\u2266",leqslant:"\\u2A7D",les:"\\u2A7D",lescc:"\\u2AA8",lesdot:"\\u2A7F",lesdoto:"\\u2A81",lesdotor:"\\u2A83",lesg:"\\u22DA\\uFE00",lesges:"\\u2A93",lessapprox:"\\u2A85",lessdot:"\\u22D6",lesseqgtr:"\\u22DA",lesseqqgtr:"\\u2A8B",LessEqualGreater:"\\u22DA",LessFullEqual:"\\u2266",LessGreater:"\\u2276",lessgtr:"\\u2276",LessLess:"\\u2AA1",lesssim:"\\u2272",LessSlantEqual:"\\u2A7D",LessTilde:"\\u2272",lfisht:"\\u297C",lfloor:"\\u230A",lfr:"\\u{1D529}",Lfr:"\\u{1D50F}",lg:"\\u2276",lgE:"\\u2A91",lHar:"\\u2962",lhard:"\\u21BD",lharu:"\\u21BC",lharul:"\\u296A",lhblk:"\\u2584",ljcy:"\\u0459",LJcy:"\\u0409",ll:"\\u226A",Ll:"\\u22D8",llarr:"\\u21C7",llcorner:"\\u231E",Lleftarrow:"\\u21DA",llhard:"\\u296B",lltri:"\\u25FA",lmidot:"\\u0140",Lmidot:"\\u013F",lmoust:"\\u23B0",lmoustache:"\\u23B0",lnap:"\\u2A89",lnapprox:"\\u2A89",lne:"\\u2A87",lnE:"\\u2268",lneq:"\\u2A87",lneqq:"\\u2268",lnsim:"\\u22E6",loang:"\\u27EC",loarr:"\\u21FD",lobrk:"\\u27E6",longleftarrow:"\\u27F5",Longleftarrow:"\\u27F8",LongLeftArrow:"\\u27F5",longleftrightarrow:"\\u27F7",Longleftrightarrow:"\\u27FA",LongLeftRightArrow:"\\u27F7",longmapsto:"\\u27FC",longrightarrow:"\\u27F6",Longrightarrow:"\\u27F9",LongRightArrow:"\\u27F6",looparrowleft:"\\u21AB",looparrowright:"\\u21AC",lopar:"\\u2985",lopf:"\\u{1D55D}",Lopf:"\\u{1D543}",loplus:"\\u2A2D",lotimes:"\\u2A34",lowast:"\\u2217",lowbar:"_",LowerLeftArrow:"\\u2199",LowerRightArrow:"\\u2198",loz:"\\u25CA",lozenge:"\\u25CA",lozf:"\\u29EB",lpar:"(",lparlt:"\\u2993",lrarr:"\\u21C6",lrcorner:"\\u231F",lrhar:"\\u21CB",lrhard:"\\u296D",lrm:"\\u200E",lrtri:"\\u22BF",lsaquo:"\\u2039",lscr:"\\u{1D4C1}",Lscr:"\\u2112",lsh:"\\u21B0",Lsh:"\\u21B0",lsim:"\\u2272",lsime:"\\u2A8D",lsimg:"\\u2A8F",lsqb:"[",lsquo:"\\u2018",lsquor:"\\u201A",lstrok:"\\u0142",Lstrok:"\\u0141",lt:"<",Lt:"\\u226A",LT:"<",ltcc:"\\u2AA6",ltcir:"\\u2A79",ltdot:"\\u22D6",lthree:"\\u22CB",ltimes:"\\u22C9",ltlarr:"\\u2976",ltquest:"\\u2A7B",ltri:"\\u25C3",ltrie:"\\u22B4",ltrif:"\\u25C2",ltrPar:"\\u2996",lurdshar:"\\u294A",luruhar:"\\u2966",lvertneqq:"\\u2268\\uFE00",lvnE:"\\u2268\\uFE00",macr:"\\xAF",male:"\\u2642",malt:"\\u2720",maltese:"\\u2720",map:"\\u21A6",Map:"\\u2905",mapsto:"\\u21A6",mapstodown:"\\u21A7",mapstoleft:"\\u21A4",mapstoup:"\\u21A5",marker:"\\u25AE",mcomma:"\\u2A29",mcy:"\\u043C",Mcy:"\\u041C",mdash:"\\u2014",mDDot:"\\u223A",measuredangle:"\\u2221",MediumSpace:"\\u205F",Mellintrf:"\\u2133",mfr:"\\u{1D52A}",Mfr:"\\u{1D510}",mho:"\\u2127",micro:"\\xB5",mid:"\\u2223",midast:"*",midcir:"\\u2AF0",middot:"\\xB7",minus:"\\u2212",minusb:"\\u229F",minusd:"\\u2238",minusdu:"\\u2A2A",MinusPlus:"\\u2213",mlcp:"\\u2ADB",mldr:"\\u2026",mnplus:"\\u2213",models:"\\u22A7",mopf:"\\u{1D55E}",Mopf:"\\u{1D544}",mp:"\\u2213",mscr:"\\u{1D4C2}",Mscr:"\\u2133",mstpos:"\\u223E",mu:"\\u03BC",Mu:"\\u039C",multimap:"\\u22B8",mumap:"\\u22B8",nabla:"\\u2207",nacute:"\\u0144",Nacute:"\\u0143",nang:"\\u2220\\u20D2",nap:"\\u2249",napE:"\\u2A70\\u0338",napid:"\\u224B\\u0338",napos:"\\u0149",napprox:"\\u2249",natur:"\\u266E",natural:"\\u266E",naturals:"\\u2115",nbsp:"\\xA0",nbump:"\\u224E\\u0338",nbumpe:"\\u224F\\u0338",ncap:"\\u2A43",ncaron:"\\u0148",Ncaron:"\\u0147",ncedil:"\\u0146",Ncedil:"\\u0145",ncong:"\\u2247",ncongdot:"\\u2A6D\\u0338",ncup:"\\u2A42",ncy:"\\u043D",Ncy:"\\u041D",ndash:"\\u2013",ne:"\\u2260",nearhk:"\\u2924",nearr:"\\u2197",neArr:"\\u21D7",nearrow:"\\u2197",nedot:"\\u2250\\u0338",NegativeMediumSpace:"\\u200B",NegativeThickSpace:"\\u200B",NegativeThinSpace:"\\u200B",NegativeVeryThinSpace:"\\u200B",nequiv:"\\u2262",nesear:"\\u2928",nesim:"\\u2242\\u0338",NestedGreaterGreater:"\\u226B",NestedLessLess:"\\u226A",NewLine:`\n`,nexist:"\\u2204",nexists:"\\u2204",nfr:"\\u{1D52B}",Nfr:"\\u{1D511}",nge:"\\u2271",ngE:"\\u2267\\u0338",ngeq:"\\u2271",ngeqq:"\\u2267\\u0338",ngeqslant:"\\u2A7E\\u0338",nges:"\\u2A7E\\u0338",nGg:"\\u22D9\\u0338",ngsim:"\\u2275",ngt:"\\u226F",nGt:"\\u226B\\u20D2",ngtr:"\\u226F",nGtv:"\\u226B\\u0338",nharr:"\\u21AE",nhArr:"\\u21CE",nhpar:"\\u2AF2",ni:"\\u220B",nis:"\\u22FC",nisd:"\\u22FA",niv:"\\u220B",njcy:"\\u045A",NJcy:"\\u040A",nlarr:"\\u219A",nlArr:"\\u21CD",nldr:"\\u2025",nle:"\\u2270",nlE:"\\u2266\\u0338",nleftarrow:"\\u219A",nLeftarrow:"\\u21CD",nleftrightarrow:"\\u21AE",nLeftrightarrow:"\\u21CE",nleq:"\\u2270",nleqq:"\\u2266\\u0338",nleqslant:"\\u2A7D\\u0338",nles:"\\u2A7D\\u0338",nless:"\\u226E",nLl:"\\u22D8\\u0338",nlsim:"\\u2274",nlt:"\\u226E",nLt:"\\u226A\\u20D2",nltri:"\\u22EA",nltrie:"\\u22EC",nLtv:"\\u226A\\u0338",nmid:"\\u2224",NoBreak:"\\u2060",NonBreakingSpace:"\\xA0",nopf:"\\u{1D55F}",Nopf:"\\u2115",not:"\\xAC",Not:"\\u2AEC",NotCongruent:"\\u2262",NotCupCap:"\\u226D",NotDoubleVerticalBar:"\\u2226",NotElement:"\\u2209",NotEqual:"\\u2260",NotEqualTilde:"\\u2242\\u0338",NotExists:"\\u2204",NotGreater:"\\u226F",NotGreaterEqual:"\\u2271",NotGreaterFullEqual:"\\u2267\\u0338",NotGreaterGreater:"\\u226B\\u0338",NotGreaterLess:"\\u2279",NotGreaterSlantEqual:"\\u2A7E\\u0338",NotGreaterTilde:"\\u2275",NotHumpDownHump:"\\u224E\\u0338",NotHumpEqual:"\\u224F\\u0338",notin:"\\u2209",notindot:"\\u22F5\\u0338",notinE:"\\u22F9\\u0338",notinva:"\\u2209",notinvb:"\\u22F7",notinvc:"\\u22F6",NotLeftTriangle:"\\u22EA",NotLeftTriangleBar:"\\u29CF\\u0338",NotLeftTriangleEqual:"\\u22EC",NotLess:"\\u226E",NotLessEqual:"\\u2270",NotLessGreater:"\\u2278",NotLessLess:"\\u226A\\u0338",NotLessSlantEqual:"\\u2A7D\\u0338",NotLessTilde:"\\u2274",NotNestedGreaterGreater:"\\u2AA2\\u0338",NotNestedLessLess:"\\u2AA1\\u0338",notni:"\\u220C",notniva:"\\u220C",notnivb:"\\u22FE",notnivc:"\\u22FD",NotPrecedes:"\\u2280",NotPrecedesEqual:"\\u2AAF\\u0338",NotPrecedesSlantEqual:"\\u22E0",NotReverseElement:"\\u220C",NotRightTriangle:"\\u22EB",NotRightTriangleBar:"\\u29D0\\u0338",NotRightTriangleEqual:"\\u22ED",NotSquareSubset:"\\u228F\\u0338",NotSquareSubsetEqual:"\\u22E2",NotSquareSuperset:"\\u2290\\u0338",NotSquareSupersetEqual:"\\u22E3",NotSubset:"\\u2282\\u20D2",NotSubsetEqual:"\\u2288",NotSucceeds:"\\u2281",NotSucceedsEqual:"\\u2AB0\\u0338",NotSucceedsSlantEqual:"\\u22E1",NotSucceedsTilde:"\\u227F\\u0338",NotSuperset:"\\u2283\\u20D2",NotSupersetEqual:"\\u2289",NotTilde:"\\u2241",NotTildeEqual:"\\u2244",NotTildeFullEqual:"\\u2247",NotTildeTilde:"\\u2249",NotVerticalBar:"\\u2224",npar:"\\u2226",nparallel:"\\u2226",nparsl:"\\u2AFD\\u20E5",npart:"\\u2202\\u0338",npolint:"\\u2A14",npr:"\\u2280",nprcue:"\\u22E0",npre:"\\u2AAF\\u0338",nprec:"\\u2280",npreceq:"\\u2AAF\\u0338",nrarr:"\\u219B",nrArr:"\\u21CF",nrarrc:"\\u2933\\u0338",nrarrw:"\\u219D\\u0338",nrightarrow:"\\u219B",nRightarrow:"\\u21CF",nrtri:"\\u22EB",nrtrie:"\\u22ED",nsc:"\\u2281",nsccue:"\\u22E1",nsce:"\\u2AB0\\u0338",nscr:"\\u{1D4C3}",Nscr:"\\u{1D4A9}",nshortmid:"\\u2224",nshortparallel:"\\u2226",nsim:"\\u2241",nsime:"\\u2244",nsimeq:"\\u2244",nsmid:"\\u2224",nspar:"\\u2226",nsqsube:"\\u22E2",nsqsupe:"\\u22E3",nsub:"\\u2284",nsube:"\\u2288",nsubE:"\\u2AC5\\u0338",nsubset:"\\u2282\\u20D2",nsubseteq:"\\u2288",nsubseteqq:"\\u2AC5\\u0338",nsucc:"\\u2281",nsucceq:"\\u2AB0\\u0338",nsup:"\\u2285",nsupe:"\\u2289",nsupE:"\\u2AC6\\u0338",nsupset:"\\u2283\\u20D2",nsupseteq:"\\u2289",nsupseteqq:"\\u2AC6\\u0338",ntgl:"\\u2279",ntilde:"\\xF1",Ntilde:"\\xD1",ntlg:"\\u2278",ntriangleleft:"\\u22EA",ntrianglelefteq:"\\u22EC",ntriangleright:"\\u22EB",ntrianglerighteq:"\\u22ED",nu:"\\u03BD",Nu:"\\u039D",num:"#",numero:"\\u2116",numsp:"\\u2007",nvap:"\\u224D\\u20D2",nvdash:"\\u22AC",nvDash:"\\u22AD",nVdash:"\\u22AE",nVDash:"\\u22AF",nvge:"\\u2265\\u20D2",nvgt:">\\u20D2",nvHarr:"\\u2904",nvinfin:"\\u29DE",nvlArr:"\\u2902",nvle:"\\u2264\\u20D2",nvlt:"<\\u20D2",nvltrie:"\\u22B4\\u20D2",nvrArr:"\\u2903",nvrtrie:"\\u22B5\\u20D2",nvsim:"\\u223C\\u20D2",nwarhk:"\\u2923",nwarr:"\\u2196",nwArr:"\\u21D6",nwarrow:"\\u2196",nwnear:"\\u2927",oacute:"\\xF3",Oacute:"\\xD3",oast:"\\u229B",ocir:"\\u229A",ocirc:"\\xF4",Ocirc:"\\xD4",ocy:"\\u043E",Ocy:"\\u041E",odash:"\\u229D",odblac:"\\u0151",Odblac:"\\u0150",odiv:"\\u2A38",odot:"\\u2299",odsold:"\\u29BC",oelig:"\\u0153",OElig:"\\u0152",ofcir:"\\u29BF",ofr:"\\u{1D52C}",Ofr:"\\u{1D512}",ogon:"\\u02DB",ograve:"\\xF2",Ograve:"\\xD2",ogt:"\\u29C1",ohbar:"\\u29B5",ohm:"\\u03A9",oint:"\\u222E",olarr:"\\u21BA",olcir:"\\u29BE",olcross:"\\u29BB",oline:"\\u203E",olt:"\\u29C0",omacr:"\\u014D",Omacr:"\\u014C",omega:"\\u03C9",Omega:"\\u03A9",omicron:"\\u03BF",Omicron:"\\u039F",omid:"\\u29B6",ominus:"\\u2296",oopf:"\\u{1D560}",Oopf:"\\u{1D546}",opar:"\\u29B7",OpenCurlyDoubleQuote:"\\u201C",OpenCurlyQuote:"\\u2018",operp:"\\u29B9",oplus:"\\u2295",or:"\\u2228",Or:"\\u2A54",orarr:"\\u21BB",ord:"\\u2A5D",order:"\\u2134",orderof:"\\u2134",ordf:"\\xAA",ordm:"\\xBA",origof:"\\u22B6",oror:"\\u2A56",orslope:"\\u2A57",orv:"\\u2A5B",oS:"\\u24C8",oscr:"\\u2134",Oscr:"\\u{1D4AA}",oslash:"\\xF8",Oslash:"\\xD8",osol:"\\u2298",otilde:"\\xF5",Otilde:"\\xD5",otimes:"\\u2297",Otimes:"\\u2A37",otimesas:"\\u2A36",ouml:"\\xF6",Ouml:"\\xD6",ovbar:"\\u233D",OverBar:"\\u203E",OverBrace:"\\u23DE",OverBracket:"\\u23B4",OverParenthesis:"\\u23DC",par:"\\u2225",para:"\\xB6",parallel:"\\u2225",parsim:"\\u2AF3",parsl:"\\u2AFD",part:"\\u2202",PartialD:"\\u2202",pcy:"\\u043F",Pcy:"\\u041F",percnt:"%",period:".",permil:"\\u2030",perp:"\\u22A5",pertenk:"\\u2031",pfr:"\\u{1D52D}",Pfr:"\\u{1D513}",phi:"\\u03C6",Phi:"\\u03A6",phiv:"\\u03D5",phmmat:"\\u2133",phone:"\\u260E",pi:"\\u03C0",Pi:"\\u03A0",pitchfork:"\\u22D4",piv:"\\u03D6",planck:"\\u210F",planckh:"\\u210E",plankv:"\\u210F",plus:"+",plusacir:"\\u2A23",plusb:"\\u229E",pluscir:"\\u2A22",plusdo:"\\u2214",plusdu:"\\u2A25",pluse:"\\u2A72",PlusMinus:"\\xB1",plusmn:"\\xB1",plussim:"\\u2A26",plustwo:"\\u2A27",pm:"\\xB1",Poincareplane:"\\u210C",pointint:"\\u2A15",popf:"\\u{1D561}",Popf:"\\u2119",pound:"\\xA3",pr:"\\u227A",Pr:"\\u2ABB",prap:"\\u2AB7",prcue:"\\u227C",pre:"\\u2AAF",prE:"\\u2AB3",prec:"\\u227A",precapprox:"\\u2AB7",preccurlyeq:"\\u227C",Precedes:"\\u227A",PrecedesEqual:"\\u2AAF",PrecedesSlantEqual:"\\u227C",PrecedesTilde:"\\u227E",preceq:"\\u2AAF",precnapprox:"\\u2AB9",precneqq:"\\u2AB5",precnsim:"\\u22E8",precsim:"\\u227E",prime:"\\u2032",Prime:"\\u2033",primes:"\\u2119",prnap:"\\u2AB9",prnE:"\\u2AB5",prnsim:"\\u22E8",prod:"\\u220F",Product:"\\u220F",profalar:"\\u232E",profline:"\\u2312",profsurf:"\\u2313",prop:"\\u221D",Proportion:"\\u2237",Proportional:"\\u221D",propto:"\\u221D",prsim:"\\u227E",prurel:"\\u22B0",pscr:"\\u{1D4C5}",Pscr:"\\u{1D4AB}",psi:"\\u03C8",Psi:"\\u03A8",puncsp:"\\u2008",qfr:"\\u{1D52E}",Qfr:"\\u{1D514}",qint:"\\u2A0C",qopf:"\\u{1D562}",Qopf:"\\u211A",qprime:"\\u2057",qscr:"\\u{1D4C6}",Qscr:"\\u{1D4AC}",quaternions:"\\u210D",quatint:"\\u2A16",quest:"?",questeq:"\\u225F",quot:\'"\',QUOT:\'"\',rAarr:"\\u21DB",race:"\\u223D\\u0331",racute:"\\u0155",Racute:"\\u0154",radic:"\\u221A",raemptyv:"\\u29B3",rang:"\\u27E9",Rang:"\\u27EB",rangd:"\\u2992",range:"\\u29A5",rangle:"\\u27E9",raquo:"\\xBB",rarr:"\\u2192",rArr:"\\u21D2",Rarr:"\\u21A0",rarrap:"\\u2975",rarrb:"\\u21E5",rarrbfs:"\\u2920",rarrc:"\\u2933",rarrfs:"\\u291E",rarrhk:"\\u21AA",rarrlp:"\\u21AC",rarrpl:"\\u2945",rarrsim:"\\u2974",rarrtl:"\\u21A3",Rarrtl:"\\u2916",rarrw:"\\u219D",ratail:"\\u291A",rAtail:"\\u291C",ratio:"\\u2236",rationals:"\\u211A",rbarr:"\\u290D",rBarr:"\\u290F",RBarr:"\\u2910",rbbrk:"\\u2773",rbrace:"}",rbrack:"]",rbrke:"\\u298C",rbrksld:"\\u298E",rbrkslu:"\\u2990",rcaron:"\\u0159",Rcaron:"\\u0158",rcedil:"\\u0157",Rcedil:"\\u0156",rceil:"\\u2309",rcub:"}",rcy:"\\u0440",Rcy:"\\u0420",rdca:"\\u2937",rdldhar:"\\u2969",rdquo:"\\u201D",rdquor:"\\u201D",rdsh:"\\u21B3",Re:"\\u211C",real:"\\u211C",realine:"\\u211B",realpart:"\\u211C",reals:"\\u211D",rect:"\\u25AD",reg:"\\xAE",REG:"\\xAE",ReverseElement:"\\u220B",ReverseEquilibrium:"\\u21CB",ReverseUpEquilibrium:"\\u296F",rfisht:"\\u297D",rfloor:"\\u230B",rfr:"\\u{1D52F}",Rfr:"\\u211C",rHar:"\\u2964",rhard:"\\u21C1",rharu:"\\u21C0",rharul:"\\u296C",rho:"\\u03C1",Rho:"\\u03A1",rhov:"\\u03F1",RightAngleBracket:"\\u27E9",rightarrow:"\\u2192",Rightarrow:"\\u21D2",RightArrow:"\\u2192",RightArrowBar:"\\u21E5",RightArrowLeftArrow:"\\u21C4",rightarrowtail:"\\u21A3",RightCeiling:"\\u2309",RightDoubleBracket:"\\u27E7",RightDownTeeVector:"\\u295D",RightDownVector:"\\u21C2",RightDownVectorBar:"\\u2955",RightFloor:"\\u230B",rightharpoondown:"\\u21C1",rightharpoonup:"\\u21C0",rightleftarrows:"\\u21C4",rightleftharpoons:"\\u21CC",rightrightarrows:"\\u21C9",rightsquigarrow:"\\u219D",RightTee:"\\u22A2",RightTeeArrow:"\\u21A6",RightTeeVector:"\\u295B",rightthreetimes:"\\u22CC",RightTriangle:"\\u22B3",RightTriangleBar:"\\u29D0",RightTriangleEqual:"\\u22B5",RightUpDownVector:"\\u294F",RightUpTeeVector:"\\u295C",RightUpVector:"\\u21BE",RightUpVectorBar:"\\u2954",RightVector:"\\u21C0",RightVectorBar:"\\u2953",ring:"\\u02DA",risingdotseq:"\\u2253",rlarr:"\\u21C4",rlhar:"\\u21CC",rlm:"\\u200F",rmoust:"\\u23B1",rmoustache:"\\u23B1",rnmid:"\\u2AEE",roang:"\\u27ED",roarr:"\\u21FE",robrk:"\\u27E7",ropar:"\\u2986",ropf:"\\u{1D563}",Ropf:"\\u211D",roplus:"\\u2A2E",rotimes:"\\u2A35",RoundImplies:"\\u2970",rpar:")",rpargt:"\\u2994",rppolint:"\\u2A12",rrarr:"\\u21C9",Rrightarrow:"\\u21DB",rsaquo:"\\u203A",rscr:"\\u{1D4C7}",Rscr:"\\u211B",rsh:"\\u21B1",Rsh:"\\u21B1",rsqb:"]",rsquo:"\\u2019",rsquor:"\\u2019",rthree:"\\u22CC",rtimes:"\\u22CA",rtri:"\\u25B9",rtrie:"\\u22B5",rtrif:"\\u25B8",rtriltri:"\\u29CE",RuleDelayed:"\\u29F4",ruluhar:"\\u2968",rx:"\\u211E",sacute:"\\u015B",Sacute:"\\u015A",sbquo:"\\u201A",sc:"\\u227B",Sc:"\\u2ABC",scap:"\\u2AB8",scaron:"\\u0161",Scaron:"\\u0160",sccue:"\\u227D",sce:"\\u2AB0",scE:"\\u2AB4",scedil:"\\u015F",Scedil:"\\u015E",scirc:"\\u015D",Scirc:"\\u015C",scnap:"\\u2ABA",scnE:"\\u2AB6",scnsim:"\\u22E9",scpolint:"\\u2A13",scsim:"\\u227F",scy:"\\u0441",Scy:"\\u0421",sdot:"\\u22C5",sdotb:"\\u22A1",sdote:"\\u2A66",searhk:"\\u2925",searr:"\\u2198",seArr:"\\u21D8",searrow:"\\u2198",sect:"\\xA7",semi:";",seswar:"\\u2929",setminus:"\\u2216",setmn:"\\u2216",sext:"\\u2736",sfr:"\\u{1D530}",Sfr:"\\u{1D516}",sfrown:"\\u2322",sharp:"\\u266F",shchcy:"\\u0449",SHCHcy:"\\u0429",shcy:"\\u0448",SHcy:"\\u0428",ShortDownArrow:"\\u2193",ShortLeftArrow:"\\u2190",shortmid:"\\u2223",shortparallel:"\\u2225",ShortRightArrow:"\\u2192",ShortUpArrow:"\\u2191",shy:"\\xAD",sigma:"\\u03C3",Sigma:"\\u03A3",sigmaf:"\\u03C2",sigmav:"\\u03C2",sim:"\\u223C",simdot:"\\u2A6A",sime:"\\u2243",simeq:"\\u2243",simg:"\\u2A9E",simgE:"\\u2AA0",siml:"\\u2A9D",simlE:"\\u2A9F",simne:"\\u2246",simplus:"\\u2A24",simrarr:"\\u2972",slarr:"\\u2190",SmallCircle:"\\u2218",smallsetminus:"\\u2216",smashp:"\\u2A33",smeparsl:"\\u29E4",smid:"\\u2223",smile:"\\u2323",smt:"\\u2AAA",smte:"\\u2AAC",smtes:"\\u2AAC\\uFE00",softcy:"\\u044C",SOFTcy:"\\u042C",sol:"/",solb:"\\u29C4",solbar:"\\u233F",sopf:"\\u{1D564}",Sopf:"\\u{1D54A}",spades:"\\u2660",spadesuit:"\\u2660",spar:"\\u2225",sqcap:"\\u2293",sqcaps:"\\u2293\\uFE00",sqcup:"\\u2294",sqcups:"\\u2294\\uFE00",Sqrt:"\\u221A",sqsub:"\\u228F",sqsube:"\\u2291",sqsubset:"\\u228F",sqsubseteq:"\\u2291",sqsup:"\\u2290",sqsupe:"\\u2292",sqsupset:"\\u2290",sqsupseteq:"\\u2292",squ:"\\u25A1",square:"\\u25A1",Square:"\\u25A1",SquareIntersection:"\\u2293",SquareSubset:"\\u228F",SquareSubsetEqual:"\\u2291",SquareSuperset:"\\u2290",SquareSupersetEqual:"\\u2292",SquareUnion:"\\u2294",squarf:"\\u25AA",squf:"\\u25AA",srarr:"\\u2192",sscr:"\\u{1D4C8}",Sscr:"\\u{1D4AE}",ssetmn:"\\u2216",ssmile:"\\u2323",sstarf:"\\u22C6",star:"\\u2606",Star:"\\u22C6",starf:"\\u2605",straightepsilon:"\\u03F5",straightphi:"\\u03D5",strns:"\\xAF",sub:"\\u2282",Sub:"\\u22D0",subdot:"\\u2ABD",sube:"\\u2286",subE:"\\u2AC5",subedot:"\\u2AC3",submult:"\\u2AC1",subne:"\\u228A",subnE:"\\u2ACB",subplus:"\\u2ABF",subrarr:"\\u2979",subset:"\\u2282",Subset:"\\u22D0",subseteq:"\\u2286",subseteqq:"\\u2AC5",SubsetEqual:"\\u2286",subsetneq:"\\u228A",subsetneqq:"\\u2ACB",subsim:"\\u2AC7",subsub:"\\u2AD5",subsup:"\\u2AD3",succ:"\\u227B",succapprox:"\\u2AB8",succcurlyeq:"\\u227D",Succeeds:"\\u227B",SucceedsEqual:"\\u2AB0",SucceedsSlantEqual:"\\u227D",SucceedsTilde:"\\u227F",succeq:"\\u2AB0",succnapprox:"\\u2ABA",succneqq:"\\u2AB6",succnsim:"\\u22E9",succsim:"\\u227F",SuchThat:"\\u220B",sum:"\\u2211",Sum:"\\u2211",sung:"\\u266A",sup:"\\u2283",Sup:"\\u22D1",sup1:"\\xB9",sup2:"\\xB2",sup3:"\\xB3",supdot:"\\u2ABE",supdsub:"\\u2AD8",supe:"\\u2287",supE:"\\u2AC6",supedot:"\\u2AC4",Superset:"\\u2283",SupersetEqual:"\\u2287",suphsol:"\\u27C9",suphsub:"\\u2AD7",suplarr:"\\u297B",supmult:"\\u2AC2",supne:"\\u228B",supnE:"\\u2ACC",supplus:"\\u2AC0",supset:"\\u2283",Supset:"\\u22D1",supseteq:"\\u2287",supseteqq:"\\u2AC6",supsetneq:"\\u228B",supsetneqq:"\\u2ACC",supsim:"\\u2AC8",supsub:"\\u2AD4",supsup:"\\u2AD6",swarhk:"\\u2926",swarr:"\\u2199",swArr:"\\u21D9",swarrow:"\\u2199",swnwar:"\\u292A",szlig:"\\xDF",Tab:" ",target:"\\u2316",tau:"\\u03C4",Tau:"\\u03A4",tbrk:"\\u23B4",tcaron:"\\u0165",Tcaron:"\\u0164",tcedil:"\\u0163",Tcedil:"\\u0162",tcy:"\\u0442",Tcy:"\\u0422",tdot:"\\u20DB",telrec:"\\u2315",tfr:"\\u{1D531}",Tfr:"\\u{1D517}",there4:"\\u2234",therefore:"\\u2234",Therefore:"\\u2234",theta:"\\u03B8",Theta:"\\u0398",thetasym:"\\u03D1",thetav:"\\u03D1",thickapprox:"\\u2248",thicksim:"\\u223C",ThickSpace:"\\u205F\\u200A",thinsp:"\\u2009",ThinSpace:"\\u2009",thkap:"\\u2248",thksim:"\\u223C",thorn:"\\xFE",THORN:"\\xDE",tilde:"\\u02DC",Tilde:"\\u223C",TildeEqual:"\\u2243",TildeFullEqual:"\\u2245",TildeTilde:"\\u2248",times:"\\xD7",timesb:"\\u22A0",timesbar:"\\u2A31",timesd:"\\u2A30",tint:"\\u222D",toea:"\\u2928",top:"\\u22A4",topbot:"\\u2336",topcir:"\\u2AF1",topf:"\\u{1D565}",Topf:"\\u{1D54B}",topfork:"\\u2ADA",tosa:"\\u2929",tprime:"\\u2034",trade:"\\u2122",TRADE:"\\u2122",triangle:"\\u25B5",triangledown:"\\u25BF",triangleleft:"\\u25C3",trianglelefteq:"\\u22B4",triangleq:"\\u225C",triangleright:"\\u25B9",trianglerighteq:"\\u22B5",tridot:"\\u25EC",trie:"\\u225C",triminus:"\\u2A3A",TripleDot:"\\u20DB",triplus:"\\u2A39",trisb:"\\u29CD",tritime:"\\u2A3B",trpezium:"\\u23E2",tscr:"\\u{1D4C9}",Tscr:"\\u{1D4AF}",tscy:"\\u0446",TScy:"\\u0426",tshcy:"\\u045B",TSHcy:"\\u040B",tstrok:"\\u0167",Tstrok:"\\u0166",twixt:"\\u226C",twoheadleftarrow:"\\u219E",twoheadrightarrow:"\\u21A0",uacute:"\\xFA",Uacute:"\\xDA",uarr:"\\u2191",uArr:"\\u21D1",Uarr:"\\u219F",Uarrocir:"\\u2949",ubrcy:"\\u045E",Ubrcy:"\\u040E",ubreve:"\\u016D",Ubreve:"\\u016C",ucirc:"\\xFB",Ucirc:"\\xDB",ucy:"\\u0443",Ucy:"\\u0423",udarr:"\\u21C5",udblac:"\\u0171",Udblac:"\\u0170",udhar:"\\u296E",ufisht:"\\u297E",ufr:"\\u{1D532}",Ufr:"\\u{1D518}",ugrave:"\\xF9",Ugrave:"\\xD9",uHar:"\\u2963",uharl:"\\u21BF",uharr:"\\u21BE",uhblk:"\\u2580",ulcorn:"\\u231C",ulcorner:"\\u231C",ulcrop:"\\u230F",ultri:"\\u25F8",umacr:"\\u016B",Umacr:"\\u016A",uml:"\\xA8",UnderBar:"_",UnderBrace:"\\u23DF",UnderBracket:"\\u23B5",UnderParenthesis:"\\u23DD",Union:"\\u22C3",UnionPlus:"\\u228E",uogon:"\\u0173",Uogon:"\\u0172",uopf:"\\u{1D566}",Uopf:"\\u{1D54C}",uparrow:"\\u2191",Uparrow:"\\u21D1",UpArrow:"\\u2191",UpArrowBar:"\\u2912",UpArrowDownArrow:"\\u21C5",updownarrow:"\\u2195",Updownarrow:"\\u21D5",UpDownArrow:"\\u2195",UpEquilibrium:"\\u296E",upharpoonleft:"\\u21BF",upharpoonright:"\\u21BE",uplus:"\\u228E",UpperLeftArrow:"\\u2196",UpperRightArrow:"\\u2197",upsi:"\\u03C5",Upsi:"\\u03D2",upsih:"\\u03D2",upsilon:"\\u03C5",Upsilon:"\\u03A5",UpTee:"\\u22A5",UpTeeArrow:"\\u21A5",upuparrows:"\\u21C8",urcorn:"\\u231D",urcorner:"\\u231D",urcrop:"\\u230E",uring:"\\u016F",Uring:"\\u016E",urtri:"\\u25F9",uscr:"\\u{1D4CA}",Uscr:"\\u{1D4B0}",utdot:"\\u22F0",utilde:"\\u0169",Utilde:"\\u0168",utri:"\\u25B5",utrif:"\\u25B4",uuarr:"\\u21C8",uuml:"\\xFC",Uuml:"\\xDC",uwangle:"\\u29A7",vangrt:"\\u299C",varepsilon:"\\u03F5",varkappa:"\\u03F0",varnothing:"\\u2205",varphi:"\\u03D5",varpi:"\\u03D6",varpropto:"\\u221D",varr:"\\u2195",vArr:"\\u21D5",varrho:"\\u03F1",varsigma:"\\u03C2",varsubsetneq:"\\u228A\\uFE00",varsubsetneqq:"\\u2ACB\\uFE00",varsupsetneq:"\\u228B\\uFE00",varsupsetneqq:"\\u2ACC\\uFE00",vartheta:"\\u03D1",vartriangleleft:"\\u22B2",vartriangleright:"\\u22B3",vBar:"\\u2AE8",Vbar:"\\u2AEB",vBarv:"\\u2AE9",vcy:"\\u0432",Vcy:"\\u0412",vdash:"\\u22A2",vDash:"\\u22A8",Vdash:"\\u22A9",VDash:"\\u22AB",Vdashl:"\\u2AE6",vee:"\\u2228",Vee:"\\u22C1",veebar:"\\u22BB",veeeq:"\\u225A",vellip:"\\u22EE",verbar:"|",Verbar:"\\u2016",vert:"|",Vert:"\\u2016",VerticalBar:"\\u2223",VerticalLine:"|",VerticalSeparator:"\\u2758",VerticalTilde:"\\u2240",VeryThinSpace:"\\u200A",vfr:"\\u{1D533}",Vfr:"\\u{1D519}",vltri:"\\u22B2",vnsub:"\\u2282\\u20D2",vnsup:"\\u2283\\u20D2",vopf:"\\u{1D567}",Vopf:"\\u{1D54D}",vprop:"\\u221D",vrtri:"\\u22B3",vscr:"\\u{1D4CB}",Vscr:"\\u{1D4B1}",vsubne:"\\u228A\\uFE00",vsubnE:"\\u2ACB\\uFE00",vsupne:"\\u228B\\uFE00",vsupnE:"\\u2ACC\\uFE00",Vvdash:"\\u22AA",vzigzag:"\\u299A",wcirc:"\\u0175",Wcirc:"\\u0174",wedbar:"\\u2A5F",wedge:"\\u2227",Wedge:"\\u22C0",wedgeq:"\\u2259",weierp:"\\u2118",wfr:"\\u{1D534}",Wfr:"\\u{1D51A}",wopf:"\\u{1D568}",Wopf:"\\u{1D54E}",wp:"\\u2118",wr:"\\u2240",wreath:"\\u2240",wscr:"\\u{1D4CC}",Wscr:"\\u{1D4B2}",xcap:"\\u22C2",xcirc:"\\u25EF",xcup:"\\u22C3",xdtri:"\\u25BD",xfr:"\\u{1D535}",Xfr:"\\u{1D51B}",xharr:"\\u27F7",xhArr:"\\u27FA",xi:"\\u03BE",Xi:"\\u039E",xlarr:"\\u27F5",xlArr:"\\u27F8",xmap:"\\u27FC",xnis:"\\u22FB",xodot:"\\u2A00",xopf:"\\u{1D569}",Xopf:"\\u{1D54F}",xoplus:"\\u2A01",xotime:"\\u2A02",xrarr:"\\u27F6",xrArr:"\\u27F9",xscr:"\\u{1D4CD}",Xscr:"\\u{1D4B3}",xsqcup:"\\u2A06",xuplus:"\\u2A04",xutri:"\\u25B3",xvee:"\\u22C1",xwedge:"\\u22C0",yacute:"\\xFD",Yacute:"\\xDD",yacy:"\\u044F",YAcy:"\\u042F",ycirc:"\\u0177",Ycirc:"\\u0176",ycy:"\\u044B",Ycy:"\\u042B",yen:"\\xA5",yfr:"\\u{1D536}",Yfr:"\\u{1D51C}",yicy:"\\u0457",YIcy:"\\u0407",yopf:"\\u{1D56A}",Yopf:"\\u{1D550}",yscr:"\\u{1D4CE}",Yscr:"\\u{1D4B4}",yucy:"\\u044E",YUcy:"\\u042E",yuml:"\\xFF",Yuml:"\\u0178",zacute:"\\u017A",Zacute:"\\u0179",zcaron:"\\u017E",Zcaron:"\\u017D",zcy:"\\u0437",Zcy:"\\u0417",zdot:"\\u017C",Zdot:"\\u017B",zeetrf:"\\u2128",ZeroWidthSpace:"\\u200B",zeta:"\\u03B6",Zeta:"\\u0396",zfr:"\\u{1D537}",Zfr:"\\u2128",zhcy:"\\u0436",ZHcy:"\\u0416",zigrarr:"\\u21DD",zopf:"\\u{1D56B}",Zopf:"\\u2124",zscr:"\\u{1D4CF}",Zscr:"\\u{1D4B5}",zwj:"\\u200D",zwnj:"\\u200C"},g={aacute:"\\xE1",Aacute:"\\xC1",acirc:"\\xE2",Acirc:"\\xC2",acute:"\\xB4",aelig:"\\xE6",AElig:"\\xC6",agrave:"\\xE0",Agrave:"\\xC0",amp:"&",AMP:"&",aring:"\\xE5",Aring:"\\xC5",atilde:"\\xE3",Atilde:"\\xC3",auml:"\\xE4",Auml:"\\xC4",brvbar:"\\xA6",ccedil:"\\xE7",Ccedil:"\\xC7",cedil:"\\xB8",cent:"\\xA2",copy:"\\xA9",COPY:"\\xA9",curren:"\\xA4",deg:"\\xB0",divide:"\\xF7",eacute:"\\xE9",Eacute:"\\xC9",ecirc:"\\xEA",Ecirc:"\\xCA",egrave:"\\xE8",Egrave:"\\xC8",eth:"\\xF0",ETH:"\\xD0",euml:"\\xEB",Euml:"\\xCB",frac12:"\\xBD",frac14:"\\xBC",frac34:"\\xBE",gt:">",GT:">",iacute:"\\xED",Iacute:"\\xCD",icirc:"\\xEE",Icirc:"\\xCE",iexcl:"\\xA1",igrave:"\\xEC",Igrave:"\\xCC",iquest:"\\xBF",iuml:"\\xEF",Iuml:"\\xCF",laquo:"\\xAB",lt:"<",LT:"<",macr:"\\xAF",micro:"\\xB5",middot:"\\xB7",nbsp:"\\xA0",not:"\\xAC",ntilde:"\\xF1",Ntilde:"\\xD1",oacute:"\\xF3",Oacute:"\\xD3",ocirc:"\\xF4",Ocirc:"\\xD4",ograve:"\\xF2",Ograve:"\\xD2",ordf:"\\xAA",ordm:"\\xBA",oslash:"\\xF8",Oslash:"\\xD8",otilde:"\\xF5",Otilde:"\\xD5",ouml:"\\xF6",Ouml:"\\xD6",para:"\\xB6",plusmn:"\\xB1",pound:"\\xA3",quot:\'"\',QUOT:\'"\',raquo:"\\xBB",reg:"\\xAE",REG:"\\xAE",sect:"\\xA7",shy:"\\xAD",sup1:"\\xB9",sup2:"\\xB2",sup3:"\\xB3",szlig:"\\xDF",thorn:"\\xFE",THORN:"\\xDE",times:"\\xD7",uacute:"\\xFA",Uacute:"\\xDA",ucirc:"\\xFB",Ucirc:"\\xDB",ugrave:"\\xF9",Ugrave:"\\xD9",uml:"\\xA8",uuml:"\\xFC",Uuml:"\\xDC",yacute:"\\xFD",Yacute:"\\xDD",yen:"\\xA5",yuml:"\\xFF"},A={0:"\\uFFFD",128:"\\u20AC",130:"\\u201A",131:"\\u0192",132:"\\u201E",133:"\\u2026",134:"\\u2020",135:"\\u2021",136:"\\u02C6",137:"\\u2030",138:"\\u0160",139:"\\u2039",140:"\\u0152",142:"\\u017D",145:"\\u2018",146:"\\u2019",147:"\\u201C",148:"\\u201D",149:"\\u2022",150:"\\u2013",151:"\\u2014",152:"\\u02DC",153:"\\u2122",154:"\\u0161",155:"\\u203A",156:"\\u0153",158:"\\u017E",159:"\\u0178"},y=[1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65e3,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111],w=String.fromCharCode,E={},z=E.hasOwnProperty,P=function(I,O){return z.call(I,O)},G=function(I,O){for(var D=-1,v=I.length;++D<v;)if(I[D]==O)return!0;return!1},R=function(I,O){if(!I)return O;var D={},v;for(v in O)D[v]=P(I,v)?I[v]:O[v];return D},V=function(I,O){var D="";return I>=55296&&I<=57343||I>1114111?(O&&S("character reference outside the permissible Unicode range"),"\\uFFFD"):P(A,I)?(O&&S("disallowed character reference"),A[I]):(O&&G(y,I)&&S("disallowed character reference"),I>65535&&(I-=65536,D+=w(I>>>10&1023|55296),I=56320|I&1023),D+=w(I),D)},X=function(I){return"&#x"+I.toString(16).toUpperCase()+";"},C=function(I){return"&#"+I+";"},S=function(I){throw Error("Parse error: "+I)},h=function(I,O){O=R(O,h.options);var D=O.strict;D&&b.test(I)&&S("forbidden code point");var v=O.encodeEverything,j=O.useNamedReferences,W=O.allowUnsafeSymbols,Z=O.decimal?C:X,ee=function(te){return Z(te.charCodeAt(0))};return v?(I=I.replace(i,function(te){return j&&P(u,te)?"&"+u[te]+";":ee(te)}),j&&(I=I.replace(/>\\u20D2/g,">⃒").replace(/<\\u20D2/g,"<⃒").replace(/fj/g,"fj")),j&&(I=I.replace(o,function(te){return"&"+u[te]+";"}))):j?(W||(I=I.replace(d,function(te){return"&"+u[te]+";"})),I=I.replace(/>\\u20D2/g,">⃒").replace(/<\\u20D2/g,"<⃒"),I=I.replace(o,function(te){return"&"+u[te]+";"})):W||(I=I.replace(d,ee)),I.replace(n,function(te){var K=te.charCodeAt(0),re=te.charCodeAt(1),le=(K-55296)*1024+re-56320+65536;return Z(le)}).replace(a,ee)};h.options={allowUnsafeSymbols:!1,encodeEverything:!1,strict:!1,useNamedReferences:!1,decimal:!1};var k=function(I,O){O=R(O,k.options);var D=O.strict;return D&&l.test(I)&&S("malformed character reference"),I.replace(f,function(v,j,W,Z,ee,te,K,re,le){var ue,fe,me,c,L,T;return j?(L=j,m[L]):W?(L=W,T=Z,T&&O.isAttributeValue?(D&&T=="="&&S("`&` did not start a character reference"),v):(D&&S("named character reference was not terminated by a semicolon"),g[L]+(T||""))):ee?(me=ee,fe=te,D&&!fe&&S("character reference was not terminated by a semicolon"),ue=parseInt(me,10),V(ue,D)):K?(c=K,fe=re,D&&!fe&&S("character reference was not terminated by a semicolon"),ue=parseInt(c,16),V(ue,D)):(D&&S("named character reference was not terminated by a semicolon"),v)})};k.options={isAttributeValue:!1,strict:!1};var Y=function(I){return I.replace(d,function(O){return p[O]})},F={version:"1.2.0",encode:h,decode:k,escape:Y,unescape:k};if(typeof define=="function"&&typeof define.amd=="object"&&define.amd)define(function(){return F});else if(e&&!e.nodeType)if(t)t.exports=F;else for(var q in F)P(F,q)&&(e[q]=F[q]);else s.he=F})(nt)});var kt=ge((gr,It)=>{(function(s){typeof gr=="object"&&typeof It<"u"?It.exports=s():typeof define=="function"&&define.amd?define([],s):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=s()})(function(){return function s(e,t,r){function n(o,u){if(!t[o]){if(!e[o]){var d=typeof Ye=="function"&&Ye;if(!u&&d)return d(o,!0);if(i)return i(o,!0);var p=new Error("Cannot find module \'"+o+"\'");throw p.code="MODULE_NOT_FOUND",p}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(b){var f=e[o][1][b];return n(f||b)},l,l.exports,s,e,t,r)}return t[o].exports}for(var i=typeof Ye=="function"&&Ye,a=0;a<r.length;a++)n(r[a]);return n}({1:[function(s,e,t){"use strict";var r=s("./utils"),n=s("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.encode=function(a){for(var o,u,d,p,l,b,f,m=[],g=0,A=a.length,y=A,w=r.getTypeOf(a)!=="string";g<a.length;)y=A-g,d=w?(o=a[g++],u=g<A?a[g++]:0,g<A?a[g++]:0):(o=a.charCodeAt(g++),u=g<A?a.charCodeAt(g++):0,g<A?a.charCodeAt(g++):0),p=o>>2,l=(3&o)<<4|u>>4,b=1<y?(15&u)<<2|d>>6:64,f=2<y?63&d:64,m.push(i.charAt(p)+i.charAt(l)+i.charAt(b)+i.charAt(f));return m.join("")},t.decode=function(a){var o,u,d,p,l,b,f=0,m=0,g="data:";if(a.substr(0,g.length)===g)throw new Error("Invalid base64 input, it looks like a data url.");var A,y=3*(a=a.replace(/[^A-Za-z0-9\\+\\/\\=]/g,"")).length/4;if(a.charAt(a.length-1)===i.charAt(64)&&y--,a.charAt(a.length-2)===i.charAt(64)&&y--,y%1!=0)throw new Error("Invalid base64 input, bad content length.");for(A=n.uint8array?new Uint8Array(0|y):new Array(0|y);f<a.length;)o=i.indexOf(a.charAt(f++))<<2|(p=i.indexOf(a.charAt(f++)))>>4,u=(15&p)<<4|(l=i.indexOf(a.charAt(f++)))>>2,d=(3&l)<<6|(b=i.indexOf(a.charAt(f++))),A[m++]=o,l!==64&&(A[m++]=u),b!==64&&(A[m++]=d);return A}},{"./support":30,"./utils":32}],2:[function(s,e,t){"use strict";var r=s("./external"),n=s("./stream/DataWorker"),i=s("./stream/Crc32Probe"),a=s("./stream/DataLengthProbe");function o(u,d,p,l,b){this.compressedSize=u,this.uncompressedSize=d,this.crc32=p,this.compression=l,this.compressedContent=b}o.prototype={getContentWorker:function(){var u=new n(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),d=this;return u.on("end",function(){if(this.streamInfo.data_length!==d.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new n(r.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(u,d,p){return u.pipe(new i).pipe(new a("uncompressedSize")).pipe(d.compressWorker(p)).pipe(new a("compressedSize")).withStreamInfo("compression",d)},e.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(s,e,t){"use strict";var r=s("./stream/GenericWorker");t.STORE={magic:"\\0\\0",compressWorker:function(n){return new r("STORE compression")},uncompressWorker:function(){return new r("STORE decompression")}},t.DEFLATE=s("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(s,e,t){"use strict";var r=s("./utils"),n=function(){for(var i,a=[],o=0;o<256;o++){i=o;for(var u=0;u<8;u++)i=1&i?3988292384^i>>>1:i>>>1;a[o]=i}return a}();e.exports=function(i,a){return i!==void 0&&i.length?r.getTypeOf(i)!=="string"?function(o,u,d,p){var l=n,b=p+d;o^=-1;for(var f=p;f<b;f++)o=o>>>8^l[255&(o^u[f])];return-1^o}(0|a,i,i.length,0):function(o,u,d,p){var l=n,b=p+d;o^=-1;for(var f=p;f<b;f++)o=o>>>8^l[255&(o^u.charCodeAt(f))];return-1^o}(0|a,i,i.length,0):0}},{"./utils":32}],5:[function(s,e,t){"use strict";t.base64=!1,t.binary=!1,t.dir=!1,t.createFolders=!0,t.date=null,t.compression=null,t.compressionOptions=null,t.comment=null,t.unixPermissions=null,t.dosPermissions=null},{}],6:[function(s,e,t){"use strict";var r=null;r=typeof Promise<"u"?Promise:s("lie"),e.exports={Promise:r}},{lie:37}],7:[function(s,e,t){"use strict";var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",n=s("pako"),i=s("./utils"),a=s("./stream/GenericWorker"),o=r?"uint8array":"array";function u(d,p){a.call(this,"FlateWorker/"+d),this._pako=null,this._pakoAction=d,this._pakoOptions=p,this.meta={}}t.magic="\\b\\0",i.inherits(u,a),u.prototype.processChunk=function(d){this.meta=d.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(o,d.data),!1)},u.prototype.flush=function(){a.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var d=this;this._pako.onData=function(p){d.push({data:p,meta:d.meta})}},t.compressWorker=function(d){return new u("Deflate",d)},t.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(s,e,t){"use strict";function r(l,b){var f,m="";for(f=0;f<b;f++)m+=String.fromCharCode(255&l),l>>>=8;return m}function n(l,b,f,m,g,A){var y,w,E=l.file,z=l.compression,P=A!==o.utf8encode,G=i.transformTo("string",A(E.name)),R=i.transformTo("string",o.utf8encode(E.name)),V=E.comment,X=i.transformTo("string",A(V)),C=i.transformTo("string",o.utf8encode(V)),S=R.length!==E.name.length,h=C.length!==V.length,k="",Y="",F="",q=E.dir,I=E.date,O={crc32:0,compressedSize:0,uncompressedSize:0};b&&!f||(O.crc32=l.crc32,O.compressedSize=l.compressedSize,O.uncompressedSize=l.uncompressedSize);var D=0;b&&(D|=8),P||!S&&!h||(D|=2048);var v=0,j=0;q&&(v|=16),g==="UNIX"?(j=798,v|=function(Z,ee){var te=Z;return Z||(te=ee?16893:33204),(65535&te)<<16}(E.unixPermissions,q)):(j=20,v|=function(Z){return 63&(Z||0)}(E.dosPermissions)),y=I.getUTCHours(),y<<=6,y|=I.getUTCMinutes(),y<<=5,y|=I.getUTCSeconds()/2,w=I.getUTCFullYear()-1980,w<<=4,w|=I.getUTCMonth()+1,w<<=5,w|=I.getUTCDate(),S&&(Y=r(1,1)+r(u(G),4)+R,k+="up"+r(Y.length,2)+Y),h&&(F=r(1,1)+r(u(X),4)+C,k+="uc"+r(F.length,2)+F);var W="";return W+=`\n\\0`,W+=r(D,2),W+=z.magic,W+=r(y,2),W+=r(w,2),W+=r(O.crc32,4),W+=r(O.compressedSize,4),W+=r(O.uncompressedSize,4),W+=r(G.length,2),W+=r(k.length,2),{fileRecord:d.LOCAL_FILE_HEADER+W+G+k,dirRecord:d.CENTRAL_FILE_HEADER+r(j,2)+W+r(X.length,2)+"\\0\\0\\0\\0"+r(v,4)+r(m,4)+G+k+X}}var i=s("../utils"),a=s("../stream/GenericWorker"),o=s("../utf8"),u=s("../crc32"),d=s("../signature");function p(l,b,f,m){a.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=f,this.encodeFileName=m,this.streamFiles=l,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(p,a),p.prototype.push=function(l){var b=l.meta.percent||0,f=this.entriesCount,m=this._sources.length;this.accumulate?this.contentBuffer.push(l):(this.bytesWritten+=l.data.length,a.prototype.push.call(this,{data:l.data,meta:{currentFile:this.currentFile,percent:f?(b+100*(f-m-1))/f:100}}))},p.prototype.openedSource=function(l){this.currentSourceOffset=this.bytesWritten,this.currentFile=l.file.name;var b=this.streamFiles&&!l.file.dir;if(b){var f=n(l,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:f.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(l){this.accumulate=!1;var b=this.streamFiles&&!l.file.dir,f=n(l,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(f.dirRecord),b)this.push({data:function(m){return d.DATA_DESCRIPTOR+r(m.crc32,4)+r(m.compressedSize,4)+r(m.uncompressedSize,4)}(l),meta:{percent:100}});else for(this.push({data:f.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var l=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var f=this.bytesWritten-l,m=function(g,A,y,w,E){var z=i.transformTo("string",E(w));return d.CENTRAL_DIRECTORY_END+"\\0\\0\\0\\0"+r(g,2)+r(g,2)+r(A,4)+r(y,4)+r(z.length,2)+z}(this.dirRecords.length,f,l,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(l){this._sources.push(l);var b=this;return l.on("data",function(f){b.processChunk(f)}),l.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),l.on("error",function(f){b.error(f)}),this},p.prototype.resume=function(){return!!a.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(l){var b=this._sources;if(!a.prototype.error.call(this,l))return!1;for(var f=0;f<b.length;f++)try{b[f].error(l)}catch{}return!0},p.prototype.lock=function(){a.prototype.lock.call(this);for(var l=this._sources,b=0;b<l.length;b++)l[b].lock()},e.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(s,e,t){"use strict";var r=s("../compressions"),n=s("./ZipFileWorker");t.generateWorker=function(i,a,o){var u=new n(a.streamFiles,o,a.platform,a.encodeFileName),d=0;try{i.forEach(function(p,l){d++;var b=function(A,y){var w=A||y,E=r[w];if(!E)throw new Error(w+" is not a valid compression method !");return E}(l.options.compression,a.compression),f=l.options.compressionOptions||a.compressionOptions||{},m=l.dir,g=l.date;l._compressWorker(b,f).withStreamInfo("file",{name:p,dir:m,date:g,comment:l.comment||"",unixPermissions:l.unixPermissions,dosPermissions:l.dosPermissions}).pipe(u)}),u.entriesCount=d}catch(p){u.error(p)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(s,e,t){"use strict";function r(){if(!(this instanceof r))return new r;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var n=new r;for(var i in this)typeof this[i]!="function"&&(n[i]=this[i]);return n}}(r.prototype=s("./object")).loadAsync=s("./load"),r.support=s("./support"),r.defaults=s("./defaults"),r.version="3.10.0",r.loadAsync=function(n,i){return new r().loadAsync(n,i)},r.external=s("./external"),e.exports=r},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(s,e,t){"use strict";var r=s("./utils"),n=s("./external"),i=s("./utf8"),a=s("./zipEntries"),o=s("./stream/Crc32Probe"),u=s("./nodejsUtils");function d(p){return new n.Promise(function(l,b){var f=p.decompressed.getContentWorker().pipe(new o);f.on("error",function(m){b(m)}).on("end",function(){f.streamInfo.crc32!==p.decompressed.crc32?b(new Error("Corrupted zip : CRC32 mismatch")):l()}).resume()})}e.exports=function(p,l){var b=this;return l=r.extend(l||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),u.isNode&&u.isStream(p)?n.Promise.reject(new Error("JSZip can\'t accept a stream when loading a zip file.")):r.prepareContent("the loaded zip file",p,!0,l.optimizedBinaryString,l.base64).then(function(f){var m=new a(l);return m.load(f),m}).then(function(f){var m=[n.Promise.resolve(f)],g=f.files;if(l.checkCRC32)for(var A=0;A<g.length;A++)m.push(d(g[A]));return n.Promise.all(m)}).then(function(f){for(var m=f.shift(),g=m.files,A=0;A<g.length;A++){var y=g[A],w=y.fileNameStr,E=r.resolve(y.fileNameStr);b.file(E,y.decompressed,{binary:!0,optimizedBinaryString:!0,date:y.date,dir:y.dir,comment:y.fileCommentStr.length?y.fileCommentStr:null,unixPermissions:y.unixPermissions,dosPermissions:y.dosPermissions,createFolders:l.createFolders}),y.dir||(b.file(E).unsafeOriginalName=w)}return m.zipComment.length&&(b.comment=m.zipComment),b})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(s,e,t){"use strict";var r=s("../utils"),n=s("../stream/GenericWorker");function i(a,o){n.call(this,"Nodejs stream input adapter for "+a),this._upstreamEnded=!1,this._bindStream(o)}r.inherits(i,n),i.prototype._bindStream=function(a){var o=this;(this._stream=a).pause(),a.on("data",function(u){o.push({data:u,meta:{percent:0}})}).on("error",function(u){o.isPaused?this.generatedError=u:o.error(u)}).on("end",function(){o.isPaused?o._upstreamEnded=!0:o.end()})},i.prototype.pause=function(){return!!n.prototype.pause.call(this)&&(this._stream.pause(),!0)},i.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},e.exports=i},{"../stream/GenericWorker":28,"../utils":32}],13:[function(s,e,t){"use strict";var r=s("readable-stream").Readable;function n(i,a,o){r.call(this,a),this._helper=i;var u=this;i.on("data",function(d,p){u.push(d)||u._helper.pause(),o&&o(p)}).on("error",function(d){u.emit("error",d)}).on("end",function(){u.push(null)})}s("../utils").inherits(n,r),n.prototype._read=function(){this._helper.resume()},e.exports=n},{"../utils":32,"readable-stream":16}],14:[function(s,e,t){"use strict";e.exports={isNode:typeof Buffer<"u",newBufferFrom:function(r,n){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(r,n);if(typeof r=="number")throw new Error(\'The "data" argument must not be a number\');return new Buffer(r,n)},allocBuffer:function(r){if(Buffer.alloc)return Buffer.alloc(r);var n=new Buffer(r);return n.fill(0),n},isBuffer:function(r){return Buffer.isBuffer(r)},isStream:function(r){return r&&typeof r.on=="function"&&typeof r.pause=="function"&&typeof r.resume=="function"}}},{}],15:[function(s,e,t){"use strict";function r(E,z,P){var G,R=i.getTypeOf(z),V=i.extend(P||{},u);V.date=V.date||new Date,V.compression!==null&&(V.compression=V.compression.toUpperCase()),typeof V.unixPermissions=="string"&&(V.unixPermissions=parseInt(V.unixPermissions,8)),V.unixPermissions&&16384&V.unixPermissions&&(V.dir=!0),V.dosPermissions&&16&V.dosPermissions&&(V.dir=!0),V.dir&&(E=g(E)),V.createFolders&&(G=m(E))&&A.call(this,G,!0);var X=R==="string"&&V.binary===!1&&V.base64===!1;P&&P.binary!==void 0||(V.binary=!X),(z instanceof d&&z.uncompressedSize===0||V.dir||!z||z.length===0)&&(V.base64=!1,V.binary=!0,z="",V.compression="STORE",R="string");var C=null;C=z instanceof d||z instanceof a?z:b.isNode&&b.isStream(z)?new f(E,z):i.prepareContent(E,z,V.binary,V.optimizedBinaryString,V.base64);var S=new p(E,C,V);this.files[E]=S}var n=s("./utf8"),i=s("./utils"),a=s("./stream/GenericWorker"),o=s("./stream/StreamHelper"),u=s("./defaults"),d=s("./compressedObject"),p=s("./zipObject"),l=s("./generate"),b=s("./nodejsUtils"),f=s("./nodejs/NodejsStreamInputAdapter"),m=function(E){E.slice(-1)==="/"&&(E=E.substring(0,E.length-1));var z=E.lastIndexOf("/");return 0<z?E.substring(0,z):""},g=function(E){return E.slice(-1)!=="/"&&(E+="/"),E},A=function(E,z){return z=z!==void 0?z:u.createFolders,E=g(E),this.files[E]||r.call(this,E,null,{dir:!0,createFolders:z}),this.files[E]};function y(E){return Object.prototype.toString.call(E)==="[object RegExp]"}var w={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(E){var z,P,G;for(z in this.files)G=this.files[z],(P=z.slice(this.root.length,z.length))&&z.slice(0,this.root.length)===this.root&&E(P,G)},filter:function(E){var z=[];return this.forEach(function(P,G){E(P,G)&&z.push(G)}),z},file:function(E,z,P){if(arguments.length!==1)return E=this.root+E,r.call(this,E,z,P),this;if(y(E)){var G=E;return this.filter(function(V,X){return!X.dir&&G.test(V)})}var R=this.files[this.root+E];return R&&!R.dir?R:null},folder:function(E){if(!E)return this;if(y(E))return this.filter(function(R,V){return V.dir&&E.test(R)});var z=this.root+E,P=A.call(this,z),G=this.clone();return G.root=P.name,G},remove:function(E){E=this.root+E;var z=this.files[E];if(z||(E.slice(-1)!=="/"&&(E+="/"),z=this.files[E]),z&&!z.dir)delete this.files[E];else for(var P=this.filter(function(R,V){return V.name.slice(0,E.length)===E}),G=0;G<P.length;G++)delete this.files[P[G].name];return this},generate:function(E){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(E){var z,P={};try{if((P=i.extend(E||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:n.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");i.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var G=P.comment||this.comment||"";z=l.generateWorker(this,P,G)}catch(R){(z=new a("error")).error(R)}return new o(z,P.type||"string",P.mimeType)},generateAsync:function(E,z){return this.generateInternalStream(E).accumulate(z)},generateNodeStream:function(E,z){return(E=E||{}).type||(E.type="nodebuffer"),this.generateInternalStream(E).toNodejsStream(z)}};e.exports=w},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(s,e,t){e.exports=s("stream")},{stream:void 0}],17:[function(s,e,t){"use strict";var r=s("./DataReader");function n(i){r.call(this,i);for(var a=0;a<this.data.length;a++)i[a]=255&i[a]}s("../utils").inherits(n,r),n.prototype.byteAt=function(i){return this.data[this.zero+i]},n.prototype.lastIndexOfSignature=function(i){for(var a=i.charCodeAt(0),o=i.charCodeAt(1),u=i.charCodeAt(2),d=i.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===a&&this.data[p+1]===o&&this.data[p+2]===u&&this.data[p+3]===d)return p-this.zero;return-1},n.prototype.readAndCheckSignature=function(i){var a=i.charCodeAt(0),o=i.charCodeAt(1),u=i.charCodeAt(2),d=i.charCodeAt(3),p=this.readData(4);return a===p[0]&&o===p[1]&&u===p[2]&&d===p[3]},n.prototype.readData=function(i){if(this.checkOffset(i),i===0)return[];var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./DataReader":18}],18:[function(s,e,t){"use strict";var r=s("../utils");function n(i){this.data=i,this.length=i.length,this.index=0,this.zero=0}n.prototype={checkOffset:function(i){this.checkIndex(this.index+i)},checkIndex:function(i){if(this.length<this.zero+i||i<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+i+"). Corrupted zip ?")},setIndex:function(i){this.checkIndex(i),this.index=i},skip:function(i){this.setIndex(this.index+i)},byteAt:function(i){},readInt:function(i){var a,o=0;for(this.checkOffset(i),a=this.index+i-1;a>=this.index;a--)o=(o<<8)+this.byteAt(a);return this.index+=i,o},readString:function(i){return r.transformTo("string",this.readData(i))},readData:function(i){},lastIndexOfSignature:function(i){},readAndCheckSignature:function(i){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},e.exports=n},{"../utils":32}],19:[function(s,e,t){"use strict";var r=s("./Uint8ArrayReader");function n(i){r.call(this,i)}s("../utils").inherits(n,r),n.prototype.readData=function(i){this.checkOffset(i);var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(s,e,t){"use strict";var r=s("./DataReader");function n(i){r.call(this,i)}s("../utils").inherits(n,r),n.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},n.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},n.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},n.prototype.readData=function(i){this.checkOffset(i);var a=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./DataReader":18}],21:[function(s,e,t){"use strict";var r=s("./ArrayReader");function n(i){r.call(this,i)}s("../utils").inherits(n,r),n.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var a=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,a},e.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(s,e,t){"use strict";var r=s("../utils"),n=s("../support"),i=s("./ArrayReader"),a=s("./StringReader"),o=s("./NodeBufferReader"),u=s("./Uint8ArrayReader");e.exports=function(d){var p=r.getTypeOf(d);return r.checkSupport(p),p!=="string"||n.uint8array?p==="nodebuffer"?new o(d):n.uint8array?new u(r.transformTo("uint8array",d)):new i(r.transformTo("array",d)):new a(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(s,e,t){"use strict";t.LOCAL_FILE_HEADER="PK",t.CENTRAL_FILE_HEADER="PK",t.CENTRAL_DIRECTORY_END="PK",t.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\\x07",t.ZIP64_CENTRAL_DIRECTORY_END="PK",t.DATA_DESCRIPTOR="PK\\x07\\b"},{}],24:[function(s,e,t){"use strict";var r=s("./GenericWorker"),n=s("../utils");function i(a){r.call(this,"ConvertWorker to "+a),this.destType=a}n.inherits(i,r),i.prototype.processChunk=function(a){this.push({data:n.transformTo(this.destType,a.data),meta:a.meta})},e.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(s,e,t){"use strict";var r=s("./GenericWorker"),n=s("../crc32");function i(){r.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}s("../utils").inherits(i,r),i.prototype.processChunk=function(a){this.streamInfo.crc32=n(a.data,this.streamInfo.crc32||0),this.push(a)},e.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(s,e,t){"use strict";var r=s("../utils"),n=s("./GenericWorker");function i(a){n.call(this,"DataLengthProbe for "+a),this.propName=a,this.withStreamInfo(a,0)}r.inherits(i,n),i.prototype.processChunk=function(a){if(a){var o=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=o+a.data.length}n.prototype.processChunk.call(this,a)},e.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(s,e,t){"use strict";var r=s("../utils"),n=s("./GenericWorker");function i(a){n.call(this,"DataWorker");var o=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,a.then(function(u){o.dataIsReady=!0,o.data=u,o.max=u&&u.length||0,o.type=r.getTypeOf(u),o.isPaused||o._tickAndRepeat()},function(u){o.error(u)})}r.inherits(i,n),i.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var a=null,o=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":a=this.data.substring(this.index,o);break;case"uint8array":a=this.data.subarray(this.index,o);break;case"array":case"nodebuffer":a=this.data.slice(this.index,o)}return this.index=o,this.push({data:a,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(s,e,t){"use strict";function r(n){this.name=n||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(n){this.emit("data",n)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(n){this.emit("error",n)}return!0},error:function(n){return!this.isFinished&&(this.isPaused?this.generatedError=n:(this.isFinished=!0,this.emit("error",n),this.previous&&this.previous.error(n),this.cleanUp()),!0)},on:function(n,i){return this._listeners[n].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(n,i){if(this._listeners[n])for(var a=0;a<this._listeners[n].length;a++)this._listeners[n][a].call(this,i)},pipe:function(n){return n.registerPrevious(this)},registerPrevious:function(n){if(this.isLocked)throw new Error("The stream \'"+this+"\' has already been used.");this.streamInfo=n.streamInfo,this.mergeStreamInfo(),this.previous=n;var i=this;return n.on("data",function(a){i.processChunk(a)}),n.on("end",function(){i.end()}),n.on("error",function(a){i.error(a)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var n=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),n=!0),this.previous&&this.previous.resume(),!n},flush:function(){},processChunk:function(n){this.push(n)},withStreamInfo:function(n,i){return this.extraStreamInfo[n]=i,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var n in this.extraStreamInfo)this.extraStreamInfo.hasOwnProperty(n)&&(this.streamInfo[n]=this.extraStreamInfo[n])},lock:function(){if(this.isLocked)throw new Error("The stream \'"+this+"\' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var n="Worker "+this.name;return this.previous?this.previous+" -> "+n:n}},e.exports=r},{}],29:[function(s,e,t){"use strict";var r=s("../utils"),n=s("./ConvertWorker"),i=s("./GenericWorker"),a=s("../base64"),o=s("../support"),u=s("../external"),d=null;if(o.nodestream)try{d=s("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(b,f){return new u.Promise(function(m,g){var A=[],y=b._internalType,w=b._outputType,E=b._mimeType;b.on("data",function(z,P){A.push(z),f&&f(P)}).on("error",function(z){A=[],g(z)}).on("end",function(){try{var z=function(P,G,R){switch(P){case"blob":return r.newBlob(r.transformTo("arraybuffer",G),R);case"base64":return a.encode(G);default:return r.transformTo(P,G)}}(w,function(P,G){var R,V=0,X=null,C=0;for(R=0;R<G.length;R++)C+=G[R].length;switch(P){case"string":return G.join("");case"array":return Array.prototype.concat.apply([],G);case"uint8array":for(X=new Uint8Array(C),R=0;R<G.length;R++)X.set(G[R],V),V+=G[R].length;return X;case"nodebuffer":return Buffer.concat(G);default:throw new Error("concat : unsupported type \'"+P+"\'")}}(y,A),E);m(z)}catch(P){g(P)}A=[]}).resume()})}function l(b,f,m){var g=f;switch(f){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=f,this._mimeType=m,r.checkSupport(g),this._worker=b.pipe(new n(g)),b.lock()}catch(A){this._worker=new i("error"),this._worker.error(A)}}l.prototype={accumulate:function(b){return p(this,b)},on:function(b,f){var m=this;return b==="data"?this._worker.on(b,function(g){f.call(m,g.data,g.meta)}):this._worker.on(b,function(){r.delay(f,arguments,m)}),this},resume:function(){return r.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(b){if(r.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},b)}},e.exports=l},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(s,e,t){"use strict";if(t.base64=!0,t.array=!0,t.string=!0,t.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",t.nodebuffer=typeof Buffer<"u",t.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")t.blob=!1;else{var r=new ArrayBuffer(0);try{t.blob=new Blob([r],{type:"application/zip"}).size===0}catch{try{var n=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);n.append(r),t.blob=n.getBlob("application/zip").size===0}catch{t.blob=!1}}}try{t.nodestream=!!s("readable-stream").Readable}catch{t.nodestream=!1}},{"readable-stream":16}],31:[function(s,e,t){"use strict";for(var r=s("./utils"),n=s("./support"),i=s("./nodejsUtils"),a=s("./stream/GenericWorker"),o=new Array(256),u=0;u<256;u++)o[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;o[254]=o[254]=1;function d(){a.call(this,"utf-8 decode"),this.leftOver=null}function p(){a.call(this,"utf-8 encode")}t.utf8encode=function(l){return n.nodebuffer?i.newBufferFrom(l,"utf-8"):function(b){var f,m,g,A,y,w=b.length,E=0;for(A=0;A<w;A++)(64512&(m=b.charCodeAt(A)))==55296&&A+1<w&&(64512&(g=b.charCodeAt(A+1)))==56320&&(m=65536+(m-55296<<10)+(g-56320),A++),E+=m<128?1:m<2048?2:m<65536?3:4;for(f=n.uint8array?new Uint8Array(E):new Array(E),A=y=0;y<E;A++)(64512&(m=b.charCodeAt(A)))==55296&&A+1<w&&(64512&(g=b.charCodeAt(A+1)))==56320&&(m=65536+(m-55296<<10)+(g-56320),A++),m<128?f[y++]=m:(m<2048?f[y++]=192|m>>>6:(m<65536?f[y++]=224|m>>>12:(f[y++]=240|m>>>18,f[y++]=128|m>>>12&63),f[y++]=128|m>>>6&63),f[y++]=128|63&m);return f}(l)},t.utf8decode=function(l){return n.nodebuffer?r.transformTo("nodebuffer",l).toString("utf-8"):function(b){var f,m,g,A,y=b.length,w=new Array(2*y);for(f=m=0;f<y;)if((g=b[f++])<128)w[m++]=g;else if(4<(A=o[g]))w[m++]=65533,f+=A-1;else{for(g&=A===2?31:A===3?15:7;1<A&&f<y;)g=g<<6|63&b[f++],A--;1<A?w[m++]=65533:g<65536?w[m++]=g:(g-=65536,w[m++]=55296|g>>10&1023,w[m++]=56320|1023&g)}return w.length!==m&&(w.subarray?w=w.subarray(0,m):w.length=m),r.applyFromCharCode(w)}(l=r.transformTo(n.uint8array?"uint8array":"array",l))},r.inherits(d,a),d.prototype.processChunk=function(l){var b=r.transformTo(n.uint8array?"uint8array":"array",l.data);if(this.leftOver&&this.leftOver.length){if(n.uint8array){var f=b;(b=new Uint8Array(f.length+this.leftOver.length)).set(this.leftOver,0),b.set(f,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var m=function(A,y){var w;for((y=y||A.length)>A.length&&(y=A.length),w=y-1;0<=w&&(192&A[w])==128;)w--;return w<0||w===0?y:w+o[A[w]]>y?w:y}(b),g=b;m!==b.length&&(n.uint8array?(g=b.subarray(0,m),this.leftOver=b.subarray(m,b.length)):(g=b.slice(0,m),this.leftOver=b.slice(m,b.length))),this.push({data:t.utf8decode(g),meta:l.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:t.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},t.Utf8DecodeWorker=d,r.inherits(p,a),p.prototype.processChunk=function(l){this.push({data:t.utf8encode(l.data),meta:l.meta})},t.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(s,e,t){"use strict";var r=s("./support"),n=s("./base64"),i=s("./nodejsUtils"),a=s("./external");function o(f){return f}function u(f,m){for(var g=0;g<f.length;++g)m[g]=255&f.charCodeAt(g);return m}s("setimmediate"),t.newBlob=function(f,m){t.checkSupport("blob");try{return new Blob([f],{type:m})}catch{try{var g=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return g.append(f),g.getBlob(m)}catch{throw new Error("Bug : can\'t construct the Blob.")}}};var d={stringifyByChunk:function(f,m,g){var A=[],y=0,w=f.length;if(w<=g)return String.fromCharCode.apply(null,f);for(;y<w;)m==="array"||m==="nodebuffer"?A.push(String.fromCharCode.apply(null,f.slice(y,Math.min(y+g,w)))):A.push(String.fromCharCode.apply(null,f.subarray(y,Math.min(y+g,w)))),y+=g;return A.join("")},stringifyByChar:function(f){for(var m="",g=0;g<f.length;g++)m+=String.fromCharCode(f[g]);return m},applyCanBeUsed:{uint8array:function(){try{return r.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return r.nodebuffer&&String.fromCharCode.apply(null,i.allocBuffer(1)).length===1}catch{return!1}}()}};function p(f){var m=65536,g=t.getTypeOf(f),A=!0;if(g==="uint8array"?A=d.applyCanBeUsed.uint8array:g==="nodebuffer"&&(A=d.applyCanBeUsed.nodebuffer),A)for(;1<m;)try{return d.stringifyByChunk(f,g,m)}catch{m=Math.floor(m/2)}return d.stringifyByChar(f)}function l(f,m){for(var g=0;g<f.length;g++)m[g]=f[g];return m}t.applyFromCharCode=p;var b={};b.string={string:o,array:function(f){return u(f,new Array(f.length))},arraybuffer:function(f){return b.string.uint8array(f).buffer},uint8array:function(f){return u(f,new Uint8Array(f.length))},nodebuffer:function(f){return u(f,i.allocBuffer(f.length))}},b.array={string:p,array:o,arraybuffer:function(f){return new Uint8Array(f).buffer},uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return i.newBufferFrom(f)}},b.arraybuffer={string:function(f){return p(new Uint8Array(f))},array:function(f){return l(new Uint8Array(f),new Array(f.byteLength))},arraybuffer:o,uint8array:function(f){return new Uint8Array(f)},nodebuffer:function(f){return i.newBufferFrom(new Uint8Array(f))}},b.uint8array={string:p,array:function(f){return l(f,new Array(f.length))},arraybuffer:function(f){return f.buffer},uint8array:o,nodebuffer:function(f){return i.newBufferFrom(f)}},b.nodebuffer={string:p,array:function(f){return l(f,new Array(f.length))},arraybuffer:function(f){return b.nodebuffer.uint8array(f).buffer},uint8array:function(f){return l(f,new Uint8Array(f.length))},nodebuffer:o},t.transformTo=function(f,m){if(m=m||"",!f)return m;t.checkSupport(f);var g=t.getTypeOf(m);return b[g][f](m)},t.resolve=function(f){for(var m=f.split("/"),g=[],A=0;A<m.length;A++){var y=m[A];y==="."||y===""&&A!==0&&A!==m.length-1||(y===".."?g.pop():g.push(y))}return g.join("/")},t.getTypeOf=function(f){return typeof f=="string"?"string":Object.prototype.toString.call(f)==="[object Array]"?"array":r.nodebuffer&&i.isBuffer(f)?"nodebuffer":r.uint8array&&f instanceof Uint8Array?"uint8array":r.arraybuffer&&f instanceof ArrayBuffer?"arraybuffer":void 0},t.checkSupport=function(f){if(!r[f.toLowerCase()])throw new Error(f+" is not supported by this platform")},t.MAX_VALUE_16BITS=65535,t.MAX_VALUE_32BITS=-1,t.pretty=function(f){var m,g,A="";for(g=0;g<(f||"").length;g++)A+="\\\\x"+((m=f.charCodeAt(g))<16?"0":"")+m.toString(16).toUpperCase();return A},t.delay=function(f,m,g){setImmediate(function(){f.apply(g||null,m||[])})},t.inherits=function(f,m){function g(){}g.prototype=m.prototype,f.prototype=new g},t.extend=function(){var f,m,g={};for(f=0;f<arguments.length;f++)for(m in arguments[f])arguments[f].hasOwnProperty(m)&&g[m]===void 0&&(g[m]=arguments[f][m]);return g},t.prepareContent=function(f,m,g,A,y){return a.Promise.resolve(m).then(function(w){return r.blob&&(w instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(w))!==-1)&&typeof FileReader<"u"?new a.Promise(function(E,z){var P=new FileReader;P.onload=function(G){E(G.target.result)},P.onerror=function(G){z(G.target.error)},P.readAsArrayBuffer(w)}):w}).then(function(w){var E=t.getTypeOf(w);return E?(E==="arraybuffer"?w=t.transformTo("uint8array",w):E==="string"&&(y?w=n.decode(w):g&&A!==!0&&(w=function(z){return u(z,r.uint8array?new Uint8Array(z.length):new Array(z.length))}(w))),w):a.Promise.reject(new Error("Can\'t read the data of \'"+f+"\'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(s,e,t){"use strict";var r=s("./reader/readerFor"),n=s("./utils"),i=s("./signature"),a=s("./zipEntry"),o=(s("./utf8"),s("./support"));function u(d){this.files=[],this.loadOptions=d}u.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+n.pretty(p)+", expected "+n.pretty(d)+")")}},isSignature:function(d,p){var l=this.reader.index;this.reader.setIndex(d);var b=this.reader.readString(4)===p;return this.reader.setIndex(l),b},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),p=o.uint8array?"uint8array":"array",l=n.transformTo(p,d);this.zipComment=this.loadOptions.decodeFileName(l)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,p,l,b=this.zip64EndOfCentralSize-44;0<b;)d=this.reader.readInt(2),p=this.reader.readInt(4),l=this.reader.readData(p),this.zip64ExtensibleData[d]={id:d,length:p,value:l}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,p;for(d=0;d<this.files.length;d++)p=this.files[d],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(i.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(i.CENTRAL_FILE_HEADER);)(d=new a({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(i.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,i.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can\'t find end of central directory"):new Error("Can\'t find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var p=d;if(this.checkSignature(i.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===n.MAX_VALUE_16BITS||this.diskWithCentralDirStart===n.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===n.MAX_VALUE_16BITS||this.centralDirRecords===n.MAX_VALUE_16BITS||this.centralDirSize===n.MAX_VALUE_32BITS||this.centralDirOffset===n.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can\'t find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,i.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can\'t find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var l=this.centralDirOffset+this.centralDirSize;this.zip64&&(l+=20,l+=12+this.zip64EndOfCentralSize);var b=p-l;if(0<b)this.isSignature(p,i.CENTRAL_FILE_HEADER)||(this.reader.zero=b);else if(b<0)throw new Error("Corrupted zip: missing "+Math.abs(b)+" bytes.")},prepareReader:function(d){this.reader=r(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},e.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utf8":31,"./utils":32,"./zipEntry":34}],34:[function(s,e,t){"use strict";var r=s("./reader/readerFor"),n=s("./utils"),i=s("./compressedObject"),a=s("./crc32"),o=s("./utf8"),u=s("./compressions"),d=s("./support");function p(l,b){this.options=l,this.loadOptions=b}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(l){var b,f;if(l.skip(22),this.fileNameLength=l.readInt(2),f=l.readInt(2),this.fileName=l.readData(this.fileNameLength),l.skip(f),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn\'t get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((b=function(m){for(var g in u)if(u.hasOwnProperty(g)&&u[g].magic===m)return u[g];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+n.pretty(this.compressionMethod)+" unknown (inner file : "+n.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,b,l.readData(this.compressedSize))},readCentralPart:function(l){this.versionMadeBy=l.readInt(2),l.skip(2),this.bitFlag=l.readInt(2),this.compressionMethod=l.readString(2),this.date=l.readDate(),this.crc32=l.readInt(4),this.compressedSize=l.readInt(4),this.uncompressedSize=l.readInt(4);var b=l.readInt(2);if(this.extraFieldsLength=l.readInt(2),this.fileCommentLength=l.readInt(2),this.diskNumberStart=l.readInt(2),this.internalFileAttributes=l.readInt(2),this.externalFileAttributes=l.readInt(4),this.localHeaderOffset=l.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");l.skip(b),this.readExtraFields(l),this.parseZIP64ExtraField(l),this.fileComment=l.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var l=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),l==0&&(this.dosPermissions=63&this.externalFileAttributes),l==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(l){if(this.extraFields[1]){var b=r(this.extraFields[1].value);this.uncompressedSize===n.MAX_VALUE_32BITS&&(this.uncompressedSize=b.readInt(8)),this.compressedSize===n.MAX_VALUE_32BITS&&(this.compressedSize=b.readInt(8)),this.localHeaderOffset===n.MAX_VALUE_32BITS&&(this.localHeaderOffset=b.readInt(8)),this.diskNumberStart===n.MAX_VALUE_32BITS&&(this.diskNumberStart=b.readInt(4))}},readExtraFields:function(l){var b,f,m,g=l.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});l.index+4<g;)b=l.readInt(2),f=l.readInt(2),m=l.readData(f),this.extraFields[b]={id:b,length:f,value:m};l.setIndex(g)},handleUTF8:function(){var l=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=o.utf8decode(this.fileName),this.fileCommentStr=o.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(b!==null)this.fileNameStr=b;else{var f=n.transformTo(l,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(f)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var g=n.transformTo(l,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(g)}}},findExtraFieldUnicodePath:function(){var l=this.extraFields[28789];if(l){var b=r(l.value);return b.readInt(1)!==1||a(this.fileName)!==b.readInt(4)?null:o.utf8decode(b.readData(l.length-5))}return null},findExtraFieldUnicodeComment:function(){var l=this.extraFields[25461];if(l){var b=r(l.value);return b.readInt(1)!==1||a(this.fileComment)!==b.readInt(4)?null:o.utf8decode(b.readData(l.length-5))}return null}},e.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(s,e,t){"use strict";function r(b,f,m){this.name=b,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=f,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var n=s("./stream/StreamHelper"),i=s("./stream/DataWorker"),a=s("./utf8"),o=s("./compressedObject"),u=s("./stream/GenericWorker");r.prototype={internalStream:function(b){var f=null,m="string";try{if(!b)throw new Error("No output type specified.");var g=(m=b.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),f=this._decompressWorker();var A=!this._dataBinary;A&&!g&&(f=f.pipe(new a.Utf8EncodeWorker)),!A&&g&&(f=f.pipe(new a.Utf8DecodeWorker))}catch(y){(f=new u("error")).error(y)}return new n(f,m,"")},async:function(b,f){return this.internalStream(b).accumulate(f)},nodeStream:function(b,f){return this.internalStream(b||"nodebuffer").toNodejsStream(f)},_compressWorker:function(b,f){if(this._data instanceof o&&this._data.compression.magic===b.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new a.Utf8EncodeWorker)),o.createWorkerFrom(m,b,f)},_decompressWorker:function(){return this._data instanceof o?this._data.getContentWorker():this._data instanceof u?this._data:new i(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},l=0;l<d.length;l++)r.prototype[d[l]]=p;e.exports=r},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(s,e,t){(function(r){"use strict";var n,i,a=r.MutationObserver||r.WebKitMutationObserver;if(a){var o=0,u=new a(b),d=r.document.createTextNode("");u.observe(d,{characterData:!0}),n=function(){d.data=o=++o%2}}else if(r.setImmediate||r.MessageChannel===void 0)n="document"in r&&"onreadystatechange"in r.document.createElement("script")?function(){var f=r.document.createElement("script");f.onreadystatechange=function(){b(),f.onreadystatechange=null,f.parentNode.removeChild(f),f=null},r.document.documentElement.appendChild(f)}:function(){setTimeout(b,0)};else{var p=new r.MessageChannel;p.port1.onmessage=b,n=function(){p.port2.postMessage(0)}}var l=[];function b(){var f,m;i=!0;for(var g=l.length;g;){for(m=l,l=[],f=-1;++f<g;)m[f]();g=l.length}i=!1}e.exports=function(f){l.push(f)!==1||i||n()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(s,e,t){"use strict";var r=s("immediate");function n(){}var i={},a=["REJECTED"],o=["FULFILLED"],u=["PENDING"];function d(g){if(typeof g!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,g!==n&&f(this,g)}function p(g,A,y){this.promise=g,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof y=="function"&&(this.onRejected=y,this.callRejected=this.otherCallRejected)}function l(g,A,y){r(function(){var w;try{w=A(y)}catch(E){return i.reject(g,E)}w===g?i.reject(g,new TypeError("Cannot resolve promise with itself")):i.resolve(g,w)})}function b(g){var A=g&&g.then;if(g&&(typeof g=="object"||typeof g=="function")&&typeof A=="function")return function(){A.apply(g,arguments)}}function f(g,A){var y=!1;function w(P){y||(y=!0,i.reject(g,P))}function E(P){y||(y=!0,i.resolve(g,P))}var z=m(function(){A(E,w)});z.status==="error"&&w(z.value)}function m(g,A){var y={};try{y.value=g(A),y.status="success"}catch(w){y.status="error",y.value=w}return y}(e.exports=d).prototype.finally=function(g){if(typeof g!="function")return this;var A=this.constructor;return this.then(function(y){return A.resolve(g()).then(function(){return y})},function(y){return A.resolve(g()).then(function(){throw y})})},d.prototype.catch=function(g){return this.then(null,g)},d.prototype.then=function(g,A){if(typeof g!="function"&&this.state===o||typeof A!="function"&&this.state===a)return this;var y=new this.constructor(n);return this.state!==u?l(y,this.state===o?g:A,this.outcome):this.queue.push(new p(y,g,A)),y},p.prototype.callFulfilled=function(g){i.resolve(this.promise,g)},p.prototype.otherCallFulfilled=function(g){l(this.promise,this.onFulfilled,g)},p.prototype.callRejected=function(g){i.reject(this.promise,g)},p.prototype.otherCallRejected=function(g){l(this.promise,this.onRejected,g)},i.resolve=function(g,A){var y=m(b,A);if(y.status==="error")return i.reject(g,y.value);var w=y.value;if(w)f(g,w);else{g.state=o,g.outcome=A;for(var E=-1,z=g.queue.length;++E<z;)g.queue[E].callFulfilled(A)}return g},i.reject=function(g,A){g.state=a,g.outcome=A;for(var y=-1,w=g.queue.length;++y<w;)g.queue[y].callRejected(A);return g},d.resolve=function(g){return g instanceof this?g:i.resolve(new this(n),g)},d.reject=function(g){var A=new this(n);return i.reject(A,g)},d.all=function(g){var A=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=g.length,w=!1;if(!y)return this.resolve([]);for(var E=new Array(y),z=0,P=-1,G=new this(n);++P<y;)R(g[P],P);return G;function R(V,X){A.resolve(V).then(function(C){E[X]=C,++z!==y||w||(w=!0,i.resolve(G,E))},function(C){w||(w=!0,i.reject(G,C))})}},d.race=function(g){var A=this;if(Object.prototype.toString.call(g)!=="[object Array]")return this.reject(new TypeError("must be an array"));var y=g.length,w=!1;if(!y)return this.resolve([]);for(var E=-1,z=new this(n);++E<y;)P=g[E],A.resolve(P).then(function(G){w||(w=!0,i.resolve(z,G))},function(G){w||(w=!0,i.reject(z,G))});var P;return z}},{immediate:36}],38:[function(s,e,t){"use strict";var r={};(0,s("./lib/utils/common").assign)(r,s("./lib/deflate"),s("./lib/inflate"),s("./lib/zlib/constants")),e.exports=r},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(s,e,t){"use strict";var r=s("./zlib/deflate"),n=s("./utils/common"),i=s("./utils/strings"),a=s("./zlib/messages"),o=s("./zlib/zstream"),u=Object.prototype.toString,d=0,p=-1,l=0,b=8;function f(g){if(!(this instanceof f))return new f(g);this.options=n.assign({level:p,method:b,chunkSize:16384,windowBits:15,memLevel:8,strategy:l,to:""},g||{});var A=this.options;A.raw&&0<A.windowBits?A.windowBits=-A.windowBits:A.gzip&&0<A.windowBits&&A.windowBits<16&&(A.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new o,this.strm.avail_out=0;var y=r.deflateInit2(this.strm,A.level,A.method,A.windowBits,A.memLevel,A.strategy);if(y!==d)throw new Error(a[y]);if(A.header&&r.deflateSetHeader(this.strm,A.header),A.dictionary){var w;if(w=typeof A.dictionary=="string"?i.string2buf(A.dictionary):u.call(A.dictionary)==="[object ArrayBuffer]"?new Uint8Array(A.dictionary):A.dictionary,(y=r.deflateSetDictionary(this.strm,w))!==d)throw new Error(a[y]);this._dict_set=!0}}function m(g,A){var y=new f(A);if(y.push(g,!0),y.err)throw y.msg||a[y.err];return y.result}f.prototype.push=function(g,A){var y,w,E=this.strm,z=this.options.chunkSize;if(this.ended)return!1;w=A===~~A?A:A===!0?4:0,typeof g=="string"?E.input=i.string2buf(g):u.call(g)==="[object ArrayBuffer]"?E.input=new Uint8Array(g):E.input=g,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new n.Buf8(z),E.next_out=0,E.avail_out=z),(y=r.deflate(E,w))!==1&&y!==d)return this.onEnd(y),!(this.ended=!0);E.avail_out!==0&&(E.avail_in!==0||w!==4&&w!==2)||(this.options.to==="string"?this.onData(i.buf2binstring(n.shrinkBuf(E.output,E.next_out))):this.onData(n.shrinkBuf(E.output,E.next_out)))}while((0<E.avail_in||E.avail_out===0)&&y!==1);return w===4?(y=r.deflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===d):w!==2||(this.onEnd(d),!(E.avail_out=0))},f.prototype.onData=function(g){this.chunks.push(g)},f.prototype.onEnd=function(g){g===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},t.Deflate=f,t.deflate=m,t.deflateRaw=function(g,A){return(A=A||{}).raw=!0,m(g,A)},t.gzip=function(g,A){return(A=A||{}).gzip=!0,m(g,A)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(s,e,t){"use strict";var r=s("./zlib/inflate"),n=s("./utils/common"),i=s("./utils/strings"),a=s("./zlib/constants"),o=s("./zlib/messages"),u=s("./zlib/zstream"),d=s("./zlib/gzheader"),p=Object.prototype.toString;function l(f){if(!(this instanceof l))return new l(f);this.options=n.assign({chunkSize:16384,windowBits:0,to:""},f||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||f&&f.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var g=r.inflateInit2(this.strm,m.windowBits);if(g!==a.Z_OK)throw new Error(o[g]);this.header=new d,r.inflateGetHeader(this.strm,this.header)}function b(f,m){var g=new l(m);if(g.push(f,!0),g.err)throw g.msg||o[g.err];return g.result}l.prototype.push=function(f,m){var g,A,y,w,E,z,P=this.strm,G=this.options.chunkSize,R=this.options.dictionary,V=!1;if(this.ended)return!1;A=m===~~m?m:m===!0?a.Z_FINISH:a.Z_NO_FLUSH,typeof f=="string"?P.input=i.binstring2buf(f):p.call(f)==="[object ArrayBuffer]"?P.input=new Uint8Array(f):P.input=f,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new n.Buf8(G),P.next_out=0,P.avail_out=G),(g=r.inflate(P,a.Z_NO_FLUSH))===a.Z_NEED_DICT&&R&&(z=typeof R=="string"?i.string2buf(R):p.call(R)==="[object ArrayBuffer]"?new Uint8Array(R):R,g=r.inflateSetDictionary(this.strm,z)),g===a.Z_BUF_ERROR&&V===!0&&(g=a.Z_OK,V=!1),g!==a.Z_STREAM_END&&g!==a.Z_OK)return this.onEnd(g),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&g!==a.Z_STREAM_END&&(P.avail_in!==0||A!==a.Z_FINISH&&A!==a.Z_SYNC_FLUSH)||(this.options.to==="string"?(y=i.utf8border(P.output,P.next_out),w=P.next_out-y,E=i.buf2string(P.output,y),P.next_out=w,P.avail_out=G-w,w&&n.arraySet(P.output,P.output,y,w,0),this.onData(E)):this.onData(n.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(V=!0)}while((0<P.avail_in||P.avail_out===0)&&g!==a.Z_STREAM_END);return g===a.Z_STREAM_END&&(A=a.Z_FINISH),A===a.Z_FINISH?(g=r.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===a.Z_OK):A!==a.Z_SYNC_FLUSH||(this.onEnd(a.Z_OK),!(P.avail_out=0))},l.prototype.onData=function(f){this.chunks.push(f)},l.prototype.onEnd=function(f){f===a.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=n.flattenChunks(this.chunks)),this.chunks=[],this.err=f,this.msg=this.strm.msg},t.Inflate=l,t.inflate=b,t.inflateRaw=function(f,m){return(m=m||{}).raw=!0,b(f,m)},t.ungzip=b},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(s,e,t){"use strict";var r=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";t.assign=function(a){for(var o=Array.prototype.slice.call(arguments,1);o.length;){var u=o.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var d in u)u.hasOwnProperty(d)&&(a[d]=u[d])}}return a},t.shrinkBuf=function(a,o){return a.length===o?a:a.subarray?a.subarray(0,o):(a.length=o,a)};var n={arraySet:function(a,o,u,d,p){if(o.subarray&&a.subarray)a.set(o.subarray(u,u+d),p);else for(var l=0;l<d;l++)a[p+l]=o[u+l]},flattenChunks:function(a){var o,u,d,p,l,b;for(o=d=0,u=a.length;o<u;o++)d+=a[o].length;for(b=new Uint8Array(d),o=p=0,u=a.length;o<u;o++)l=a[o],b.set(l,p),p+=l.length;return b}},i={arraySet:function(a,o,u,d,p){for(var l=0;l<d;l++)a[p+l]=o[u+l]},flattenChunks:function(a){return[].concat.apply([],a)}};t.setTyped=function(a){a?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,n)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,i))},t.setTyped(r)},{}],42:[function(s,e,t){"use strict";var r=s("./common"),n=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch{n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{i=!1}for(var a=new r.Buf8(256),o=0;o<256;o++)a[o]=252<=o?6:248<=o?5:240<=o?4:224<=o?3:192<=o?2:1;function u(d,p){if(p<65537&&(d.subarray&&i||!d.subarray&&n))return String.fromCharCode.apply(null,r.shrinkBuf(d,p));for(var l="",b=0;b<p;b++)l+=String.fromCharCode(d[b]);return l}a[254]=a[254]=1,t.string2buf=function(d){var p,l,b,f,m,g=d.length,A=0;for(f=0;f<g;f++)(64512&(l=d.charCodeAt(f)))==55296&&f+1<g&&(64512&(b=d.charCodeAt(f+1)))==56320&&(l=65536+(l-55296<<10)+(b-56320),f++),A+=l<128?1:l<2048?2:l<65536?3:4;for(p=new r.Buf8(A),f=m=0;m<A;f++)(64512&(l=d.charCodeAt(f)))==55296&&f+1<g&&(64512&(b=d.charCodeAt(f+1)))==56320&&(l=65536+(l-55296<<10)+(b-56320),f++),l<128?p[m++]=l:(l<2048?p[m++]=192|l>>>6:(l<65536?p[m++]=224|l>>>12:(p[m++]=240|l>>>18,p[m++]=128|l>>>12&63),p[m++]=128|l>>>6&63),p[m++]=128|63&l);return p},t.buf2binstring=function(d){return u(d,d.length)},t.binstring2buf=function(d){for(var p=new r.Buf8(d.length),l=0,b=p.length;l<b;l++)p[l]=d.charCodeAt(l);return p},t.buf2string=function(d,p){var l,b,f,m,g=p||d.length,A=new Array(2*g);for(l=b=0;l<g;)if((f=d[l++])<128)A[b++]=f;else if(4<(m=a[f]))A[b++]=65533,l+=m-1;else{for(f&=m===2?31:m===3?15:7;1<m&&l<g;)f=f<<6|63&d[l++],m--;1<m?A[b++]=65533:f<65536?A[b++]=f:(f-=65536,A[b++]=55296|f>>10&1023,A[b++]=56320|1023&f)}return u(A,b)},t.utf8border=function(d,p){var l;for((p=p||d.length)>d.length&&(p=d.length),l=p-1;0<=l&&(192&d[l])==128;)l--;return l<0||l===0?p:l+a[d[l]]>p?l:p}},{"./common":41}],43:[function(s,e,t){"use strict";e.exports=function(r,n,i,a){for(var o=65535&r|0,u=r>>>16&65535|0,d=0;i!==0;){for(i-=d=2e3<i?2e3:i;u=u+(o=o+n[a++]|0)|0,--d;);o%=65521,u%=65521}return o|u<<16|0}},{}],44:[function(s,e,t){"use strict";e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(s,e,t){"use strict";var r=function(){for(var n,i=[],a=0;a<256;a++){n=a;for(var o=0;o<8;o++)n=1&n?3988292384^n>>>1:n>>>1;i[a]=n}return i}();e.exports=function(n,i,a,o){var u=r,d=o+a;n^=-1;for(var p=o;p<d;p++)n=n>>>8^u[255&(n^i[p])];return-1^n}},{}],46:[function(s,e,t){"use strict";var r,n=s("../utils/common"),i=s("./trees"),a=s("./adler32"),o=s("./crc32"),u=s("./messages"),d=0,p=4,l=0,b=-2,f=-1,m=4,g=2,A=8,y=9,w=286,E=30,z=19,P=2*w+1,G=15,R=3,V=258,X=V+R+1,C=42,S=113,h=1,k=2,Y=3,F=4;function q(c,L){return c.msg=u[L],L}function I(c){return(c<<1)-(4<c?9:0)}function O(c){for(var L=c.length;0<=--L;)c[L]=0}function D(c){var L=c.state,T=L.pending;T>c.avail_out&&(T=c.avail_out),T!==0&&(n.arraySet(c.output,L.pending_buf,L.pending_out,T,c.next_out),c.next_out+=T,L.pending_out+=T,c.total_out+=T,c.avail_out-=T,L.pending-=T,L.pending===0&&(L.pending_out=0))}function v(c,L){i._tr_flush_block(c,0<=c.block_start?c.block_start:-1,c.strstart-c.block_start,L),c.block_start=c.strstart,D(c.strm)}function j(c,L){c.pending_buf[c.pending++]=L}function W(c,L){c.pending_buf[c.pending++]=L>>>8&255,c.pending_buf[c.pending++]=255&L}function Z(c,L){var T,_,x=c.max_chain_length,B=c.strstart,U=c.prev_length,M=c.nice_match,N=c.strstart>c.w_size-X?c.strstart-(c.w_size-X):0,H=c.window,J=c.w_mask,$=c.prev,Q=c.strstart+V,ce=H[B+U-1],ne=H[B+U];c.prev_length>=c.good_match&&(x>>=2),M>c.lookahead&&(M=c.lookahead);do if(H[(T=L)+U]===ne&&H[T+U-1]===ce&&H[T]===H[B]&&H[++T]===H[B+1]){B+=2,T++;do;while(H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&H[++B]===H[++T]&&B<Q);if(_=V-(Q-B),B=Q-V,U<_){if(c.match_start=L,M<=(U=_))break;ce=H[B+U-1],ne=H[B+U]}}while((L=$[L&J])>N&&--x!=0);return U<=c.lookahead?U:c.lookahead}function ee(c){var L,T,_,x,B,U,M,N,H,J,$=c.w_size;do{if(x=c.window_size-c.lookahead-c.strstart,c.strstart>=$+($-X)){for(n.arraySet(c.window,c.window,$,$,0),c.match_start-=$,c.strstart-=$,c.block_start-=$,L=T=c.hash_size;_=c.head[--L],c.head[L]=$<=_?_-$:0,--T;);for(L=T=$;_=c.prev[--L],c.prev[L]=$<=_?_-$:0,--T;);x+=$}if(c.strm.avail_in===0)break;if(U=c.strm,M=c.window,N=c.strstart+c.lookahead,H=x,J=void 0,J=U.avail_in,H<J&&(J=H),T=J===0?0:(U.avail_in-=J,n.arraySet(M,U.input,U.next_in,J,N),U.state.wrap===1?U.adler=a(U.adler,M,J,N):U.state.wrap===2&&(U.adler=o(U.adler,M,J,N)),U.next_in+=J,U.total_in+=J,J),c.lookahead+=T,c.lookahead+c.insert>=R)for(B=c.strstart-c.insert,c.ins_h=c.window[B],c.ins_h=(c.ins_h<<c.hash_shift^c.window[B+1])&c.hash_mask;c.insert&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[B+R-1])&c.hash_mask,c.prev[B&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=B,B++,c.insert--,!(c.lookahead+c.insert<R)););}while(c.lookahead<X&&c.strm.avail_in!==0)}function te(c,L){for(var T,_;;){if(c.lookahead<X){if(ee(c),c.lookahead<X&&L===d)return h;if(c.lookahead===0)break}if(T=0,c.lookahead>=R&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),T!==0&&c.strstart-T<=c.w_size-X&&(c.match_length=Z(c,T)),c.match_length>=R)if(_=i._tr_tally(c,c.strstart-c.match_start,c.match_length-R),c.lookahead-=c.match_length,c.match_length<=c.max_lazy_match&&c.lookahead>=R){for(c.match_length--;c.strstart++,c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart,--c.match_length!=0;);c.strstart++}else c.strstart+=c.match_length,c.match_length=0,c.ins_h=c.window[c.strstart],c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+1])&c.hash_mask;else _=i._tr_tally(c,0,c.window[c.strstart]),c.lookahead--,c.strstart++;if(_&&(v(c,!1),c.strm.avail_out===0))return h}return c.insert=c.strstart<R-1?c.strstart:R-1,L===p?(v(c,!0),c.strm.avail_out===0?Y:F):c.last_lit&&(v(c,!1),c.strm.avail_out===0)?h:k}function K(c,L){for(var T,_,x;;){if(c.lookahead<X){if(ee(c),c.lookahead<X&&L===d)return h;if(c.lookahead===0)break}if(T=0,c.lookahead>=R&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),c.prev_length=c.match_length,c.prev_match=c.match_start,c.match_length=R-1,T!==0&&c.prev_length<c.max_lazy_match&&c.strstart-T<=c.w_size-X&&(c.match_length=Z(c,T),c.match_length<=5&&(c.strategy===1||c.match_length===R&&4096<c.strstart-c.match_start)&&(c.match_length=R-1)),c.prev_length>=R&&c.match_length<=c.prev_length){for(x=c.strstart+c.lookahead-R,_=i._tr_tally(c,c.strstart-1-c.prev_match,c.prev_length-R),c.lookahead-=c.prev_length-1,c.prev_length-=2;++c.strstart<=x&&(c.ins_h=(c.ins_h<<c.hash_shift^c.window[c.strstart+R-1])&c.hash_mask,T=c.prev[c.strstart&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=c.strstart),--c.prev_length!=0;);if(c.match_available=0,c.match_length=R-1,c.strstart++,_&&(v(c,!1),c.strm.avail_out===0))return h}else if(c.match_available){if((_=i._tr_tally(c,0,c.window[c.strstart-1]))&&v(c,!1),c.strstart++,c.lookahead--,c.strm.avail_out===0)return h}else c.match_available=1,c.strstart++,c.lookahead--}return c.match_available&&(_=i._tr_tally(c,0,c.window[c.strstart-1]),c.match_available=0),c.insert=c.strstart<R-1?c.strstart:R-1,L===p?(v(c,!0),c.strm.avail_out===0?Y:F):c.last_lit&&(v(c,!1),c.strm.avail_out===0)?h:k}function re(c,L,T,_,x){this.good_length=c,this.max_lazy=L,this.nice_length=T,this.max_chain=_,this.func=x}function le(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=A,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new n.Buf16(2*P),this.dyn_dtree=new n.Buf16(2*(2*E+1)),this.bl_tree=new n.Buf16(2*(2*z+1)),O(this.dyn_ltree),O(this.dyn_dtree),O(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new n.Buf16(G+1),this.heap=new n.Buf16(2*w+1),O(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new n.Buf16(2*w+1),O(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ue(c){var L;return c&&c.state?(c.total_in=c.total_out=0,c.data_type=g,(L=c.state).pending=0,L.pending_out=0,L.wrap<0&&(L.wrap=-L.wrap),L.status=L.wrap?C:S,c.adler=L.wrap===2?0:1,L.last_flush=d,i._tr_init(L),l):q(c,b)}function fe(c){var L=ue(c);return L===l&&function(T){T.window_size=2*T.w_size,O(T.head),T.max_lazy_match=r[T.level].max_lazy,T.good_match=r[T.level].good_length,T.nice_match=r[T.level].nice_length,T.max_chain_length=r[T.level].max_chain,T.strstart=0,T.block_start=0,T.lookahead=0,T.insert=0,T.match_length=T.prev_length=R-1,T.match_available=0,T.ins_h=0}(c.state),L}function me(c,L,T,_,x,B){if(!c)return b;var U=1;if(L===f&&(L=6),_<0?(U=0,_=-_):15<_&&(U=2,_-=16),x<1||y<x||T!==A||_<8||15<_||L<0||9<L||B<0||m<B)return q(c,b);_===8&&(_=9);var M=new le;return(c.state=M).strm=c,M.wrap=U,M.gzhead=null,M.w_bits=_,M.w_size=1<<M.w_bits,M.w_mask=M.w_size-1,M.hash_bits=x+7,M.hash_size=1<<M.hash_bits,M.hash_mask=M.hash_size-1,M.hash_shift=~~((M.hash_bits+R-1)/R),M.window=new n.Buf8(2*M.w_size),M.head=new n.Buf16(M.hash_size),M.prev=new n.Buf16(M.w_size),M.lit_bufsize=1<<x+6,M.pending_buf_size=4*M.lit_bufsize,M.pending_buf=new n.Buf8(M.pending_buf_size),M.d_buf=1*M.lit_bufsize,M.l_buf=3*M.lit_bufsize,M.level=L,M.strategy=B,M.method=T,fe(c)}r=[new re(0,0,0,0,function(c,L){var T=65535;for(T>c.pending_buf_size-5&&(T=c.pending_buf_size-5);;){if(c.lookahead<=1){if(ee(c),c.lookahead===0&&L===d)return h;if(c.lookahead===0)break}c.strstart+=c.lookahead,c.lookahead=0;var _=c.block_start+T;if((c.strstart===0||c.strstart>=_)&&(c.lookahead=c.strstart-_,c.strstart=_,v(c,!1),c.strm.avail_out===0)||c.strstart-c.block_start>=c.w_size-X&&(v(c,!1),c.strm.avail_out===0))return h}return c.insert=0,L===p?(v(c,!0),c.strm.avail_out===0?Y:F):(c.strstart>c.block_start&&(v(c,!1),c.strm.avail_out),h)}),new re(4,4,8,4,te),new re(4,5,16,8,te),new re(4,6,32,32,te),new re(4,4,16,16,K),new re(8,16,32,32,K),new re(8,16,128,128,K),new re(8,32,128,256,K),new re(32,128,258,1024,K),new re(32,258,258,4096,K)],t.deflateInit=function(c,L){return me(c,L,A,15,8,0)},t.deflateInit2=me,t.deflateReset=fe,t.deflateResetKeep=ue,t.deflateSetHeader=function(c,L){return c&&c.state?c.state.wrap!==2?b:(c.state.gzhead=L,l):b},t.deflate=function(c,L){var T,_,x,B;if(!c||!c.state||5<L||L<0)return c?q(c,b):b;if(_=c.state,!c.output||!c.input&&c.avail_in!==0||_.status===666&&L!==p)return q(c,c.avail_out===0?-5:b);if(_.strm=c,T=_.last_flush,_.last_flush=L,_.status===C)if(_.wrap===2)c.adler=0,j(_,31),j(_,139),j(_,8),_.gzhead?(j(_,(_.gzhead.text?1:0)+(_.gzhead.hcrc?2:0)+(_.gzhead.extra?4:0)+(_.gzhead.name?8:0)+(_.gzhead.comment?16:0)),j(_,255&_.gzhead.time),j(_,_.gzhead.time>>8&255),j(_,_.gzhead.time>>16&255),j(_,_.gzhead.time>>24&255),j(_,_.level===9?2:2<=_.strategy||_.level<2?4:0),j(_,255&_.gzhead.os),_.gzhead.extra&&_.gzhead.extra.length&&(j(_,255&_.gzhead.extra.length),j(_,_.gzhead.extra.length>>8&255)),_.gzhead.hcrc&&(c.adler=o(c.adler,_.pending_buf,_.pending,0)),_.gzindex=0,_.status=69):(j(_,0),j(_,0),j(_,0),j(_,0),j(_,0),j(_,_.level===9?2:2<=_.strategy||_.level<2?4:0),j(_,3),_.status=S);else{var U=A+(_.w_bits-8<<4)<<8;U|=(2<=_.strategy||_.level<2?0:_.level<6?1:_.level===6?2:3)<<6,_.strstart!==0&&(U|=32),U+=31-U%31,_.status=S,W(_,U),_.strstart!==0&&(W(_,c.adler>>>16),W(_,65535&c.adler)),c.adler=1}if(_.status===69)if(_.gzhead.extra){for(x=_.pending;_.gzindex<(65535&_.gzhead.extra.length)&&(_.pending!==_.pending_buf_size||(_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),D(c),x=_.pending,_.pending!==_.pending_buf_size));)j(_,255&_.gzhead.extra[_.gzindex]),_.gzindex++;_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),_.gzindex===_.gzhead.extra.length&&(_.gzindex=0,_.status=73)}else _.status=73;if(_.status===73)if(_.gzhead.name){x=_.pending;do{if(_.pending===_.pending_buf_size&&(_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),D(c),x=_.pending,_.pending===_.pending_buf_size)){B=1;break}B=_.gzindex<_.gzhead.name.length?255&_.gzhead.name.charCodeAt(_.gzindex++):0,j(_,B)}while(B!==0);_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),B===0&&(_.gzindex=0,_.status=91)}else _.status=91;if(_.status===91)if(_.gzhead.comment){x=_.pending;do{if(_.pending===_.pending_buf_size&&(_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),D(c),x=_.pending,_.pending===_.pending_buf_size)){B=1;break}B=_.gzindex<_.gzhead.comment.length?255&_.gzhead.comment.charCodeAt(_.gzindex++):0,j(_,B)}while(B!==0);_.gzhead.hcrc&&_.pending>x&&(c.adler=o(c.adler,_.pending_buf,_.pending-x,x)),B===0&&(_.status=103)}else _.status=103;if(_.status===103&&(_.gzhead.hcrc?(_.pending+2>_.pending_buf_size&&D(c),_.pending+2<=_.pending_buf_size&&(j(_,255&c.adler),j(_,c.adler>>8&255),c.adler=0,_.status=S)):_.status=S),_.pending!==0){if(D(c),c.avail_out===0)return _.last_flush=-1,l}else if(c.avail_in===0&&I(L)<=I(T)&&L!==p)return q(c,-5);if(_.status===666&&c.avail_in!==0)return q(c,-5);if(c.avail_in!==0||_.lookahead!==0||L!==d&&_.status!==666){var M=_.strategy===2?function(N,H){for(var J;;){if(N.lookahead===0&&(ee(N),N.lookahead===0)){if(H===d)return h;break}if(N.match_length=0,J=i._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++,J&&(v(N,!1),N.strm.avail_out===0))return h}return N.insert=0,H===p?(v(N,!0),N.strm.avail_out===0?Y:F):N.last_lit&&(v(N,!1),N.strm.avail_out===0)?h:k}(_,L):_.strategy===3?function(N,H){for(var J,$,Q,ce,ne=N.window;;){if(N.lookahead<=V){if(ee(N),N.lookahead<=V&&H===d)return h;if(N.lookahead===0)break}if(N.match_length=0,N.lookahead>=R&&0<N.strstart&&($=ne[Q=N.strstart-1])===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]){ce=N.strstart+V;do;while($===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&$===ne[++Q]&&Q<ce);N.match_length=V-(ce-Q),N.match_length>N.lookahead&&(N.match_length=N.lookahead)}if(N.match_length>=R?(J=i._tr_tally(N,1,N.match_length-R),N.lookahead-=N.match_length,N.strstart+=N.match_length,N.match_length=0):(J=i._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++),J&&(v(N,!1),N.strm.avail_out===0))return h}return N.insert=0,H===p?(v(N,!0),N.strm.avail_out===0?Y:F):N.last_lit&&(v(N,!1),N.strm.avail_out===0)?h:k}(_,L):r[_.level].func(_,L);if(M!==Y&&M!==F||(_.status=666),M===h||M===Y)return c.avail_out===0&&(_.last_flush=-1),l;if(M===k&&(L===1?i._tr_align(_):L!==5&&(i._tr_stored_block(_,0,0,!1),L===3&&(O(_.head),_.lookahead===0&&(_.strstart=0,_.block_start=0,_.insert=0))),D(c),c.avail_out===0))return _.last_flush=-1,l}return L!==p?l:_.wrap<=0?1:(_.wrap===2?(j(_,255&c.adler),j(_,c.adler>>8&255),j(_,c.adler>>16&255),j(_,c.adler>>24&255),j(_,255&c.total_in),j(_,c.total_in>>8&255),j(_,c.total_in>>16&255),j(_,c.total_in>>24&255)):(W(_,c.adler>>>16),W(_,65535&c.adler)),D(c),0<_.wrap&&(_.wrap=-_.wrap),_.pending!==0?l:1)},t.deflateEnd=function(c){var L;return c&&c.state?(L=c.state.status)!==C&&L!==69&&L!==73&&L!==91&&L!==103&&L!==S&&L!==666?q(c,b):(c.state=null,L===S?q(c,-3):l):b},t.deflateSetDictionary=function(c,L){var T,_,x,B,U,M,N,H,J=L.length;if(!c||!c.state||(B=(T=c.state).wrap)===2||B===1&&T.status!==C||T.lookahead)return b;for(B===1&&(c.adler=a(c.adler,L,J,0)),T.wrap=0,J>=T.w_size&&(B===0&&(O(T.head),T.strstart=0,T.block_start=0,T.insert=0),H=new n.Buf8(T.w_size),n.arraySet(H,L,J-T.w_size,T.w_size,0),L=H,J=T.w_size),U=c.avail_in,M=c.next_in,N=c.input,c.avail_in=J,c.next_in=0,c.input=L,ee(T);T.lookahead>=R;){for(_=T.strstart,x=T.lookahead-(R-1);T.ins_h=(T.ins_h<<T.hash_shift^T.window[_+R-1])&T.hash_mask,T.prev[_&T.w_mask]=T.head[T.ins_h],T.head[T.ins_h]=_,_++,--x;);T.strstart=_,T.lookahead=R-1,ee(T)}return T.strstart+=T.lookahead,T.block_start=T.strstart,T.insert=T.lookahead,T.lookahead=0,T.match_length=T.prev_length=R-1,T.match_available=0,c.next_in=M,c.input=N,c.avail_in=U,T.wrap=B,l},t.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(s,e,t){"use strict";e.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(s,e,t){"use strict";e.exports=function(r,n){var i,a,o,u,d,p,l,b,f,m,g,A,y,w,E,z,P,G,R,V,X,C,S,h,k;i=r.state,a=r.next_in,h=r.input,o=a+(r.avail_in-5),u=r.next_out,k=r.output,d=u-(n-r.avail_out),p=u+(r.avail_out-257),l=i.dmax,b=i.wsize,f=i.whave,m=i.wnext,g=i.window,A=i.hold,y=i.bits,w=i.lencode,E=i.distcode,z=(1<<i.lenbits)-1,P=(1<<i.distbits)-1;e:do{y<15&&(A+=h[a++]<<y,y+=8,A+=h[a++]<<y,y+=8),G=w[A&z];t:for(;;){if(A>>>=R=G>>>24,y-=R,(R=G>>>16&255)===0)k[u++]=65535&G;else{if(!(16&R)){if((64&R)==0){G=w[(65535&G)+(A&(1<<R)-1)];continue t}if(32&R){i.mode=12;break e}r.msg="invalid literal/length code",i.mode=30;break e}V=65535&G,(R&=15)&&(y<R&&(A+=h[a++]<<y,y+=8),V+=A&(1<<R)-1,A>>>=R,y-=R),y<15&&(A+=h[a++]<<y,y+=8,A+=h[a++]<<y,y+=8),G=E[A&P];r:for(;;){if(A>>>=R=G>>>24,y-=R,!(16&(R=G>>>16&255))){if((64&R)==0){G=E[(65535&G)+(A&(1<<R)-1)];continue r}r.msg="invalid distance code",i.mode=30;break e}if(X=65535&G,y<(R&=15)&&(A+=h[a++]<<y,(y+=8)<R&&(A+=h[a++]<<y,y+=8)),l<(X+=A&(1<<R)-1)){r.msg="invalid distance too far back",i.mode=30;break e}if(A>>>=R,y-=R,(R=u-d)<X){if(f<(R=X-R)&&i.sane){r.msg="invalid distance too far back",i.mode=30;break e}if(S=g,(C=0)===m){if(C+=b-R,R<V){for(V-=R;k[u++]=g[C++],--R;);C=u-X,S=k}}else if(m<R){if(C+=b+m-R,(R-=m)<V){for(V-=R;k[u++]=g[C++],--R;);if(C=0,m<V){for(V-=R=m;k[u++]=g[C++],--R;);C=u-X,S=k}}}else if(C+=m-R,R<V){for(V-=R;k[u++]=g[C++],--R;);C=u-X,S=k}for(;2<V;)k[u++]=S[C++],k[u++]=S[C++],k[u++]=S[C++],V-=3;V&&(k[u++]=S[C++],1<V&&(k[u++]=S[C++]))}else{for(C=u-X;k[u++]=k[C++],k[u++]=k[C++],k[u++]=k[C++],2<(V-=3););V&&(k[u++]=k[C++],1<V&&(k[u++]=k[C++]))}break}}break}}while(a<o&&u<p);a-=V=y>>3,A&=(1<<(y-=V<<3))-1,r.next_in=a,r.next_out=u,r.avail_in=a<o?o-a+5:5-(a-o),r.avail_out=u<p?p-u+257:257-(u-p),i.hold=A,i.bits=y}},{}],49:[function(s,e,t){"use strict";var r=s("../utils/common"),n=s("./adler32"),i=s("./crc32"),a=s("./inffast"),o=s("./inftrees"),u=1,d=2,p=0,l=-2,b=1,f=852,m=592;function g(C){return(C>>>24&255)+(C>>>8&65280)+((65280&C)<<8)+((255&C)<<24)}function A(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function y(C){var S;return C&&C.state?(S=C.state,C.total_in=C.total_out=S.total=0,C.msg="",S.wrap&&(C.adler=1&S.wrap),S.mode=b,S.last=0,S.havedict=0,S.dmax=32768,S.head=null,S.hold=0,S.bits=0,S.lencode=S.lendyn=new r.Buf32(f),S.distcode=S.distdyn=new r.Buf32(m),S.sane=1,S.back=-1,p):l}function w(C){var S;return C&&C.state?((S=C.state).wsize=0,S.whave=0,S.wnext=0,y(C)):l}function E(C,S){var h,k;return C&&C.state?(k=C.state,S<0?(h=0,S=-S):(h=1+(S>>4),S<48&&(S&=15)),S&&(S<8||15<S)?l:(k.window!==null&&k.wbits!==S&&(k.window=null),k.wrap=h,k.wbits=S,w(C))):l}function z(C,S){var h,k;return C?(k=new A,(C.state=k).window=null,(h=E(C,S))!==p&&(C.state=null),h):l}var P,G,R=!0;function V(C){if(R){var S;for(P=new r.Buf32(512),G=new r.Buf32(32),S=0;S<144;)C.lens[S++]=8;for(;S<256;)C.lens[S++]=9;for(;S<280;)C.lens[S++]=7;for(;S<288;)C.lens[S++]=8;for(o(u,C.lens,0,288,P,0,C.work,{bits:9}),S=0;S<32;)C.lens[S++]=5;o(d,C.lens,0,32,G,0,C.work,{bits:5}),R=!1}C.lencode=P,C.lenbits=9,C.distcode=G,C.distbits=5}function X(C,S,h,k){var Y,F=C.state;return F.window===null&&(F.wsize=1<<F.wbits,F.wnext=0,F.whave=0,F.window=new r.Buf8(F.wsize)),k>=F.wsize?(r.arraySet(F.window,S,h-F.wsize,F.wsize,0),F.wnext=0,F.whave=F.wsize):(k<(Y=F.wsize-F.wnext)&&(Y=k),r.arraySet(F.window,S,h-k,Y,F.wnext),(k-=Y)?(r.arraySet(F.window,S,h-k,k,0),F.wnext=k,F.whave=F.wsize):(F.wnext+=Y,F.wnext===F.wsize&&(F.wnext=0),F.whave<F.wsize&&(F.whave+=Y))),0}t.inflateReset=w,t.inflateReset2=E,t.inflateResetKeep=y,t.inflateInit=function(C){return z(C,15)},t.inflateInit2=z,t.inflate=function(C,S){var h,k,Y,F,q,I,O,D,v,j,W,Z,ee,te,K,re,le,ue,fe,me,c,L,T,_,x=0,B=new r.Buf8(4),U=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!C||!C.state||!C.output||!C.input&&C.avail_in!==0)return l;(h=C.state).mode===12&&(h.mode=13),q=C.next_out,Y=C.output,O=C.avail_out,F=C.next_in,k=C.input,I=C.avail_in,D=h.hold,v=h.bits,j=I,W=O,L=p;e:for(;;)switch(h.mode){case b:if(h.wrap===0){h.mode=13;break}for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(2&h.wrap&&D===35615){B[h.check=0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0),v=D=0,h.mode=2;break}if(h.flags=0,h.head&&(h.head.done=!1),!(1&h.wrap)||(((255&D)<<8)+(D>>8))%31){C.msg="incorrect header check",h.mode=30;break}if((15&D)!=8){C.msg="unknown compression method",h.mode=30;break}if(v-=4,c=8+(15&(D>>>=4)),h.wbits===0)h.wbits=c;else if(c>h.wbits){C.msg="invalid window size",h.mode=30;break}h.dmax=1<<c,C.adler=h.check=1,h.mode=512&D?10:12,v=D=0;break;case 2:for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(h.flags=D,(255&h.flags)!=8){C.msg="unknown compression method",h.mode=30;break}if(57344&h.flags){C.msg="unknown header flags set",h.mode=30;break}h.head&&(h.head.text=D>>8&1),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0)),v=D=0,h.mode=3;case 3:for(;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.head&&(h.head.time=D),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,B[2]=D>>>16&255,B[3]=D>>>24&255,h.check=i(h.check,B,4,0)),v=D=0,h.mode=4;case 4:for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.head&&(h.head.xflags=255&D,h.head.os=D>>8),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0)),v=D=0,h.mode=5;case 5:if(1024&h.flags){for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.length=D,h.head&&(h.head.extra_len=D),512&h.flags&&(B[0]=255&D,B[1]=D>>>8&255,h.check=i(h.check,B,2,0)),v=D=0}else h.head&&(h.head.extra=null);h.mode=6;case 6:if(1024&h.flags&&(I<(Z=h.length)&&(Z=I),Z&&(h.head&&(c=h.head.extra_len-h.length,h.head.extra||(h.head.extra=new Array(h.head.extra_len)),r.arraySet(h.head.extra,k,F,Z,c)),512&h.flags&&(h.check=i(h.check,k,Z,F)),I-=Z,F+=Z,h.length-=Z),h.length))break e;h.length=0,h.mode=7;case 7:if(2048&h.flags){if(I===0)break e;for(Z=0;c=k[F+Z++],h.head&&c&&h.length<65536&&(h.head.name+=String.fromCharCode(c)),c&&Z<I;);if(512&h.flags&&(h.check=i(h.check,k,Z,F)),I-=Z,F+=Z,c)break e}else h.head&&(h.head.name=null);h.length=0,h.mode=8;case 8:if(4096&h.flags){if(I===0)break e;for(Z=0;c=k[F+Z++],h.head&&c&&h.length<65536&&(h.head.comment+=String.fromCharCode(c)),c&&Z<I;);if(512&h.flags&&(h.check=i(h.check,k,Z,F)),I-=Z,F+=Z,c)break e}else h.head&&(h.head.comment=null);h.mode=9;case 9:if(512&h.flags){for(;v<16;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(D!==(65535&h.check)){C.msg="header crc mismatch",h.mode=30;break}v=D=0}h.head&&(h.head.hcrc=h.flags>>9&1,h.head.done=!0),C.adler=h.check=0,h.mode=12;break;case 10:for(;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}C.adler=h.check=g(D),v=D=0,h.mode=11;case 11:if(h.havedict===0)return C.next_out=q,C.avail_out=O,C.next_in=F,C.avail_in=I,h.hold=D,h.bits=v,2;C.adler=h.check=1,h.mode=12;case 12:if(S===5||S===6)break e;case 13:if(h.last){D>>>=7&v,v-=7&v,h.mode=27;break}for(;v<3;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}switch(h.last=1&D,v-=1,3&(D>>>=1)){case 0:h.mode=14;break;case 1:if(V(h),h.mode=20,S!==6)break;D>>>=2,v-=2;break e;case 2:h.mode=17;break;case 3:C.msg="invalid block type",h.mode=30}D>>>=2,v-=2;break;case 14:for(D>>>=7&v,v-=7&v;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if((65535&D)!=(D>>>16^65535)){C.msg="invalid stored block lengths",h.mode=30;break}if(h.length=65535&D,v=D=0,h.mode=15,S===6)break e;case 15:h.mode=16;case 16:if(Z=h.length){if(I<Z&&(Z=I),O<Z&&(Z=O),Z===0)break e;r.arraySet(Y,k,F,Z,q),I-=Z,F+=Z,O-=Z,q+=Z,h.length-=Z;break}h.mode=12;break;case 17:for(;v<14;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(h.nlen=257+(31&D),D>>>=5,v-=5,h.ndist=1+(31&D),D>>>=5,v-=5,h.ncode=4+(15&D),D>>>=4,v-=4,286<h.nlen||30<h.ndist){C.msg="too many length or distance symbols",h.mode=30;break}h.have=0,h.mode=18;case 18:for(;h.have<h.ncode;){for(;v<3;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.lens[U[h.have++]]=7&D,D>>>=3,v-=3}for(;h.have<19;)h.lens[U[h.have++]]=0;if(h.lencode=h.lendyn,h.lenbits=7,T={bits:h.lenbits},L=o(0,h.lens,0,19,h.lencode,0,h.work,T),h.lenbits=T.bits,L){C.msg="invalid code lengths set",h.mode=30;break}h.have=0,h.mode=19;case 19:for(;h.have<h.nlen+h.ndist;){for(;re=(x=h.lencode[D&(1<<h.lenbits)-1])>>>16&255,le=65535&x,!((K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(le<16)D>>>=K,v-=K,h.lens[h.have++]=le;else{if(le===16){for(_=K+2;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(D>>>=K,v-=K,h.have===0){C.msg="invalid bit length repeat",h.mode=30;break}c=h.lens[h.have-1],Z=3+(3&D),D>>>=2,v-=2}else if(le===17){for(_=K+3;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}v-=K,c=0,Z=3+(7&(D>>>=K)),D>>>=3,v-=3}else{for(_=K+7;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}v-=K,c=0,Z=11+(127&(D>>>=K)),D>>>=7,v-=7}if(h.have+Z>h.nlen+h.ndist){C.msg="invalid bit length repeat",h.mode=30;break}for(;Z--;)h.lens[h.have++]=c}}if(h.mode===30)break;if(h.lens[256]===0){C.msg="invalid code -- missing end-of-block",h.mode=30;break}if(h.lenbits=9,T={bits:h.lenbits},L=o(u,h.lens,0,h.nlen,h.lencode,0,h.work,T),h.lenbits=T.bits,L){C.msg="invalid literal/lengths set",h.mode=30;break}if(h.distbits=6,h.distcode=h.distdyn,T={bits:h.distbits},L=o(d,h.lens,h.nlen,h.ndist,h.distcode,0,h.work,T),h.distbits=T.bits,L){C.msg="invalid distances set",h.mode=30;break}if(h.mode=20,S===6)break e;case 20:h.mode=21;case 21:if(6<=I&&258<=O){C.next_out=q,C.avail_out=O,C.next_in=F,C.avail_in=I,h.hold=D,h.bits=v,a(C,W),q=C.next_out,Y=C.output,O=C.avail_out,F=C.next_in,k=C.input,I=C.avail_in,D=h.hold,v=h.bits,h.mode===12&&(h.back=-1);break}for(h.back=0;re=(x=h.lencode[D&(1<<h.lenbits)-1])>>>16&255,le=65535&x,!((K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(re&&(240&re)==0){for(ue=K,fe=re,me=le;re=(x=h.lencode[me+((D&(1<<ue+fe)-1)>>ue)])>>>16&255,le=65535&x,!(ue+(K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}D>>>=ue,v-=ue,h.back+=ue}if(D>>>=K,v-=K,h.back+=K,h.length=le,re===0){h.mode=26;break}if(32&re){h.back=-1,h.mode=12;break}if(64&re){C.msg="invalid literal/length code",h.mode=30;break}h.extra=15&re,h.mode=22;case 22:if(h.extra){for(_=h.extra;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.length+=D&(1<<h.extra)-1,D>>>=h.extra,v-=h.extra,h.back+=h.extra}h.was=h.length,h.mode=23;case 23:for(;re=(x=h.distcode[D&(1<<h.distbits)-1])>>>16&255,le=65535&x,!((K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if((240&re)==0){for(ue=K,fe=re,me=le;re=(x=h.distcode[me+((D&(1<<ue+fe)-1)>>ue)])>>>16&255,le=65535&x,!(ue+(K=x>>>24)<=v);){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}D>>>=ue,v-=ue,h.back+=ue}if(D>>>=K,v-=K,h.back+=K,64&re){C.msg="invalid distance code",h.mode=30;break}h.offset=le,h.extra=15&re,h.mode=24;case 24:if(h.extra){for(_=h.extra;v<_;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}h.offset+=D&(1<<h.extra)-1,D>>>=h.extra,v-=h.extra,h.back+=h.extra}if(h.offset>h.dmax){C.msg="invalid distance too far back",h.mode=30;break}h.mode=25;case 25:if(O===0)break e;if(Z=W-O,h.offset>Z){if((Z=h.offset-Z)>h.whave&&h.sane){C.msg="invalid distance too far back",h.mode=30;break}ee=Z>h.wnext?(Z-=h.wnext,h.wsize-Z):h.wnext-Z,Z>h.length&&(Z=h.length),te=h.window}else te=Y,ee=q-h.offset,Z=h.length;for(O<Z&&(Z=O),O-=Z,h.length-=Z;Y[q++]=te[ee++],--Z;);h.length===0&&(h.mode=21);break;case 26:if(O===0)break e;Y[q++]=h.length,O--,h.mode=21;break;case 27:if(h.wrap){for(;v<32;){if(I===0)break e;I--,D|=k[F++]<<v,v+=8}if(W-=O,C.total_out+=W,h.total+=W,W&&(C.adler=h.check=h.flags?i(h.check,Y,W,q-W):n(h.check,Y,W,q-W)),W=O,(h.flags?D:g(D))!==h.check){C.msg="incorrect data check",h.mode=30;break}v=D=0}h.mode=28;case 28:if(h.wrap&&h.flags){for(;v<32;){if(I===0)break e;I--,D+=k[F++]<<v,v+=8}if(D!==(4294967295&h.total)){C.msg="incorrect length check",h.mode=30;break}v=D=0}h.mode=29;case 29:L=1;break e;case 30:L=-3;break e;case 31:return-4;case 32:default:return l}return C.next_out=q,C.avail_out=O,C.next_in=F,C.avail_in=I,h.hold=D,h.bits=v,(h.wsize||W!==C.avail_out&&h.mode<30&&(h.mode<27||S!==4))&&X(C,C.output,C.next_out,W-C.avail_out)?(h.mode=31,-4):(j-=C.avail_in,W-=C.avail_out,C.total_in+=j,C.total_out+=W,h.total+=W,h.wrap&&W&&(C.adler=h.check=h.flags?i(h.check,Y,W,C.next_out-W):n(h.check,Y,W,C.next_out-W)),C.data_type=h.bits+(h.last?64:0)+(h.mode===12?128:0)+(h.mode===20||h.mode===15?256:0),(j==0&&W===0||S===4)&&L===p&&(L=-5),L)},t.inflateEnd=function(C){if(!C||!C.state)return l;var S=C.state;return S.window&&(S.window=null),C.state=null,p},t.inflateGetHeader=function(C,S){var h;return C&&C.state?(2&(h=C.state).wrap)==0?l:((h.head=S).done=!1,p):l},t.inflateSetDictionary=function(C,S){var h,k=S.length;return C&&C.state?(h=C.state).wrap!==0&&h.mode!==11?l:h.mode===11&&n(1,S,k,0)!==h.check?-3:X(C,S,k,k)?(h.mode=31,-4):(h.havedict=1,p):l},t.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(s,e,t){"use strict";var r=s("../utils/common"),n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],o=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(u,d,p,l,b,f,m,g){var A,y,w,E,z,P,G,R,V,X=g.bits,C=0,S=0,h=0,k=0,Y=0,F=0,q=0,I=0,O=0,D=0,v=null,j=0,W=new r.Buf16(16),Z=new r.Buf16(16),ee=null,te=0;for(C=0;C<=15;C++)W[C]=0;for(S=0;S<l;S++)W[d[p+S]]++;for(Y=X,k=15;1<=k&&W[k]===0;k--);if(k<Y&&(Y=k),k===0)return b[f++]=20971520,b[f++]=20971520,g.bits=1,0;for(h=1;h<k&&W[h]===0;h++);for(Y<h&&(Y=h),C=I=1;C<=15;C++)if(I<<=1,(I-=W[C])<0)return-1;if(0<I&&(u===0||k!==1))return-1;for(Z[1]=0,C=1;C<15;C++)Z[C+1]=Z[C]+W[C];for(S=0;S<l;S++)d[p+S]!==0&&(m[Z[d[p+S]]++]=S);if(P=u===0?(v=ee=m,19):u===1?(v=n,j-=257,ee=i,te-=257,256):(v=a,ee=o,-1),C=h,z=f,q=S=D=0,w=-1,E=(O=1<<(F=Y))-1,u===1&&852<O||u===2&&592<O)return 1;for(;;){for(G=C-q,V=m[S]<P?(R=0,m[S]):m[S]>P?(R=ee[te+m[S]],v[j+m[S]]):(R=96,0),A=1<<C-q,h=y=1<<F;b[z+(D>>q)+(y-=A)]=G<<24|R<<16|V|0,y!==0;);for(A=1<<C-1;D&A;)A>>=1;if(A!==0?(D&=A-1,D+=A):D=0,S++,--W[C]==0){if(C===k)break;C=d[p+m[S]]}if(Y<C&&(D&E)!==w){for(q===0&&(q=Y),z+=h,I=1<<(F=C-q);F+q<k&&!((I-=W[F+q])<=0);)F++,I<<=1;if(O+=1<<F,u===1&&852<O||u===2&&592<O)return 1;b[w=D&E]=Y<<24|F<<16|z-f|0}}return D!==0&&(b[z+D]=C-q<<24|64<<16|0),g.bits=Y,0}},{"../utils/common":41}],51:[function(s,e,t){"use strict";e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(s,e,t){"use strict";var r=s("../utils/common"),n=0,i=1;function a(x){for(var B=x.length;0<=--B;)x[B]=0}var o=0,u=29,d=256,p=d+1+u,l=30,b=19,f=2*p+1,m=15,g=16,A=7,y=256,w=16,E=17,z=18,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],G=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],R=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X=new Array(2*(p+2));a(X);var C=new Array(2*l);a(C);var S=new Array(512);a(S);var h=new Array(256);a(h);var k=new Array(u);a(k);var Y,F,q,I=new Array(l);function O(x,B,U,M,N){this.static_tree=x,this.extra_bits=B,this.extra_base=U,this.elems=M,this.max_length=N,this.has_stree=x&&x.length}function D(x,B){this.dyn_tree=x,this.max_code=0,this.stat_desc=B}function v(x){return x<256?S[x]:S[256+(x>>>7)]}function j(x,B){x.pending_buf[x.pending++]=255&B,x.pending_buf[x.pending++]=B>>>8&255}function W(x,B,U){x.bi_valid>g-U?(x.bi_buf|=B<<x.bi_valid&65535,j(x,x.bi_buf),x.bi_buf=B>>g-x.bi_valid,x.bi_valid+=U-g):(x.bi_buf|=B<<x.bi_valid&65535,x.bi_valid+=U)}function Z(x,B,U){W(x,U[2*B],U[2*B+1])}function ee(x,B){for(var U=0;U|=1&x,x>>>=1,U<<=1,0<--B;);return U>>>1}function te(x,B,U){var M,N,H=new Array(m+1),J=0;for(M=1;M<=m;M++)H[M]=J=J+U[M-1]<<1;for(N=0;N<=B;N++){var $=x[2*N+1];$!==0&&(x[2*N]=ee(H[$]++,$))}}function K(x){var B;for(B=0;B<p;B++)x.dyn_ltree[2*B]=0;for(B=0;B<l;B++)x.dyn_dtree[2*B]=0;for(B=0;B<b;B++)x.bl_tree[2*B]=0;x.dyn_ltree[2*y]=1,x.opt_len=x.static_len=0,x.last_lit=x.matches=0}function re(x){8<x.bi_valid?j(x,x.bi_buf):0<x.bi_valid&&(x.pending_buf[x.pending++]=x.bi_buf),x.bi_buf=0,x.bi_valid=0}function le(x,B,U,M){var N=2*B,H=2*U;return x[N]<x[H]||x[N]===x[H]&&M[B]<=M[U]}function ue(x,B,U){for(var M=x.heap[U],N=U<<1;N<=x.heap_len&&(N<x.heap_len&&le(B,x.heap[N+1],x.heap[N],x.depth)&&N++,!le(B,M,x.heap[N],x.depth));)x.heap[U]=x.heap[N],U=N,N<<=1;x.heap[U]=M}function fe(x,B,U){var M,N,H,J,$=0;if(x.last_lit!==0)for(;M=x.pending_buf[x.d_buf+2*$]<<8|x.pending_buf[x.d_buf+2*$+1],N=x.pending_buf[x.l_buf+$],$++,M===0?Z(x,N,B):(Z(x,(H=h[N])+d+1,B),(J=P[H])!==0&&W(x,N-=k[H],J),Z(x,H=v(--M),U),(J=G[H])!==0&&W(x,M-=I[H],J)),$<x.last_lit;);Z(x,y,B)}function me(x,B){var U,M,N,H=B.dyn_tree,J=B.stat_desc.static_tree,$=B.stat_desc.has_stree,Q=B.stat_desc.elems,ce=-1;for(x.heap_len=0,x.heap_max=f,U=0;U<Q;U++)H[2*U]!==0?(x.heap[++x.heap_len]=ce=U,x.depth[U]=0):H[2*U+1]=0;for(;x.heap_len<2;)H[2*(N=x.heap[++x.heap_len]=ce<2?++ce:0)]=1,x.depth[N]=0,x.opt_len--,$&&(x.static_len-=J[2*N+1]);for(B.max_code=ce,U=x.heap_len>>1;1<=U;U--)ue(x,H,U);for(N=Q;U=x.heap[1],x.heap[1]=x.heap[x.heap_len--],ue(x,H,1),M=x.heap[1],x.heap[--x.heap_max]=U,x.heap[--x.heap_max]=M,H[2*N]=H[2*U]+H[2*M],x.depth[N]=(x.depth[U]>=x.depth[M]?x.depth[U]:x.depth[M])+1,H[2*U+1]=H[2*M+1]=N,x.heap[1]=N++,ue(x,H,1),2<=x.heap_len;);x.heap[--x.heap_max]=x.heap[1],function(ne,ye){var Me,we,Oe,de,rt,Et,ve=ye.dyn_tree,fr=ye.max_code,Ei=ye.stat_desc.static_tree,Bi=ye.stat_desc.has_stree,Ii=ye.stat_desc.extra_bits,mr=ye.stat_desc.extra_base,je=ye.stat_desc.max_length,it=0;for(de=0;de<=m;de++)ne.bl_count[de]=0;for(ve[2*ne.heap[ne.heap_max]+1]=0,Me=ne.heap_max+1;Me<f;Me++)je<(de=ve[2*ve[2*(we=ne.heap[Me])+1]+1]+1)&&(de=je,it++),ve[2*we+1]=de,fr<we||(ne.bl_count[de]++,rt=0,mr<=we&&(rt=Ii[we-mr]),Et=ve[2*we],ne.opt_len+=Et*(de+rt),Bi&&(ne.static_len+=Et*(Ei[2*we+1]+rt)));if(it!==0){do{for(de=je-1;ne.bl_count[de]===0;)de--;ne.bl_count[de]--,ne.bl_count[de+1]+=2,ne.bl_count[je]--,it-=2}while(0<it);for(de=je;de!==0;de--)for(we=ne.bl_count[de];we!==0;)fr<(Oe=ne.heap[--Me])||(ve[2*Oe+1]!==de&&(ne.opt_len+=(de-ve[2*Oe+1])*ve[2*Oe],ve[2*Oe+1]=de),we--)}}(x,B),te(H,ce,x.bl_count)}function c(x,B,U){var M,N,H=-1,J=B[1],$=0,Q=7,ce=4;for(J===0&&(Q=138,ce=3),B[2*(U+1)+1]=65535,M=0;M<=U;M++)N=J,J=B[2*(M+1)+1],++$<Q&&N===J||($<ce?x.bl_tree[2*N]+=$:N!==0?(N!==H&&x.bl_tree[2*N]++,x.bl_tree[2*w]++):$<=10?x.bl_tree[2*E]++:x.bl_tree[2*z]++,H=N,ce=($=0)===J?(Q=138,3):N===J?(Q=6,3):(Q=7,4))}function L(x,B,U){var M,N,H=-1,J=B[1],$=0,Q=7,ce=4;for(J===0&&(Q=138,ce=3),M=0;M<=U;M++)if(N=J,J=B[2*(M+1)+1],!(++$<Q&&N===J)){if($<ce)for(;Z(x,N,x.bl_tree),--$!=0;);else N!==0?(N!==H&&(Z(x,N,x.bl_tree),$--),Z(x,w,x.bl_tree),W(x,$-3,2)):$<=10?(Z(x,E,x.bl_tree),W(x,$-3,3)):(Z(x,z,x.bl_tree),W(x,$-11,7));H=N,ce=($=0)===J?(Q=138,3):N===J?(Q=6,3):(Q=7,4)}}a(I);var T=!1;function _(x,B,U,M){W(x,(o<<1)+(M?1:0),3),function(N,H,J,$){re(N),$&&(j(N,J),j(N,~J)),r.arraySet(N.pending_buf,N.window,H,J,N.pending),N.pending+=J}(x,B,U,!0)}t._tr_init=function(x){T||(function(){var B,U,M,N,H,J=new Array(m+1);for(N=M=0;N<u-1;N++)for(k[N]=M,B=0;B<1<<P[N];B++)h[M++]=N;for(h[M-1]=N,N=H=0;N<16;N++)for(I[N]=H,B=0;B<1<<G[N];B++)S[H++]=N;for(H>>=7;N<l;N++)for(I[N]=H<<7,B=0;B<1<<G[N]-7;B++)S[256+H++]=N;for(U=0;U<=m;U++)J[U]=0;for(B=0;B<=143;)X[2*B+1]=8,B++,J[8]++;for(;B<=255;)X[2*B+1]=9,B++,J[9]++;for(;B<=279;)X[2*B+1]=7,B++,J[7]++;for(;B<=287;)X[2*B+1]=8,B++,J[8]++;for(te(X,p+1,J),B=0;B<l;B++)C[2*B+1]=5,C[2*B]=ee(B,5);Y=new O(X,P,d+1,p,m),F=new O(C,G,0,l,m),q=new O(new Array(0),R,0,b,A)}(),T=!0),x.l_desc=new D(x.dyn_ltree,Y),x.d_desc=new D(x.dyn_dtree,F),x.bl_desc=new D(x.bl_tree,q),x.bi_buf=0,x.bi_valid=0,K(x)},t._tr_stored_block=_,t._tr_flush_block=function(x,B,U,M){var N,H,J=0;0<x.level?(x.strm.data_type===2&&(x.strm.data_type=function($){var Q,ce=4093624447;for(Q=0;Q<=31;Q++,ce>>>=1)if(1&ce&&$.dyn_ltree[2*Q]!==0)return n;if($.dyn_ltree[18]!==0||$.dyn_ltree[20]!==0||$.dyn_ltree[26]!==0)return i;for(Q=32;Q<d;Q++)if($.dyn_ltree[2*Q]!==0)return i;return n}(x)),me(x,x.l_desc),me(x,x.d_desc),J=function($){var Q;for(c($,$.dyn_ltree,$.l_desc.max_code),c($,$.dyn_dtree,$.d_desc.max_code),me($,$.bl_desc),Q=b-1;3<=Q&&$.bl_tree[2*V[Q]+1]===0;Q--);return $.opt_len+=3*(Q+1)+5+5+4,Q}(x),N=x.opt_len+3+7>>>3,(H=x.static_len+3+7>>>3)<=N&&(N=H)):N=H=U+5,U+4<=N&&B!==-1?_(x,B,U,M):x.strategy===4||H===N?(W(x,2+(M?1:0),3),fe(x,X,C)):(W(x,4+(M?1:0),3),function($,Q,ce,ne){var ye;for(W($,Q-257,5),W($,ce-1,5),W($,ne-4,4),ye=0;ye<ne;ye++)W($,$.bl_tree[2*V[ye]+1],3);L($,$.dyn_ltree,Q-1),L($,$.dyn_dtree,ce-1)}(x,x.l_desc.max_code+1,x.d_desc.max_code+1,J+1),fe(x,x.dyn_ltree,x.dyn_dtree)),K(x),M&&re(x)},t._tr_tally=function(x,B,U){return x.pending_buf[x.d_buf+2*x.last_lit]=B>>>8&255,x.pending_buf[x.d_buf+2*x.last_lit+1]=255&B,x.pending_buf[x.l_buf+x.last_lit]=255&U,x.last_lit++,B===0?x.dyn_ltree[2*U]++:(x.matches++,B--,x.dyn_ltree[2*(h[U]+d+1)]++,x.dyn_dtree[2*v(B)]++),x.last_lit===x.lit_bufsize-1},t._tr_align=function(x){W(x,2,3),Z(x,y,X),function(B){B.bi_valid===16?(j(B,B.bi_buf),B.bi_buf=0,B.bi_valid=0):8<=B.bi_valid&&(B.pending_buf[B.pending++]=255&B.bi_buf,B.bi_buf>>=8,B.bi_valid-=8)}(x)}},{"../utils/common":41}],53:[function(s,e,t){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(s,e,t){(function(r){(function(n,i){"use strict";if(!n.setImmediate){var a,o,u,d,p=1,l={},b=!1,f=n.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(n);m=m&&m.setTimeout?m:n,a={}.toString.call(n.process)==="[object process]"?function(w){process.nextTick(function(){A(w)})}:function(){if(n.postMessage&&!n.importScripts){var w=!0,E=n.onmessage;return n.onmessage=function(){w=!1},n.postMessage("","*"),n.onmessage=E,w}}()?(d="setImmediate$"+Math.random()+"$",n.addEventListener?n.addEventListener("message",y,!1):n.attachEvent("onmessage",y),function(w){n.postMessage(d+w,"*")}):n.MessageChannel?((u=new MessageChannel).port1.onmessage=function(w){A(w.data)},function(w){u.port2.postMessage(w)}):f&&"onreadystatechange"in f.createElement("script")?(o=f.documentElement,function(w){var E=f.createElement("script");E.onreadystatechange=function(){A(w),E.onreadystatechange=null,o.removeChild(E),E=null},o.appendChild(E)}):function(w){setTimeout(A,0,w)},m.setImmediate=function(w){typeof w!="function"&&(w=new Function(""+w));for(var E=new Array(arguments.length-1),z=0;z<E.length;z++)E[z]=arguments[z+1];var P={callback:w,args:E};return l[p]=P,a(p),p++},m.clearImmediate=g}function g(w){delete l[w]}function A(w){if(b)setTimeout(A,0,w);else{var E=l[w];if(E){b=!0;try{(function(z){var P=z.callback,G=z.args;switch(G.length){case 0:P();break;case 1:P(G[0]);break;case 2:P(G[0],G[1]);break;case 3:P(G[0],G[1],G[2]);break;default:P.apply(i,G)}})(E)}finally{g(w),b=!1}}}}function y(w){w.source===n&&typeof w.data=="string"&&w.data.indexOf(d)===0&&A(+w.data.slice(d.length))}})(typeof self>"u"?r===void 0?this:r:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})});var Tt=ge(Ee=>{"use strict";var xr=":A-Za-z_\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D\\\\u037F-\\\\u1FFF\\\\u200C-\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD",Ui=xr+"\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040",yr="["+xr+"]["+Ui+"]*",Vi=new RegExp("^"+yr+"$"),Mi=function(s,e){let t=[],r=e.exec(s);for(;r;){let n=[];n.startIndex=e.lastIndex-r[0].length;let i=r.length;for(let a=0;a<i;a++)n.push(r[a]);t.push(n),r=e.exec(s)}return t},Oi=function(s){let e=Vi.exec(s);return!(e===null||typeof e>"u")};Ee.isExist=function(s){return typeof s<"u"};Ee.isEmptyObject=function(s){return Object.keys(s).length===0};Ee.merge=function(s,e,t){if(e){let r=Object.keys(e),n=r.length;for(let i=0;i<n;i++)t==="strict"?s[r[i]]=[e[r[i]]]:s[r[i]]=e[r[i]]}};Ee.getValue=function(s){return Ee.isExist(s)?s:""};Ee.isName=Oi;Ee.getAllMatches=Mi;Ee.nameRegexp=yr});var Rt=ge(vr=>{"use strict";var Pt=Tt(),ji={allowBooleanAttributes:!1,unpairedTags:[]};vr.validate=function(s,e){e=Object.assign({},ji,e);let t=[],r=!1,n=!1;s[0]==="\\uFEFF"&&(s=s.substr(1));for(let i=0;i<s.length;i++)if(s[i]==="<"&&s[i+1]==="?"){if(i+=2,i=_r(s,i),i.err)return i}else if(s[i]==="<"){let a=i;if(i++,s[i]==="!"){i=Dr(s,i);continue}else{let o=!1;s[i]==="/"&&(o=!0,i++);let u="";for(;i<s.length&&s[i]!==">"&&s[i]!==" "&&s[i]!==" "&&s[i]!==`\n`&&s[i]!=="\\r";i++)u+=s[i];if(u=u.trim(),u[u.length-1]==="/"&&(u=u.substring(0,u.length-1),i--),!Ki(u)){let l;return u.trim().length===0?l="Invalid space after \'<\'.":l="Tag \'"+u+"\' is an invalid name.",he("InvalidTag",l,be(s,i))}let d=$i(s,i);if(d===!1)return he("InvalidAttr","Attributes for \'"+u+"\' have open quote.",be(s,i));let p=d.value;if(i=d.index,p[p.length-1]==="/"){let l=i-p.length;p=p.substring(0,p.length-1);let b=Cr(p,e);if(b===!0)r=!0;else return he(b.err.code,b.err.msg,be(s,l+b.err.line))}else if(o)if(d.tagClosed){if(p.trim().length>0)return he("InvalidTag","Closing tag \'"+u+"\' can\'t have attributes or invalid starting.",be(s,a));{let l=t.pop();if(u!==l.tagName){let b=be(s,l.tagStartPos);return he("InvalidTag","Expected closing tag \'"+l.tagName+"\' (opened in line "+b.line+", col "+b.col+") instead of closing tag \'"+u+"\'.",be(s,a))}t.length==0&&(n=!0)}}else return he("InvalidTag","Closing tag \'"+u+"\' doesn\'t have proper closing.",be(s,i));else{let l=Cr(p,e);if(l!==!0)return he(l.err.code,l.err.msg,be(s,i-p.length+l.err.line));if(n===!0)return he("InvalidXml","Multiple possible root nodes found.",be(s,i));e.unpairedTags.indexOf(u)!==-1||t.push({tagName:u,tagStartPos:a}),r=!0}for(i++;i<s.length;i++)if(s[i]==="<")if(s[i+1]==="!"){i++,i=Dr(s,i);continue}else if(s[i+1]==="?"){if(i=_r(s,++i),i.err)return i}else break;else if(s[i]==="&"){let l=Xi(s,i);if(l==-1)return he("InvalidChar","char \'&\' is not expected.",be(s,i));i=l}else if(n===!0&&!wr(s[i]))return he("InvalidXml","Extra text at the end",be(s,i));s[i]==="<"&&i--}}else{if(wr(s[i]))continue;return he("InvalidChar","char \'"+s[i]+"\' is not expected.",be(s,i))}if(r){if(t.length==1)return he("InvalidTag","Unclosed tag \'"+t[0].tagName+"\'.",be(s,t[0].tagStartPos));if(t.length>0)return he("InvalidXml","Invalid \'"+JSON.stringify(t.map(i=>i.tagName),null,4).replace(/\\r?\\n/g,"")+"\' found.",{line:1,col:1})}else return he("InvalidXml","Start tag expected.",1);return!0};function wr(s){return s===" "||s===" "||s===`\n`||s==="\\r"}function _r(s,e){let t=e;for(;e<s.length;e++)if(s[e]=="?"||s[e]==" "){let r=s.substr(t,e-t);if(e>5&&r==="xml")return he("InvalidXml","XML declaration allowed only at the start of the document.",be(s,e));if(s[e]=="?"&&s[e+1]==">"){e++;break}else continue}return e}function Dr(s,e){if(s.length>e+5&&s[e+1]==="-"&&s[e+2]==="-"){for(e+=3;e<s.length;e++)if(s[e]==="-"&&s[e+1]==="-"&&s[e+2]===">"){e+=2;break}}else if(s.length>e+8&&s[e+1]==="D"&&s[e+2]==="O"&&s[e+3]==="C"&&s[e+4]==="T"&&s[e+5]==="Y"&&s[e+6]==="P"&&s[e+7]==="E"){let t=1;for(e+=8;e<s.length;e++)if(s[e]==="<")t++;else if(s[e]===">"&&(t--,t===0))break}else if(s.length>e+9&&s[e+1]==="["&&s[e+2]==="C"&&s[e+3]==="D"&&s[e+4]==="A"&&s[e+5]==="T"&&s[e+6]==="A"&&s[e+7]==="["){for(e+=8;e<s.length;e++)if(s[e]==="]"&&s[e+1]==="]"&&s[e+2]===">"){e+=2;break}}return e}var Yi=\'"\',Hi="\'";function $i(s,e){let t="",r="",n=!1;for(;e<s.length;e++){if(s[e]===Yi||s[e]===Hi)r===""?r=s[e]:r!==s[e]||(r="");else if(s[e]===">"&&r===""){n=!0;break}t+=s[e]}return r!==""?!1:{value:t,index:e,tagClosed:n}}var qi=new RegExp(`(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*([\'"])(([\\\\s\\\\S])*?)\\\\5)?`,"g");function Cr(s,e){let t=Pt.getAllMatches(s,qi),r={};for(let n=0;n<t.length;n++){if(t[n][1].length===0)return he("InvalidAttr","Attribute \'"+t[n][2]+"\' has no space in starting.",qe(t[n]));if(t[n][3]!==void 0&&t[n][4]===void 0)return he("InvalidAttr","Attribute \'"+t[n][2]+"\' is without value.",qe(t[n]));if(t[n][3]===void 0&&!e.allowBooleanAttributes)return he("InvalidAttr","boolean attribute \'"+t[n][2]+"\' is not allowed.",qe(t[n]));let i=t[n][2];if(!Qi(i))return he("InvalidAttr","Attribute \'"+i+"\' is an invalid name.",qe(t[n]));if(!r.hasOwnProperty(i))r[i]=1;else return he("InvalidAttr","Attribute \'"+i+"\' is repeated.",qe(t[n]))}return!0}function Ji(s,e){let t=/\\d/;for(s[e]==="x"&&(e++,t=/[\\da-fA-F]/);e<s.length;e++){if(s[e]===";")return e;if(!s[e].match(t))break}return-1}function Xi(s,e){if(e++,s[e]===";")return-1;if(s[e]==="#")return e++,Ji(s,e);let t=0;for(;e<s.length;e++,t++)if(!(s[e].match(/\\w/)&&t<20)){if(s[e]===";")break;return-1}return e}function he(s,e,t){return{err:{code:s,msg:e,line:t.line||t,col:t.col}}}function Qi(s){return Pt.isName(s)}function Ki(s){return Pt.isName(s)}function be(s,e){let t=s.substring(0,e).split(/\\r?\\n/);return{line:t.length,col:t[t.length-1].length+1}}function qe(s){return s.startIndex+s[1].length}});var Br=ge(Zt=>{var Er={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0},tagValueProcessor:function(s,e){return e},attributeValueProcessor:function(s,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1},en=function(s){return Object.assign({},Er,s)};Zt.buildOptions=en;Zt.defaultOptions=Er});var kr=ge((wa,Ir)=>{"use strict";var zt=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){this.child.push({[e]:t})}addChild(e){e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,[":@"]:e[":@"]}):this.child.push({[e.tagname]:e.child})}};Ir.exports=zt});var Fr=ge((_a,Nr)=>{function tn(s,e){let t={};if(s[e+3]==="O"&&s[e+4]==="C"&&s[e+5]==="T"&&s[e+6]==="Y"&&s[e+7]==="P"&&s[e+8]==="E"){e=e+9;let r=1,n=!1,i=!1,a=!1,o="";for(;e<s.length;e++)if(s[e]==="<"){if(n&&s[e+1]==="!"&&s[e+2]==="E"&&s[e+3]==="N"&&s[e+4]==="T"&&s[e+5]==="I"&&s[e+6]==="T"&&s[e+7]==="Y")e+=7,i=!0;else if(n&&s[e+1]==="!"&&s[e+2]==="E"&&s[e+3]==="L"&&s[e+4]==="E"&&s[e+5]==="M"&&s[e+6]==="E"&&s[e+7]==="N"&&s[e+8]==="T")e+=8;else if(n&&s[e+1]==="!"&&s[e+2]==="A"&&s[e+3]==="T"&&s[e+4]==="T"&&s[e+5]==="L"&&s[e+6]==="I"&&s[e+7]==="S"&&s[e+8]==="T")e+=8;else if(n&&s[e+1]==="!"&&s[e+2]==="N"&&s[e+3]==="O"&&s[e+4]==="T"&&s[e+5]==="A"&&s[e+6]==="T"&&s[e+7]==="I"&&s[e+8]==="O"&&s[e+9]==="N")e+=9;else if(s[e+1]==="!"&&s[e+2]==="-"&&s[e+3]==="-")a=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(s[e]===">"){if(a)if(s[e-1]==="-"&&s[e-2]==="-")a=!1;else throw new Error("Invalid XML comment in DOCTYPE");else i&&(nn(o,t),i=!1);if(r--,r===0)break}else s[e]==="["?n=!0:o+=s[e];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:t,i:e}}var rn=RegExp(`^\\\\s([a-zA-z0-0]+)[ ]([\'"])([^&]+)\\\\2`);function nn(s,e){let t=rn.exec(s);t&&(e[t[1]]={regx:RegExp(`&${t[1]};`,"g"),val:t[3]})}Nr.exports=tn});var Tr=ge((Da,Sr)=>{var sn=/^[-+]?0x[a-fA-F0-9]+$/,an=/^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var on={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function un(s,e={}){if(e=Object.assign({},on,e),!s||typeof s!="string")return s;let t=s.trim();if(e.skipLike!==void 0&&e.skipLike.test(t))return s;if(e.hex&&sn.test(t))return Number.parseInt(t,16);{let r=an.exec(t);if(r){let n=r[1],i=r[2],a=ln(r[3]),o=r[4]||r[6];if(!e.leadingZeros&&i.length>0&&n&&t[2]!==".")return s;if(!e.leadingZeros&&i.length>0&&!n&&t[1]!==".")return s;{let u=Number(t),d=""+u;return d.search(/[eE]/)!==-1||o?e.eNotation?u:s:t.indexOf(".")!==-1?d==="0"&&a===""||d===a||n&&d==="-"+a?u:s:i?a===d||n+a===d?u:s:t===d||t===n+d?u:s}}else return s}}function ln(s){return s&&s.indexOf(".")!==-1&&(s=s.replace(/0+$/,""),s==="."?s="0":s[0]==="."?s="0"+s:s[s.length-1]==="."&&(s=s.substr(0,s.length-1))),s}Sr.exports=un});var Rr=ge((va,Pr)=>{"use strict";var Ut=Tt(),Je=kr(),cn=Fr(),dn=Tr(),Ca="<((!\\\\[CDATA\\\\[([\\\\s\\\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\\\/)(NAME)\\\\s*>))([^<]*)".replace(/NAME/g,Ut.nameRegexp),Lt=class{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={amp:{regex:/&(amp|#38|#x26);/g,val:"&"},apos:{regex:/&(apos|#39|#x27);/g,val:"\'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:\'"\'}},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\\xA2"},pound:{regex:/&(pound|#163);/g,val:"\\xA3"},yen:{regex:/&(yen|#165);/g,val:"\\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\\xA9"},reg:{regex:/&(reg|#174);/g,val:"\\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\\u20B9"}},this.addExternalEntities=hn,this.parseXml=bn,this.parseTextData=pn,this.resolveNameSpace=fn,this.buildAttributesMap=gn,this.isItStopNode=yn,this.replaceEntitiesValue=An,this.readStopNodeData=_n,this.saveTextToParentTag=xn}};function hn(s){let e=Object.keys(s);for(let t=0;t<e.length;t++){let r=e[t];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:s[r]}}}function pn(s,e,t,r,n,i,a){if(s!==void 0&&(this.options.trimValues&&!r&&(s=s.trim()),s.length>0)){a||(s=this.replaceEntitiesValue(s));let o=this.options.tagValueProcessor(e,s,t,n,i);return o==null?s:typeof o!=typeof s||o!==s?o:this.options.trimValues?Gt(s,this.options.parseTagValue,this.options.numberParseOptions):s.trim()===s?Gt(s,this.options.parseTagValue,this.options.numberParseOptions):s}}function fn(s){if(this.options.removeNSPrefix){let e=s.split(":"),t=s.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(s=t+e[1])}return s}var mn=new RegExp(`([^\\\\s=]+)\\\\s*(=\\\\s*([\'"])([\\\\s\\\\S]*?)\\\\3)?`,"gm");function gn(s,e){if(!this.options.ignoreAttributes&&typeof s=="string"){let t=Ut.getAllMatches(s,mn),r=t.length,n={};for(let i=0;i<r;i++){let a=this.resolveNameSpace(t[i][1]),o=t[i][4],u=this.options.attributeNamePrefix+a;if(a.length)if(o!==void 0){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);let d=this.options.attributeValueProcessor(a,o,e);d==null?n[u]=o:typeof d!=typeof o||d!==o?n[u]=d:n[u]=Gt(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[u]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){let i={};return i[this.options.attributesGroupName]=n,i}return n}}var bn=function(s){s=s.replace(/\\r\\n?/g,`\n`);let e=new Je("!xml"),t=e,r="",n="";for(let i=0;i<s.length;i++)if(s[i]==="<")if(s[i+1]==="/"){let o=Re(s,">",i,"Closing Tag is not closed."),u=s.substring(i+2,o).trim();if(this.options.removeNSPrefix){let d=u.indexOf(":");d!==-1&&(u=u.substr(d+1))}this.options.transformTagName&&(u=this.options.transformTagName(u)),t&&(r=this.saveTextToParentTag(r,t,n)),n=n.substr(0,n.lastIndexOf(".")),t=this.tagsNodeStack.pop(),r="",i=o}else if(s[i+1]==="?"){let o=Wt(s,i,!1,"?>");if(!o)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,t,n),!(this.options.ignoreDeclaration&&o.tagName==="?xml"||this.options.ignorePiTags)){let u=new Je(o.tagName);u.add(this.options.textNodeName,""),o.tagName!==o.tagExp&&o.attrExpPresent&&(u[":@"]=this.buildAttributesMap(o.tagExp,n)),t.addChild(u)}i=o.closeIndex+1}else if(s.substr(i+1,3)==="!--"){let o=Re(s,"-->",i+4,"Comment is not closed.");if(this.options.commentPropName){let u=s.substring(i+4,o-2);r=this.saveTextToParentTag(r,t,n),t.add(this.options.commentPropName,[{[this.options.textNodeName]:u}])}i=o}else if(s.substr(i+1,2)==="!D"){let o=cn(s,i);this.docTypeEntities=o.entities,i=o.i}else if(s.substr(i+1,2)==="!["){let o=Re(s,"]]>",i,"CDATA is not closed.")-2,u=s.substring(i+9,o);if(r=this.saveTextToParentTag(r,t,n),this.options.cdataPropName)t.add(this.options.cdataPropName,[{[this.options.textNodeName]:u}]);else{let d=this.parseTextData(u,t.tagname,n,!0,!1,!0);d==null&&(d=""),t.add(this.options.textNodeName,d)}i=o+2}else{let o=Wt(s,i,this.options.removeNSPrefix),u=o.tagName,d=o.tagExp,p=o.attrExpPresent,l=o.closeIndex;this.options.transformTagName&&(u=this.options.transformTagName(u)),t&&r&&t.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,t,n,!1)),u!==e.tagname&&(n+=n?"."+u:u);let b=t;if(b&&this.options.unpairedTags.indexOf(b.tagname)!==-1&&(t=this.tagsNodeStack.pop()),this.isItStopNode(this.options.stopNodes,n,u)){let f="";if(d.length>0&&d.lastIndexOf("/")===d.length-1)i=o.closeIndex;else if(this.options.unpairedTags.indexOf(u)!==-1)i=o.closeIndex;else{let g=this.readStopNodeData(s,u,l+1);if(!g)throw new Error(`Unexpected end of ${u}`);i=g.i,f=g.tagContent}let m=new Je(u);u!==d&&p&&(m[":@"]=this.buildAttributesMap(d,n)),f&&(f=this.parseTextData(f,u,n,!0,p,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),m.add(this.options.textNodeName,f),t.addChild(m)}else{if(d.length>0&&d.lastIndexOf("/")===d.length-1){u[u.length-1]==="/"?(u=u.substr(0,u.length-1),d=u):d=d.substr(0,d.length-1),this.options.transformTagName&&(u=this.options.transformTagName(u));let f=new Je(u);u!==d&&p&&(f[":@"]=this.buildAttributesMap(d,n)),n=n.substr(0,n.lastIndexOf(".")),t.addChild(f)}else{let f=new Je(u);this.tagsNodeStack.push(t),u!==d&&p&&(f[":@"]=this.buildAttributesMap(d,n)),t.addChild(f),t=f}r="",i=l}}else r+=s[i];return e.child},An=function(s){if(this.options.processEntities){for(let e in this.docTypeEntities){let t=this.docTypeEntities[e];s=s.replace(t.regx,t.val)}for(let e in this.lastEntities){let t=this.lastEntities[e];s=s.replace(t.regex,t.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){let t=this.htmlEntities[e];s=s.replace(t.regex,t.val)}}return s};function xn(s,e,t,r){return s&&(r===void 0&&(r=Object.keys(e.child).length===0),s=this.parseTextData(s,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,r),s!==void 0&&s!==""&&e.add(this.options.textNodeName,s),s=""),s}function yn(s,e,t){let r="*."+t;for(let n in s){let i=s[n];if(r===i||e===i)return!0}return!1}function wn(s,e,t=">"){let r,n="";for(let i=e;i<s.length;i++){let a=s[i];if(r)a===r&&(r="");else if(a===\'"\'||a==="\'")r=a;else if(a===t[0])if(t[1]){if(s[i+1]===t[1])return{data:n,index:i}}else return{data:n,index:i};else a===" "&&(a=" ");n+=a}}function Re(s,e,t,r){let n=s.indexOf(e,t);if(n===-1)throw new Error(r);return n+e.length-1}function Wt(s,e,t,r=">"){let n=wn(s,e+1,r);if(!n)return;let i=n.data,a=n.index,o=i.search(/\\s/),u=i,d=!0;if(o!==-1&&(u=i.substr(0,o).replace(/\\s\\s*$/,""),i=i.substr(o+1)),t){let p=u.indexOf(":");p!==-1&&(u=u.substr(p+1),d=u!==n.data.substr(p+1))}return{tagName:u,tagExp:i,closeIndex:a,attrExpPresent:d}}function _n(s,e,t){let r=t,n=1;for(;t<s.length;t++)if(s[t]==="<")if(s[t+1]==="/"){let i=Re(s,">",t,`${e} is not closed`);if(s.substring(t+2,i).trim()===e&&(n--,n===0))return{tagContent:s.substring(r,t),i};t=i}else if(s[t+1]==="?")t=Re(s,"?>",t+1,"StopNode is not closed.");else if(s.substr(t+1,3)==="!--")t=Re(s,"-->",t+3,"StopNode is not closed.");else if(s.substr(t+1,2)==="![")t=Re(s,"]]>",t,"StopNode is not closed.")-2;else{let i=Wt(s,t,">");i&&((i&&i.tagName)===e&&i.tagExp[i.tagExp.length-1]!=="/"&&n++,t=i.closeIndex)}}function Gt(s,e,t){if(e&&typeof s=="string"){let r=s.trim();return r==="true"?!0:r==="false"?!1:dn(s,t)}else return Ut.isExist(s)?s:""}Pr.exports=Lt});var Lr=ge(zr=>{"use strict";function Dn(s,e){return Zr(s,e)}function Zr(s,e,t){let r,n={};for(let i=0;i<s.length;i++){let a=s[i],o=Cn(a),u="";if(t===void 0?u=o:u=t+"."+o,o===e.textNodeName)r===void 0?r=a[o]:r+=""+a[o];else{if(o===void 0)continue;if(a[o]){let d=Zr(a[o],e,u),p=En(d,e);a[":@"]?vn(d,a[":@"],u,e):Object.keys(d).length===1&&d[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?d=d[e.textNodeName]:Object.keys(d).length===0&&(e.alwaysCreateTextNode?d[e.textNodeName]="":d=""),n[o]!==void 0&&n.hasOwnProperty(o)?(Array.isArray(n[o])||(n[o]=[n[o]]),n[o].push(d)):e.isArray(o,u,p)?n[o]=[d]:n[o]=d}}}return typeof r=="string"?r.length>0&&(n[e.textNodeName]=r):r!==void 0&&(n[e.textNodeName]=r),n}function Cn(s){let e=Object.keys(s);for(let t=0;t<e.length;t++){let r=e[t];if(r!==":@")return r}}function vn(s,e,t,r){if(e){let n=Object.keys(e),i=n.length;for(let a=0;a<i;a++){let o=n[a];r.isArray(o,t+"."+o,!0,!0)?s[o]=[e[o]]:s[o]=e[o]}}}function En(s,e){let t=Object.keys(s).length;return!!(t===0||t===1&&s[e.textNodeName])}zr.prettify=Dn});var Gr=ge((Ba,Wr)=>{var{buildOptions:Bn}=Br(),In=Rr(),{prettify:kn}=Lr(),Nn=Rt(),Vt=class{constructor(e){this.externalEntities={},this.options=Bn(e)}parse(e,t){if(typeof e!="string")if(e.toString)e=e.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});let i=Nn.validate(e,t);if(i!==!0)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}let r=new In(this.options);r.addExternalEntities(this.externalEntities);let n=r.parseXml(e);return this.options.preserveOrder||n===void 0?n:kn(n,this.options)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can\'t have \'&\'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without \'&\' and \';\'. Eg. use \'#xD\' for \'
\'");this.externalEntities[e]=t}};Wr.exports=Vt});var jr=ge((Ia,Or)=>{var Fn=`\n`;function Sn(s,e){return Vr(s,e,"",0)}function Vr(s,e,t,r){let n="",i="";e.format&&e.indentBy.length>0&&(i=Fn+""+e.indentBy.repeat(r));for(let a=0;a<s.length;a++){let o=s[a],u=Tn(o),d="";if(t.length===0?d=u:d=`${t}.${u}`,u===e.textNodeName){let f=o[u];Pn(d,e)||(f=e.tagValueProcessor(u,f),f=Mr(f,e)),n+=i+f;continue}else if(u===e.cdataPropName){n+=i+`<![CDATA[${o[u][0][e.textNodeName]}]]>`;continue}else if(u===e.commentPropName){n+=i+`<!--${o[u][0][e.textNodeName]}-->`;continue}else if(u[0]==="?"){let f=Ur(o[":@"],e),m=u==="?xml"?"":i,g=o[u][0][e.textNodeName];g=g.length!==0?" "+g:"",n+=m+`<${u}${g}${f}?>`;continue}let p=Ur(o[":@"],e),l=i+`<${u}${p}`,b=Vr(o[u],e,d,r+1);e.unpairedTags.indexOf(u)!==-1?e.suppressUnpairedNode?n+=l+">":n+=l+"/>":(!b||b.length===0)&&e.suppressEmptyNode?n+=l+"/>":n+=l+`>${b}${i}</${u}>`}return n}function Tn(s){let e=Object.keys(s);for(let t=0;t<e.length;t++){let r=e[t];if(r!==":@")return r}}function Ur(s,e){let t="";if(s&&!e.ignoreAttributes)for(let r in s){let n=e.attributeValueProcessor(r,s[r]);n=Mr(n,e),n===!0&&e.suppressBooleanAttributes?t+=` ${r.substr(e.attributeNamePrefix.length)}`:t+=` ${r.substr(e.attributeNamePrefix.length)}="${n}"`}return t}function Pn(s,e){s=s.substr(0,s.length-e.textNodeName.length-1);let t=s.substr(s.lastIndexOf(".")+1);for(let r in e.stopNodes)if(e.stopNodes[r]===s||e.stopNodes[r]==="*."+t)return!0;return!1}function Mr(s,e){if(s&&s.length>0&&e.processEntities)for(let t=0;t<e.entities.length;t++){let r=e.entities[t];s=s.replace(r.regex,r.val)}return s}Or.exports=Sn});var qr=ge((ka,$r)=>{"use strict";var Rn=jr(),Zn={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(s,e){return e},attributeValueProcessor:function(s,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("\'","g"),val:"'"},{regex:new RegExp(\'"\',"g"),val:"""}],processEntities:!0,stopNodes:[],transformTagName:!1};function Mt(s){this.options=Object.assign({},Zn,s),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Mn),this.processTextOrObjNode=Ln,this.options.format?(this.indentate=Vn,this.tagEndChar=`>\n`,this.newLine=`\n`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine=""),this.options.suppressEmptyNode?(this.buildTextNode=Un,this.buildObjNode=Wn):(this.buildTextNode=Hr,this.buildObjNode=Yr),this.buildTextValNode=Hr,this.buildObjectNode=Yr,this.replaceEntitiesValue=Gn,this.buildAttrPairStr=zn}Mt.prototype.build=function(s){return this.options.preserveOrder?Rn(s,this.options):(Array.isArray(s)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(s={[this.options.arrayNodeName]:s}),this.j2x(s,0).val)};Mt.prototype.j2x=function(s,e){let t="",r="";for(let n in s)if(!(typeof s[n]>"u"))if(s[n]===null)n[0]==="?"?r+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+n+"/"+this.tagEndChar;else if(s[n]instanceof Date)r+=this.buildTextNode(s[n],n,"",e);else if(typeof s[n]!="object"){let i=this.isAttribute(n);if(i)t+=this.buildAttrPairStr(i,""+s[n]);else if(n===this.options.textNodeName){let a=this.options.tagValueProcessor(n,""+s[n]);r+=this.replaceEntitiesValue(a)}else r+=this.buildTextNode(s[n],n,"",e)}else if(Array.isArray(s[n])){let i=s[n].length;for(let a=0;a<i;a++){let o=s[n][a];typeof o>"u"||(o===null?n[0]==="?"?r+=this.indentate(e)+"<"+n+"?"+this.tagEndChar:r+=this.indentate(e)+"<"+n+"/"+this.tagEndChar:typeof o=="object"?r+=this.processTextOrObjNode(o,n,e):r+=this.buildTextNode(o,n,"",e))}}else if(this.options.attributesGroupName&&n===this.options.attributesGroupName){let i=Object.keys(s[n]),a=i.length;for(let o=0;o<a;o++)t+=this.buildAttrPairStr(i[o],""+s[n][i[o]])}else r+=this.processTextOrObjNode(s[n],n,e);return{attrStr:t,val:r}};function zn(s,e){return e=this.options.attributeValueProcessor(s,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+s:" "+s+\'="\'+e+\'"\'}function Ln(s,e,t){let r=this.j2x(s,t+1);return s[this.options.textNodeName]!==void 0&&Object.keys(s).length===1?this.buildTextNode(s[this.options.textNodeName],e,r.attrStr,t):this.buildObjNode(r.val,e,r.attrStr,t)}function Yr(s,e,t,r){let n="</"+e+this.tagEndChar,i="";return e[0]==="?"&&(i="?",n=""),t&&s.indexOf("<")===-1?this.indentate(r)+"<"+e+t+i+">"+s+n:this.options.commentPropName!==!1&&e===this.options.commentPropName&&i.length===0?this.indentate(r)+`<!--${s}-->`+this.newLine:this.indentate(r)+"<"+e+t+i+this.tagEndChar+s+this.indentate(r)+n}function Wn(s,e,t,r){return s!==""?this.buildObjectNode(s,e,t,r):e[0]==="?"?this.indentate(r)+"<"+e+t+"?"+this.tagEndChar:this.indentate(r)+"<"+e+t+"/"+this.tagEndChar}function Hr(s,e,t,r){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${s}]]>`+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(r)+`<!--${s}-->`+this.newLine;{let n=this.options.tagValueProcessor(e,s);return n=this.replaceEntitiesValue(n),n===""&&this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode?this.indentate(r)+"<"+e+this.tagEndChar:this.indentate(r)+"<"+e+"/"+this.tagEndChar:this.indentate(r)+"<"+e+t+">"+n+"</"+e+this.tagEndChar}}function Gn(s){if(s&&s.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){let t=this.options.entities[e];s=s.replace(t.regex,t.val)}return s}function Un(s,e,t,r){return s===""&&this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode?this.indentate(r)+"<"+e+this.tagEndChar:this.indentate(r)+"<"+e+"/"+this.tagEndChar:s!==""?this.buildTextValNode(s,e,t,r):e[0]==="?"?this.indentate(r)+"<"+e+t+"?"+this.tagEndChar:this.indentate(r)+"<"+e+t+"/"+this.tagEndChar}function Vn(s){return this.options.indentBy.repeat(s)}function Mn(s){return s.startsWith(this.options.attributeNamePrefix)?s.substr(this.attrPrefixLen):!1}$r.exports=Mt});var ut=ge((Na,Jr)=>{"use strict";var On=Rt(),jn=Gr(),Yn=qr();Jr.exports={XMLParser:jn,XMLValidator:On,XMLBuilder:Yn}});var Di=Fe(st()),Ci=Fe(kt());var at=s=>{let e=Math.floor((s-5)/7*100+.5)/100;return Math.floor((e*7+5)/7*256)/256},Nt=s=>Math.floor((256*s+Math.floor(18.285714285714285))/256*7);var br="UEsDBAoAAAAAAAAAIQBi7p1okAQAAJAEAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjxUeXBlcyB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3BhY2thZ2UvMjAwNi9jb250ZW50LXR5cGVzIj48RGVmYXVsdCBFeHRlbnNpb249InJlbHMiIENvbnRlbnRUeXBlPSJhcHBsaWNhdGlvbi92bmQub3BlbnhtbGZvcm1hdHMtcGFja2FnZS5yZWxhdGlvbnNoaXBzK3htbCIvPjxEZWZhdWx0IEV4dGVuc2lvbj0ieG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24veG1sIi8+PE92ZXJyaWRlIFBhcnROYW1lPSIveGwvd29ya2Jvb2sueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LnNwcmVhZHNoZWV0bWwuc2hlZXQubWFpbit4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii94bC93b3Jrc2hlZXRzL3NoZWV0MS54bWwiIENvbnRlbnRUeXBlPSJhcHBsaWNhdGlvbi92bmQub3BlbnhtbGZvcm1hdHMtb2ZmaWNlZG9jdW1lbnQuc3ByZWFkc2hlZXRtbC53b3Jrc2hlZXQreG1sIi8+PE92ZXJyaWRlIFBhcnROYW1lPSIveGwvdGhlbWUvdGhlbWUxLnhtbCIgQ29udGVudFR5cGU9ImFwcGxpY2F0aW9uL3ZuZC5vcGVueG1sZm9ybWF0cy1vZmZpY2Vkb2N1bWVudC50aGVtZSt4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii94bC9zdHlsZXMueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LnNwcmVhZHNoZWV0bWwuc3R5bGVzK3htbCIvPjxPdmVycmlkZSBQYXJ0TmFtZT0iL3hsL3NoYXJlZFN0cmluZ3MueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LnNwcmVhZHNoZWV0bWwuc2hhcmVkU3RyaW5ncyt4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii9kb2NQcm9wcy9jb3JlLnhtbCIgQ29udGVudFR5cGU9ImFwcGxpY2F0aW9uL3ZuZC5vcGVueG1sZm9ybWF0cy1wYWNrYWdlLmNvcmUtcHJvcGVydGllcyt4bWwiLz48T3ZlcnJpZGUgUGFydE5hbWU9Ii9kb2NQcm9wcy9hcHAueG1sIiBDb250ZW50VHlwZT0iYXBwbGljYXRpb24vdm5kLm9wZW54bWxmb3JtYXRzLW9mZmljZWRvY3VtZW50LmV4dGVuZGVkLXByb3BlcnRpZXMreG1sIi8+PC9UeXBlcz5QSwMECgAAAAAAAAAhALVVMCNMAgAATAIAAAsAAABfcmVscy8ucmVsczw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjxSZWxhdGlvbnNoaXBzIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvcGFja2FnZS8yMDA2L3JlbGF0aW9uc2hpcHMiPjxSZWxhdGlvbnNoaXAgSWQ9InJJZDMiIFR5cGU9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L3JlbGF0aW9uc2hpcHMvZXh0ZW5kZWQtcHJvcGVydGllcyIgVGFyZ2V0PSJkb2NQcm9wcy9hcHAueG1sIi8+PFJlbGF0aW9uc2hpcCBJZD0icklkMiIgVHlwZT0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3BhY2thZ2UvMjAwNi9yZWxhdGlvbnNoaXBzL21ldGFkYXRhL2NvcmUtcHJvcGVydGllcyIgVGFyZ2V0PSJkb2NQcm9wcy9jb3JlLnhtbCIvPjxSZWxhdGlvbnNoaXAgSWQ9InJJZDEiIFR5cGU9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L3JlbGF0aW9uc2hpcHMvb2ZmaWNlRG9jdW1lbnQiIFRhcmdldD0ieGwvd29ya2Jvb2sueG1sIi8+PC9SZWxhdGlvbnNoaXBzPlBLAwQKAAAAAAAAACEAunCeZsoGAADKBgAADwAAAHhsL3dvcmtib29rLnhtbDw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjx3b3JrYm9vayB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3NwcmVhZHNoZWV0bWwvMjAwNi9tYWluIiB4bWxuczpyPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzIiB4bWxuczptYz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL21hcmt1cC1jb21wYXRpYmlsaXR5LzIwMDYiIG1jOklnbm9yYWJsZT0ieDE1IHhyIHhyNiB4cjEwIHhyMiIgeG1sbnM6eDE1PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvbWFpbiIgeG1sbnM6eHI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAxNC9yZXZpc2lvbiIgeG1sbnM6eHI2PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTYvcmV2aXNpb242IiB4bWxuczp4cjEwPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTYvcmV2aXNpb24xMCIgeG1sbnM6eHIyPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTUvcmV2aXNpb24yIj48ZmlsZVZlcnNpb24gYXBwTmFtZT0ieGwiIGxhc3RFZGl0ZWQ9IjciIGxvd2VzdEVkaXRlZD0iNyIgcnVwQnVpbGQ9IjIxMTI2Ii8+PHdvcmtib29rUHIgZGVmYXVsdFRoZW1lVmVyc2lvbj0iMTY2OTI1Ii8+PG1jOkFsdGVybmF0ZUNvbnRlbnQgeG1sbnM6bWM9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9tYXJrdXAtY29tcGF0aWJpbGl0eS8yMDA2Ij48bWM6Q2hvaWNlIFJlcXVpcmVzPSJ4MTUiPjx4MTVhYzphYnNQYXRoIHVybD0iSDpcVFJFQlx0cmViLWV4cG9ydFx0ZW1wbGF0ZVwiIHhtbG5zOngxNWFjPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvYWMiLz48L21jOkNob2ljZT48L21jOkFsdGVybmF0ZUNvbnRlbnQ+PHhyOnJldmlzaW9uUHRyIHJldklETGFzdFNhdmU9IjAiIGRvY3VtZW50SWQ9Ijhfe0Q4NThGOUY3LTBEOTItNEFFNC04QTQyLTQ4MENCMzU5QjYyRH0iIHhyNjpjb2F1dGhWZXJzaW9uTGFzdD0iNDAiIHhyNjpjb2F1dGhWZXJzaW9uTWF4PSI0MCIgeHIxMDp1aWRMYXN0U2F2ZT0iezAwMDAwMDAwLTAwMDAtMDAwMC0wMDAwLTAwMDAwMDAwMDAwMH0iLz48Ym9va1ZpZXdzPjx3b3JrYm9va1ZpZXcgeFdpbmRvdz0iMCIgeVdpbmRvdz0iMCIgd2luZG93V2lkdGg9IjI0NTcwIiB3aW5kb3dIZWlnaHQ9IjExMTMwIiB4cjI6dWlkPSJ7REU0RTdEMzUtNDkyRC00MEQ3LTk5MjUtNDY0N0Y1ODdFMURFfSIvPjwvYm9va1ZpZXdzPjxzaGVldHM+PHNoZWV0IG5hbWU9IlNoZWV0MSIgc2hlZXRJZD0iMSIgcjppZD0icklkMSIvPjwvc2hlZXRzPjxjYWxjUHIgY2FsY0lkPSIxOTEwMjkiLz48ZXh0THN0PjxleHQgdXJpPSJ7MTQwQTcwOTQtMEUzNS00ODkyLTg0MzItQzREMkU1N0VERUI1fSIgeG1sbnM6eDE1PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvbWFpbiI+PHgxNTp3b3JrYm9va1ByIGNoYXJ0VHJhY2tpbmdSZWZCYXNlPSIxIi8+PC9leHQ+PC9leHRMc3Q+PC93b3JrYm9vaz5QSwMECgAAAAAAAAAhAIE+lJe6AgAAugIAABoAAAB4bC9fcmVscy93b3JrYm9vay54bWwucmVsczw/eG1sIHZlcnNpb249IjEuMCIgZW5jb2Rpbmc9IlVURi04IiBzdGFuZGFsb25lPSJ5ZXMiPz4NCjxSZWxhdGlvbnNoaXBzIHhtbG5zPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvcGFja2FnZS8yMDA2L3JlbGF0aW9uc2hpcHMiPjxSZWxhdGlvbnNoaXAgSWQ9InJJZDMiIFR5cGU9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L3JlbGF0aW9uc2hpcHMvc3R5bGVzIiBUYXJnZXQ9InN0eWxlcy54bWwiLz48UmVsYXRpb25zaGlwIElkPSJySWQyIiBUeXBlPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzL3RoZW1lIiBUYXJnZXQ9InRoZW1lL3RoZW1lMS54bWwiLz48UmVsYXRpb25zaGlwIElkPSJySWQxIiBUeXBlPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzL3dvcmtzaGVldCIgVGFyZ2V0PSJ3b3Jrc2hlZXRzL3NoZWV0MS54bWwiLz48UmVsYXRpb25zaGlwIElkPSJySWQ0IiBUeXBlPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzL3NoYXJlZFN0cmluZ3MiIFRhcmdldD0ic2hhcmVkU3RyaW5ncy54bWwiLz48L1JlbGF0aW9uc2hpcHM+UEsDBAoAAAAAAAAAIQACrURzpAMAAKQDAAAYAAAAeGwvd29ya3NoZWV0cy9zaGVldDEueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPHdvcmtzaGVldCB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3NwcmVhZHNoZWV0bWwvMjAwNi9tYWluIiB4bWxuczpyPSJodHRwOi8vc2NoZW1hcy5vcGVueG1sZm9ybWF0cy5vcmcvb2ZmaWNlRG9jdW1lbnQvMjAwNi9yZWxhdGlvbnNoaXBzIiB4bWxuczptYz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL21hcmt1cC1jb21wYXRpYmlsaXR5LzIwMDYiIG1jOklnbm9yYWJsZT0ieDE0YWMgeHIgeHIyIHhyMyIgeG1sbnM6eDE0YWM9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAwOS85L2FjIiB4bWxuczp4cj0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDE0L3JldmlzaW9uIiB4bWxuczp4cjI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAxNS9yZXZpc2lvbjIiIHhtbG5zOnhyMz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDE2L3JldmlzaW9uMyIgeHI6dWlkPSJ7MEQ4RTVDQTItNUM5RS00RDRCLTk0QzUtRjM1QzA0MUYzOUJEfSI+PGRpbWVuc2lvbiByZWY9IkExIi8+PHNoZWV0Vmlld3M+PHNoZWV0VmlldyB0YWJTZWxlY3RlZD0iMSIgd29ya2Jvb2tWaWV3SWQ9IjAiLz48L3NoZWV0Vmlld3M+PHNoZWV0Rm9ybWF0UHIgZGVmYXVsdFJvd0hlaWdodD0iMTUiIHgxNGFjOmR5RGVzY2VudD0iMC4yNSIvPjxzaGVldERhdGEvPjxwYWdlTWFyZ2lucyBsZWZ0PSIwLjciIHJpZ2h0PSIwLjciIHRvcD0iMC43NSIgYm90dG9tPSIwLjc1IiBoZWFkZXI9IjAuMyIgZm9vdGVyPSIwLjMiLz48L3dvcmtzaGVldD5QSwMECgAAAAAAAAAhAMEXEL7GIAAAxiAAABMAAAB4bC90aGVtZS90aGVtZTEueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPGE6dGhlbWUgeG1sbnM6YT0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL2RyYXdpbmdtbC8yMDA2L21haW4iIG5hbWU9Ik9mZmljZSBUaGVtZSI+PGE6dGhlbWVFbGVtZW50cz48YTpjbHJTY2hlbWUgbmFtZT0iT2ZmaWNlIj48YTpkazE+PGE6c3lzQ2xyIHZhbD0id2luZG93VGV4dCIgbGFzdENscj0iMDAwMDAwIi8+PC9hOmRrMT48YTpsdDE+PGE6c3lzQ2xyIHZhbD0id2luZG93IiBsYXN0Q2xyPSJGRkZGRkYiLz48L2E6bHQxPjxhOmRrMj48YTpzcmdiQ2xyIHZhbD0iNDQ1NDZBIi8+PC9hOmRrMj48YTpsdDI+PGE6c3JnYkNsciB2YWw9IkU3RTZFNiIvPjwvYTpsdDI+PGE6YWNjZW50MT48YTpzcmdiQ2xyIHZhbD0iNDQ3MkM0Ii8+PC9hOmFjY2VudDE+PGE6YWNjZW50Mj48YTpzcmdiQ2xyIHZhbD0iRUQ3RDMxIi8+PC9hOmFjY2VudDI+PGE6YWNjZW50Mz48YTpzcmdiQ2xyIHZhbD0iQTVBNUE1Ii8+PC9hOmFjY2VudDM+PGE6YWNjZW50ND48YTpzcmdiQ2xyIHZhbD0iRkZDMDAwIi8+PC9hOmFjY2VudDQ+PGE6YWNjZW50NT48YTpzcmdiQ2xyIHZhbD0iNUI5QkQ1Ii8+PC9hOmFjY2VudDU+PGE6YWNjZW50Nj48YTpzcmdiQ2xyIHZhbD0iNzBBRDQ3Ii8+PC9hOmFjY2VudDY+PGE6aGxpbms+PGE6c3JnYkNsciB2YWw9IjA1NjNDMSIvPjwvYTpobGluaz48YTpmb2xIbGluaz48YTpzcmdiQ2xyIHZhbD0iOTU0RjcyIi8+PC9hOmZvbEhsaW5rPjwvYTpjbHJTY2hlbWU+PGE6Zm9udFNjaGVtZSBuYW1lPSJPZmZpY2UiPjxhOm1ham9yRm9udD48YTpsYXRpbiB0eXBlZmFjZT0iQ2FsaWJyaSBMaWdodCIgcGFub3NlPSIwMjBGMDMwMjAyMDIwNDAzMDIwNCIvPjxhOmVhIHR5cGVmYWNlPSIiLz48YTpjcyB0eXBlZmFjZT0iIi8+PGE6Zm9udCBzY3JpcHQ9IkpwYW4iIHR5cGVmYWNlPSLmuLjjgrTjgrfjg4Pjgq8gTGlnaHQiLz48YTpmb250IHNjcmlwdD0iSGFuZyIgdHlwZWZhY2U9IuunkeydgCDqs6DrlJUiLz48YTpmb250IHNjcmlwdD0iSGFucyIgdHlwZWZhY2U9Iuetiee6vyBMaWdodCIvPjxhOmZvbnQgc2NyaXB0PSJIYW50IiB0eXBlZmFjZT0i5paw57Sw5piO6auUIi8+PGE6Zm9udCBzY3JpcHQ9IkFyYWIiIHR5cGVmYWNlPSJUaW1lcyBOZXcgUm9tYW4iLz48YTpmb250IHNjcmlwdD0iSGViciIgdHlwZWZhY2U9IlRpbWVzIE5ldyBSb21hbiIvPjxhOmZvbnQgc2NyaXB0PSJUaGFpIiB0eXBlZmFjZT0iVGFob21hIi8+PGE6Zm9udCBzY3JpcHQ9IkV0aGkiIHR5cGVmYWNlPSJOeWFsYSIvPjxhOmZvbnQgc2NyaXB0PSJCZW5nIiB0eXBlZmFjZT0iVnJpbmRhIi8+PGE6Zm9udCBzY3JpcHQ9Ikd1anIiIHR5cGVmYWNlPSJTaHJ1dGkiLz48YTpmb250IHNjcmlwdD0iS2htciIgdHlwZWZhY2U9Ik1vb2xCb3JhbiIvPjxhOmZvbnQgc2NyaXB0PSJLbmRhIiB0eXBlZmFjZT0iVHVuZ2EiLz48YTpmb250IHNjcmlwdD0iR3VydSIgdHlwZWZhY2U9IlJhYXZpIi8+PGE6Zm9udCBzY3JpcHQ9IkNhbnMiIHR5cGVmYWNlPSJFdXBoZW1pYSIvPjxhOmZvbnQgc2NyaXB0PSJDaGVyIiB0eXBlZmFjZT0iUGxhbnRhZ2VuZXQgQ2hlcm9rZWUiLz48YTpmb250IHNjcmlwdD0iWWlpaSIgdHlwZWZhY2U9Ik1pY3Jvc29mdCBZaSBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJUaWJ0IiB0eXBlZmFjZT0iTWljcm9zb2Z0IEhpbWFsYXlhIi8+PGE6Zm9udCBzY3JpcHQ9IlRoYWEiIHR5cGVmYWNlPSJNViBCb2xpIi8+PGE6Zm9udCBzY3JpcHQ9IkRldmEiIHR5cGVmYWNlPSJNYW5nYWwiLz48YTpmb250IHNjcmlwdD0iVGVsdSIgdHlwZWZhY2U9IkdhdXRhbWkiLz48YTpmb250IHNjcmlwdD0iVGFtbCIgdHlwZWZhY2U9IkxhdGhhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cmMiIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJPcnlhIiB0eXBlZmFjZT0iS2FsaW5nYSIvPjxhOmZvbnQgc2NyaXB0PSJNbHltIiB0eXBlZmFjZT0iS2FydGlrYSIvPjxhOmZvbnQgc2NyaXB0PSJMYW9vIiB0eXBlZmFjZT0iRG9rQ2hhbXBhIi8+PGE6Zm9udCBzY3JpcHQ9IlNpbmgiIHR5cGVmYWNlPSJJc2tvb2xhIFBvdGEiLz48YTpmb250IHNjcmlwdD0iTW9uZyIgdHlwZWZhY2U9Ik1vbmdvbGlhbiBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJWaWV0IiB0eXBlZmFjZT0iVGltZXMgTmV3IFJvbWFuIi8+PGE6Zm9udCBzY3JpcHQ9IlVpZ2giIHR5cGVmYWNlPSJNaWNyb3NvZnQgVWlnaHVyIi8+PGE6Zm9udCBzY3JpcHQ9Ikdlb3IiIHR5cGVmYWNlPSJTeWxmYWVuIi8+PGE6Zm9udCBzY3JpcHQ9IkFybW4iIHR5cGVmYWNlPSJBcmlhbCIvPjxhOmZvbnQgc2NyaXB0PSJCdWdpIiB0eXBlZmFjZT0iTGVlbGF3YWRlZSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJCb3BvIiB0eXBlZmFjZT0iTWljcm9zb2Z0IEpoZW5nSGVpIi8+PGE6Zm9udCBzY3JpcHQ9IkphdmEiIHR5cGVmYWNlPSJKYXZhbmVzZSBUZXh0Ii8+PGE6Zm9udCBzY3JpcHQ9Ikxpc3UiIHR5cGVmYWNlPSJTZWdvZSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJNeW1yIiB0eXBlZmFjZT0iTXlhbm1hciBUZXh0Ii8+PGE6Zm9udCBzY3JpcHQ9Ik5rb28iIHR5cGVmYWNlPSJFYnJpbWEiLz48YTpmb250IHNjcmlwdD0iT2xjayIgdHlwZWZhY2U9Ik5pcm1hbGEgVUkiLz48YTpmb250IHNjcmlwdD0iT3NtYSIgdHlwZWZhY2U9IkVicmltYSIvPjxhOmZvbnQgc2NyaXB0PSJQaGFnIiB0eXBlZmFjZT0iUGhhZ3NwYSIvPjxhOmZvbnQgc2NyaXB0PSJTeXJuIiB0eXBlZmFjZT0iRXN0cmFuZ2VsbyBFZGVzc2EiLz48YTpmb250IHNjcmlwdD0iU3lyaiIgdHlwZWZhY2U9IkVzdHJhbmdlbG8gRWRlc3NhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cmUiIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJTb3JhIiB0eXBlZmFjZT0iTmlybWFsYSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJUYWxlIiB0eXBlZmFjZT0iTWljcm9zb2Z0IFRhaSBMZSIvPjxhOmZvbnQgc2NyaXB0PSJUYWx1IiB0eXBlZmFjZT0iTWljcm9zb2Z0IE5ldyBUYWkgTHVlIi8+PGE6Zm9udCBzY3JpcHQ9IlRmbmciIHR5cGVmYWNlPSJFYnJpbWEiLz48L2E6bWFqb3JGb250PjxhOm1pbm9yRm9udD48YTpsYXRpbiB0eXBlZmFjZT0iQ2FsaWJyaSIgcGFub3NlPSIwMjBGMDUwMjAyMDIwNDAzMDIwNCIvPjxhOmVhIHR5cGVmYWNlPSIiLz48YTpjcyB0eXBlZmFjZT0iIi8+PGE6Zm9udCBzY3JpcHQ9IkpwYW4iIHR5cGVmYWNlPSLmuLjjgrTjgrfjg4Pjgq8iLz48YTpmb250IHNjcmlwdD0iSGFuZyIgdHlwZWZhY2U9IuunkeydgCDqs6DrlJUiLz48YTpmb250IHNjcmlwdD0iSGFucyIgdHlwZWZhY2U9Iuetiee6vyIvPjxhOmZvbnQgc2NyaXB0PSJIYW50IiB0eXBlZmFjZT0i5paw57Sw5piO6auUIi8+PGE6Zm9udCBzY3JpcHQ9IkFyYWIiIHR5cGVmYWNlPSJBcmlhbCIvPjxhOmZvbnQgc2NyaXB0PSJIZWJyIiB0eXBlZmFjZT0iQXJpYWwiLz48YTpmb250IHNjcmlwdD0iVGhhaSIgdHlwZWZhY2U9IlRhaG9tYSIvPjxhOmZvbnQgc2NyaXB0PSJFdGhpIiB0eXBlZmFjZT0iTnlhbGEiLz48YTpmb250IHNjcmlwdD0iQmVuZyIgdHlwZWZhY2U9IlZyaW5kYSIvPjxhOmZvbnQgc2NyaXB0PSJHdWpyIiB0eXBlZmFjZT0iU2hydXRpIi8+PGE6Zm9udCBzY3JpcHQ9IktobXIiIHR5cGVmYWNlPSJEYXVuUGVuaCIvPjxhOmZvbnQgc2NyaXB0PSJLbmRhIiB0eXBlZmFjZT0iVHVuZ2EiLz48YTpmb250IHNjcmlwdD0iR3VydSIgdHlwZWZhY2U9IlJhYXZpIi8+PGE6Zm9udCBzY3JpcHQ9IkNhbnMiIHR5cGVmYWNlPSJFdXBoZW1pYSIvPjxhOmZvbnQgc2NyaXB0PSJDaGVyIiB0eXBlZmFjZT0iUGxhbnRhZ2VuZXQgQ2hlcm9rZWUiLz48YTpmb250IHNjcmlwdD0iWWlpaSIgdHlwZWZhY2U9Ik1pY3Jvc29mdCBZaSBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJUaWJ0IiB0eXBlZmFjZT0iTWljcm9zb2Z0IEhpbWFsYXlhIi8+PGE6Zm9udCBzY3JpcHQ9IlRoYWEiIHR5cGVmYWNlPSJNViBCb2xpIi8+PGE6Zm9udCBzY3JpcHQ9IkRldmEiIHR5cGVmYWNlPSJNYW5nYWwiLz48YTpmb250IHNjcmlwdD0iVGVsdSIgdHlwZWZhY2U9IkdhdXRhbWkiLz48YTpmb250IHNjcmlwdD0iVGFtbCIgdHlwZWZhY2U9IkxhdGhhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cmMiIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJPcnlhIiB0eXBlZmFjZT0iS2FsaW5nYSIvPjxhOmZvbnQgc2NyaXB0PSJNbHltIiB0eXBlZmFjZT0iS2FydGlrYSIvPjxhOmZvbnQgc2NyaXB0PSJMYW9vIiB0eXBlZmFjZT0iRG9rQ2hhbXBhIi8+PGE6Zm9udCBzY3JpcHQ9IlNpbmgiIHR5cGVmYWNlPSJJc2tvb2xhIFBvdGEiLz48YTpmb250IHNjcmlwdD0iTW9uZyIgdHlwZWZhY2U9Ik1vbmdvbGlhbiBCYWl0aSIvPjxhOmZvbnQgc2NyaXB0PSJWaWV0IiB0eXBlZmFjZT0iQXJpYWwiLz48YTpmb250IHNjcmlwdD0iVWlnaCIgdHlwZWZhY2U9Ik1pY3Jvc29mdCBVaWdodXIiLz48YTpmb250IHNjcmlwdD0iR2VvciIgdHlwZWZhY2U9IlN5bGZhZW4iLz48YTpmb250IHNjcmlwdD0iQXJtbiIgdHlwZWZhY2U9IkFyaWFsIi8+PGE6Zm9udCBzY3JpcHQ9IkJ1Z2kiIHR5cGVmYWNlPSJMZWVsYXdhZGVlIFVJIi8+PGE6Zm9udCBzY3JpcHQ9IkJvcG8iIHR5cGVmYWNlPSJNaWNyb3NvZnQgSmhlbmdIZWkiLz48YTpmb250IHNjcmlwdD0iSmF2YSIgdHlwZWZhY2U9IkphdmFuZXNlIFRleHQiLz48YTpmb250IHNjcmlwdD0iTGlzdSIgdHlwZWZhY2U9IlNlZ29lIFVJIi8+PGE6Zm9udCBzY3JpcHQ9Ik15bXIiIHR5cGVmYWNlPSJNeWFubWFyIFRleHQiLz48YTpmb250IHNjcmlwdD0iTmtvbyIgdHlwZWZhY2U9IkVicmltYSIvPjxhOmZvbnQgc2NyaXB0PSJPbGNrIiB0eXBlZmFjZT0iTmlybWFsYSBVSSIvPjxhOmZvbnQgc2NyaXB0PSJPc21hIiB0eXBlZmFjZT0iRWJyaW1hIi8+PGE6Zm9udCBzY3JpcHQ9IlBoYWciIHR5cGVmYWNlPSJQaGFnc3BhIi8+PGE6Zm9udCBzY3JpcHQ9IlN5cm4iIHR5cGVmYWNlPSJFc3RyYW5nZWxvIEVkZXNzYSIvPjxhOmZvbnQgc2NyaXB0PSJTeXJqIiB0eXBlZmFjZT0iRXN0cmFuZ2VsbyBFZGVzc2EiLz48YTpmb250IHNjcmlwdD0iU3lyZSIgdHlwZWZhY2U9IkVzdHJhbmdlbG8gRWRlc3NhIi8+PGE6Zm9udCBzY3JpcHQ9IlNvcmEiIHR5cGVmYWNlPSJOaXJtYWxhIFVJIi8+PGE6Zm9udCBzY3JpcHQ9IlRhbGUiIHR5cGVmYWNlPSJNaWNyb3NvZnQgVGFpIExlIi8+PGE6Zm9udCBzY3JpcHQ9IlRhbHUiIHR5cGVmYWNlPSJNaWNyb3NvZnQgTmV3IFRhaSBMdWUiLz48YTpmb250IHNjcmlwdD0iVGZuZyIgdHlwZWZhY2U9IkVicmltYSIvPjwvYTptaW5vckZvbnQ+PC9hOmZvbnRTY2hlbWU+PGE6Zm10U2NoZW1lIG5hbWU9Ik9mZmljZSI+PGE6ZmlsbFN0eWxlTHN0PjxhOnNvbGlkRmlsbD48YTpzY2hlbWVDbHIgdmFsPSJwaENsciIvPjwvYTpzb2xpZEZpbGw+PGE6Z3JhZEZpbGwgcm90V2l0aFNoYXBlPSIxIj48YTpnc0xzdD48YTpncyBwb3M9IjAiPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIj48YTpsdW1Nb2QgdmFsPSIxMTAwMDAiLz48YTpzYXRNb2QgdmFsPSIxMDUwMDAiLz48YTp0aW50IHZhbD0iNjcwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48YTpncyBwb3M9IjUwMDAwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6bHVtTW9kIHZhbD0iMTA1MDAwIi8+PGE6c2F0TW9kIHZhbD0iMTAzMDAwIi8+PGE6dGludCB2YWw9IjczMDAwIi8+PC9hOnNjaGVtZUNscj48L2E6Z3M+PGE6Z3MgcG9zPSIxMDAwMDAiPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIj48YTpsdW1Nb2QgdmFsPSIxMDUwMDAiLz48YTpzYXRNb2QgdmFsPSIxMDkwMDAiLz48YTp0aW50IHZhbD0iODEwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48L2E6Z3NMc3Q+PGE6bGluIGFuZz0iNTQwMDAwMCIgc2NhbGVkPSIwIi8+PC9hOmdyYWRGaWxsPjxhOmdyYWRGaWxsIHJvdFdpdGhTaGFwZT0iMSI+PGE6Z3NMc3Q+PGE6Z3MgcG9zPSIwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6c2F0TW9kIHZhbD0iMTAzMDAwIi8+PGE6bHVtTW9kIHZhbD0iMTAyMDAwIi8+PGE6dGludCB2YWw9Ijk0MDAwIi8+PC9hOnNjaGVtZUNscj48L2E6Z3M+PGE6Z3MgcG9zPSI1MDAwMCI+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiPjxhOnNhdE1vZCB2YWw9IjExMDAwMCIvPjxhOmx1bU1vZCB2YWw9IjEwMDAwMCIvPjxhOnNoYWRlIHZhbD0iMTAwMDAwIi8+PC9hOnNjaGVtZUNscj48L2E6Z3M+PGE6Z3MgcG9zPSIxMDAwMDAiPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIj48YTpsdW1Nb2QgdmFsPSI5OTAwMCIvPjxhOnNhdE1vZCB2YWw9IjEyMDAwMCIvPjxhOnNoYWRlIHZhbD0iNzgwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48L2E6Z3NMc3Q+PGE6bGluIGFuZz0iNTQwMDAwMCIgc2NhbGVkPSIwIi8+PC9hOmdyYWRGaWxsPjwvYTpmaWxsU3R5bGVMc3Q+PGE6bG5TdHlsZUxzdD48YTpsbiB3PSI2MzUwIiBjYXA9ImZsYXQiIGNtcGQ9InNuZyIgYWxnbj0iY3RyIj48YTpzb2xpZEZpbGw+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiLz48L2E6c29saWRGaWxsPjxhOnByc3REYXNoIHZhbD0ic29saWQiLz48YTptaXRlciBsaW09IjgwMDAwMCIvPjwvYTpsbj48YTpsbiB3PSIxMjcwMCIgY2FwPSJmbGF0IiBjbXBkPSJzbmciIGFsZ249ImN0ciI+PGE6c29saWRGaWxsPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIi8+PC9hOnNvbGlkRmlsbD48YTpwcnN0RGFzaCB2YWw9InNvbGlkIi8+PGE6bWl0ZXIgbGltPSI4MDAwMDAiLz48L2E6bG4+PGE6bG4gdz0iMTkwNTAiIGNhcD0iZmxhdCIgY21wZD0ic25nIiBhbGduPSJjdHIiPjxhOnNvbGlkRmlsbD48YTpzY2hlbWVDbHIgdmFsPSJwaENsciIvPjwvYTpzb2xpZEZpbGw+PGE6cHJzdERhc2ggdmFsPSJzb2xpZCIvPjxhOm1pdGVyIGxpbT0iODAwMDAwIi8+PC9hOmxuPjwvYTpsblN0eWxlTHN0PjxhOmVmZmVjdFN0eWxlTHN0PjxhOmVmZmVjdFN0eWxlPjxhOmVmZmVjdExzdC8+PC9hOmVmZmVjdFN0eWxlPjxhOmVmZmVjdFN0eWxlPjxhOmVmZmVjdExzdC8+PC9hOmVmZmVjdFN0eWxlPjxhOmVmZmVjdFN0eWxlPjxhOmVmZmVjdExzdD48YTpvdXRlclNoZHcgYmx1clJhZD0iNTcxNTAiIGRpc3Q9IjE5MDUwIiBkaXI9IjU0MDAwMDAiIGFsZ249ImN0ciIgcm90V2l0aFNoYXBlPSIwIj48YTpzcmdiQ2xyIHZhbD0iMDAwMDAwIj48YTphbHBoYSB2YWw9IjYzMDAwIi8+PC9hOnNyZ2JDbHI+PC9hOm91dGVyU2hkdz48L2E6ZWZmZWN0THN0PjwvYTplZmZlY3RTdHlsZT48L2E6ZWZmZWN0U3R5bGVMc3Q+PGE6YmdGaWxsU3R5bGVMc3Q+PGE6c29saWRGaWxsPjxhOnNjaGVtZUNsciB2YWw9InBoQ2xyIi8+PC9hOnNvbGlkRmlsbD48YTpzb2xpZEZpbGw+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiPjxhOnRpbnQgdmFsPSI5NTAwMCIvPjxhOnNhdE1vZCB2YWw9IjE3MDAwMCIvPjwvYTpzY2hlbWVDbHI+PC9hOnNvbGlkRmlsbD48YTpncmFkRmlsbCByb3RXaXRoU2hhcGU9IjEiPjxhOmdzTHN0PjxhOmdzIHBvcz0iMCI+PGE6c2NoZW1lQ2xyIHZhbD0icGhDbHIiPjxhOnRpbnQgdmFsPSI5MzAwMCIvPjxhOnNhdE1vZCB2YWw9IjE1MDAwMCIvPjxhOnNoYWRlIHZhbD0iOTgwMDAiLz48YTpsdW1Nb2QgdmFsPSIxMDIwMDAiLz48L2E6c2NoZW1lQ2xyPjwvYTpncz48YTpncyBwb3M9IjUwMDAwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6dGludCB2YWw9Ijk4MDAwIi8+PGE6c2F0TW9kIHZhbD0iMTMwMDAwIi8+PGE6c2hhZGUgdmFsPSI5MDAwMCIvPjxhOmx1bU1vZCB2YWw9IjEwMzAwMCIvPjwvYTpzY2hlbWVDbHI+PC9hOmdzPjxhOmdzIHBvcz0iMTAwMDAwIj48YTpzY2hlbWVDbHIgdmFsPSJwaENsciI+PGE6c2hhZGUgdmFsPSI2MzAwMCIvPjxhOnNhdE1vZCB2YWw9IjEyMDAwMCIvPjwvYTpzY2hlbWVDbHI+PC9hOmdzPjwvYTpnc0xzdD48YTpsaW4gYW5nPSI1NDAwMDAwIiBzY2FsZWQ9IjAiLz48L2E6Z3JhZEZpbGw+PC9hOmJnRmlsbFN0eWxlTHN0PjwvYTpmbXRTY2hlbWU+PC9hOnRoZW1lRWxlbWVudHM+PGE6b2JqZWN0RGVmYXVsdHMvPjxhOmV4dHJhQ2xyU2NoZW1lTHN0Lz48YTpleHRMc3Q+PGE6ZXh0IHVyaT0iezA1QTRDMjVDLTA4NUUtNDM0MC04NUEzLUE1NTMxRTUxMERCMn0iPjx0aG0xNTp0aGVtZUZhbWlseSB4bWxuczp0aG0xNT0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2UvdGhlbWVtbC8yMDEyL21haW4iIG5hbWU9Ik9mZmljZSBUaGVtZSIgaWQ9Ins2MkY5MzlCNi05M0FGLTREQjgtOUM2Qi1ENkM3REZEQzU4OUZ9IiB2aWQ9Ins0QTNDNDZFOC02MUNDLTQ2MDMtQTU4OS03NDIyQTQ3QThFNEF9Ii8+PC9hOmV4dD48L2E6ZXh0THN0PjwvYTp0aGVtZT5QSwMECgAAAAAAAAAhAHmhgGxSBgAAUgYAAA0AAAB4bC9zdHlsZXMueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPHN0eWxlU2hlZXQgeG1sbnM9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9zcHJlYWRzaGVldG1sLzIwMDYvbWFpbiIgeG1sbnM6bWM9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9tYXJrdXAtY29tcGF0aWJpbGl0eS8yMDA2IiBtYzpJZ25vcmFibGU9IngxNGFjIHgxNnIyIHhyIiB4bWxuczp4MTRhYz0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDA5LzkvYWMiIHhtbG5zOngxNnIyPSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTUvMDIvbWFpbiIgeG1sbnM6eHI9Imh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vb2ZmaWNlL3NwcmVhZHNoZWV0bWwvMjAxNC9yZXZpc2lvbiI+PGZvbnRzIGNvdW50PSIxIiB4MTRhYzprbm93bkZvbnRzPSIxIj48Zm9udD48c3ogdmFsPSIxMSIvPjxjb2xvciB0aGVtZT0iMSIvPjxuYW1lIHZhbD0iQ2FsaWJyaSIvPjxmYW1pbHkgdmFsPSIyIi8+PHNjaGVtZSB2YWw9Im1pbm9yIi8+PC9mb250PjwvZm9udHM+PGZpbGxzIGNvdW50PSIyIj48ZmlsbD48cGF0dGVybkZpbGwgcGF0dGVyblR5cGU9Im5vbmUiLz48L2ZpbGw+PGZpbGw+PHBhdHRlcm5GaWxsIHBhdHRlcm5UeXBlPSJncmF5MTI1Ii8+PC9maWxsPjwvZmlsbHM+PGJvcmRlcnMgY291bnQ9IjEiPjxib3JkZXI+PGxlZnQvPjxyaWdodC8+PHRvcC8+PGJvdHRvbS8+PGRpYWdvbmFsLz48L2JvcmRlcj48L2JvcmRlcnM+PGNlbGxTdHlsZVhmcyBjb3VudD0iMSI+PHhmIG51bUZtdElkPSIwIiBmb250SWQ9IjAiIGZpbGxJZD0iMCIgYm9yZGVySWQ9IjAiLz48L2NlbGxTdHlsZVhmcz48Y2VsbFhmcyBjb3VudD0iMSI+PHhmIG51bUZtdElkPSIwIiBmb250SWQ9IjAiIGZpbGxJZD0iMCIgYm9yZGVySWQ9IjAiIHhmSWQ9IjAiLz48L2NlbGxYZnM+PGNlbGxTdHlsZXMgY291bnQ9IjEiPjxjZWxsU3R5bGUgbmFtZT0iTm9ybWFsIiB4ZklkPSIwIiBidWlsdGluSWQ9IjAiLz48L2NlbGxTdHlsZXM+PGR4ZnMgY291bnQ9IjAiLz48dGFibGVTdHlsZXMgY291bnQ9IjAiIGRlZmF1bHRUYWJsZVN0eWxlPSJUYWJsZVN0eWxlTWVkaXVtMiIgZGVmYXVsdFBpdm90U3R5bGU9IlBpdm90U3R5bGVMaWdodDE2Ii8+PGV4dExzdD48ZXh0IHVyaT0ie0VCNzlERUYyLTgwQjgtNDNlNS05NUJELTU0Q0JEREY5MDIwQ30iIHhtbG5zOngxND0iaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS9vZmZpY2Uvc3ByZWFkc2hlZXRtbC8yMDA5LzkvbWFpbiI+PHgxNDpzbGljZXJTdHlsZXMgZGVmYXVsdFNsaWNlclN0eWxlPSJTbGljZXJTdHlsZUxpZ2h0MSIvPjwvZXh0PjxleHQgdXJpPSJ7OTI2MEE1MTAtRjMwMS00NmE4LTg2MzUtRjUxMkQ2NEJFNUY1fSIgeG1sbnM6eDE1PSJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL29mZmljZS9zcHJlYWRzaGVldG1sLzIwMTAvMTEvbWFpbiI+PHgxNTp0aW1lbGluZVN0eWxlcyBkZWZhdWx0VGltZWxpbmVTdHlsZT0iVGltZVNsaWNlclN0eWxlTGlnaHQxIi8+PC9leHQ+PC9leHRMc3Q+PC9zdHlsZVNoZWV0PlBLAwQKAAAAAAAAACEA0IywC4EAAACBAAAAFAAAAHhsL3NoYXJlZFN0cmluZ3MueG1sPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pg0KPHNzdCB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL3NwcmVhZHNoZWV0bWwvMjAwNi9tYWluIi8+UEsDBAoAAAAAAAAAIQDcCx83XQIAAF0CAAARAAAAZG9jUHJvcHMvY29yZS54bWw8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCIgc3RhbmRhbG9uZT0ieWVzIj8+DQo8Y3A6Y29yZVByb3BlcnRpZXMgeG1sbnM6Y3A9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9wYWNrYWdlLzIwMDYvbWV0YWRhdGEvY29yZS1wcm9wZXJ0aWVzIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOmRjdGVybXM9Imh0dHA6Ly9wdXJsLm9yZy9kYy90ZXJtcy8iIHhtbG5zOmRjbWl0eXBlPSJodHRwOi8vcHVybC5vcmcvZGMvZGNtaXR5cGUvIiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIj48ZGM6Y3JlYXRvcj5kdW5jYW48L2RjOmNyZWF0b3I+PGNwOmxhc3RNb2RpZmllZEJ5PmR1bmNhbjwvY3A6bGFzdE1vZGlmaWVkQnk+PGRjdGVybXM6Y3JlYXRlZCB4c2k6dHlwZT0iZGN0ZXJtczpXM0NEVEYiPjIwMTktMDEtMzFUMTY6NDg6MDNaPC9kY3Rlcm1zOmNyZWF0ZWQ+PGRjdGVybXM6bW9kaWZpZWQgeHNpOnR5cGU9ImRjdGVybXM6VzNDRFRGIj4yMDE5LTAxLTMxVDE2OjQ4OjI4WjwvZGN0ZXJtczptb2RpZmllZD48L2NwOmNvcmVQcm9wZXJ0aWVzPlBLAwQKAAAAAAAAACEAYUkJEBEDAAARAwAAEAAAAGRvY1Byb3BzL2FwcC54bWw8P3htbCB2ZXJzaW9uPSIxLjAiIGVuY29kaW5nPSJVVEYtOCIgc3RhbmRhbG9uZT0ieWVzIj8+DQo8UHJvcGVydGllcyB4bWxucz0iaHR0cDovL3NjaGVtYXMub3BlbnhtbGZvcm1hdHMub3JnL29mZmljZURvY3VtZW50LzIwMDYvZXh0ZW5kZWQtcHJvcGVydGllcyIgeG1sbnM6dnQ9Imh0dHA6Ly9zY2hlbWFzLm9wZW54bWxmb3JtYXRzLm9yZy9vZmZpY2VEb2N1bWVudC8yMDA2L2RvY1Byb3BzVlR5cGVzIj48QXBwbGljYXRpb24+TWljcm9zb2Z0IEV4Y2VsPC9BcHBsaWNhdGlvbj48RG9jU2VjdXJpdHk+MDwvRG9jU2VjdXJpdHk+PFNjYWxlQ3JvcD5mYWxzZTwvU2NhbGVDcm9wPjxIZWFkaW5nUGFpcnM+PHZ0OnZlY3RvciBzaXplPSIyIiBiYXNlVHlwZT0idmFyaWFudCI+PHZ0OnZhcmlhbnQ+PHZ0Omxwc3RyPldvcmtzaGVldHM8L3Z0Omxwc3RyPjwvdnQ6dmFyaWFudD48dnQ6dmFyaWFudD48dnQ6aTQ+MTwvdnQ6aTQ+PC92dDp2YXJpYW50PjwvdnQ6dmVjdG9yPjwvSGVhZGluZ1BhaXJzPjxUaXRsZXNPZlBhcnRzPjx2dDp2ZWN0b3Igc2l6ZT0iMSIgYmFzZVR5cGU9Imxwc3RyIj48dnQ6bHBzdHI+U2hlZXQxPC92dDpscHN0cj48L3Z0OnZlY3Rvcj48L1RpdGxlc09mUGFydHM+PENvbXBhbnk+PC9Db21wYW55PjxMaW5rc1VwVG9EYXRlPmZhbHNlPC9MaW5rc1VwVG9EYXRlPjxTaGFyZWREb2M+ZmFsc2U8L1NoYXJlZERvYz48SHlwZXJsaW5rc0NoYW5nZWQ+ZmFsc2U8L0h5cGVybGlua3NDaGFuZ2VkPjxBcHBWZXJzaW9uPjE2LjAzMDA8L0FwcFZlcnNpb24+PC9Qcm9wZXJ0aWVzPlBLAQIUAAoAAAAAAAAAIQBi7p1okAQAAJAEAAATAAAAAAAAAAAAAAAAAAAAAABbQ29udGVudF9UeXBlc10ueG1sUEsBAhQACgAAAAAAAAAhALVVMCNMAgAATAIAAAsAAAAAAAAAAAAAAAAAwQQAAF9yZWxzLy5yZWxzUEsBAhQACgAAAAAAAAAhALpwnmbKBgAAygYAAA8AAAAAAAAAAAAAAAAANgcAAHhsL3dvcmtib29rLnhtbFBLAQIUAAoAAAAAAAAAIQCBPpSXugIAALoCAAAaAAAAAAAAAAAAAAAAAC0OAAB4bC9fcmVscy93b3JrYm9vay54bWwucmVsc1BLAQIUAAoAAAAAAAAAIQACrURzpAMAAKQDAAAYAAAAAAAAAAAAAAAAAB8RAAB4bC93b3Jrc2hlZXRzL3NoZWV0MS54bWxQSwECFAAKAAAAAAAAACEAwRcQvsYgAADGIAAAEwAAAAAAAAAAAAAAAAD5FAAAeGwvdGhlbWUvdGhlbWUxLnhtbFBLAQIUAAoAAAAAAAAAIQB5oYBsUgYAAFIGAAANAAAAAAAAAAAAAAAAAPA1AAB4bC9zdHlsZXMueG1sUEsBAhQACgAAAAAAAAAhANCMsAuBAAAAgQAAABQAAAAAAAAAAAAAAAAAbTwAAHhsL3NoYXJlZFN0cmluZ3MueG1sUEsBAhQACgAAAAAAAAAhANwLHzddAgAAXQIAABEAAAAAAAAAAAAAAAAAID0AAGRvY1Byb3BzL2NvcmUueG1sUEsBAhQACgAAAAAAAAAhAGFJCRARAwAAEQMAABAAAAAAAAAAAAAAAAAArD8AAGRvY1Byb3BzL2FwcC54bWxQSwUGAAAAAAoACgCAAgAA60IAAAAA";var Ar=s=>typeof s=="object"&&typeof s.row<"u"&&typeof s.column<"u";var ae=class{start_;end_;constructor(e,t=e,r=!1){this.end_=this.PatchNull(t),this.start_=this.PatchNull(e),r&&this.Normalize()}static FromColumn(e){return new ae({row:1/0,column:e})}static FromRow(e){return new ae({row:e,column:1/0})}static ColumnToLabel(e){let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}static CellAddressToLabel(e,t=!1){return(t?`${e.sheet_id||0}!`:"")+(e.absolute_column?"$":"")+this.ColumnToLabel(e.column)+(e.absolute_row?"$":"")+(e.row+1)}static Join(e,...t){let r=new ae(e.start,e.end);for(let n of t)n&&(r.ConsumeAddress(n.start),r.ConsumeAddress(n.end));return r}static Bleed(e,t=1){return new ae({row:Math.max(0,e.start.row-t),column:Math.max(0,e.start.column-t),sheet_id:e.start.sheet_id},{row:e.end.row+t,column:e.end.column+t})}get start(){return{...this.start_}}set start(e){this.start_=e}get end(){return{...this.end_}}set end(e){this.end_=e}get rows(){return this.start_.row===1/0||this.end_.row===1/0?1/0:this.end_.row-this.start_.row+1}get columns(){return this.start_.column===1/0||this.end_.column===1/0?1/0:this.end_.column-this.start_.column+1}get count(){return this.rows*this.columns}get entire_sheet(){return this.entire_row&&this.entire_column}get entire_column(){return this.start_.row===1/0}get entire_row(){return this.start_.column===1/0}PatchNull(e){let t={...e};return t.row===null&&(t.row=1/0),t.column===null&&(t.column=1/0),t}SetSheetID(e){this.start_.sheet_id=e}Normalize(){let e={...this.start_},t={...this.end_};e.row===1/0||t.row===1/0?e.row=t.row=1/0:e.row>t.row&&(e.row=this.end_.row,e.absolute_row=this.end_.absolute_row,t.row=this.start_.row,t.absolute_row=this.start_.absolute_row),e.column===1/0||t.column===1/0?e.column=t.column=1/0:e.column>t.column&&(e.column=this.end_.column,e.absolute_column=this.end_.absolute_column,t.column=this.start_.column,t.absolute_column=this.start_.absolute_column),this.start_=e,this.end_=t}TopLeft(){let e={row:0,column:0};return this.entire_row||(e.column=this.start.column),this.entire_column||(e.row=this.start.row),e}BottomRight(){let e={row:0,column:0};return this.entire_row||(e.column=this.end.column),this.entire_column||(e.row=this.end.row),e}ContainsRow(e){return this.entire_column||e>=this.start_.row&&e<=this.end_.row}ContainsColumn(e){return this.entire_row||e>=this.start_.column&&e<=this.end_.column}Contains(e){return(this.entire_column||e.row>=this.start_.row&&e.row<=this.end_.row)&&(this.entire_row||e.column>=this.start_.column&&e.column<=this.end_.column)}ContainsArea(e){return this.start.column<=e.start.column&&this.end.column>=e.end.column&&this.start.row<=e.start.row&&this.end.row>=e.end.row}Intersects(e){return!(e.start.column>this.end.column||this.start.column>e.end.column||e.start.row>this.end.row||this.start.row>e.end.row)}Equals(e){return e.start_.row===this.start_.row&&e.start_.column===this.start_.column&&e.end_.row===this.end_.row&&e.end_.column===this.end_.column}Clone(){return new ae(this.start,this.end)}Array(){if(this.entire_column||this.entire_row)throw new Error("can\'t convert infinite area to array");let e=new Array(this.rows*this.columns),t=this.start_.sheet_id,r=0;for(let n=this.start_.row;n<=this.end_.row;n++)for(let i=this.start_.column;i<=this.end_.column;i++)e[r++]={row:n,column:i,sheet_id:t};return e}get left(){let e=new ae(this.start_,this.end_);return e.end_.column=e.start_.column,e}get right(){let e=new ae(this.start_,this.end_);return e.start_.column=e.end_.column,e}get top(){let e=new ae(this.start_,this.end_);return e.end_.row=e.start_.row,e}get bottom(){let e=new ae(this.start_,this.end_);return e.start_.row=e.end_.row,e}Shift(e,t){return this.start_.row+=e,this.start_.column+=t,this.end_.row+=e,this.end_.column+=t,this}ConsumeAddress(e){this.entire_row||(e.column<this.start_.column&&(this.start_.column=e.column),e.column>this.end_.column&&(this.end_.column=e.column)),this.entire_column||(e.row<this.start_.row&&(this.start_.row=e.row),e.row>this.end_.row&&(this.end_.row=e.row))}ConsumeArea(e){this.ConsumeAddress(e.start),this.ConsumeAddress(e.end)}Resize(e,t){return this.end_.row=this.start_.row+e-1,this.end_.column=this.start_.column+t-1,this}Iterate(e){if(this.entire_column||this.entire_row){console.warn("don\'t iterate infinite area");return}for(let t=this.start_.column;t<=this.end_.column;t++)for(let r=this.start_.row;r<=this.end_.row;r++)e({column:t,row:r,sheet_id:this.start_.sheet_id})}get spreadsheet_label(){let e;return this.entire_sheet?"":this.entire_column?(e=ae.ColumnToLabel(this.start_.column),e+=":"+ae.ColumnToLabel(this.end_.column),e):this.entire_row?(e=String(this.start_.row+1),e+=":"+(this.end_.row+1),e):(e=ae.CellAddressToLabel(this.start_),this.columns>1||this.rows>1?e+":"+ae.CellAddressToLabel(this.end_):e)}toJSON(){return{start:{...this.start_},end:{...this.end_}}}};var Zi=s=>typeof s=="object"&&!!s&&typeof s.real=="number"&&typeof s.imaginary=="number";var Ft=s=>typeof s=="object"&&!!s&&typeof s.value=="number"&&typeof s.unit=="string";var Se=s=>{switch(typeof s){case"undefined":return 0;case"number":return 3;case"boolean":return 4;case"object":return s===null?0:Zi(s)?7:Ft(s)?9:5;case"string":return s[0]==="="?1:2;default:return 6}};var Ae=class{static StringToColumn(e){let t=0;e=e.toUpperCase();for(let r=0;r<e.length;r++)t*=26,t+=e.charCodeAt(r)-64;return t-1}value;type=0;calculated;calculated_type;formatted;rendered_type;style;area;merge_area;renderer_data;render_clean=[];note;hyperlink;editing;render_function;click_function;validation;constructor(e,t){typeof e<"u"&&this.Set(e,t)}ValueIsNumber(){return this.type===3}ValueIsFormula(){return this.type===1}ValueIsBoolean(){return this.type===4}ValueIsComplex(){return this.type===7}FlushStyle(){this.formatted=this.rendered_type=this.style=void 0,this.render_clean=[]}FlushArray(){this.area=void 0}FlushCache(){this.calculated=this.calculated_type=this.formatted=this.rendered_type=this.render_function=this.click_function=void 0,this.render_clean=[]}Reset(){this.type=0,this.value=this.note=this.hyperlink=this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.area=this.renderer_data=this.render_function=this.click_function=void 0,this.render_clean=[]}Set(e,t=Se(e)){this.value=e,this.type=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=this.render_function=this.click_function=this.area=void 0,this.render_clean=[]}SetCalculatedValue(e,t=Se(e)){this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}SetCalculatedValueOrError(e,t){typeof t>"u"&&(typeof e=="object"&&e.error?(t=6,e=e.error):t=Se(e)),this.calculated!==e&&(this.calculated=e,this.calculated_type=t,this.formatted=this.rendered_type=void 0,this.render_clean=[])}GetValue(){return this.calculated_type?this.calculated:typeof this.value=="string"&&this.value[0]==="\'"?this.value.slice(1):this.value}GetValue4(){return this.calculated_type?{type:this.calculated_type,value:this.calculated}:this.type===1?{type:3,value:0}:{type:this.type,value:typeof this.value=="string"&&this.value[0]==="\'"?this.value.slice(1):this.value}}SetNote(e){this.note=e,this.render_clean=[]}SetCalculationError(e="ERR"){this.SetCalculatedValue(e,6)}SetArray(e){this.type=0,this.value=this.formatted=this.rendered_type=this.style=this.hyperlink=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}SetArrayHead(e,t){this.type=Se(t),this.value=t,this.formatted=this.rendered_type=this.style=this.calculated=this.calculated_type=void 0,this.area=e,this.render_clean=[]}};var zi=s=>!s.cells,Li=s=>!!s[0]&&zi(s[0]),Wi=s=>!!s[0]&&s[0].row!==void 0,ot=class{data=[];rows_=0;columns_=0;get rows(){return this.rows_}get columns(){return this.columns_}EnsureRow(e){this.rows_=Math.max(e+1,this.rows_)}EnsureColumn(e){this.columns_=Math.max(e+1,this.columns_)}InsertColumns(e=0,t=1){let r=JSON.parse(JSON.stringify(this.data[13]));this.data=this.data.map(n=>{if(n.length>=e){let i=n.slice(0,e),a=e+t,o=n.slice(e);for(let u=0;u<o.length;u++)i[a++]=o[u];return i}return n}),this.columns_+=t}DeleteColumns(e,t=1){this.data.forEach(r=>r.splice(e,t)),this.columns_-=t}DeleteRows(e,t=1){this.data.splice(e,t),this.rows_-=t}InsertRows(e=0,t=1){let r=[e,0,[]];for(let n=1;n<t;n++)r.push([]);Array.prototype.splice.apply(this.data,r),this.rows_+=t}GetCell(e,t){let{row:r,column:n}=e;if(!this.data[r])if(t)this.data[r]=[],this.rows_=Math.max(this.rows_,r+1);else return;return this.data[r][n]||t&&(this.data[r][n]=new Ae,this.columns_=Math.max(this.columns_,n+1)),this.data[r][n]}EnsureCell(e){let{row:t,column:r}=e,n=this.data[t];n||(this.data[t]=n=[],this.rows_=Math.max(this.rows_,t+1));let i=n[r];return i||(i=n[r]=new Ae,this.columns_=Math.max(this.columns_,r+1)),i}FromArray(e=[],t=!1){this.data=[];let r=0,n=0;if(t){n=e.length;for(let i=0;i<n;i++){let a=e[i];r=Math.max(r,a.length);for(let o=0;o<a.length;o++)this.data[o]||(this.data[o]=[]),this.data[o][i]=new Ae(a[o])}}else{r=e.length;for(let i=0;i<r;i++){let a=[],o=e[i];n=Math.max(n,o.length);for(let u=0;u<o.length;u++)a[u]=new Ae(o[u]);this.data[i]=a}}this.rows_=r,this.columns_=n}FromJSON(e=[],t){if(this.data=[],!Li(e)){let r=[];if(Wi(e))for(let n of e)for(let i of n.cells)r.push({...i,row:n.row});else for(let n of e)for(let i of n.cells)r.push({...i,column:n.column});e=r}for(let r of e){this.data[r.row]||(this.data[r.row]=[]);let n=new Ae(r.value);if(typeof r.calculated<"u"&&n.SetCalculatedValue(r.calculated,r.calculated_type),t&&typeof r.style_ref<"u"&&(n.style=t[r.style_ref]),typeof r.note<"u"&&(n.note=r.note),typeof r.hyperlink<"u"&&(n.hyperlink=r.hyperlink),this.data[r.row][r.column]&&this.data[r.row][r.column].area&&(n.area=this.data[r.row][r.column].area),this.data[r.row][r.column]=n,r.area){let i=new ae(r.area.start,r.area.end);for(let a=i.start.row;a<=i.end.row;a++)for(let o=i.start.column;o<=i.end.column;o++)this.data[a]||(this.data[a]=[]),this.data[a][o]||(this.data[a][o]=new Ae),this.data[a][o].area=i}if(r.merge_area){let i=new ae(r.merge_area.start,r.merge_area.end);for(let a=i.start.row;a<=i.end.row;a++)for(let o=i.start.column;o<=i.end.column;o++)this.data[a]||(this.data[a]=[]),this.data[a][o]||(this.data[a][o]=new Ae),this.data[a][o].merge_area=i}r.validation&&(n.validation=r.validation)}this.rows_=this.data.length,this.columns_=this.data.reduce((r,n)=>Math.max(r,n.length),0)}toJSON(e={}){let t=0,r=0,n=this.data.length-1,i;e.subset&&(t=e.subset.start.column,r=e.subset.start.row,n=e.subset.end.row);let a=[],o=-1,u=-1,d={},p={};for(let l=r;l<=n;l++)if(this.data[l]){let b=this.data[l];i=b.length-1,e.subset&&(i=e.subset.end.column);for(let f=t;f<=i;f++){let m=b[f],g=m&&m.merge_area&&m.merge_area.start.row===l&&m.merge_area.start.column===f,A=m&&m.area&&m.area.start.row===l&&m.area.start.column===f,y=m?m.type===2&&!m.value:!0;if(m&&(!y||e.preserve_empty_strings)&&(g||m.type||m.calculated_type&&e.expand_arrays||m.calculated_type&&e.calculated_value||m.validation||e.decorated_cells&&m.style&&(m.style.fill||m.style.border_bottom||m.style.border_top||m.style.border_left||m.style.border_right))){let w={row:l,column:f,value:m.value};m.note&&(w.note=m.note),m.hyperlink&&(w.hyperlink=m.hyperlink),e.preserve_type&&(w.type=m.type),e.sheet_id&&(w.sheet_id=e.sheet_id),e.calculated_value&&typeof m.calculated<"u"&&(w.calculated=m.calculated,(e.preserve_type||m.calculated_type===6)&&(w.calculated_type=m.calculated_type)),m.area&&A&&(w.area=m.area.toJSON()),m.merge_area&&(w.merge_area=m.merge_area.toJSON()),m.validation&&(w.validation=m.validation),e.cell_style_refs&&e.cell_style_refs[f]&&e.cell_style_refs[f][l]&&(w.style_ref=e.cell_style_refs[f][l],e.cell_style_refs[f][l]=0),d[l]=l,p[f]=f,o=Math.max(l,o),u=Math.max(f,u),a.push(w)}}}if(e.nested){let l=Object.keys(d),b=Object.keys(p);if(l.length<=b.length&&l.length){let f={},m=[];for(let g of a){let{row:A,...y}=g;f[g.row]||(f[g.row]=[]),f[g.row].push(y)}for(let g of l){let A=Number(g);m.push({row:A,cells:f[A]})}return{data:m,rows:o,columns:u+1}}else if(b.length){let f={},m=[];for(let g of a){let{column:A,...y}=g;f[g.column]||(f[g.column]=[]),f[g.column].push(y)}for(let g of b){let A=Number(g);m.push({column:A,cells:f[A]})}return{data:m,rows:o,columns:u+1}}}return{data:a,rows:o+1,columns:u+1}}GetAll(e=!1){return this.GetRange({row:0,column:0},{row:this.rows_-1,column:this.columns_-1},e)}Normalize2(e,t){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),t.column===1/0&&(t={...t,column:this.columns_-1}),t.row===1/0&&(t={...t,row:this.rows_-1}),{from:e,to:t}}Normalize1(e){return e.column===1/0&&(e={...e,column:0}),e.row===1/0&&(e={...e,row:0}),e}RawValue(e,t=e){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].value:void 0;let r=[],n=this.data.slice(e.row,t.row+1),i=e.column,a=t.column+1;for(let o of n){let u=[];for(let d=i,p=0;d<a;d++,p++){let l=o[d];u.push(l?l.value:void 0)}r.push(u)}return r}GetRange(e,t,r=!1){if(t?{from:e,to:t}=this.Normalize2(e,t):e=this.Normalize1(e),!t||e===t||e.column===t.column&&e.row===t.row)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue():void 0;let n=[];if(r)for(let i=e.column;i<=t.column;i++){let a=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][i]?a.push(this.data[o][i].GetValue()):a.push(void 0);n.push(a)}else for(let i=e.row;i<=t.row;i++){let a=[];for(let o=e.column;o<=t.column;o++)this.data[i]&&this.data[i][o]?a.push(this.data[i][o].GetValue()):a.push(void 0);n.push(a)}return n}GetRange4(e,t=e,r=!1){if({from:e,to:t}=this.Normalize2(e,t),e.row===t.row&&e.column===t.column)return this.data[e.row]&&this.data[e.row][e.column]?this.data[e.row][e.column].GetValue4():{value:void 0,type:0};let n=[];if(r)for(let i=e.column;i<=t.column;i++){let a=[];for(let o=e.row;o<=t.row;o++)this.data[o]&&this.data[o][i]?a.push(this.data[o][i].GetValue4()):a.push({type:0});n.push(a)}else for(let i=e.row;i<=t.row;i++){let a=[];for(let o=e.column;o<=t.column;o++)this.data[i]&&this.data[i][o]?a.push(this.data[i][o].GetValue4()):a.push({type:0});n.push(a)}return{type:8,value:n}}Apply(e,t,r=!1){if(Ar(e)&&(e=new ae(e)),e.entire_column||e.entire_row)throw new Error("don\'t iterate infinite cells");let n=e.start,i=e.end;if(r)for(let a=n.row;a<=i.row;a++){this.data[a]||(this.data[a]=[]);let o=this.data[a];for(let u=n.column;u<=i.column;u++)o[u]||(o[u]=new Ae),t(o[u],u,a)}else for(let a=n.row;a<=i.row;a++)if(this.data[a]){let o=this.data[a];for(let u=n.column;u<=i.column;u++)o[u]&&t(o[u],u,a)}}SetArea(e,t){if(ArrayBuffer.isView(t))throw new Error("ABIV");if(Array.isArray(t))for(let r=e.start.row,n=0;r<=e.end.row;r++,n++){this.data[r]||(this.data[r]=[]);let i=this.data[r];if(t[n])for(let a=e.start.column,o=0;a<=e.end.column;a++,o++)i[a]||(i[a]=new Ae),i[a].Set(t[n][o])}else{let r=Se(t);for(let n=e.start.row;n<=e.end.row;n++){this.data[n]||(this.data[n]=[]);let i=this.data[n];for(let a=e.start.column;a<=e.end.column;a++)i[a]||(i[a]=new Ae),i[a].Set(t,r)}}this.rows_=Math.max(this.rows_,e.end.row+1),this.columns_=Math.max(this.columns_,e.end.column+1)}IterateAll(e){for(let t of this.data)if(t)for(let r of t)r&&e(r)}FlushCellStyles(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushStyle()}FlushCachedValues(){for(let e of this.data)if(e)for(let t of e)t&&t.FlushCache()}};var oe=class{static UpdateLocale(e){if(e)this.locale=e;else if(typeof self<"u"){let n=self?.document?.location;if(n&&n.search&&/locale=([^?&]+?)(?:\\?|$|&)/.test(n.search)){let i=n.search.match(/locale=(.*?)(?:\\?|$|&)/);i&&(this.locale=i[1]),console.info("override locale",this.locale)}else typeof navigator<"u"&&(navigator.languages&&navigator.languages[0]?this.locale=navigator.languages[0]:this.locale=navigator.language)}let t=new Intl.NumberFormat(this.locale,{minimumFractionDigits:1}).format(3.3).replace(/\\d/g,"");this.decimal_separator=t===","?",":".",this.decimal_separator===","?(this.argument_separator=";",this.grouping_separator=" "):(this.argument_separator=",",this.grouping_separator=",");let r=new Date(2e3,0,2,12,0,0,0);this.UpdateDateComponent(0,0,r),r=new Date(2e3,1,7,12,0,0,0),this.UpdateDateComponent(1,1,r),r=new Date(2e3,2,7,12,0,0,0),this.UpdateDateComponent(2,2,r),r=new Date(2e3,3,5,12,0,0,0),this.UpdateDateComponent(3,3,r),r=new Date(2e3,4,4,12,0,0,0),this.UpdateDateComponent(4,4,r),r=new Date(2e3,5,2,12,0,0,0),this.UpdateDateComponent(5,5,r),r=new Date(2e3,6,1,12,0,0,0),this.UpdateDateComponent(6,6,r),r=new Date(2e3,7,1,12,0,0,0),this.UpdateDateComponent(7,-1,r),r=new Date(2e3,8,1,12,0,0,0),this.UpdateDateComponent(8,-1,r),r=new Date(2e3,9,1,12,0,0,0),this.UpdateDateComponent(9,-1,r),r=new Date(2e3,10,1,12,0,0,0),this.UpdateDateComponent(10,-1,r),r=new Date(2e3,11,1,12,0,0,0),this.UpdateDateComponent(11,-1,r)}static UpdateDateComponent(e,t,r){t>=0&&(this.date_components.short_days[t]=r.toLocaleString(this.locale,{weekday:"short"}),this.date_components.long_days[t]=r.toLocaleString(this.locale,{weekday:"long"})),e>=0&&(this.date_components.short_months[e]=r.toLocaleString(this.locale,{month:"short"}),this.date_components.long_months[e]=r.toLocaleString(this.locale,{month:"long"}))}};ie(oe,"locale","en-us"),ie(oe,"decimal_separator","."),ie(oe,"argument_separator",","),ie(oe,"grouping_separator",","),ie(oe,"date_components",{short_days:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],long_days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],short_months:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],long_months:["January","February","March","April","May","June","July","August","September","October","November","December"]});oe.UpdateLocale();var pe;(f=>{let s=JSON.stringify({}),e;(w=>(w.None="",w.Left="left",w.Center="center",w.Right="right"))(e=f.HorizontalAlign||={});let t;(w=>(w.None="",w.Top="top",w.Bottom="bottom",w.Middle="middle"))(t=f.VerticalAlign||={}),f.DefaultProperties={horizontal_align:"",vertical_align:"",number_format:"General",nan:"NaN",font_size:{unit:"pt",value:10.5},font_face:"sans-serif",bold:!1,italic:!1,underline:!1,strike:!1,text:{theme:1},border_top:0,border_left:0,border_right:0,border_bottom:0},f.CompositeBorders=m=>({top:{width:m.border_top||0,color:m.border_top_fill||{}},left:{width:m.border_left||0,color:m.border_left_fill||{}},right:{width:m.border_right||0,color:m.border_right_fill||{}},bottom:{width:m.border_bottom||0,color:m.border_bottom_fill||{}}}),f.Merge=(m,g,A=!0)=>{let y=A?{...m,...g}:{...g};return JSON.parse(JSON.stringify(y))},f.Composite=m=>JSON.parse(JSON.stringify(m.reduce((g,A)=>({...g,...A}),{}))),f.Empty=m=>JSON.stringify(m)===s,f.ValidColor=m=>!!(m&&!m.none&&(m.text||m.theme||m.theme===0)),f.ParseFontSize=(m="",g="em")=>{let A=m.match(/(-*[\\d.]+)\\s*(\\S*)/);if(A){let y=Number(A[1]);if(!y||isNaN(y)||y<0)return{};let w=A[2].toLowerCase()||g;if(w==="pt"||w==="em"||w==="%"||w==="px")return{font_size:{unit:w,value:y}}}return{}},f.RelativeFontSize=(m,g)=>{let A=12,y=12;switch(m.font_size?.unit){case"pt":if(!m.font_size.value)return 1;y=m.font_size.value;break;case"px":if(!m.font_size.value)return 1;y=Math.round(m.font_size.value*300/4)/100;break;case"em":return m.font_size.value||1;case"%":return(m.font_size.value||100)/100;default:return 1}switch(g.font_size?.unit){case"pt":if(!g.font_size.value)return 1;A=g.font_size.value;break;case"px":if(!g.font_size.value)return 1;A=Math.round(g.font_size.value*300/4)/100;break;default:return 1}return y/A},f.FontSize=(m,g=!0)=>{let A=m.font_size?.value;switch(m.font_size?.unit){case"pt":return(A||12)+"pt";case"px":return g?Math.round((A||16)*300/4)/100+"pt":(A||16)+"px";case"em":return(A||1)+"em";case"%":return(A||100)+"%"}return""},f.Font=(m,g=1)=>{let A=[];return m.bold&&A.push("bold"),m.italic&&A.push("italic"),A.push(((m.font_size?.value||0)*g).toFixed(2)+(m.font_size?.unit||"pt")),A.push(m.font_face||""),A.join(" ")}})(pe||={});var St=class{Darken(e,t,r,n,i=!1){let{h:a,s:o,l:u}=this.RGBToHSL(e,t,r);return i?u-=u*n/100:u-=n/100,u=Math.max(0,Math.min(1,u)),this.HSLToRGB(a,o,u)}Lighten(e,t,r,n,i=!1){let{h:a,s:o,l:u}=this.RGBToHSL(e,t,r);return i?u+=u*n/100:u+=n/100,u=Math.max(0,Math.min(1,u)),this.HSLToRGB(a,o,u)}RGBToHSL(e,t,r){e/=255,t/=255,r/=255;let n=Math.max(e,t,r),i=Math.min(e,t,r),a=0,o=0,u=(n+i)/2;if(n===i)a=o=0;else{let d=n-i;switch(o=u>.5?d/(2-n-i):d/(n+i),n){case e:a=(t-r)/d+(t<r?6:0);break;case t:a=(r-e)/d+2;break;case r:a=(e-t)/d+4;break}a/=6}return{h:a*360,s:o,l:u}}HSLToRGB(e,t,r){let n,i,a;if(t===0)n=i=a=r;else{e=e/360;let o=r<.5?r*(1+t):r+t-r*t,u=2*r-o;n=this.HueToRGB(u,o,e+1/3),i=this.HueToRGB(u,o,e),a=this.HueToRGB(u,o,e-1/3)}return{r:Math.round(n*255),g:Math.round(i*255),b:Math.round(a*255)}}HueToRGB(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+(t-e)*6*r:r<1/2?t:r<2/3?e+(t-e)*(2/3-r)*6:e}},Gi=new St;var xt=Fe(ut());var Xr=Fe(st()),Fa=Fe(ut()),Qr=(s,e)=>Xr.decode(e),Kr={ignoreAttributes:!1,attributeNamePrefix:"__",trimValues:!1,textNodeName:"text__",tagValueProcessor:Qr,ignoreDeclaration:!0},lt={ignoreAttributes:!1,attributesGroupName:"a$",attributeNamePrefix:"",textNodeName:"t$",trimValues:!1,ignoreDeclaration:!0,isArray:(s,e,t,r)=>/Relationship$/.test(s),tagValueProcessor:Qr},se=class{static FindChild(e={},t){let r=t.split("/");for(let n of r)if(e=e[n],!e)return;return e}static FindAll(e={},t){let r=t.split("/");if(r[0]==="."&&r.shift(),r[0]==="..")throw new Error("invalid path (no access to parent)");if(r[0]==="")throw new Error("invalid path (no access to root)");if(r[0]==="**")throw new Error("ENOTIMPL");return this.FindAllTail(e,r)}static FindAllTail(e,t){if(Array.isArray(e))return e.reduce((r,n)=>r.concat(this.FindAllTail(n,t)),[]);for(let r=0;r<t.length;r++){let n=t[r];if(n==="*"?e=Object.keys(e).filter(i=>i!=="a$"&&i!=="t$").map(i=>e[i]):e=e[n],!e)return[];if(Array.isArray(e)){if(r===t.length-1||e.length===0)return e;let i=t.slice(1);return e.reduce((a,o)=>a.concat(this.FindAllTail(o,i)),[])}}return[e]}};var We=class{strings=[];reverse={};FromXML(e){this.strings=[],this.reverse={};let t=0;for(let r of se.FindAll(e,"sst/si")){if(r.t){let n="";typeof r.t=="string"?n=r.t:r.t.t$&&(n=r.t.t$),this.strings[t]=n,this.reverse[n]=t}else if(r.r){let i=se.FindAll(r.r,"t").map(a=>typeof a=="string"?a:a.t$||"").join("");this.strings[t]=i,this.reverse[i]=t}else console.warn(` ** unexpected shared string @ ${t}`),console.info(r);t++}}Get(e){return this.strings[e]}Ensure(e){e[0]==="\'"&&(e=e.substring(1));let t=this.reverse[e];return typeof t=="number"||(t=this.strings.length,this.strings.push(e),this.reverse[e]=t),t}};var Ot=class{colors={};FromXML(e){let t=Object.keys(e)[0],r="",n=t.toString().match(/^(.*?):/);if(n&&(r=n[1]+":"),e[t]&&e[t][`${r}themeElements`]){let i=e[t][`${r}themeElements`][`${r}clrScheme`];for(let a of Ot.color_map){let o=i[`${r}${a}`],u,d="rgb";o[`${r}srgbClr`]?(d="rgb",u=o[`${r}srgbClr`].a$.val||""):o[`${r}sysClr`]&&(d="system",u=o[`${r}sysClr`].a$.lastClr||""),this.colors[a]={name:a,value:u,type:d}}}}},Be=Ot;ie(Be,"color_map",["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"]);var Ie=class{date_format=!1;string_format=!1;fraction_format=!1;twelve_hour=!1;fraction_denominator=0;fraction_integer=!0;fraction_align=0;fraction_denominator_digits=0;integer_min_digits=0;decimal_min_digits=0;decimal_max_digits=0;grouping=!1;has_number_format=!1;prefix=[{text:""}];suffix=[{text:""}];scaling=0;percent=!1;exponential=!1;has_asterisk=!1};var ei=42,ti=95,jt=63,ct=48,ri=46,Yt=44,ii=37,Ht=34,Xe=35,ni=59,dt=92,si=64,$n=91,qn=93,ai=69,oi=101,Jn=72,Xn=104,Qn=77,Kn=109,es=83,ts=115,rs=68,is=100,ns=89,ss=121,as=65,os=97;var xe=class{static Parse(e){if(this.pattern=e,this.characters=e.split("").map(t=>t.charCodeAt(0)),this.char_index=0,this.current_section=new Ie,this.sections=[this.current_section],this.ParseDatePattern())return this.sections;for(this.char_index=0,this.current_section=new Ie,this.sections=[this.current_section];this.char_index<this.characters.length;)this.ConsumeChar();return this.sections}static ConsumeString(){let e="";for(this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case dt:this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index+1<this.characters.length&&(e+=this.pattern[++this.char_index]);break;case Ht:return this.preserve_formatting_characters&&(e+=this.pattern[this.char_index]),this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated string")}static ConsumeFormatting(){let e="";for(++this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case dt:throw new Error("invalid escape character in formatting block");case qn:return this.char_index++,e;default:e+=this.pattern[this.char_index];break}throw new Error("unterminated format")}static ScanFractionFormat(){let e=/^([#?]+ +){0,1}([#?]+)\\/([#?0-9]+)(?:$|[^#?0-9])/,r=this.pattern.substr(this.char_index).match(e);if(!r)return!1;let n=(r[1]||"").length+r[2].length+r[3].length+1;this.current_section.fraction_format=!0,this.current_section.fraction_integer=!!r[1];let i=Number(r[3]);return isNaN(i)||(this.current_section.fraction_denominator=i),this.current_section.decimal_max_digits=this.current_section.fraction_denominator_digits=r[3].length,this.char_index+=n,this.current_section.has_number_format=!0,!0}static ConsumeNumberFormat(){let e=0;for(this.char_index;this.char_index<this.characters.length;this.char_index++)switch(this.characters[this.char_index]){case this.group_separator:{let r=!1;for(let n=this.char_index+1;!r&&n<this.characters.length;n++){let i=this.characters[n];if(i===this.decimal_mark||i===Xe||i===ct)r=!0;else if(i!==Yt)break}if(r){if(e===1)throw new Error("invalid grouping in decimal part");this.current_section.grouping=!0}else this.current_section.scaling=(this.current_section.scaling||1)*1e3}break;case this.decimal_mark:if(e===1)throw new Error("too many decimal marks");e=1;break;case Xe:e===1?this.current_section.decimal_max_digits++:this.current_section.integer_min_digits&&this.current_section.integer_min_digits++;break;case ct:e===1?(this.current_section.decimal_max_digits++,this.current_section.decimal_min_digits=this.current_section.decimal_max_digits):this.current_section.integer_min_digits++;break;default:return}}static AppendCharAsText(e=!0){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=this.pattern[this.char_index]:this.current_section.prefix[this.current_section.prefix.length-1].text+=this.pattern[this.char_index],e&&this.char_index++}static AppendString(e){this.current_section.has_number_format?this.current_section.suffix[this.current_section.suffix.length-1].text+=e:this.current_section.prefix[this.current_section.prefix.length-1].text+=e}static AppendTextPart(e){this.current_section.has_number_format?(this.current_section.suffix.push(e),this.current_section.suffix.push({text:""})):(this.current_section.prefix.push(e),this.current_section.prefix.push({text:""}))}static ConsumeChar(){let e=this.characters[this.char_index];if(!((e===jt||e===Xe)&&!this.current_section.has_number_format&&!this.current_section.string_format&&this.ScanFractionFormat()))switch(e){case ni:this.char_index++,this.current_section=new Ie,this.sections.length===3&&(this.current_section.string_format=!0),this.sections.push(this.current_section);break;case si:this.char_index++,this.AppendTextPart({text:"@",flag:5}),this.current_section.string_format=!0;break;case ct:case Xe:case ri:case Yt:!this.current_section.has_number_format&&!this.current_section.string_format?(this.ConsumeNumberFormat(),this.current_section.has_number_format=!0):this.AppendCharAsText();break;case $n:this.AppendTextPart({text:this.ConsumeFormatting(),flag:6});break;case Ht:this.AppendString(this.ConsumeString());break;case jt:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case ti:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case ei:if(this.current_section.has_asterisk)throw new Error("we don\'t support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case oi:case ai:this.current_section.percent||this.current_section.exponential||this.current_section.string_format?this.AppendCharAsText():(this.current_section.exponential=!0,this.char_index++);break;case ii:!this.current_section.exponential&&!this.current_section.string_format&&(this.current_section.percent=!0),this.AppendCharAsText();break;case dt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}static ParseDatePattern(){for(this.date_pattern=!0;this.date_pattern&&this.char_index<this.pattern.length;)this.DatePatternConsumeChar();if(this.date_pattern){this.date_pattern=!1;for(let e of this.sections)for(let t of e.prefix)t.flag&&t.flag&7&&(this.date_pattern=!0)}return this.date_pattern&&(this.sections[0].date_format=!0,this.sections[0].prefix.forEach((e,t)=>{if(e.flag===3&&(e.text==="mm"||e.text==="m")){if(t)for(let r=t-1;r;r--){let n=this.sections[0].prefix[r];if(n.flag===3){/h/i.test(n.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}if(t<this.sections[0].prefix.length-1)for(let r=t+1;r<this.sections[0].prefix.length;r++){let n=this.sections[0].prefix[r];if(n.flag===3){/s/i.test(n.text)&&(e.flag=4,e.text=e.text.toLowerCase());break}}}})),this.date_pattern}static ConsumeDatePart(){let e=this.pattern[this.char_index++],t=e.toLowerCase(),r={text:e,flag:3};for(;this.pattern[this.char_index]&&this.pattern[this.char_index].toLowerCase()===t;)r.text+=this.pattern[this.char_index++];if(t==="s"&&this.pattern[this.char_index]===".")for(r.text+=this.pattern[this.char_index++];this.pattern[this.char_index]==="0";)r.text+=this.pattern[this.char_index++];return r}static ConsumeAMPM(){let e=this.pattern.substr(this.char_index,5);if(e==="am/pm"||e==="AM/PM")return this.char_index+=5,this.sections[0].twelve_hour=!0,{text:e,flag:3};if(e=this.pattern.substr(this.char_index,3),e==="a/p"||e==="A/P")return this.char_index+=3,this.sections[0].twelve_hour=!0,{text:e,flag:3}}static DatePatternConsumeChar(){switch(this.characters[this.char_index]){case ni:this.char_index=this.characters.length;break;case ct:case Xe:case oi:case ai:case ii:case si:this.date_pattern=!1;break;case Jn:case Xn:case Qn:case Kn:case es:case ts:case rs:case is:case ns:case ss:this.AppendTextPart(this.ConsumeDatePart());break;case as:case os:{let t=this.ConsumeAMPM();t?this.AppendTextPart(t):this.AppendCharAsText()}break;case Ht:this.AppendString(this.ConsumeString());break;case jt:this.preserve_formatting_characters?this.AppendCharAsText():(this.AppendTextPart({text:"0",flag:1}),this.char_index++);break;case ti:if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:1})}break;case ei:if(this.current_section.has_asterisk)throw new Error("we don\'t support multiple asterisks");if(this.preserve_formatting_characters)this.AppendCharAsText();else{if(++this.char_index>=this.characters.length)throw new Error("invalid pad character at end");this.AppendTextPart({text:this.pattern[this.char_index++],flag:2}),this.current_section.has_asterisk=!0}break;case dt:if(this.preserve_formatting_characters&&this.AppendCharAsText(!1),++this.char_index>=this.characters.length)throw new Error("invalid escape character at end");this.AppendCharAsText();break;default:this.AppendCharAsText()}}};ie(xe,"date_pattern",!1),ie(xe,"pattern",""),ie(xe,"char_index",0),ie(xe,"characters",[]),ie(xe,"sections",[]),ie(xe,"current_section",new Ie),ie(xe,"preserve_formatting_characters",!1),ie(xe,"decimal_mark",ri),ie(xe,"group_separator",Yt);var us=s=>(s>=60&&s--,new Date(-22090752e5+864e5*s)),ui=(s,e=!0)=>{if(e){let t=new Date(s),r=new Date;r.setUTCMilliseconds(t.getUTCMilliseconds()),r.setUTCSeconds(t.getUTCSeconds()),r.setUTCMinutes(t.getUTCMinutes()),r.setUTCHours(t.getHours()),r.setUTCDate(t.getDate()),r.setUTCMonth(t.getMonth()),r.setUTCFullYear(t.getFullYear()),s=r.getTime()}return s=(s+22090752e5)/864e5,s>=60&&s++,s},ke=class{magic_decimal=!1;transform_value;_pattern="";sections;decimal_zero_regexp=[];cloned=[];get pattern(){return this._pattern}get date_format(){return this.sections[0]&&this.sections[0].date_format}constructor(e){if(this._pattern=e,this.sections=xe.Parse(e),this.sections.length||(this.sections=[]),this.sections[0]||(this.sections[0]=new Ie),this.sections[1]||(this.sections[1]={...this.sections[0]},this.sections[1].prefix=JSON.parse(JSON.stringify(this.sections[1].prefix)),this.sections[1].suffix=JSON.parse(JSON.stringify(this.sections[1].suffix)),this.sections[1].prefix.push({text:"-"}),this.cloned[1]=!0),this.sections[2]||(this.sections[2]={...this.sections[0]},this.cloned[2]=!0),!this.sections[3]){for(let t of this.sections[0].prefix)if(t.flag===5){this.sections[3]={...this.sections[0]},this.sections[3].string_format=!0,this.cloned[3]=!0;break}}this.decimal_zero_regexp=this.sections.map(t=>{if(t.decimal_max_digits>t.decimal_min_digits)return new RegExp(`0{1,${t.decimal_max_digits-t.decimal_min_digits}}(?:$|e)`)})}static FormatPartsAsText(e,t=0){let r=-1,n=e.map((i,a)=>{switch(i.flag){case 2:return r=a,i.text;case 1:return i.text.replace(/./g," ");case 6:return"";default:return i.text}});if(r>=0&&t){let i=n.reduce((o,u,d)=>d===r?o:o+u.length,0),a="";for(let o=0;o<t-i;o++)a+=n[r];n[r]=a}return n.join("")}SetDecimal(e){for(let t of this.sections)t.fraction_format||(t.decimal_min_digits=e,t.decimal_max_digits=e)}IncreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.min(e.fraction_denominator_digits+1,4)):(e.decimal_min_digits++,e.decimal_max_digits=e.decimal_min_digits)})}DecreaseDecimal(){this.sections.forEach(e=>{e.fraction_format?e.fraction_denominator||(e.fraction_denominator_digits=Math.max(e.fraction_denominator_digits-1,1)):(e.decimal_min_digits=Math.max(0,e.decimal_min_digits-1),e.decimal_max_digits=e.decimal_min_digits)})}AddGrouping(){this.sections.forEach(e=>{e.grouping=!0})}RemoveGrouping(){this.sections.forEach(e=>{e.grouping=!1})}ToggleGrouping(){let e=!this.sections[0].grouping;this.sections.forEach(t=>{t.grouping=e})}toString(){return this.sections[0].date_format?this._pattern:this.sections.filter((e,t)=>!this.cloned[t]).map(e=>{let t="",r=0;if(e.fraction_format){e.fraction_integer&&(t+="? ");let n="";for(let i=0;i<e.fraction_denominator_digits;i++)n+="#";t+=n,t+="/",e.fraction_denominator?t+=e.fraction_denominator:t+=n}else if(e.has_number_format){for(r=0;r<e.integer_min_digits;r++)t+="0";if(e.grouping&&(t.length<4&&(t=("####"+t).slice(-4)),t=t.replace(/[\\d#]{1,3}(?=([\\d#]{3})+(?![\\d#]))/g,"$&,")),e.decimal_max_digits||e.decimal_min_digits){for(t+=".",r=0;r<e.decimal_min_digits;r++)t+="0";for(;r<e.decimal_max_digits;r++)t+="#"}if(e.scaling){let n=Math.log10(e.scaling)/3;for(r=0;r<n;r++)t+=","}e.exponential&&(t+="e")}return e.prefix.map(n=>n.flag===1?n.text==="0"?"?":"_"+n.text:n.flag===2?"*"+n.text:n.flag===6?"["+n.text+"]":n.text).join("")+t+e.suffix.map(n=>n.flag===1?n.text==="0"?"?":"_"+n.text:n.flag===2?"*"+n.text:n.text).join("")}).join(";")}FormatDimensionedQuantity(e){if(this.transform_value){let r=this.transform_value(e);if(Ft(r))e=r;else return typeof r=="string"?r:this.FormatParts(r)}let t=this.FormatParts(e.value||0);return e.unit&&t.push({text:" "},{text:e.unit}),t}FormatComplex(e){let t=[],r=[],n=!1,i=!!e.imaginary;i&&(t=this.FormatParts(e.imaginary),i=t.some(u=>/[1-9]/.test(u.text)),t.length===1&&this.sections[0].integer_min_digits<=1&&t[0].text==="1"?(t[0].text="",n=!0):t.length===1&&this.sections[1].integer_min_digits<=1&&t[0].text==="-1"&&(t[0].text="-",n=!0));let a=!!e.real;a&&(r=this.FormatParts(e.real),a=r.some(u=>/[1-9]/.test(u.text)));let o=[];if(a||!a&&!i){if(o.push(...r),i){let u=Math.abs(e.imaginary);o.push({text:e.imaginary<0?` ${ke.minus_character} `:" + "});let d=n?[]:this.FormatParts(Math.abs(e.imaginary));o.push(...d,{text:ke.imaginary_character})}}else i&&o.push(...t,{text:ke.imaginary_character});return o}FormatParts(e){if(typeof e!="number"&&!this.sections[3])return[{text:e.toString()}];let{parts:t,section:r}=this.BaseFormat(e),n=[];if(r.date_format||r.string_format)for(let i of t)typeof i=="string"?n.push({text:i}):n.push(i);else this.magic_decimal&&t[1]===""&&t.splice(1,1),n=[...r.prefix.map(i=>({...i})),{text:r.has_number_format?t.join(oe.decimal_separator):""},...r.suffix.map(i=>({...i}))];for(let i=1;i<n.length;i++)n[i].flag===n[i-1].flag&&(n[i].text=n[i-1].text+n[i].text,n[i-1].text="");return n.filter(i=>i.text)}Format(e,t=0){return ke.FormatPartsAsText(this.FormatParts(e),t)}ZeroPad(e,t){for(;e.length<t;)e="0"+e;return e}DateFormat(e){let t=us(e),r=this.sections[0],n=t.getUTCHours();return r.twelve_hour&&(n>12&&(n-=12),n===0&&(n=12)),{parts:r.prefix.map(a=>{if(a.flag===4)return a.text==="mm"?{text:this.ZeroPad(t.getUTCMinutes().toString(),2)}:{text:this.ZeroPad(t.getUTCMinutes().toString(),1)};if(a.flag===3){switch(a.text.toLowerCase()){case"am/pm":case"a/p":{let u=a.text.split("/");return{text:t.getUTCHours()>12?u[1]:u[0]}}case"mmmmm":return{text:oe.date_components.long_months[t.getUTCMonth()][0]};case"mmmm":return a.text==="MMMM"?{text:oe.date_components.long_months[t.getUTCMonth()].toUpperCase()}:{text:oe.date_components.long_months[t.getUTCMonth()]};case"mmm":return a.text==="MMM"?{text:oe.date_components.short_months[t.getUTCMonth()].toUpperCase()}:{text:oe.date_components.short_months[t.getUTCMonth()]};case"mm":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),2)};case"m":return{text:this.ZeroPad((t.getUTCMonth()+1).toString(),1)};case"ddddd":case"dddd":return a.text==="DDDDD"||a.text==="DDDD"?{text:oe.date_components.long_days[t.getUTCDay()].toUpperCase()}:{text:oe.date_components.long_days[t.getUTCDay()]};case"ddd":return a.text==="DDD"?{text:oe.date_components.short_days[t.getUTCDay()].toUpperCase()}:{text:oe.date_components.short_days[t.getUTCDay()]};case"dd":return{text:this.ZeroPad(t.getUTCDate().toString(),2)};case"d":return{text:this.ZeroPad(t.getUTCDate().toString(),1)};case"yyyy":case"yyy":return{text:t.getUTCFullYear().toString()};case"yy":case"y":return{text:this.ZeroPad((t.getUTCFullYear()%100).toString(),2)};case"hh":return{text:this.ZeroPad(n.toString(),2)};case"h":return{text:this.ZeroPad(n.toString(),1)};case"ss":return{text:this.ZeroPad(t.getUTCSeconds().toString(),2)};case"s":return{text:this.ZeroPad(t.getUTCSeconds().toString(),1)}}let o=a.text.match(/^(s+)\\.(0+)$/);if(o)return{text:this.ZeroPad(t.getUTCSeconds().toString(),o[1].length)+oe.decimal_separator+(t.getUTCMilliseconds()/1e3).toFixed(o[2].length).substr(2)}}return{...a}}),section:r}}StringFormat(e,t){let r=[];for(let n of t.prefix)n.flag===5?r.push({text:e}):r.push({...n});return{parts:r,section:t}}Round2(e,t){let r=Math.pow(10,t);return Math.round(r*e)/r}FormatFraction(e,t){t.percent&&(e*=100);let r={denominator:1,numerator:Math.round(e),error:Math.abs(Math.round(e)-e)};if(t.fraction_denominator)r.denominator=t.fraction_denominator,r.numerator=Math.round(e*r.denominator);else if(r.error){let i=ke.fraction_limits[t.fraction_denominator_digits-1]||ke.fraction_limits[0];for(let a=2;a<=i;a++){let o=Math.round(e*a),u=Math.abs(o/a-e);if(u<r.error&&(r={numerator:o,denominator:a,error:u},!u))break}}let n=[];if(t.fraction_integer){let i=Math.floor(r.numerator/r.denominator);r.numerator%=r.denominator,(i||!r.numerator)&&(n.push(i.toString()),r.numerator&&n.push(" "))}else r.numerator||n.push("0");return r.numerator&&(n.push(r.numerator.toString()),n.push("/"),n.push(r.denominator.toString())),n.join("")}BaseFormat(e){if(this.sections[0].date_format)return this.DateFormat(Number(e));if(typeof e!="number")return this.StringFormat(e.toString(),this.sections[3]);let t=this.sections[0],r=this.decimal_zero_regexp[0];e<0&&(t=this.sections[1]);let n=t.percent?t.decimal_max_digits+2:t.decimal_max_digits,i=Math.pow(10,-n)/2,a=Math.abs(e);if(a<i&&(t=this.sections[2],r=this.decimal_zero_regexp[2]),t.scaling&&(a/=t.scaling,a<i&&(t=this.sections[2],r=this.decimal_zero_regexp[2])),t.string_format)return this.StringFormat(e.toString(),t);let o="";if(t.fraction_format)return{parts:[this.FormatFraction(a,t)],section:t};t.exponential?o=a.toExponential(t.decimal_max_digits):(t.percent&&(a*=100),o=this.Round2(a,t.decimal_max_digits).toFixed(t.decimal_max_digits)),r&&(o=o.replace(r,""));let u=o.split(".");for(;u[0].length<t.integer_min_digits;)u[0]=("0000000000000000"+u[0]).slice(-t.integer_min_digits);return t.integer_min_digits===0&&u[0]==="0"&&(u[0]=""),t.grouping&&(u[0]=u[0].replace(ke.grouping_regexp,"$&"+oe.grouping_separator)),{parts:u,section:t}}},_e=ke;ie(_e,"grouping_regexp",/\\d{1,3}(?=(\\d{3})+(?!\\d))/g),ie(_e,"fraction_limits",[9,99,999,9999]),ie(_e,"imaginary_character","\\u{1D456}"),ie(_e,"minus_character","-");var De=class{static Get(e,t=!1){if(t&&e==="General")return this.complex_general;let r=this.symbolc_name_map[e.toLowerCase()],n=this.cache[r||e];return n||(n=new _e(e),this.cache[e]=n),n}static Equals(e,t){if(e===t)return!0;let r=this.Get(e),n=this.Get(t);return r.pattern===n.pattern}static Translate(e){let t=this.symbolc_name_map[e.toLowerCase()];return t?this.cache[t].toString():e}static SymbolicName(e){for(let t of Object.keys(this.base_formats))if(e===this.base_formats[t])return t;return null}static InitCache(){for(let e of Object.keys(this.base_formats))this.cache[e]=new _e(this.base_formats[e]),this.symbolc_name_map[e.toLowerCase()]=e;this.cache.General.magic_decimal=!0,this.complex_general=new _e("0.###"),this.complex_general.magic_decimal=!0;for(let e of Object.keys(this.aliases))this.cache[e]=this.cache[this.aliases[e]],this.symbolc_name_map[e.toLowerCase()]=e}};ie(De,"cache",{}),ie(De,"complex_general"),ie(De,"symbolc_name_map",{}),ie(De,"base_formats",{Accounting:"_(#,##0.00_);(#,##0.00);-???",Number:"0.00",Integer:"0",Percent:"0.00%",General:"0.######",Fraction:"# ?/?",Dollar:"$* _(#,##0.00_);$* (#,##0.00);$* -???",Exponential:"0.000e","Short Date":"mm/dd/yy","Long Date":"dddd, mmm d yyyy",Timestamp:"mm-dd-yy hh:mm:ss"}),ie(De,"aliases",{Scientific:"Exponential",Percentage:"Percent",Currency:"Dollar"});De.InitCache();var li=new Date().getUTCFullYear(),$t=class{compare_day;compare_month;TestDate(e){let t=Date.parse(e);if(isNaN(t))return!1;let r=new Date(t),i=e.replace(/[\\d\\-\\\\/,.\\s]+/g," ").toLocaleLowerCase().split(/\\s+/).map(u=>u.trim()).filter(u=>!!u);if(!i.length)return t;if(!this.compare_month){this.compare_month={};for(let u=0;u<12;u++)this.compare_month[oe.date_components.long_months[u].toLocaleLowerCase().replace(/\\./,"")]=u,this.compare_month[oe.date_components.short_months[u].toLocaleLowerCase().replace(/\\./,"")]=u}if(!this.compare_day){this.compare_day={};for(let u=0;u<7;u++)this.compare_day[oe.date_components.long_days[u].toLocaleLowerCase().replace(/\\./,"")]=u,this.compare_day[oe.date_components.short_days[u].toLocaleLowerCase().replace(/\\./,"")]=u}let a=!1,o=!1;for(let u of i){let d=!1;for(let[p,l]of Object.entries(this.compare_month))if(u===p){if(a||r.getUTCMonth()!==l)return!1;d=!0,a=!0}if(!d){for(let[p,l]of Object.entries(this.compare_day))if(u===p){if(o||r.getUTCDay()!==l)return!1;d=!0,o=!0}}if(!d)return!1}return o&&!a?!1:t}TryParse(e=""){let t=0;if(e[0]==="\'")return{value:e,type:2};if(e==="")return{value:e,type:2};if(e==="NaN")return{value:NaN,type:3,hints:1};let r=e.trim(),n=r.match(/^[$](.*?)$/);n&&(r=n[1],t|=8);let i=r.match(/^\\((.*?)\\)$/);i&&(r=i[1],t|=32);let a=r.match(/^(.*?)%\\s*$/);a&&(r=a[1],t|=4),oe.decimal_separator==="."?/,/.test(r)&&(r=r.replace(/,/g,""),t|=16):(r=r.replace(/(\\d)\\s+/g,"$1"),r=r.replace(/\\./g,""),r=r.replace(/,/,"."));let o=Number(r);if(o===null||isNaN(o)){let u=e.toLowerCase();if(u==="false")return{value:!1,type:4};if(u==="true")return{value:!0,type:4};let d=this.TestDate(e);if(d!==!1&&!isNaN(d)){let p=new Date(d),l=p.getUTCFullYear();if(l>=li-200&&l<=li+200)return t=64,(p.getHours()||p.getMinutes()||p.getSeconds())&&(t|=128),{value:ui(d),type:3,hints:t}}return{value:e,type:2}}if(i&&(o=-o),a){let u=o<0?-1:1,d=(u*o).toString().split(".");d[0]=("00"+d[0]).replace(/(\\d\\d)$/,".$1"),o=Number(d.join(""))*u}return/e/.test(e)&&(t|=2),{value:o,type:3,hints:t}}},io=new $t;var ci=Fe(st()),qt={top:{},left:{},bottom:{},right:{},diagonal:{}},ht=class{theme=new Be;cell_xfs=[];fonts=[];borders=[];fills=[];number_formats=[];base_number_format_id=200;modified=!1;Clamp(e,t,r){return Math.max(t,Math.min(e,r))}TintColor(e,t){let r=parseInt(e.substr(0,2),16),n=parseInt(e.substr(2,2),16),i=parseInt(e.substr(4,2),16);return t<0?(r=Math.round(r*t+r),n=Math.round(n*t+n),i=Math.round(i*t+i)):(r=Math.round((255-r)*t+r),n=Math.round((255-n)*t+n),i=Math.round((255-i)*t+i)),[r,n,i].map(a=>{let o=this.Clamp(a,0,255).toString(16);return o.length<2?"0"+o:o}).join("")}StyleOptionsFromProperties(e){let t=JSON.parse(JSON.stringify(e));for(let d of Object.keys(t))t[d]==="none"&&delete t[d];let r={},n={pattern_type:"none"},i=JSON.parse(JSON.stringify(qt)),a={font:r,border:i};t.number_format&&(a.number_format={format:De.Translate(t.number_format),symbolic_name:t.number_format}),t.font_size?.unit&&t.font_size.value&&(t.font_size.unit!=="pt"?console.warn("can\'t handle non-point font (FIXME)"):r.size=t.font_size.value),t.bold&&(r.bold=!0),t.italic&&(r.italic=!0),t.underline&&(r.underline=!0),t.text&&(t.text.text?r.color_argb=t.text.text:typeof t.text.theme=="number"&&(r.color_theme=t.text.theme,t.text.tint&&(r.color_tint=t.text.tint)));let o=(d,p)=>{d.width&&(p.style="thin",d.color.text?p.rgba=d.color.text:typeof d.color.theme=="number"?(p.theme=d.color.theme,d.color.tint&&(p.tint=d.color.tint)):p.color=64)},u=pe.CompositeBorders(t);switch(o(u.top,i.top),o(u.left,i.left),o(u.right,i.right),o(u.bottom,i.bottom),t.vertical_align){case pe.VerticalAlign.Top:a.vertical_alignment="top";break;case pe.VerticalAlign.Middle:a.vertical_alignment="center";break}switch(t.horizontal_align){case pe.HorizontalAlign.Center:a.horizontal_alignment="center";break;case pe.HorizontalAlign.Left:a.horizontal_alignment="left";break;case pe.HorizontalAlign.Right:a.horizontal_alignment="right";break}return t.fill&&(n.pattern_type="solid",t.fill.text?n.fg_color={argb:t.fill.text}:typeof t.fill.theme=="number"?(n.fg_color={theme:t.fill.theme},t.fill.tint&&(n.fg_color.tint=t.fill.tint)):n.fg_color={theme:1},a.fill=n),t.wrap&&(a.wrap=!0),a}CellXfToStyle(e){let t={},r=ht.default_styles[e.number_format];if(!r){for(let u of this.number_formats)if(u.id===e.number_format&&u.format){r=u.format;break}}if(r){let u=/\\[\\$(.)-[0-9A-Za-z]{1,4}\\]/g;r=r.replace(u,"$1");let d=/\\[\\$-[0-9A-Za-z]{1,4}\\]/g;r=r.replace(d,""),t.number_format=r}let n=this.fonts[0],i=this.fonts[e.font||0];i&&(i.bold&&(t.bold=!0),i.italic&&(t.italic=!0),i.underline&&(t.underline=!0),i.strike&&(t.strike=!0),n&&n.size&&i.size&&n.size!==i.size&&(t.font_size={value:100*i.size/n.size,unit:"%"}),i.color_argb?t.text={text:"#"+(i.color_argb.length>6?i.color_argb.substr(i.color_argb.length-6):i.color_argb)}:typeof i.color_theme=="number"&&(t.text={theme:i.color_theme}));let a=this.fills[e.fill||0];if(a&&a.pattern_type!=="none"){if(a.pattern_type==="gray"){let u=Math.round((a.pattern_gray||0)/1e3*255);t.fill={text:`rgb(${u}, ${u}, ${u})`}}a.pattern_type==="solid"&&a.fg_color&&(a.fg_color.argb?t.fill={text:"#"+(a.fg_color.argb.length>6?a.fg_color.argb.substr(a.fg_color.argb.length-6):a.fg_color.argb)}:typeof a.fg_color.theme=="number"&&(t.fill={theme:a.fg_color.theme},a.fg_color.tint&&(t.fill.tint=Math.round(a.fg_color.tint*1e3)/1e3)))}switch(e.horizontal_alignment){case"center":t.horizontal_align=pe.HorizontalAlign.Center;break;case"right":t.horizontal_align=pe.HorizontalAlign.Right;break;case"left":t.horizontal_align=pe.HorizontalAlign.Left;break}switch(e.vertical_alignment){case"center":t.vertical_align=pe.VerticalAlign.Middle;break;case"top":t.vertical_align=pe.VerticalAlign.Top;break;case"bottom":t.vertical_align=pe.VerticalAlign.Bottom;break}e.wrap_text&&(t.wrap=!0);let o=this.borders[e.border||0];return o&&(o.bottom.style&&(o.bottom.style==="double"?t.border_bottom=2:t.border_bottom=1),o.left.style&&(t.border_left=1),o.top.style&&(t.border_top=1),o.right.style&&(t.border_right=1)),t}CellXfToStyles(){return this.cell_xfs.map(e=>this.CellXfToStyle(e))}EnsureNumberFormat(e){if(typeof e.format>"u"||e.symbolic_name&&/^general$/i.test(e.symbolic_name))return 0;for(let r=0;r<100;r++){let n=ht.default_styles[r];if(n&&n===e.format)return r}for(let r of this.number_formats)if(r.format===e.format)return r.id||0;this.modified=!0;let t={id:this.base_number_format_id++,format:e.format};return this.number_formats.push(t),t.id}CompareBorderEdge(e,t){return e.color===t.color&&e.rgba===t.rgba&&e.style===t.style&&e.theme===t.theme&&e.tint===t.tint}CompareBorder(e,t){return this.CompareBorderEdge(e.top,t.top)&&this.CompareBorderEdge(e.left,t.left)&&this.CompareBorderEdge(e.bottom,t.bottom)&&this.CompareBorderEdge(e.right,t.right)&&this.CompareBorderEdge(e.diagonal,t.diagonal)}EnsureBorder(e){for(let r=0;r<this.borders.length;r++){let n=this.borders[r];if(this.CompareBorder(n,e))return r}this.modified=!0;let t=JSON.parse(JSON.stringify(e));return this.borders.push(t),this.borders.length-1}MatchColor(e,t){return!e&&!t?!0:!e||!t?!1:e.argb===t.argb&&e.indexed===t.indexed&&e.theme===t.theme&&e.tint===t.tint}EnsureFill(e){for(let r=0;r<this.fills.length;r++){let n=this.fills[r];if(this.MatchColor(e.bg_color,n.bg_color)&&this.MatchColor(e.fg_color,n.fg_color)&&e.pattern_gray===n.pattern_gray&&e.pattern_type===n.pattern_type)return r}this.modified=!0;let t={...e};return this.fills.push(t),this.fills.length-1}EnsureFont(e){let t={...this.fonts[0],...e};for(let r=0;r<this.fonts.length;r++){let n=this.fonts[r];if(n.bold===t.bold&&n.italic===t.italic&&n.underline===t.underline&&n.size===t.size&&n.strike===t.strike&&n.color_argb===t.color_argb&&n.color_theme===t.color_theme&&n.color_tint===t.color_tint&&n.family===t.family)return r}return this.modified=!0,this.fonts.push(t),this.fonts.length-1}EnsureStyle(e){let t=this.EnsureFont(e.font||{}),r=this.EnsureBorder(e.border||qt),n=this.EnsureNumberFormat(e.number_format||{}),i=this.EnsureFill(e.fill||{pattern_type:"none"});for(let o=0;o<this.cell_xfs.length;o++){let u=this.cell_xfs[o];if(u.font===t&&u.fill===i&&u.border===r&&u.number_format===n&&!!u.wrap_text==!!e.wrap&&(!e.horizontal_alignment&&!u.horizontal_alignment||e.horizontal_alignment===u.horizontal_alignment)&&(!e.vertical_alignment&&!u.vertical_alignment||e.vertical_alignment===u.vertical_alignment))return o}this.modified=!0;let a={font:t,fill:i,border:r,number_format:n};return e.horizontal_alignment&&(a.horizontal_alignment=e.horizontal_alignment),e.vertical_alignment&&(a.vertical_alignment=e.vertical_alignment),e.wrap&&(a.wrap_text=!0),this.cell_xfs.push(a),this.cell_xfs.length-1}FromXML(e,t){let r=se.FindAll.bind(se,e);this.theme=t;let n=r("styleSheet/numFmts/numFmt");this.number_formats=n.map(i=>({id:Number(i.a$?.numFmtId||0),format:ci.decode(i.a$?.formatCode||"")})),n=r("styleSheet/borders/border"),this.borders=n.map(i=>{let a=JSON.parse(JSON.stringify(qt));return i.left&&(a.left.style=i.left.a$.style,a.left.color=Number(i.left.color?.a$?.indexed)),i.right&&(a.right.style=i.right.a$.style,a.right.color=Number(i.right.color?.a$?.indexed)),i.top&&(a.top.style=i.top.a$.style,a.top.color=Number(i.top.color?.a$?.indexed)),i.bottom&&(a.bottom.style=i.bottom.a$.style,a.bottom.color=Number(i.bottom.color?.a$?.indexed)),a}),n=r("styleSheet/cellXfs/xf"),this.cell_xfs=n.map(i=>{let a={number_format:Number(i.a$.numFmtId),font:Number(i.a$.fontId),fill:Number(i.a$.fillId),border:Number(i.a$.borderId),xfid:Number(i.a$.xfId)};return i.alignment&&(a.horizontal_alignment=i.alignment.a$.horizontal,a.vertical_alignment=i.alignment.a$.vertical,a.wrap_text=!!i.alignment.a$.wrapText),a}),n=r("styleSheet/fills/fill"),this.fills=n.map(i=>{let a={pattern_type:"none"};if(i.patternFill){let o=i.patternFill.a$?.patternType;switch(o){case"none":case void 0:break;case"solid":a.pattern_type="solid",i.patternFill.fgColor&&(a.fg_color={theme:i.patternFill.fgColor.a$?.theme?Number(i.patternFill.fgColor.a$.theme):void 0,indexed:i.patternFill.fgColor.a$?.indexed?Number(i.patternFill.fgColor.a$.indexed):void 0,tint:i.patternFill.fgColor.a$?.tint?Number(i.patternFill.fgColor.a$.tint):void 0,argb:i.patternFill.fgColor.a$?.rgb});break;default:{let u=o?.match(/^gray(\\d+)$/);if(u){a.pattern_type="gray",a.pattern_gray=Number(u[1]);break}}}}return a}),n=r("styleSheet/fonts/font"),this.fonts=n.map(i=>{let a={};return a.italic=typeof i.i<"u",a.bold=typeof i.b<"u",a.underline=typeof i.u<"u",a.strike=typeof i.strike<"u",i.sz&&(a.size=Number(i.sz.a$.val)),i.scheme&&(a.scheme=i.scheme.a$.val),i.name&&(a.name=i.name.a$.val),i.family&&(a.family=Number(i.family.a$.val)),i.color&&(i.color.a$?.theme&&(a.color_theme=Number(i.color.a$.theme)),i.color.a$?.tint&&(a.color_tint=Number(i.color.a$.tint)),i.color.a$?.rgb&&(a.color_argb=i.color.a$.rgb)),a})}},Ze=ht;ie(Ze,"default_styles",{0:"General",1:"0",2:"0.00",3:"#,##0",4:"#,##0.00",9:"0%",10:"0.00%",11:"0.00E+00",12:"# ?/?",13:"# ??/??",14:"mm-dd-yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",37:"#,##0 ;(#,##0)",38:"#,##0 ;[Red](#,##0)",39:"#,##0.00;(#,##0.00)",40:"#,##0.00;[Red](#,##0.00)",45:"mm:ss",46:"[h]:mm:ss",47:"mmss.0",48:"##0.0E+0",49:"@"});var Ce=(s,e,t,r)=>{let i=`rId${Object.keys(s).length+1}`;return s[i]={id:i,type:e,target:t,mode:r},i};var sr=/[\\s-+=<>!()]/;var Jt=34,Xt=39,ls=160,cs=32,ds=9,hs=10,ps=13,Ne=48,Qe=57,Qt=46,Kt=43,Ke=45,di=40,er=41,pt=44,fs=37,tr=95,ft=36,ms=123,gs=125,hi=91,pi=93,bs=33,fi=59,As=35,Ge=65,et=97,xs=69,ys=101,mt=90,gt=122,ws=105;var rr=192,ir=312,nr={"==":6,"!=":6,"<>":6,"=":6,"<":7,">":7,"<=":7,">=":7,"+":9,"-":9,"&":9,"*":10,"/":10,"^":11,":":13},_s=Object.keys(nr).sort((s,e)=>e.length-s.length),Ds={"-":100,"+":100},Ue=class{argument_separator=",";decimal_mark=".";flags={spreadsheet_semantics:!0,dimensioned_quantities:!1,fractions:!0};r1c1_regex=/[rR]((?:\\[[-+]{0,1}\\d+\\]|\\d+))[cC]((?:\\[[-+]{0,1}\\d+\\]|\\d+))$/;argument_separator_char=pt;decimal_mark_char=Qt;imaginary_char=ws;imaginary_number="i";id_counter=0;expression="";data=[];index=0;length=0;valid=!0;error_position;error;dependencies={addresses:{},ranges:{}};address_refcount={};full_reference_list=[];Walk(e,t){switch(e.type){case"address":case"missing":case"literal":case"complex":case"identifier":case"operator":t(e);return;case"dimensioned":t(e)&&(this.Walk(e.expression,t),this.Walk(e.unit,t));return;case"range":t(e)&&(this.Walk(e.start,t),this.Walk(e.end,t));return;case"binary":t(e)&&(this.Walk(e.left,t),this.Walk(e.right,t));return;case"unary":t(e)&&this.Walk(e.operand,t);return;case"group":t(e)&&e.elements.forEach(r=>this.Walk(r,t));return;case"call":t(e)&&e.args.forEach(r=>this.Walk(r,t))}}Transpose(e){let t=e.length,r=[],n=0;for(let i=0;i<t;i++)Array.isArray(e[i])&&(n=Math.max(n,e[i].length));for(let i=0;i<n;i++){r[i]=[];for(let a=0;a<t;a++)r[i][a]=e[a][i]}return r}Render(e,t={rows:0,columns:0},r="(missing)",n,i,a){let o=this.argument_separator+" ";i===","?o=", ":i===";"&&(o="; ");let u=this.imaginary_number;a&&(u=a);let d=n===","?",":".",p=this.decimal_mark===","?/,/:/\\./;switch(e.type){case"address":return this.AddressLabel(e,t);case"range":return this.AddressLabel(e.start,t)+":"+this.AddressLabel(e.end,t);case"missing":return r;case"array":return"{"+this.Transpose(e.values).map(l=>l.map(b=>typeof b=="string"?\'"\'+b+\'"\':b).join(", ")).join("; ")+"}";case"binary":return this.Render(e.left,t,r,n,i)+" "+e.operator+" "+this.Render(e.right,t,r,n,i);case"unary":return e.operator+this.Render(e.operand,t,r,n,i);case"complex":if(e.real){let l=Math.abs(e.imaginary);return`${e.real||0}${e.imaginary<0?" - ":" + "}${l===1?"":l}i`}else return e.imaginary===-1?"-i":e.imaginary===1?"i":`${e.imaginary}i`;break;case"literal":if(typeof e.value=="string")return\'"\'+e.value.replace(/"/g,\'""\')+\'"\';if(n&&typeof e.value=="number")if(e.text){let l=e.text;return n===","&&this.decimal_mark==="."&&(l=l.replace(/,/g,"")),l.replace(p,d)}else return e.value.toString().replace(/\\./,d);else if(e.text)return e.text;return e.value.toString();case"identifier":return e.name;case"operator":return"["+e.operator+"]";case"group":return e.explicit?"("+e.elements.map(l=>this.Render(l,t,r,n,i)).join(o)+")":e.elements.map(l=>this.Render(l,t,r,n,i)).join(o);case"call":return e.name+"("+e.args.map(l=>this.Render(l,t,r,n,i)).join(o)+")";case"dimensioned":return this.Render(e.expression)+" "+this.Render(e.unit)}return"??"}Parse(e){switch(e=e.trim(),e[0]==="="&&(e=e.substr(1).trim()),this.expression=e,this.data=[],this.length=e.length,this.index=0,this.valid=!0,this.error_position=void 0,this.error=void 0,this.dependencies.addresses={},this.dependencies.ranges={},this.address_refcount={},this.full_reference_list=[],this.id_counter=0,this.argument_separator){case";":this.argument_separator_char=fi;break;default:this.argument_separator_char=pt;break}switch(this.decimal_mark){case",":this.decimal_mark_char=pt;break;default:this.decimal_mark_char=Qt;break}for(let n=0;n<this.length;n++)this.data[n]=e.charCodeAt(n);let t=this.ParseGeneric(),r={};for(let n of Object.keys(this.dependencies.addresses))this.address_refcount[n]&&(r[n]=this.dependencies.addresses[n]);return this.dependencies.addresses=r,{expression:t||void 0,valid:this.valid,error:this.error,error_position:this.error_position,dependencies:this.dependencies,separator:this.argument_separator,decimal_mark:this.decimal_mark,full_reference_list:this.full_reference_list.slice(0)}}ColumnLabel(e){if(e===1/0)return"";let t=String.fromCharCode(65+e%26);for(;e>25;)e=Math.floor(e/26)-1,t=String.fromCharCode(65+e%26)+t;return t}AddressLabel(e,t){let r=e.column;!e.absolute_column&&e.column!==1/0&&(r+=t.columns);let n=e.row;if(!e.absolute_row&&e.row!==1/0&&(n+=t.rows),n<0||r<0||n===1/0&&r===1/0)return"#REF";let i="";return e.sheet&&(i=(sr.test(e.sheet)?"\'"+e.sheet+"\'":e.sheet)+"!"),n===1/0?i+(e.absolute_column?"$":"")+this.ColumnLabel(r):r===1/0?i+(e.absolute_row?"$":"")+(n+1):i+(e.absolute_column?"$":"")+this.ColumnLabel(r)+(e.absolute_row?"$":"")+(n+1)}ParseGeneric(e=[0]){let t=[];for(;this.index<this.length;){let r=this.ParseNext(t.length===0);if(typeof r=="number"){if(e.some(n=>r===n))break;if(r===di){this.index++;let n=this.ParseGeneric([er]);this.index++,n&&t.push({type:"group",id:this.id_counter++,elements:[n],explicit:!0})}else{let n=this.ConsumeOperator();n?t.push(n):(this.error=`unexpected character [1]: ${String.fromCharCode(r)}, 0x${r.toString(16)}`,this.valid=!1,this.index++)}}else t.push(r)}if(t.length){if(t=this.BinaryToRange2(t),this.flags.fractions){let r=[],n=a=>a.type==="literal"&&typeof a.value=="number"&&a.value%1===0,i=0;for(;i<t.length-3;i++)if(n(t[i])&&n(t[i+1])&&t[i+2].type==="operator"&&t[i+2].operator==="/"&&n(t[i+3])){let a=t[i],o=t[i+1],u=t[i+3],d=(a.value<0?-1:1)*(o.value/u.value);i+=3,r.push({id:t[i].id,type:"literal",text:this.expression.substring(a.position,u.position+1),value:a.value+d,position:a.position})}else r.push(t[i]);for(;i<t.length;i++)r.push(t[i]);t=r}if(t=t.map(r=>r.type==="identifier"&&r.name===this.imaginary_number?{type:"complex",real:0,imaginary:1,position:r.position,text:r.name,id:this.id_counter++}:r),this.flags.dimensioned_quantities){let r=[],n;for(let i=0;i<t.length;i++){let a=t[i];if(!n)n=a;else if(a.type==="identifier"&&(n.type==="literal"||n.type==="group"||n.type==="call")){let o=a;for(;t[i+1]?.type==="identifier";)o.name+=" "+t[++i].name;r.push({type:"dimensioned",expression:n,unit:a,id:this.id_counter++}),n=void 0}else r.push(n),n=a}n&&r.push(n),t=r}}return t.length===0?null:t.length===1?t[0]:this.BinaryToComplex(this.ArrangeUnits(t))}UnitToAddress(e){if(e.type==="literal"){if(typeof e.value=="number"&&e.value>0&&!/\\./.test(e.text||""))return{type:"address",position:e.position,label:e.value.toString(),row:e.value-1,id:this.id_counter++,column:1/0}}else{let t,r=e.name,n=r.split("!");if(n.length>1&&(t=n.slice(0,n.length-1).join("!"),r=r.substr(t.length+1),t[0]==="\'"))if(t.length>1&&t[t.length-1]==="\'")t=t.substr(1,t.length-2);else return;let i=r[0]==="$";r=(i?r.substr(1):r).toUpperCase();let a=Number(r);if(isNaN(a)){if(/[A-Z]{1,3}/.test(r)){let o=-1;for(let u=0;u<r.length;u++){let d=r[u].charCodeAt(0);o=26*(1+o)+(d-Ge)}return{type:"address",position:e.position,absolute_column:i,label:e.name,column:o,id:this.id_counter++,row:1/0,sheet:t}}}else if(a>0&&a!==1/0&&!/\\./.test(r))return{type:"address",position:e.position,absolute_row:i,label:e.name,row:a-1,id:this.id_counter++,column:1/0,sheet:t}}}BinaryToRange2(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r],i=e[r+1],a=e[r+2],o,u="",d;if(n&&i&&a&&i.type==="operator"&&i.operator===":"){if(n.type==="address"&&a.type==="address"){let p=n.position+n.label.length,l=a.position;o={type:"range",id:this.id_counter++,position:n.position,start:n,end:a,label:n.label+this.expression.substring(p,l)+a.label},u=o.start.label+":"+o.end.label,this.address_refcount[o.start.label]--,this.address_refcount[o.end.label]--;let b=[n.position,a.position];this.full_reference_list=this.full_reference_list.filter(f=>f.position!==b[0]&&f.position!==b[1])}else if((n.type==="literal"||n.type==="identifier")&&(a.type==="literal"||a.type==="identifier")){let p=this.UnitToAddress(n);if(!p&&n.type==="literal"&&typeof n.value=="number"&&n.value<0){let b={...n,text:(n.text||"").replace(/^-/,""),position:n.position+1,value:-n.value};p=this.UnitToAddress(b),p&&(d={type:"operator",operator:"-",position:n.position,id:this.id_counter++})}let l=this.UnitToAddress(a);p&&l&&(p.column===1/0&&l.column===1/0||p.row===1/0&&l.row===1/0)&&(u=p.label+":"+l.label,o={type:"range",id:this.id_counter++,position:p.position,start:p,end:l,label:u})}}o?(d&&t.push(d),t.push(o),this.dependencies.ranges[u]=o,this.full_reference_list.push(o),r+=2):t.push(n)}return t}BinaryToComplex(e){if(e.type==="binary")if((e.operator==="+"||e.operator==="-")&&e.left.type==="literal"&&typeof e.left.value=="number"&&e.right.type==="complex"&&!e.right.composited){let t="";t=this.expression.substring(e.left.position,e.right.position+(e.right.text?.length||0));let r=e.right.imaginary;return e.operator==="-"&&(r=-r),{type:"complex",position:e.left.position,text:t,id:this.id_counter++,imaginary:r,real:e.left.value,composited:!0}}else e.left=this.BinaryToComplex(e.left),e.right=this.BinaryToComplex(e.right);else if(e.type==="unary"&&(e.operator==="-"||e.operator==="+")&&e.operand.type==="complex"&&e.operand.text===this.imaginary_number)return{...e.operand,position:e.position,text:this.expression.substring(e.position,e.operand.position+(e.operand.text||"").length),imaginary:e.operand.imaginary*(e.operator==="-"?-1:1)};return e}BinaryToRangeX(e){if(e.type==="binary"){if(e.operator===":"){let t,r="";if(e.left.type==="address"&&e.right.type==="address"){let n=e.left.position+e.left.label.length,i=e.right.position;t={type:"range",id:this.id_counter++,position:e.left.position,start:e.left,end:e.right,label:e.left.label+this.expression.substring(n,i)+e.right.label},r=t.start.label+":"+t.end.label,this.address_refcount[t.start.label]--,this.address_refcount[t.end.label]--;let a=[e.left.position,e.right.position];this.full_reference_list=this.full_reference_list.filter(o=>o.position!==a[0]&&o.position!==a[1])}else if((e.left.type==="literal"||e.left.type==="identifier")&&(e.right.type==="literal"||e.right.type==="identifier")){let n=this.UnitToAddress(e.left),i=this.UnitToAddress(e.right);n&&i&&(n.column===1/0&&i.column===1/0||n.row===1/0&&i.row===1/0)&&(r=n.label+":"+i.label,t={type:"range",id:this.id_counter++,position:e.left.position,start:n,end:i,label:r})}if(t)return this.dependencies.ranges[r]=t,this.full_reference_list.push(t),t;this.error="unexpected character: :",this.valid=!1}e.left=this.BinaryToRangeX(e.left),e.right=this.BinaryToRangeX(e.right)}return e}ArrangeUnits(e){if(e.length===0)return{type:"missing",id:this.id_counter++};if(e.length===1)return e[0];let t=[];for(let r=0;r<e.length;r++){let n=e[r];if(n.type==="operator")if(t.length===0||t[t.length-1].type==="operator")if(Ds[n.operator]){let i=this.BinaryToComplex(this.ArrangeUnits(e.slice(r+1)));if(!this.valid)return{type:"group",id:this.id_counter++,elements:e,explicit:!1};i.type==="binary"?(i.left={type:"unary",id:this.id_counter++,operator:n.operator,operand:i.left,position:n.position},n=i):n={type:"unary",id:this.id_counter++,operator:n.operator,operand:i,position:n.position},r=e.length}else return this.error=`unexpected character [2]: ${n.operator}`,this.error_position=n.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1};else{t.push(n);continue}if(t.length<2)t.push(n);else if(t[t.length-1].type==="operator"){let i=t[t.length-2],a=t[t.length-1],o=a.operator,u={type:"binary",id:this.id_counter++,left:i,operator:o,position:a.position,right:n};i.type==="binary"&&nr[o]>nr[i.operator]&&(u.left=i.left,u.operator=i.operator,u.position=i.position,u.right={type:"binary",id:this.id_counter++,left:i.right,right:n,operator:o,position:a.position}),t.splice(-2,2,u)}else return this.error="multiple expressions",this.error_position=n.position,this.valid=!1,{type:"group",id:this.id_counter++,elements:e,explicit:!1}}return t[0]}ParseNext(e=!0){this.ConsumeWhiteSpace();let t=this.data[this.index];if(t===Jt)return{type:"literal",id:this.id_counter++,position:this.index,value:this.ConsumeString()};if(t>=Ne&&t<=Qe||t===this.decimal_mark_char)return this.ConsumeNumber();if(t===ms)return this.ConsumeArray();if(e&&(t===Ke||t===Kt)){let r=this.data[this.index+1];if(r>=Ne&&r<=Qe||r===this.decimal_mark_char)return this.ConsumeNumber()}else if(t>=Ge&&t<=mt||t>=et&&t<=gt||t===tr||t===As||t===Xt||t===ft||t>=rr&&t<=ir)return this.ConsumeToken(t);return t}ConsumeArray(){let e={type:"array",id:this.id_counter++,values:[],position:this.index};this.index++;let t=0,r=0;for(;this.index<this.length;){let n=this.ParseNext(),i=this.index;if(typeof n=="number")switch(this.index++,n){case fi:r++,t=0;break;case pt:t++;break;case gs:return e;default:this.valid&&(this.error="invalid character in array literal",this.error_position=i,this.valid=!1);break}else switch(n.type){case"literal":e.values[t]||(e.values[t]=[]),e.values[t][r]=n.value;break;default:this.valid&&(this.error="invalid value in array literal",this.error_position=i,this.valid=!1);break}}return e}ConsumeOperator(){for(let e of _s)if(this.expression.substr(this.index,e.length)===e){let t=this.index;return this.index+=e.length,{type:"operator",id:this.id_counter++,operator:e,position:t}}return null}ConsumeArguments(){this.index++;let e=0,t=[];for(;this.index<this.length;){let r=this.ParseGeneric([this.argument_separator_char,er]);r!==null&&t.push(r);let n=this.data[this.index];if(n===this.argument_separator_char){this.index++,e++;for(let i=t.length;i<e;i++)t.push({type:"missing",id:this.id_counter++})}else if(n===er)return this.index++,t}return t}ConsumeToken(e){let t=[e],r=this.index,n=e===Xt,i=!1;for(++this.index;this.index<this.length;this.index++){let d=this.data[this.index];if(d>=Ge&&d<=mt||d>=et&&d<=gt||d>=rr&&d<=ir||d===tr||d===ft||d===Qt||d===bs||n||d>=Ne&&d<=Qe||this.flags.r1c1&&(d===hi||d===pi||d===Ke&&i))t.push(d),d===hi&&(i=!0),d===pi&&(i=!1),d===Xt&&(n=!1);else break}let a=t.map(d=>String.fromCharCode(d)).join("");if(n)return this.error="unbalanced single quote",this.error_position=r,this.valid=!1,{type:"identifier",id:this.id_counter++,name:a,position:r};if(a.toLowerCase()==="true")return{type:"literal",id:this.id_counter++,value:!0,position:r};if(a.toLowerCase()==="false")return{type:"literal",id:this.id_counter++,value:!1,position:r};if(this.ConsumeWhiteSpace(),this.data[this.index]===di){let d=this.ConsumeArguments();return{type:"call",id:this.id_counter++,name:a,args:d,position:r}}if(this.flags.spreadsheet_semantics){let d=this.ConsumeAddress(a,r);if(d)return d}let u={type:"identifier",id:this.id_counter++,name:a,position:r};return this.full_reference_list.push(u),u}ConsumeAddress(e,t){let r=t,n=e.length,i,a=e.split("!");if(a.length>1&&(i=a.slice(0,a.length-1).join("!"),t+=i.length+1),this.flags.r1c1){let l=a[a.length-1].match(this.r1c1_regex);if(l){let b={type:"address",id:this.id_counter++,label:e,row:0,column:0,position:r,sheet:i,r1c1:!0};return l[1][0]==="["?(b.offset_row=!0,b.row=Number(l[1].substring(1,l[1].length-1))):b.row=Number(l[1])-1,l[2][0]==="["?(b.offset_column=!0,b.column=Number(l[2].substring(1,l[2].length-1))):b.column=Number(l[2])-1,b}}let o=this.ConsumeAddressColumn(t);if(!o)return null;t=o.position;let u=this.ConsumeAddressRow(t);if(!u)return null;t=u.position;let d=i?i+e.substr(i.length,t-r).toUpperCase():e.substr(0,t-r).toUpperCase();i&&i[0]==="\'"&&(i=i.substr(1,i.length-2));let p={type:"address",id:this.id_counter++,label:d,row:u.row,column:o.column,absolute_row:u.absolute,absolute_column:o.absolute,position:r,sheet:i};return n!==t-r?null:(this.dependencies.addresses[p.label]=p,this.address_refcount[p.label]=(this.address_refcount[p.label]||0)+1,this.full_reference_list.push(p),p)}ConsumeAddressRow(e){let t=this.data[e]===ft;t&&e++;let r=e,n=0;for(;;e++){let i=this.data[e];if(i>=Ne&&i<=Qe)n*=10,n+=i-Ne;else break}return r===e?!1:{absolute:t,row:n-1,position:e}}ConsumeAddressColumn(e){let t=-1,r=0,n=this.data[e]===ft;for(n&&e++;;e++,r++){if(r>=4)return!1;let i=this.data[e];if(i>=Ge&&i<=mt)t=26*(1+t)+(i-Ge);else if(i>=et&&i<=gt)t=26*(1+t)+(i-et);else break}return t<0?!1:{absolute:n,column:t,position:e}}ConsumeNumber(){let e=this.index,t=0,r=!1,n=!1,i=0,a=0,o=0,u="integer",d=0,p=!1,l=this.index;for(;this.index<this.length;this.index++,d++){let f=this.data[this.index];if(f===this.decimal_mark_char)if(u==="integer")u="fraction";else break;else if(f===fs){i/=100,o/=100,this.index++;break}else if(f===Kt||f===Ke)if(d===0)f===Ke&&(n=!0);else break;else if(f===xs||f===ys)if(u==="integer"||u==="fraction")u="exponent",this.index<this.length-1&&(this.data[this.index+1]===Kt?this.index++:this.data[this.index+1]===Ke&&(this.index++,r=!0));else break;else if(f===this.imaginary_char){let m=this.data[this.index+1];if(m>=Ge&&m<=mt||m>=et&&m<=gt||m>=rr&&m<=ir||m===tr)break;if(u==="integer"||u==="fraction"){this.index++,p=!0;break}}else if(f>=Ne&&f<=Qe)switch(u){case"integer":i=i*10+(f-Ne);break;case"fraction":o=o*10+(f-Ne),a++;break;case"exponent":t=t*10+(f-Ne);break}else break}let b=i+o/Math.pow(10,a);return u==="exponent"&&(b=b*Math.pow(10,(r?-1:1)*t)),p?{type:"complex",id:this.id_counter++,position:e,imaginary:n?-b:b,real:0,text:this.expression.substring(l,this.index)||""}:{type:"literal",id:this.id_counter++,position:e,value:n?-b:b,text:this.expression.substring(l,this.index)||""}}ConsumeString(){this.index++;let e=[];for(;this.index<this.length;this.index++){let t=this.data[this.index];if(t===Jt&&(this.index++,this.index>=this.length||this.data[this.index]!==Jt))break;e.push(t)}return e.map(t=>String.fromCharCode(t)).join("")}ConsumeWhiteSpace(){for(;this.index<this.length;){let e=this.data[this.index];if(e===cs||e===ds||e===hs||e===ps||e===ls)this.index++;else return}}};var or=class{constructor(){}static get instance(){return this._instance}HTML(e){let t=[];for(let r of e){let n=[];for(let i of r)i.pre&&n.push("<pre>"),i.emphasis&&n.push("<em>"),i.strong&&n.push("<strong>"),i.strike&&n.push("<strike>"),n.push(i.text),i.strike&&n.push("</strike>"),i.strong&&n.push("</strong>"),i.emphasis&&n.push("</em>"),i.pre&&n.push("</pre>");t.push(n.join(""))}return t.join(`<br/>\n`)}Dummy(e=""){return e.split(/\\n/).map(t=>[{text:t}])}Parse(e=""){let t=this.Tokenize(e);for(let r=0;r<t.length;r++){let n=t[r];if(n.type==="delimeter"){let i=t[r-1],a=t[r+1],o=!i||i.type==="whitespace"||i.type==="newline",u=i&&i.type==="text"&&/[^\\w\\d]$/.test(i.text),d=!a||a.type==="whitespace"||a.type==="newline",p=a&&a.type==="text"&&/^[^\\w\\d]/.test(a.text);n.left_flanking=!d&&(!p||o),n.right_flanking=!o&&(!u||d)}}return this.ApplyFormatting(t),this.Consolidate(t)}IsWhitespace(e){return e===" "||e===" "}IsNewline(e){return e==="\\r"||e===`\n`}IsDelimeter(e){return e==="*"||e==="_"||e==="~"}Consolidate(e){let t=[],r={},n=[],i={type:"text",text:""};for(let a of e)if(a.type==="newline")i.text.length&&n.push(i),i={...r,text:"",type:"text"},t.push(n),n=[];else switch((!!r.strong!=!!a.strong||!!r.emphasis!=!!a.emphasis||!!r.strike!=!!a.strike)&&(r.strong=!!a.strong,r.emphasis=!!a.emphasis,r.strike=!!a.strike,i.text.length&&n.push(i),i={...r,text:"",type:"text"}),a.type){case"text":case"whitespace":i.text+=a.text;break;case"delimeter":for(let o=0;o<a.length;o++)i.text+=a.char;break}return i.text.length&&n.push(i),n.length&&t.push(n),t}ApplyFormatting(e,t){let r=0,n=e.length;for(r=0;r<n;r++){let i=e[r];if(i.type==="delimeter"){if(t&&i.right_flanking&&t.char===i.char&&i.length>0)return{index:r,token:i};if(i.left_flanking){let a=this.ApplyFormatting(e.slice(r+1),i);if(a.token){let o=Math.min(a.token.length,i.length),u=i.char==="~",d=!u&&!!(o%2),p=!u&&o>=2;for(let l=r+1;l<=r+a.index;l++)e[l].strong=!!e[l].strong||p,e[l].emphasis=!!e[l].emphasis||d,e[l].strike=!!e[l].strike||u;a.token.length-=o,i.length-=o,i.length>0?r--:r+=a.index}}}}return{index:r}}Tokenize(e=""){let t=[],r=e.length,n=0,i=!1,a="";for(n=0;n<r;n++){let o=e[n];if(this.IsWhitespace(o)){a&&t.push({type:"text",text:a});let u=o;for(;;){let d=e[n+1];if(this.IsWhitespace(d))u+=d,n++;else break}t.push({type:"whitespace",text:u}),i=!1,a=""}else if(this.IsNewline(o)){a&&t.push({type:"text",text:a});let u=o;for(;;){let d=e[n+1];if(this.IsNewline(d))u+=d,n++;else break}t.push({type:"newline",text:u}),i=!1,a=""}else if(i)a+=o,i=!1;else if(this.IsDelimeter(o)){a&&t.push({type:"text",text:a});let u=o;for(;;){let d=e[n+1];if(d===o)u+=d,n++;else break}t.push({type:"delimeter",text:u,char:o,length:u.length}),i=!1,a=""}else o==="\\\\"?i=!0:a+=o}return a&&t.push({type:"text",text:a}),t}},ar=or;ie(ar,"_instance",new or);var mi={"c:tx":{"c:strRef":{"c:f":"","c:strCache":{"c:ptCount":{a$:{val:"1"}},"c:pt":{a$:{idx:"0"},"c:v":""}}}},"c:overlay":{a$:{val:"0"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"1400",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",spc:"0",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}}},gi={"c:tx":{"c:rich":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"1400",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",spc:"0",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:r":{"a:rPr":{a$:{lang:""}},"a:t":""}}}},"c:overlay":{a$:{val:"0"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"1400",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",spc:"0",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}}},bt={"c:chartSpace":{a$:{"xmlns:c":"http://schemas.openxmlformats.org/drawingml/2006/chart","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:c16r2":"http://schemas.microsoft.com/office/drawing/2015/06/chart"},"c:date1904":{a$:{val:"0"}},"c:lang":{a$:{val:"en-US"}},"c:roundedCorners":{a$:{val:"0"}},"mc:AlternateContent":{a$:{"xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006"},"mc:Choice":{a$:{Requires:"c14","xmlns:c14":"http://schemas.microsoft.com/office/drawing/2007/8/2/chart"},"c14:style":{a$:{val:"102"}}},"mc:Fallback":{"c:style":{a$:{val:"2"}}}},"c:chart":{},"c:spPr":{"a:solidFill":{"a:schemeClr":{a$:{val:"bg1"}}},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:printSettings":{"c:headerFooter":{},"c:pageMargins":{a$:{b:"0.75",l:"0.7",r:"0.7",t:"0.75",header:"0.3",footer:"0.3"}},"c:pageSetup":{}}}};var bi={"c:idx":{a$:{val:"0"}},"c:order":{a$:{val:"0"}},"c:spPr":{"a:solidFill":{"a:schemeClr":{a$:{val:"accent1"}}},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:invertIfNegative":{a$:{val:"0"}},"c:val":{"c:numRef":{"c:f":""}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000000-F52E-47BC-822F-A046A80610BE}"}}}}},Ai={"c:title":{},"c:autoTitleDeleted":{a$:{val:"0"}},"c:plotArea":{"c:layout":{},"c:barChart":{"c:barDir":{a$:{val:"col"}},"c:grouping":{a$:{val:"clustered"}},"c:varyColors":{a$:{val:"0"}},"c:ser":[],"c:dLbls":{"c:showLegendKey":{a$:{val:"0"}},"c:showVal":{a$:{val:"0"}},"c:showCatName":{a$:{val:"0"}},"c:showSerName":{a$:{val:"0"}},"c:showPercent":{a$:{val:"0"}},"c:showBubbleSize":{a$:{val:"0"}}},"c:gapWidth":{a$:{val:"219"}},"c:overlap":{a$:{val:"-27"}},"c:axId":[{a$:{val:"47003664"}},{a$:{val:"1789284464"}}]},"c:catAx":{"c:axId":{a$:{val:"47003664"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"b"}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"1789284464"}},"c:crosses":{a$:{val:"autoZero"}},"c:auto":{a$:{val:"1"}},"c:lblAlgn":{a$:{val:"ctr"}},"c:lblOffset":{a$:{val:"100"}},"c:noMultiLvlLbl":{a$:{val:"0"}}},"c:valAx":{"c:axId":{a$:{val:"1789284464"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"l"}},"c:majorGridlines":{"c:spPr":{"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}}},"c:numFmt":{a$:{formatCode:"General",sourceLinked:"1"}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"47003664"}},"c:crosses":{a$:{val:"autoZero"}},"c:crossBetween":{a$:{val:"between"}}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}}},"c:plotVisOnly":{a$:{val:"1"}},"c:dispBlanksAs":{a$:{val:"gap"}},"c:extLst":{"c:ext":{a$:{uri:"{56B9EC1D-385E-4148-901F-78D8002777C0}","xmlns:c16r3":"http://schemas.microsoft.com/office/drawing/2017/03/chart"},"c16r3:dataDisplayOptions16":{"c16r3:dispNaAsBlank":{a$:{val:"1"}}}}},"c:showDLblsOverMax":{a$:{val:"0"}}};var xi={"c:title":{},"c:autoTitleDeleted":{a$:{val:"0"}},"c:plotArea":{"c:layout":{},"c:doughnutChart":{"c:varyColors":{a$:{val:"1"}},"c:ser":{"c:idx":{a$:{val:"0"}},"c:order":{a$:{val:"0"}},"c:dPt":{"c:idx":{a$:{val:"3"}},"c:bubble3D":{a$:{val:"0"}},"c:spPr":{"a:solidFill":{"a:schemeClr":{a$:{val:"accent4"}}},"a:ln":{a$:{w:"19050"},"a:solidFill":{"a:schemeClr":{a$:{val:"lt1"}}}},"a:effectLst":{}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000007-E886-49A6-AE6D-C67D8A27530F}"}}}}},"c:cat":{"c:strRef":{"c:f":""}},"c:val":{"c:numRef":{"c:f":""}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000000-3689-4BB4-A84F-05B9F3BBE577}"}}}}},"c:dLbls":{"c:showLegendKey":{a$:{val:"0"}},"c:showVal":{a$:{val:"0"}},"c:showCatName":{a$:{val:"0"}},"c:showSerName":{a$:{val:"0"}},"c:showPercent":{a$:{val:"0"}},"c:showBubbleSize":{a$:{val:"0"}},"c:showLeaderLines":{a$:{val:"1"}}},"c:firstSliceAng":{a$:{val:"0"}},"c:holeSize":{a$:{val:"75"}}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}}},"c:legend":{"c:legendPos":{a$:{val:"b"}},"c:overlay":{a$:{val:"0"}},"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"0",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{a$:{rtl:"0"},"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}}},"c:plotVisOnly":{a$:{val:"1"}},"c:dispBlanksAs":{a$:{val:"gap"}},"c:extLst":{"c:ext":{a$:{uri:"{56B9EC1D-385E-4148-901F-78D8002777C0}","xmlns:c16r3":"http://schemas.microsoft.com/office/drawing/2017/03/chart"},"c16r3:dataDisplayOptions16":{"c16r3:dispNaAsBlank":{a$:{val:"1"}}}}},"c:showDLblsOverMax":{a$:{val:"0"}}};var yi={"c:title":{},"c:autoTitleDeleted":{a$:{val:"0"}},"c:plotArea":{"c:layout":{},"c:scatterChart":{"c:scatterStyle":{a$:{val:"lineMarker"}},"c:varyColors":{a$:{val:"0"}},"c:ser":[],"c:dLbls":{"c:showLegendKey":{a$:{val:"0"}},"c:showVal":{a$:{val:"0"}},"c:showCatName":{a$:{val:"0"}},"c:showSerName":{a$:{val:"0"}},"c:showPercent":{a$:{val:"0"}},"c:showBubbleSize":{a$:{val:"0"}}},"c:axId":[{a$:{val:"2028657983"}},{a$:{val:"2023395087"}}]},"c:valAx":[{"c:axId":{a$:{val:"2028657983"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"b"}},"c:majorGridlines":{"c:spPr":{"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"25000"}},"a:lumOff":{a$:{val:"75000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"2023395087"}},"c:crosses":{a$:{val:"autoZero"}},"c:crossBetween":{a$:{val:"midCat"}}},{"c:axId":{a$:{val:"2023395087"}},"c:scaling":{"c:orientation":{a$:{val:"minMax"}}},"c:delete":{a$:{val:"0"}},"c:axPos":{a$:{val:"l"}},"c:majorGridlines":{"c:spPr":{"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"15000"}},"a:lumOff":{a$:{val:"85000"}}}},"a:round":{}},"a:effectLst":{}}},"c:numFmt":{a$:{formatCode:"0.00",sourceLinked:"1"}},"c:majorTickMark":{a$:{val:"none"}},"c:minorTickMark":{a$:{val:"none"}},"c:tickLblPos":{a$:{val:"nextTo"}},"c:spPr":{"a:noFill":{},"a:ln":{a$:{w:"9525",cap:"flat",cmpd:"sng",algn:"ctr"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"25000"}},"a:lumOff":{a$:{val:"75000"}}}},"a:round":{}},"a:effectLst":{}},"c:txPr":{"a:bodyPr":{a$:{rot:"-60000000",spcFirstLastPara:"1",vertOverflow:"ellipsis",vert:"horz",wrap:"square",anchor:"ctr",anchorCtr:"1"}},"a:lstStyle":{},"a:p":{"a:pPr":{"a:defRPr":{a$:{sz:"900",b:"0",i:"0",u:"none",strike:"noStrike",kern:"1200",baseline:"0"},"a:solidFill":{"a:schemeClr":{a$:{val:"tx1"},"a:lumMod":{a$:{val:"65000"}},"a:lumOff":{a$:{val:"35000"}}}},"a:latin":{a$:{typeface:"+mn-lt"}},"a:ea":{a$:{typeface:"+mn-ea"}},"a:cs":{a$:{typeface:"+mn-cs"}}}},"a:endParaRPr":{a$:{lang:"en-US"}}}},"c:crossAx":{a$:{val:"2028657983"}},"c:crosses":{a$:{val:"autoZero"}},"c:crossBetween":{a$:{val:"midCat"}}}],"c:spPr":{"a:noFill":{},"a:ln":{"a:noFill":{}},"a:effectLst":{}}},"c:plotVisOnly":{a$:{val:"1"}},"c:dispBlanksAs":{a$:{val:"gap"}},"c:extLst":{"c:ext":{a$:{uri:"{56B9EC1D-385E-4148-901F-78D8002777C0}","xmlns:c16r3":"http://schemas.microsoft.com/office/drawing/2017/03/chart"},"c16r3:dataDisplayOptions16":{"c16r3:dispNaAsBlank":{a$:{val:"1"}}}}},"c:showDLblsOverMax":{a$:{val:"0"}}},wi={"c:spPr":{"a:ln":{a$:{w:"19050",cap:"rnd"},"a:solidFill":{"a:schemeClr":{a$:{val:"accent1"}}},"a:round":{}},"a:effectLst":{}},"c:marker":{"c:symbol":{a$:{val:"none"}}},"c:xVal":{"c:numRef":{"c:f":""}},"c:yVal":{"c:numRef":{"c:f":""}},"c:smooth":{a$:{val:"0"}},"c:extLst":{"c:ext":{a$:{uri:"{C3380CC4-5D6E-409C-BE32-E72D297353CC}","xmlns:c16":"http://schemas.microsoft.com/office/drawing/2014/chart"},"c16:uniqueId":{a$:{val:"{00000000-1F6C-44A9-AA4F-6706F20CC72E}"}}}}};var ur=class{constructor(e,t=ur.next_chart_index++){this.options=e;this.index=t}relationships={};UpdateChartTitle(e){let t=this.options.title||{type:"literal",value:""};if(t&&t.type==="literal"){let r=JSON.parse(JSON.stringify(gi)),n=r["c:tx"]["c:rich"]["a:p"];n["a:r"]={"a:rPr":{a$:{lang:oe.locale}},"a:t":t.value},e["c:title"]=r}else if(t){let r=JSON.parse(JSON.stringify(mi));r["c:tx"]["c:strRef"]["c:f"]=t.label,e["c:title"]=r}}toJSON(){switch(this.options.type){case"column":case"bar":return this.CreateBarChart();case"scatter":case"scatter2":return this.CreateScatterChart();case"donut":return this.CreateDonutChart();default:console.info("unhandled chart type",this.options.type)}return this.CreateBarChart()}CreateScatterChart(){let e=JSON.parse(JSON.stringify(bt)),t=e["c:chartSpace"],r=JSON.parse(JSON.stringify(yi));this.options.smooth&&(r["c:plotArea"]["c:scatterChart"]["c:scatterStyle"].a$.val="smoothMarker"),t["c:chart"]=r,this.UpdateChartTitle(t["c:chart"]);let n=t["c:chart"]["c:plotArea"]["c:scatterChart"]["c:ser"],i=!1;for(let a=0;a<this.options.data.length;a++){let o=JSON.parse(JSON.stringify(wi));if(o["c:idx"]={a$:{val:a.toString()}},o["c:order"]={a$:{val:a.toString()}},this.options.names&&this.options.names[a]){let u=this.options.names[a];switch(u.type){case"literal":o["c:tx"]={"c:v":u.value.toString()},i=!0;break;case"range":case"address":o["c:tx"]={"c:strRef":{"c:f":u.label}},i=!0;break}}o["c:spPr"]["a:ln"]["a:solidFill"]["a:schemeClr"].a$.val=`accent${a+1}`,o["c:yVal"]["c:numRef"]["c:f"]=this.options.data[a]?.label,this.options.labels2&&this.options.labels2[a]&&(o["c:xVal"]["c:numRef"]["c:f"]=this.options.labels2[a]?.label),this.options.smooth&&(o["c:smooth"]={a$:{val:1}}),n.push(o)}return i&&(t["c:chart"]["c:legend"]={"c:legendPos":{a$:{val:"b"}},"c:overlay":{a$:{val:"0"}}}),e}CreateDonutChart(){let e=JSON.parse(JSON.stringify(bt)),t=e["c:chartSpace"],r=JSON.parse(JSON.stringify(xi));t["c:chart"]=r,this.UpdateChartTitle(t["c:chart"]);let n=r["c:plotArea"]["c:doughnutChart"];return n&&(n["c:ser"]["c:cat"]["c:strRef"]["c:f"]=this.options.labels?.label||"",n["c:ser"]["c:val"]["c:numRef"]["c:f"]=this.options.data[0]?.label||""),e}CreateBarChart(){let e=JSON.parse(JSON.stringify(bt)),t=e["c:chartSpace"],r=JSON.parse(JSON.stringify(Ai));t["c:chart"]=r,this.UpdateChartTitle(t["c:chart"]);let n=r["c:plotArea"]["c:barChart"];if(n){let i=n["c:barDir"];i&&(i.a$.val=this.options.type==="bar"?"bar":"col");let a=n["c:ser"];for(let o=0;o<this.options.data.length;o++){let u=JSON.parse(JSON.stringify(bi));u["c:idx"]={a$:{val:o.toString()}},u["c:order"]={a$:{val:o.toString()}},u["c:spPr"]["a:solidFill"]["a:schemeClr"].a$.val=`accent${o+1}`,!o&&this.options.labels&&(u["c:cat"]={"c:strRef":{"c:f":this.options.labels.label}}),u["c:val"]["c:numRef"]["c:f"]=this.options.data[o]?.label,a.push(u)}}return e}},ze=ur;ie(ze,"next_chart_index",1);var lr=class{constructor(e,t=lr.next_image_index++){this.options=e;this.index=t;switch(e.mimetype){case"svg+xml":this.extension="svg";break;case"image/png":this.extension="png";break;case"jpg":this.extension="jpeg";break;case"svg":case"png":case"jpeg":case"gif":this.extension=e.mimetype;break;default:console.warn("unhandled mime type",e.mimetype);break}}extension=""},tt=lr;ie(tt,"next_image_index",1);var _i=9525,cr=class{constructor(e=cr.next_drawing_index++){this.index=e}sheet_drawing_relationship=0;charts=[];images=[];relationships={};AddImage(e,t){let r=new tt(e);if(r.extension){let n=Ce(this.relationships,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",`../media/image${r.index}.${r.extension}`);this.images.push({image:r,relationship:n,anchor:t})}}AddChart(e,t){let r=new ze(e),n=Ce(this.relationships,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",`../charts/chart${r.index}.xml`);this.charts.push({chart:r,anchor:t,relationship:n})}CornerToJSON(e){return{"xdr:col":e.column,"xdr:colOff":(e.column_offset||0)*_i,"xdr:row":e.row,"xdr:rowOff":(e.row_offset||0)*_i}}AnchorToJSON(e){return{"xdr:from":{...this.CornerToJSON(e.from)},"xdr:to":{...this.CornerToJSON(e.to)}}}toJSON(){let e=this.images.map(n=>({a$:{editAs:"oneCell"},...this.AnchorToJSON(n.anchor),"xdr:pic":{"xdr:nvPicPr":{"xdr:cNvPr":{a$:{id:n.image.index+1,name:"Image "+n.image.index}},"xdr:cNvPicPr":{"a:picLocks":{a$:{noChangeAspect:1}}}},"xdr:blipFill":{"a:blip":{a$:n.image.extension==="svg"?{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships"}:{"xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:embed":n.relationship},"a:extLst":{"a:ext":[{a$:{uri:"{28A0092B-C50C-407E-A947-70E740481C1C}"},"a14:useLocalDpi":{a$:{"xmlns:a14":"http://schemas.microsoft.com/office/drawing/2010/main",val:0}}},n.image.extension==="svg"?{a$:{uri:"{96DAC541-7B7A-43D3-8B79-37D633B846F1}"},"asvg:svgBlip":{a$:{"xmlns:asvg":"http://schemas.microsoft.com/office/drawing/2016/SVG/main","r:embed":n.relationship}}}:void 0]}},"a:stretch":{"a:fillRect":{}}},"xdr:spPr":{"a:xfrm":{"a:off":{a$:{x:0,y:0}},"a:ext":{a$:{cx:4057650,cy:6172200}}},"a:prstGeom":{a$:{prst:"rect"},"a:avLst":{}}}},"xdr:clientData":{}})),t=this.charts.map(n=>({...this.AnchorToJSON(n.anchor),"xdr:graphicFrame":{a$:{macro:""},"xdr:nvGraphicFramePr":{"xdr:cNvPr":{a$:{id:n.chart.index+1,name:`Chart ${n.chart.index}`}},"xdr:cNvGraphicFramePr":{}},"xdr:xfrm":{"a:off":{a$:{x:0,y:0}},"a:ext":{a$:{cx:0,cy:0}}},"a:graphic":{"a:graphicData":{a$:{uri:"http://schemas.openxmlformats.org/drawingml/2006/chart"},"c:chart":{a$:{"xmlns:c":"http://schemas.openxmlformats.org/drawingml/2006/chart","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","r:id":n.relationship}}}}},"xdr:clientData":{}}));return{"xdr:wsDr":{a$:{"xmlns:xdr":"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing","xmlns:a":"http://schemas.openxmlformats.org/drawingml/2006/main"},"xdr:twoCellAnchor":[...t,...e]}}}},Ve=cr;ie(Ve,"next_drawing_index",1);var Te=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n`,At=class{zip;xmloptions={format:!0,attributesGroupName:"a$",textNodeName:"t$",ignoreAttributes:!1,suppressEmptyNode:!0,tagValueProcessor:(e,t)=>typeof t=="string"?Di.encode(t,{useNamedReferences:!0}):t};xmlbuilder1=new xt.XMLBuilder(this.xmloptions);xmlparser2=new xt.XMLParser(lt);parser=new Ue;decorated_functions={};async Init(e={}){for(let t of Object.keys(e))this.decorated_functions[t.toLowerCase()]=e[t];this.zip=await new Ci.default().loadAsync(br,{base64:!0})}async WriteRels(e,t,r=!1){if(!this.zip)throw new Error("missing zip");let n=Object.keys(e),i={Relationships:{a$:{xmlns:"http://schemas.openxmlformats.org/package/2006/relationships"},Relationship:n.map(o=>{let u=e[o],d={Id:u.id,Target:u.target,Type:u.type};return u.mode&&(d.TargetMode=u.mode),{a$:d}})}},a=Te+this.xmlbuilder1.build(i);r&&console.info(a),await this.zip?.file(t,a)}async WriteStyleCache(e){if(!this.zip)throw new Error("missing zip");let t=p=>{let l={};return p.indexed!==void 0&&(l.indexed=p.indexed),p.theme!==void 0&&(l.theme=p.theme),p.tint!==void 0&&(l.tint=p.tint),p.argb!==void 0&&(l.rgb=p.argb),l},r=e.cell_xfs.map(p=>{let l={a$:{numFmtId:p.number_format,fontId:p.font,fillId:p.fill,borderId:p.border}};return(p.horizontal_alignment||p.vertical_alignment||p.wrap_text)&&(l.alignment={a$:{}},p.horizontal_alignment&&(l.alignment.a$.horizontal=p.horizontal_alignment),p.vertical_alignment&&(l.alignment.a$.vertical=p.vertical_alignment),p.wrap_text&&(l.alignment.a$.wrapText=1)),l}),n=p=>{if(p.color)return{indexed:p.color};if(p.rgba)return{rgb:p.rgba};if(p.theme){let l={theme:p.theme};return p.tint&&(l.tint=p.tint),l}},i=e.borders.map(p=>{let l={left:{},right:{},top:{},bottom:{},diagonal:{}};if(p.top.style){l.top.a$={style:p.top.style};let b=n(p.top);b&&(l.top.color={a$:b})}if(p.left.style){l.left.a$={style:p.left.style};let b=n(p.left);b&&(l.left.color={a$:b})}if(p.bottom.style){l.bottom.a$={style:p.bottom.style};let b=n(p.bottom);b&&(l.bottom.color={a$:b})}if(p.right.style){l.right.a$={style:p.right.style};let b=n(p.right);b&&(l.right.color={a$:b})}if(p.diagonal.style){l.diagonal.a$={style:p.diagonal.style};let b=n(p.diagonal);b&&(l.diagonal.color={a$:b})}return l}),a=e.fills.map(p=>{let l={a$:{patternType:p.pattern_type}};return p.pattern_gray!==void 0&&(l.a$.patternType=`gray${p.pattern_gray}`),p.bg_color&&(l.bgColor={a$:t(p.bg_color)}),p.fg_color&&(l.fgColor={a$:t(p.fg_color)}),{patternFill:l}}),o=e.fonts.map(p=>{let l={};return p.bold&&(l.b=""),p.italic&&(l.i=""),p.underline&&(l.u=""),p.strike&&(l.strike=""),p.size!==void 0&&(l.sz={a$:{val:p.size}}),p.family!==void 0&&(l.family={a$:{val:p.family}}),p.name!==void 0&&(l.name={a$:{val:p.name}}),p.scheme!==void 0&&(l.scheme={a$:{val:p.scheme}}),p.color_argb!==void 0?l.color={a$:{rgb:p.color_argb}}:p.color_theme!==void 0&&(l.color={a$:{theme:p.color_theme}},p.color_tint&&(l.color.a$.tint=p.color_tint)),l}),u={styleSheet:{a$:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac x16r2 xr","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac","xmlns:x16r2":"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision"}}};e.number_formats.length&&(u.styleSheet.numFmts={a$:{count:e.number_formats.length},numFmt:e.number_formats.map(p=>({a$:{numFmtId:p.id,formatCode:p.format}}))}),o.length&&(u.styleSheet.fonts={a$:{count:o.length},font:o}),a.length&&(u.styleSheet.fills={a$:{count:a.length},fill:a}),i.length&&(u.styleSheet.borders={a$:{count:i.length},border:i}),r.length&&(u.styleSheet.cellXfs={a$:{count:r.length},xf:r});let d=Te+this.xmlbuilder1.build(u);await this.zip?.file("xl/styles.xml",d)}async WriteSharedStrings(e){if(!this.zip)throw new Error("missing zip");let t={sst:{a$:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main",count:e.strings.length,uniqueCount:e.strings.length},si:[...e.strings.map(n=>({t:n}))]}},r=Te+this.xmlbuilder1.build(t);await this.zip?.file("xl/sharedStrings.xml",r)}StyleFromCell(e,t,r,n,i={}){let a=e.styles||e.cell_style_refs||[],o=[e.sheet_style];if(e.row_pattern&&e.row_pattern.length&&o.push(e.row_pattern[r%e.row_pattern.length]),e.row_style){let d=e.row_style[r];typeof d=="number"&&(d=a[d]),d&&o.push(d)}if(e.column_style){let d=e.column_style[n];typeof d=="number"&&(d=a[d]),d&&o.push(d)}o.push(i);let u=t.StyleOptionsFromProperties(pe.Composite(o));return t.EnsureStyle(u)}NormalizeAddress(e,t){let r=e.type==="address"?[e]:[e.start,e.end];for(let n of r)n.absolute_row=!0,n.absolute_column=!0,n.sheet||(n.sheet=t.name);return e.type==="range"&&(e.end.sheet=void 0),e.label=this.parser.Render(e),e}AnnotationLayoutToAnchor(e,t){let r=n=>{let i=t.column_width&&t.column_width[n.address.column]?t.column_width[n.address.column]:t.default_column_width||100,a=t.row_height&&t.row_height[n.address.row]?t.row_height[n.address.row]:t.default_row_height||20;return{...n.address,row_offset:Math.round(n.offset.y*a),column_offset:Math.round(n.offset.x*i)}};return{from:r(e.tl),to:r(e.br)}}AnnotationRectToAnchor(e,t){let r={from:{row:-1,column:-1},to:{row:-1,column:-1}},n={...e,right:e.left+e.width,bottom:e.top+e.height};for(let i=0,a=0;a<1e3;a++){let o=t.column_width&&t.column_width[a]?t.column_width[a]:t.default_column_width||100;if(r.from.column<0&&n.left<=i+o&&(r.from.column=a,r.from.column_offset=n.left-i),r.to.column<0&&n.right<=i+o){r.to.column=a,r.to.column_offset=n.right-i;break}i+=o}for(let i=0,a=0;a<1e3;a++){let o=t.row_height&&t.row_height[a]?t.row_height[a]:t.default_row_height||20;if(r.from.row<0&&n.top<=i+o&&(r.from.row=a,r.from.row_offset=n.top-i),r.to.row<0&&n.bottom<=i+o){r.to.row=a,r.to.row_offset=n.bottom-i;break}i+=o}return r}ParseImages(e){let t=[];for(let r of e.annotations||[])if(r.type==="image"&&r.data?.src){let n=r.data.src,i=n.match(/^data:image\\/([^;]*?);base64,/);if(i){let a=n.substr(i[0].length),o=i[1],u={data:a,mimetype:o,encoding:"base64"};switch(o){case"svg+xml":case"webp":case"jpeg":case"jpg":case"image/png":case"png":case"gif":r.rect?t.push({anchor:this.AnnotationRectToAnchor(r.rect,e),options:u}):r.layout?t.push({anchor:this.AnnotationLayoutToAnchor(r.layout,e),options:u}):console.warn("annotation missing layout");break;default:console.info("unhandled image type",o);break}}}return t}ParseCharts(e){let t=[],r=(n,i)=>{if(n.type==="range")i.data.push(this.NormalizeAddress(n,e));else if(n.type==="call"){if(/group/i.test(n.name))for(let a of n.args||[])r(a,i);else if(/series/i.test(n.name)){let[a,o,u]=n.args;u&&u.type==="range"?(i.data.push(this.NormalizeAddress(u,e)),a&&(i.names||(i.names=[]),a.type==="address"&&this.NormalizeAddress(a,e),a.type==="range"?(this.NormalizeAddress(a.start,e),i.names[i.data.length-1]=a.start):i.names[i.data.length-1]=a),i.labels2||(i.labels2=[]),o&&o.type==="range"&&(i.labels2[i.data.length-1]=this.NormalizeAddress(o,e))):console.info("invalid series missing Y")}}};for(let n of e.annotations||[]){let i=this.parser.Parse(n.formula||"");if(i.expression&&i.expression.type==="call"){let a="";switch(i.expression.name.toLowerCase()){case"line.chart":a="scatter";break;case"scatter.line":a="scatter2";break;case"donut.chart":a="donut";break;case"bar.chart":a="bar";break;case"column.chart":a="column";break}if(a==="column"||a==="donut"||a==="bar"||a==="scatter"||a==="scatter2"){let o={type:a,data:[]},u=a==="scatter2"?1:2,d=i.expression.args[u];if(d&&d.type==="literal"?o.title=d:d&&d.type==="address"&&(o.title=this.NormalizeAddress(d,e)),i.expression.args[0]){let p=i.expression.args[0];if(a==="scatter2"||a==="bar"||a==="column"||a==="scatter")r(p,o);else if(p.type==="range")o.data.push(this.NormalizeAddress(p,e));else if(p.type==="call"&&/group/i.test(p.name))for(let l of p.args)l.type==="range"?o.data.push(this.NormalizeAddress(l,e)):l.type==="call"&&/series/i.test(l.name)&&l.args[2]&&l.args[2].type==="range"&&o.data.push(this.NormalizeAddress(l.args[2],e));else p.type==="call"&&/series/i.test(p.name)&&p.args[2]&&p.args[2].type==="range"&&o.data.push(this.NormalizeAddress(p.args[2],e))}a!=="scatter2"&&i.expression.args[1]&&i.expression.args[1].type==="range"&&(o.labels=this.NormalizeAddress(i.expression.args[1],e)),(a==="scatter"&&i.expression.args[4]&&i.expression.args[4].type==="literal"&&i.expression.args[4].value.toString().toLowerCase()==="smooth"||a==="scatter2"&&i.expression.args[2]&&i.expression.args[2].type==="literal"&&/smooth/i.test(i.expression.args[2].value.toString()))&&(o.smooth=!0),n.rect?t.push({anchor:this.AnnotationRectToAnchor(n.rect,e),options:o}):n.layout?t.push({anchor:this.AnnotationLayoutToAnchor(n.layout,e),options:o}):console.warn("annotation missing layout")}}}return t}FormulaText(e){if(e[0]!=="=")return e;let t=this.parser.Parse(e);return t.expression?(this.parser.Walk(t.expression,r=>{if(r.type==="call"){let n=r.name.toLowerCase();this.decorated_functions[n]&&(r.name=this.decorated_functions[n]+"."+r.name)}return!0}),this.parser.Render(t.expression,void 0,"")):(console.warn("parsing function failed"),console.warn(e),e.substr(1))}async Export(e){let t=0,r=[];for(let y=0;y<e.sheet_data.length;y++){let w=e.sheet_data[y],E=w.id||0;E&&(r[E]=w.name||""),E===e.active_sheet&&(t=y)}let n=new We,i=new Ze,a=new Be,o=await this.zip?.file("xl/theme/theme1.xml")?.async("text");a.FromXML(this.xmlparser2.parse(o||"")),o=await this.zip?.file("xl/styles.xml")?.async("text"),i.FromXML(this.xmlparser2.parse(o||""),a),Ve.next_drawing_index=1,ze.next_chart_index=1;let u=[];for(let y=0;y<e.sheet_data.length;y++){let w=e.sheet_data[y],E={},z={xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x14ac xr xr2 xr3","xmlns:x14ac":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision","xmlns:xr2":"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2","xmlns:xr3":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision3","xr:uid":"{D37933E2-499F-4789-8D13-194E11B743FC}"},P=w.default_row_height?w.default_row_height/20*15:15,G={worksheet:{a$:{...z},dimension:{a$:{ref:"A1"}},sheetViews:{sheetView:{a$:{workbookViewId:0}}},sheetFormatPr:{a$:P===15?{"x14ac:dyDescent":.25}:{defaultRowHeight:P,customHeight:1,"x14ac:dyDescent":.25}},cols:{},sheetData:{},mergeCells:{a$:{count:0}},dataValidations:{},hyperlinks:{},pageMargins:{a$:{left:.7,right:.7,top:.75,bottom:.75,header:.3,footer:.3}},drawing:{},extLst:{ext:{a$:{uri:"{05C60535-1F16-4fd2-B633-F4F36F0B64E0}","xmlns:x14":"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}}}}},R=w.styles||w.cell_style_refs||[],V=new ot;V.FromJSON(w.data,R);for(let D of w.cell_styles){let v=V.EnsureCell(D);v.style||(v.style=R[D.ref])}let X={start:{row:V.rows+1,column:V.columns+1},end:{row:V.rows+1,column:V.columns+1}},C={row:[]},S=[],h=[],k=[],Y=[];for(let D=0;D<V.data.length;D++)if(V.data[D]&&V.data[D].length){D<X.start.row&&(X.start.row=D);let v={start:-1,end:-1},j=[];for(let W=0;W<V.data[D].length;W++){let Z=V.data[D][W];if(Z){if(Z.merge_area&&Z.merge_area.start.row===D&&Z.merge_area.start.column===W&&k.push(new ae(Z.merge_area.start,Z.merge_area.end)),Z.hyperlink){let ue=Ce(E,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",Z.hyperlink,"External");S.push({rel:ue,target:Z.hyperlink,address:{row:D,column:W}})}if(Z.validation&&(Z.validation.type===0||Z.validation.type===2)&&Y.push({address:{row:D,column:W},validation:Z.validation}),Z.type===1&&/^=?sparkline\\./i.test(Z.value)){h.push({address:{row:D,column:W},formula:Z.value,style:Z.style});continue}W<X.start.column&&(X.start.column=W),v.start<0&&(v.start=W),v.end=W;let ee=this.StyleFromCell(w,i,D,W,Z.style),te,K,re;switch(Z.type){case 1:switch(re=this.FormulaText(Z.value),Z.calculated_type){case 2:te=Z.calculated,K="str";break;case 3:te=Z.calculated;break;case 4:te=Z.calculated?1:0,K="b";break}break;case 2:te=n.Ensure(Z.value),K="s";break;case 3:te=Z.value;break;case 4:te=Z.value?1:0,K="b";break}Z.area&&Z.area.start.row===D&&Z.area.start.column===W&&typeof re=="string"&&(re={t$:re,a$:{t:"array",ref:Z.area.spreadsheet_label}});let le={a$:{r:ae.CellAddressToLabel({row:D,column:W})}};K!==void 0&&(le.a$.t=K),ee!==void 0&&(le.a$.s=ee),re!==void 0&&(le.f=re),te!==void 0&&(le.v=te),j.push(le)}}if(j.length){let W={a$:{r:D+1,spans:`${v.start+1}:${v.end+1}`},c:j};w.row_height&&typeof w.row_height[D]=="number"&&w.row_height[D]!==w.default_row_height&&(W.a$.customHeight=1,W.a$.ht=w.row_height[D]*3/4),C.row.push(W)}}let F=[];w.default_column_width&&(G.worksheet.sheetFormatPr.a$.defaultColWidth=at(w.default_column_width));for(let D=0;D<w.columns;D++){let v={index:D};w.column_width&&w.default_column_width&&typeof w.column_width[D]=="number"&&w.column_width[D]!==w.default_column_width&&(v.width=at(w.column_width[D]));let j=w.column_style[D];typeof j=="number"&&(j=R[j]),j&&(v.style=i.EnsureStyle(i.StyleOptionsFromProperties(j))),(v.style!==void 0||v.width!==void 0)&&(F[D]=v)}if(F.length)for(let D of F)G.worksheet.cols.col=F.map(v=>{let j={min:v.index+1,max:v.index+1};return v.style!==void 0&&(j.style=v.style),v.width!==void 0?(j.width=v.width,j.customWidth=1):j.width=at(w.default_column_width||90),{a$:j}});else delete G.worksheet.cols;Y.length?G.worksheet.dataValidations={a$:{count:Y.length},dataValidation:Y.map(D=>{let v={a$:{type:"list",allowBlank:1,showInputMessage:1,showErrorMessage:1,sqref:new ae(D.address).spreadsheet_label}};if(D.validation.type===2){let j=new ae({...D.validation.area.start,absolute_column:!0,absolute_row:!0},{...D.validation.area.end,absolute_column:!0,absolute_row:!0});v.formula1=`${j.spreadsheet_label}`}else D.validation.type===0&&(v.formula1=`"${D.validation.list.join(",")}"`);return v})}:delete G.worksheet.dataValidations,k.length?(G.worksheet.mergeCells.a$.count=k.length,G.worksheet.mergeCells.mergeCell=k.map(D=>({a$:{ref:D.spreadsheet_label}}))):delete G.worksheet.mergeCells,S.length?G.worksheet.hyperlinks.hyperlink=S.map(D=>({a$:{"r:id":D.rel,ref:new ae(D.address).spreadsheet_label,"xr:uid":"{0C6B7792-7EA0-4932-BF15-D49C453C565D}"}})):delete G.worksheet.hyperlinks,h.length?G.worksheet.extLst.ext["x14:sparklineGroups"]={a$:{"xmlns:xm":"http://schemas.microsoft.com/office/excel/2006/main"},"x14:sparklineGroup":h.map(D=>{let v=this.parser.Parse(D.formula),j="";if(v.expression&&v.expression.type==="call"&&v.expression.args.length>0){let Z=v.expression.args[0];if(Z.type==="range"||Z.type==="address"){let ee=Z.type==="range"?Z.start:Z;ee.sheet||(typeof ee.sheet_id<"u"?ee.sheet=r[ee.sheet_id]:ee.sheet=w.name),j=this.parser.Render(Z)}}let W={displayEmptyCellsAs:"gap"};return/column/i.test(D.formula)&&(W.type="column"),{a$:W,"x14:colorSeries":{a$:{rgb:"FF376092"}},"x14:sparklines":{"x14:sparkline":{"xm:f":j,"xm:sqref":new ae(D.address).spreadsheet_label}}}})}:delete G.worksheet.extLst,G.worksheet.sheetData=C;let q=this.ParseCharts(w),I=this.ParseImages(w);if(q.length||I.length){let D=new Ve;for(let W of q)D.AddChart(W.options,W.anchor);for(let W of I)D.AddImage(W.options,W.anchor);for(let{image:W}of D.images)await this.zip?.file(`xl/media/image${W.index}.${W.extension}`,W.options.data||"",{base64:W.options.encoding==="base64"});for(let{chart:W}of D.charts){let Z=W.toJSON(),ee=Te+this.xmlbuilder1.build(Z);await this.zip?.file(`xl/charts/chart${W.index}.xml`,ee),await this.WriteRels(W.relationships,`xl/charts/_rels/chart${W.index}.xml.rels`)}await this.WriteRels(D.relationships,`xl/drawings/_rels/drawing${D.index}.xml.rels`);let v=Te+this.xmlbuilder1.build(D.toJSON());await this.zip?.file(`xl/drawings/drawing${D.index}.xml`,v),u.push(D);let j=Ce(E,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",`../drawings/drawing${D.index}.xml`);G.worksheet.drawing={a$:{"r:id":j}}}else delete G.worksheet.drawing;G.worksheet.dimension.a$.ref=new ae(X.start,X.end).spreadsheet_label;let O=Te+this.xmlbuilder1.build(G);await this.zip?.file(`xl/worksheets/sheet${y+1}.xml`,O),Object.keys(E).length&&this.WriteRels(E,`xl/worksheets/_rels/sheet${y+1}.xml.rels`)}await this.WriteSharedStrings(n),await this.WriteStyleCache(i);let d={};Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles","styles.xml"),Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme","theme/theme1.xml"),Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings","sharedStrings.xml");let p=e.sheet_data.map((y,w)=>Ce(d,"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",`worksheets/sheet${w+1}.xml`));await this.WriteRels(d,"xl/_rels/workbook.xml.rels");let l={definedName:[]};if(e.named_ranges){let y=Object.keys(e.named_ranges);for(let w of y){let E="",z=new ae(e.named_ranges[w].start,e.named_ranges[w].end);if(z.start.absolute_column=z.start.absolute_row=!0,z.end.absolute_column=z.end.absolute_row=!0,z.start.sheet_id){for(let P of e.sheet_data)if(P.id===z.start.sheet_id){E=P.name||"";break}}E&&(sr.test(E)&&(E=`\'${E}\'`),E+="!"),l.definedName.push({a$:{name:w},t$:E+z.spreadsheet_label})}}if(e.named_expressions)for(let y of e.named_expressions)l.definedName.push({a$:{name:y.name},t$:y.expression});l.definedName.length||(l=void 0);let b={workbook:{a$:{xmlns:"http://schemas.openxmlformats.org/spreadsheetml/2006/main","xmlns:r":"http://schemas.openxmlformats.org/officeDocument/2006/relationships","xmlns:mc":"http://schemas.openxmlformats.org/markup-compatibility/2006","mc:Ignorable":"x15 xr xr6 xr10 xr2","xmlns:x15":"http://schemas.microsoft.com/office/spreadsheetml/2010/11/main","xmlns:xr":"http://schemas.microsoft.com/office/spreadsheetml/2014/revision","xmlns:xr6":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision6","xmlns:xr10":"http://schemas.microsoft.com/office/spreadsheetml/2016/revision10","xmlns:xr2":"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2"},workbookPr:{a$:{defaultThemeVersion:"166925"}},bookViews:{workbookView:{a$:{activeTab:t||0}}},sheets:{sheet:e.sheet_data.map((y,w)=>{let E={name:y.name||`Sheet${w+1}`,sheetId:w+1,"r:id":p[w]};return y.visible===!1&&(E.state="hidden"),{a$:E}})},definedNames:l}},f=Te+this.xmlbuilder1.build(b);await this.zip?.file("xl/workbook.xml",f);let m={};for(let y of u)for(let w of y.images)switch(w.image.extension){case"gif":case"png":case"jpeg":m[w.image.extension]="image/"+w.image.extension;break;case"svg":m.svg="image/svg+xml";break}let g={Types:{a$:{xmlns:"http://schemas.openxmlformats.org/package/2006/content-types"},Default:[{a$:{Extension:"rels",ContentType:"application/vnd.openxmlformats-package.relationships+xml"}},{a$:{Extension:"xml",ContentType:"application/xml"}},...Object.keys(m).map(y=>({a$:{Extension:y,ContentType:m[y]}}))],Override:[{a$:{PartName:"/xl/workbook.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"}},...e.sheet_data.map((y,w)=>({a$:{ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",PartName:`/xl/worksheets/sheet${w+1}.xml`}})),...u.reduce((y,w)=>y.concat([...w.charts.map(E=>({a$:{ContentType:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml",PartName:`/xl/charts/chart${E.chart.index}.xml`}})),{a$:{ContentType:"application/vnd.openxmlformats-officedocument.drawing+xml",PartName:`/xl/drawings/drawing${w.index}.xml`}}]),[]),{a$:{PartName:"/xl/theme/theme1.xml",ContentType:"application/vnd.openxmlformats-officedocument.theme+xml"}},{a$:{PartName:"/xl/styles.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"}},{a$:{PartName:"/xl/sharedStrings.xml",ContentType:"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"}},{a$:{PartName:"/docProps/core.xml",ContentType:"application/vnd.openxmlformats-package.core-properties+xml"}},{a$:{PartName:"/docProps/app.xml",ContentType:"application/vnd.openxmlformats-officedocument.extended-properties+xml"}}]}},A=Te+this.xmlbuilder1.build(g);await this.zip?.file("[Content_Types].xml",A)}async AsBinaryString(e){if(!this.zip)throw new Error("missing zip");let t={type:"binarystring"};return typeof e<"u"&&(t.compression="DEFLATE",t.compressionOptions={level:e}),await this.zip.generateAsync(t)}async AsBlob(e){if(!this.zip)throw new Error("missing zip");let t={type:"blob"};return typeof e<"u"&&(t.compression="DEFLATE",t.compressionOptions={level:e}),await this.zip.generateAsync(t)}};var vi=Fe(kt());var hr=Fe(ut());var yt=s=>"row"in s&&"col"in s,Pe=s=>"from"in s&&"to"in s&&yt(s.from)&&yt(s.to),wt=(s,e)=>e.sheet===s.sheet&&e.row>=s.from.row&&e.row<=s.to.row&&e.col>=s.from.col&&e.col<=s.to.col,dr=(s,e=0,t=0)=>({from:{row:s.from.row+e,col:s.from.col+t,sheet:s.from.sheet},to:{row:s.to.row+e,col:s.to.col+t,sheet:s.to.sheet}});var _t=class{constructor(e={}){this.options=e}path;rels_path;rels={};sheet_data={};shared_strings;extent;visible_state;tab_selected=!1;default_width=0;drawings=[];TranslateAddress(e){e=e.toUpperCase();let t=e.match(/([A-Z]+\\d+):([A-Z]+\\d+)/);if(t)return{from:this.TranslateAddress(t[1]),to:this.TranslateAddress(t[2])};let r=0,n=0;if(t=e.match(/^([A-Z]+)(\\d+)$/),t){r=Number(t[2]),n=0;let i=t[1].length;for(let a=0;a<i;a++){let o=t[1].charCodeAt(a)-64;n=n*26+o}}return{row:r,col:n}}Address(e,t=!1){if(Pe(e))return this.Address(e.from,t)+":"+this.Address(e.to,t);let r="",n=e.col;for(;n>0;){let a=(n-1)%26+1;r=String.fromCharCode(64+a)+r,n=(n-a)/26}let i=e.sheet?`\'${e.sheet}\'!`:"";return t?`${i}$${r}$${e.row}`:i+r+e.row}NormalizeAddress(e){let t,r;return typeof e=="string"?(t=e.toUpperCase(),r=this.TranslateAddress(t)):(r=e,t=this.Address(r)),{a:t,rc:r}}Parse(){let e=this.sheet_data.worksheet?.dimension?.a$?.ref,t=this.TranslateAddress(e||"");Pe(t)?this.extent=JSON.parse(JSON.stringify(t)):this.extent={from:JSON.parse(JSON.stringify(t)),to:JSON.parse(JSON.stringify(t))}}};var Es=new hr.XMLParser(Kr),Le=new hr.XMLParser(lt);var Dt=class{constructor(e){this.zip=e}xml={};shared_strings=new We;style_cache=new Ze;theme=new Be;defined_names={};rels={};sheets=[];active_tab=0;get sheet_count(){return this.sheets.length}async ReadRels(e){let t={},r=await this.zip.file(e)?.async("text"),n=Le.parse(r||"");for(let i of n.Relationships?.Relationship||[]){let a=i.a$.Id;t[a]={id:a,type:i.a$.Type,target:i.a$.Target}}return t}async Init(){this.rels=await this.ReadRels("xl/_rels/workbook.xml.rels");let e=await this.zip.file("xl/sharedStrings.xml")?.async("text"),t=Le.parse(e||"");this.shared_strings.FromXML(t),e=await this.zip.file("xl/theme/theme1.xml")?.async("text"),t=Le.parse(e),this.theme.FromXML(t),e=await this.zip.file("xl/styles.xml")?.async("text"),t=Le.parse(e),this.style_cache.FromXML(t,this.theme),console.info({c:this.style_cache}),e=await this.zip.file("xl/workbook.xml")?.async("text"),t=Le.parse(e),this.defined_names={};let r=se.FindAll(t,"workbook/definedNames/definedName");for(let a of r){let o=a.a$?.name,u=a.t$||"";o&&u&&(this.defined_names[o]=u)}let n=se.FindAll(t,"workbook/bookViews/workbookView");n[0]?.a$?.activeTab&&(this.active_tab=Number(n[0].a$.activeTab)||0);let i=se.FindAll(t,"workbook/sheets/sheet");for(let a of i){let o=a.a$?.name;if(o){let u=a.a$.state,d=a.a$["r:id"],p=new _t({name:o,rid:d,id:Number(a.a$.sheetId)});u==="hidden"?p.visible_state=1:u==="veryHidden"&&(p.visible_state=2),p.shared_strings=this.shared_strings,p.path=`xl/${this.rels[d].target}`,p.rels_path=p.path.replace("worksheets","worksheets/_rels")+".rels",e=await this.zip.file(p.path)?.async("text"),p.sheet_data=Le.parse(e||""),p.rels=await this.ReadRels(p.rels_path),p.Parse(),this.sheets.push(p)}}}async ReadDrawing(e){let t=await this.zip.file(e.replace(/^../,"xl"))?.async("text");if(!t)return;let r=Le.parse(t),n=await this.ReadRels(e.replace(/^..\\/drawings/,"xl/drawings/_rels")+".rels"),i=[],a=se.FindAll(r,"xdr:wsDr/xdr:twoCellAnchor"),o=(u={})=>({column:u["xdr:col"]||0,column_offset:u["xdr:colOff"]||0,row:u["xdr:row"]||0,row_offset:u["xdr:rowOff"]||0});for(let u of a){let p={anchor:{from:o(u["xdr:from"]),to:o(u["xdr:to"])}},l=se.FindAll(u,"xdr:graphicFrame/a:graphic/a:graphicData/c:chart")[0];if(l&&l.a$&&l.a$["r:id"]){let b=n[l.a$["r:id"]];b&&b.target&&(p.chart=await this.ReadChart(b.target))}i.push(p)}return i}async ReadChart(e){let t=await this.zip.file(e.replace(/^../,"xl"))?.async("text");if(!t)return;let r=Es.parse(t),n={type:0},i=se.FindChild(r,"c:chartSpace/c:chart/c:title");if(i){let u=se.FindChild(i,"c:tx/c:strRef/c:f");if(u)typeof u=="string"?n.title=u:u.text__&&(n.title=u.text__);else{let d=se.FindAll(i,"c:tx/c:rich/a:p/a:r/a:t");n.title=\'"\'+d.join("")+\'"\'}}let a=(u,d=!1)=>{let p=[],l=u["c:ser"]||[];Array.isArray(l)||(l=[l]);for(let b of l){let f=p.length,m=b["c:order"];m&&(f=Number(m.__val||0)||0);let g={},A=se.FindChild(b,"c:tx/c:v");if(A){let y=A;y&&(g.title=`"${y}"`)}else A=se.FindChild(b,"c:tx/c:strRef/c:f"),A&&(g.title=A);if(d){let y=se.FindChild(b,"c:xVal/c:numRef/c:f");y&&(g.categories=y);let w=se.FindChild(b,"c:yVal/c:numRef/c:f");w&&(g.values=w)}else{let y=se.FindChild(b,"c:val/c:numRef/c:f");y&&(g.values=y);let w=se.FindChild(b,"c:cat/c:strRef/c:f");w||(w=se.FindChild(b,"c:cat/c:numRef/c:f")),w&&(g.categories=w)}p[f]=g}return p},o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:barChart");return o&&(n.type=2,o["c:barDir"]&&o["c:barDir"].__val==="col"&&(n.type=1),n.series=a(o)),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:lineChart"),o&&(n.type=3,n.series=a(o))),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:doughnutChart"),o&&(n.type=5,n.series=a(o))),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:pieChart"),o&&(n.type=6,n.series=a(o))),o||(o=se.FindChild(r,"c:chartSpace/c:chart/c:plotArea/c:scatterChart"),o&&(n.type=4,n.series=a(o,!0))),n}GetNamedRanges(){return this.defined_names}};var Ct=class{parser=new Ue;workbook;archive;async Init(e){typeof e=="string"?this.archive=await(0,vi.default)().loadAsync(e):this.archive=e,this.archive&&(this.workbook=new Dt(this.archive),await this.workbook.Init())}SheetCount(){return this.workbook?.sheet_count||0}ParseCell(e,t,r,n,i,a,o){let u=t.a$?.r;if(!u){console.warn("cell missing address");return}let d=e.TranslateAddress(u);if(Pe(d)){console.warn("cell has range address");return}let p,l=0,b,f=0;if(t.a$?.t&&t.a$.t==="s"){if(l=2,typeof t.v!==void 0){let A=Number(t.v);!isNaN(A)&&e.shared_strings&&(p=e.shared_strings.Get(A)||"",p[0]==="="&&(p="\'"+p))}}else if(typeof t.f<"u"){l=1;let A=(typeof t.f=="string"?t.f:t.f.t$)||"";if(A){p="="+A.replace(/^_xll\\./g,"");let y=this.parser.Parse(A);y.expression&&(this.parser.Walk(y.expression,w=>(w.type==="call"&&/^_xll\\./.test(w.name)&&(w.name=w.name.substr(5)),!0)),p="="+this.parser.Render(y.expression,void 0,"")),typeof t.f!="string"&&t.f.a$?.t==="shared"&&t.f.a$.si&&(r[t.f.a$.si]={row:d.row-1,column:d.col-1,formula:p,parse_result:this.parser.Parse(p)})}else if(typeof t.f!="string"&&t.f.a$?.t==="shared"&&t.f.a$.si){let y=r[t.f.a$.si];y&&(y.parse_result.expression?p="="+this.parser.Render(y.parse_result.expression,{rows:d.row-1-y.row,columns:d.col-1-y.column},""):p=y.formula)}if(typeof t.f!="string"&&t.f.a$?.t==="array"){let y=e.TranslateAddress(t.f.a$.ref||"");Pe(y)&&n.push(dr(y,-1,-1))}if(typeof t.v<"u"){let y=Number(t.v.toString());isNaN(y)?(f=2,b=t.v.toString()):(f=3,b=y)}}else if(typeof t.v<"u"){let A=Number(t.v.toString());isNaN(A)?(l=2,p=t.v.toString()):(l=3,p=A)}let m={row:d.row-1,col:d.col-1};for(let A of n)wt(A,m)&&(m.row!==A.from.row||m.col!==A.from.col)&&(f=l,b=p,p=void 0,l=0);let g={row:m.row,column:m.col,value:p,type:l};typeof b<"u"&&(g.calculated_type=f,g.calculated=b),t.a$?.s&&(g.style_ref=Number(t.a$.s));for(let A of a)A.address.row===d.row&&A.address.col===d.col&&(g.hyperlink=A.reference);for(let A of o)if(A.address.row===m.row&&A.address.column===m.col){g.validation=A.validation;break}for(let A of i)wt(A,m)&&(g.merge_area={start:{row:A.from.row,column:A.from.col},end:{row:A.to.row,column:A.to.col}});for(let A of n)wt(A,m)&&(g.area={start:{row:A.from.row,column:A.from.col},end:{row:A.to.row,column:A.to.col}});return g}async GetSheet(e=0){if(!this.workbook)throw new Error("missing workbook");let t=this.workbook.sheets[e],r=[],n={},i=[],a=[],o=[],u=[],d=[],p=se.FindAll.bind(se,t.sheet_data),l=p("worksheet/mergeCells/mergeCell");for(let h of l)if(h.a$.ref){let k=t.TranslateAddress(h.a$.ref);Pe(k)&&a.push(dr(k,-1,-1))}let b=p("worksheet/dataValidations/dataValidation");for(let h of b){let k=h.a$?.type,Y=h.a$?.sqref,F=h.formula1;if(Y&&F&&k==="list"){let q,I,O=this.parser.Parse(Y);O.expression&&(O.expression.type==="address"?q=O.expression:O.expression.type==="range"&&(q=O.expression.start)),O=this.parser.Parse(F),O.expression&&(O.expression.type==="range"?I={type:2,area:O.expression}:O.expression.type==="literal"&&(I={type:0,list:O.expression.value.toString().split(/,/).map(D=>{let v=this.parser.Parse(D);if(v.expression?.type==="group"&&/\\s/.test(D))return D;if(v.expression?.type==="literal")return v.expression.value;if(v.expression?.type==="identifier")return v.expression.name})})),q&&I&&u.push({address:q,validation:I})}}let f=p("worksheet/hyperlinks/hyperlink");for(let h of f){let k=t.TranslateAddress(h.a$?.ref||"");Pe(k)&&(k=k.from);let Y="",F="";if(h.a$&&h.a$["r:id"]){Y="remote link";let q=t.rels[h.a$["r:id"]];q&&(F=q.target||"")}else F=h.__location||"",Y=h.__display||"";o.push({address:k,reference:F,text:Y})}let m=21,g=100,A=t.sheet_data.worksheet?.sheetFormatPr;if(A){if(A.a$?.defaultColWidth){let h=Number(A.a$.defaultColWidth);isNaN(h)||(g=Nt(h))}if(A.a$?.defaultRowHeight){let h=Number(A.a$.defaultRowHeight);isNaN(h)||(m=Math.round(h*4/3))}}let y=[],w=p("worksheet/sheetData/row");for(let h of w){let k=h.a$?.r?Number(h.a$.r):1,Y=m;if(h.a$?.ht){let q=Number(h.a$.ht);isNaN(q)||(Y=Math.round(q*4/3))}Y!==m&&(y[k-1]=Y);let F=h.c||[];Array.isArray(F)||(F=[F]);for(let q of F){let I=this.ParseCell(t,q,n,i,a,o,u);I&&r.push(I)}}let E=[],z=-1,P=[],G=p("worksheet/cols/col");for(let h of G){let k=Number(h.a$?.min),Y=Number(h.a$?.max);if(h.a$?.style){let F=Number(h.a$.style);if(!isNaN(k)&&!isNaN(Y)&&!isNaN(F))if(t.extent&&Y>=t.extent.to.col||Y-k>100)z=F;else for(let q=k;q<=Y;q++)E[q]=F}if(h.a$?.customWidth){let F=Number(h.a$.width);if(!isNaN(k)&&!isNaN(Y)&&!isNaN(F)&&Y!==16384){F=Nt(F);for(let q=k;q<=Y;q++)P[q-1]=F}}}let R=p("worksheet/drawing"),V=[];for(let h of R){let k=h.a$?h.a$["r:id"]:void 0;if(k){let Y="",F=t.rels[k];if(F&&(Y=F.target||""),Y){let q=await this.workbook.ReadDrawing(Y);q&&q.length&&V.push(...q)}}}let X=h=>{let k={address:{row:h.row,column:h.column},offset:{x:0,y:0}};if(h.row_offset){let Y=y[h.row];Y===void 0&&(Y=m),k.offset.y=h.row_offset/9525/Y}if(h.column_offset){let Y=P[h.column];Y===void 0&&(Y=g),k.offset.x=h.column_offset/9525/Y}return k};for(let h of V)if(h&&h.chart){let k={tl:X(h.anchor.from),br:X(h.anchor.to)},Y,F=[],q="",I=h.chart?.series;switch(h.chart.type){case 4:Y="treb-chart",q="Scatter.Line",I&&I.length&&(F[0]=`Group(${I.map(D=>`Series(${D.title||""},${D.categories||""},${D.values||""})`||"").join(", ")})`),F[1]=h.chart.title;break;case 5:case 6:q=h.chart.type===5?"Donut.Chart":"Pie.Chart",Y="treb-chart",I&&I[0]&&(F[0]=I[0].values,F[1]=I[0]?.categories||""),F[2]=h.chart.title;break;case 2:case 1:case 3:switch(F[2]=h.chart.title,Y="treb-chart",h.chart.type){case 2:q="Bar.Chart";break;case 1:q="Column.Chart";break;default:q="Line.Chart"}I&&(I.length>1?F[0]=`Group(${I.map(D=>`Series(${D.title||""},,${D.values||""})`||"").join(", ")})`:I.length===1&&(I[0].title?F[0]=`Series(${I[0].title||""},,${I[0].values||""})`:F[0]=I[0].values),F[1]=I[0]?.categories||"");break}let O=`=${q}(${F.join(", ")})`;Y&&O&&d.push({layout:k,type:Y,formula:O})}let C=p("worksheet/extLst/ext");for(let h of C){let k="";for(let F of Object.keys(h?.a$||{})){let q=F.match(/^xmlns:(.*)$/);if(q){k=q[1];break}}let Y=se.FindAll(h,`${k}:sparklineGroups/${k}:sparklineGroup`);for(let F of Y){let q="Sparkline.line",I="",O="";F.a$?.type==="column"&&(q="Sparkline.column");let D=se.FindAll(F,`${k}:sparklines/${k}:sparkline`);for(let v of D)for(let j of Object.keys(v))/:f$/.test(j)?O=v[j]:/:sqref$/.test(j)&&(I=v[j]);if(O&&I){let v=`=${q}(${O})`,j=t.TranslateAddress(I);if(yt(j)){let W={row:j.row-1,column:j.col-1,value:v,type:1},Z=!1;for(let ee of r)if(ee.row===W.row&&ee.column===W.column){Z=!0,ee.type=1,ee.value=v;break}Z||r.push(W)}}}}let S={name:t.options.name,cells:r,default_column_width:g,column_widths:P,row_heights:y,annotations:d,styles:this.workbook?.style_cache?.CellXfToStyles()||[]};return(t.visible_state===1||t.visible_state===2)&&(S.hidden=!0),z>=0&&(S.sheet_style=z),E.length&&(S.column_styles=E),S}};var vt=self,pr=new At,Bs=async s=>{if(s.sheet){await pr.Init(s.decorated||[]),await pr.Export(s.sheet);let e=await pr.AsBlob(1),t=e.slice(0,e.size,"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");vt.postMessage({status:"complete",blob:t})}},Is=async s=>{let e=new Ct;try{await e.Init(s.data);let t=e.SheetCount(),r={sheets:[],names:e.workbook?.GetNamedRanges(),active_tab:e.workbook?.active_tab};for(let n=0;n<t;n++){let i=await e.GetSheet(n);i&&r.sheets.push(i)}vt.postMessage({status:"complete",results:r})}catch(t){console.warn("error importing xlsx file"),console.info(t),vt.postMessage({status:"error",data:t})}};vt.addEventListener("message",s=>{s.data&&s.data.command==="export"?Bs(s.data):s.data&&s.data.command==="import"&&Is(s.data)});})();\n/*!\n\nJSZip v3.10.0 - A JavaScript class for generating and reading zip files\n<http://stuartk.com/jszip>\n\n(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>\nDual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.\n\nJSZip uses the library pako released under the MIT license :\nhttps://github.com/nodeca/pako/blob/main/LICENSE\n*/\n/*! https://mths.be/he v1.2.0 by @mathias | MIT license */\n';rs&&(ne.export_worker_text=rs);var t_={version:"21.6.5",CreateSpreadsheet:c=>gt.Create(ne,c).sheet,SetScriptPath:c=>{ne.treb_base_path=c}};ne.BuildPath();export{t_ as TREB};
|